Imagine Cup 2008

28 01 2008

image_2.png

Looking to show out your talent? How far you can do wonders with Software and Technology? Then Imagine Cup should be in your list :)

If you are in University Of Otago and want to participate in this year’s Imagine Cup, please email me and I am happy to assist you.

I do have a Project in mind for Software Design competition and looking to form a team. You can read more about Software Design here. So please do email me if you want to jump in 8)

Before you leave, here is the theme for Imagine Cup 2008,

“Imagine a world where technology enables a sustainable environment.”





Microsoft Student Partners 2008 – University Of Otago

28 01 2008

Ok, Here are the Microsoft Student Partners 2008 for University Of Otago :)

david-msp.png

chaks-msp.png

8)





Survey for my blog readers

27 01 2008

FAQ

Hi Friends,

Its been a long time since I started blogging but I haven’t yet asked for any feedback about my blog to my friends and readers. So, I thought let me have a small survey conducted on my blog. I would be really happy if you can complete this small survey here and give your valuable inputs 8)

Thanks,

Regards,

Chakkaradeep (a.k.a Chaks)





Mock Objects

25 01 2008

tdd.png

So, you have started reading or doing more on Test Driven Development? Then am sure you would have now heard about Mocking or Mock Objects :D

Before getting started and seeing what is this Mock Object, let me quote the definition of Unit Test from Wikipedia

In computer programming, unit testing is a procedure used to validate that individual units of source code are working properly. A unit is the smallest testable part of an application.

The goal of unit testing is to isolate each part of the program and show that the individual parts are correct. A unit test provides a strict, written contract that the piece of code must satisfy.

So, Unit Testing covers testing each individual part in your program. In other words, when we say we are unit testing a Component A, we actually test the functions, properties etc., inside that component.

Below is a pictorial representation of what we do,

unit-test.png

For Component A , we write several unit test cases and test it. Since this component does not depend on anything else, it is fairly easy to test all the parts of the component and hence it satisfies the definition of Unit Testing.

Now we bring in another Component B, which depends on Component A and thus now we have something like this,

unit-test-2.png

How do we test Component B now?

Let me write down the scenario of where we are now,

1) We have Component A which is been tested

2) We have Component B which uses/depends on some of the functions of Component A

3) We have to test Component B such a way that its isolated from Component A, yet still use Component A

4) If we test along with Component A with Component B, its not Unit Test, rather its, Integration Testing!

What do we do now? Mock Component A 8)

Yes, here comes the use of Mock Objects. From Wikipedia,

In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to test the behavior of a car during an accident.

So, its kinda Fake Object, but a Mock Object has some expectations and results being set on it.

Now, to make use of Mock Objects, we change the Component A to implement an interface Interface A and Component B an interface Interface B .Using Interfaces helps us to have just the functions and properties of the Component being written which is what Mock needs ;)

Here we are now,

unit-test-3.png

TDD has hence allowed to make changes to your design now and you would have changed tests accordingly.

Introducing Mock Objects, we now have,

unit-test-mocking.png

So, we interact with Component A using our Mock Repository which holds the Mock Object – Interface A

We can now set expectations on Mock Objects, meaning that, you can say that – When a function named FunctionA is called, return the string “Hello World”

It may confuse you initially, but am sure you will get the whole picture once you start mocking yourself ;)

Here is a sample test case along with Mocking (Using NUnit and Rhino Mocks),

[TestFixture]
public class AdminTests
{
    private MockRepository mocks;
    private EduAdmin eduAdmin;
    private Bl.IBLAdmin mockAdmin;
    private delegate bool ValidRegisterDelegate(Db.Admin entity);

    [SetUp]
    public void Setup()
    {
         mocks= new MockRepository();

         mockAdmin = mocks.DynamicMock<Bl.IBLAdmin>();
    }

    [Test]
    public void Check_Method_Register()
    {
        AdminEntity inputEntity = new AdminEntity();
        inputEntity.AdminId = "admin";
        inputEntity.AdminPassword = "admin";

        Db.Admin dbAdmin=new Educator.DataAccess.Admin
        {
            AdminId = "admin",
            AdminPwd = "admin"
        };

        With.Mocks(mocks).Expecting(() =>
        {
            Expect
                .Call(mockAdmin.Translate(inputEntity))
                .Return(dbAdmin);

            Expect
                .Call(delegate { mockAdmin.Insert(dbAdmin); })
                .Callback((ValidRegisterDelegate)
                               ((entity) => { return entity.AdminId == "admin" && entity.AdminPwd == "admin"; }));

        }).Verify(delegate
       {
           eduAdmin = new EduAdmin(mockAdmin);

           eduAdmin.RegisterAdmin(inputEntity);
       });
    }
}

More resources on Mock Objects,

1) All about Mock Objects

2) Mock aren’t Stubs

3) Rhino Mocks





Summer road trip Update

23 01 2008

winvista-button_rgb.jpg vs08_v_rgb_web.jpg ms_net_rgb_web.jpg

Darryl has posted an update for the Summer road trip 8)

So, to sum it up, here is the schedule

  • Feb 4, Auckland – AIT, Ground Floor, Write Stevenson House, 585 Great South Road, Auckland
  • Feb 5, Tauranga – Bureta Park Motor Inn, Redwood Room, Vale Street, Otumoetai, Tauranga
  • Feb 7, Hamilton – Wintec, Room C1.18, Gate 5, Tristram Street, Hamilton
  • Feb 8, New Plymouth – Quality Hotel, Blenheim room, Cnr Courtenay and Leach Streets, New Plymouth
  • Feb 11, Napier – East Pier, 50 Nelson Quay, Ahuriri, Napier
  • Feb 12, Palmerston North – PN Convention Centre, The Conference Room, 1st Floor, 354 Main Street, Palmerson North
  • Feb 13, Wellington – Paramount Theatre, 25 Courtney Place, Wellington
  • Feb 14, Nelson – Tahuna Beach Function Rooms, Tui Room, 70 Beach Road, Tahunanui, Nelson
  • Feb 15, Christchurch – Christchurch convention centre, Cambridge Room, 1st Floor, 86 Kilmore Street, Christchurch
  • Feb 18, Dunedin – Town Hall, 1 Harrop Street, Dunedin
  • Feb 19, Invercargill – Ascot Park Hotel, Oreti Room, Corner of Tay Street and Racecourse Road, Invercargill

Session gathering @ 1.00 p.m

Session starts @ 1.30 p.m

Maximum duration upto 2 hours :D

Cool 8)





This is really awesome – The Best movie for now – CloverField

21 01 2008

Here is a four minute preview

8)





Windows Vista Facts

20 01 2008

winvista-button_rgb.jpg

I am not sure whether this page is there from the beginning, but I found this today via NeowinWindows Vista: Facts 

I do agree with those Facts 8)








Follow

Get every new post delivered to your Inbox.