Welcome to Themba's Blog
in

dotnet.org.za

South African .NET Developer Portal

This Blog

Syndication

Tags

Archives

Welcome to Themba's Blog

{Develop with pleasure}
  • IIS7 - HTTP Error 404.3 - Not Found

    Hi Everyone

    Maybe some of you know this already, but if you don't kow, hope this will help. After installing IIS 7, you need to configure it before in order for it to handle ASP.NET pages.

    To do that you can follow these easy step:

    * Open Control Panel --> Click 'Turn Windows features on or off'

    * When everything is loaded.

    Navigate Internet Information Services --> World Wide Web --> Application Development  and select ASP.NET.

    Click OK and you should be fine.

    Hope this helps.

    Thanks

    Posted Aug 01 2008, 01:24 PM by themba with 2 comment(s)
    Filed under:
  • TDD for Beginners

    Hi there

    In this post I will work-through a beginner on Test Driven Development (TDD). Before we begin, make sure that you installed testdriven.net personal edition. This can be downloaded free on the following address:  http://www.testdriven.net/download.aspx.

    I normally start by creating a blank solution, I’ll call this HelloTDDWorld. Add a new project, a class library, call it HelloTDDWorldTests.

    Add nunit.framework.dll as a reference to the project. Delete class1.cs and add a new class, call it HelloTDDWorldTestFixture.cs. Add using NUnit.Framework under using System.Text. Above the class name, add [TestFitxure]. You should have something like this

    using System;

    using System.Collections.Generic;using System.Text;using NUnit.Framework; namespace HelloTDDWorldTests{    [TestFixture]    public class HelloTDDWorldTestFixture    {           }

    }

    TDD’s principle is:

    ·         RED: Write a failing test.

    ·         GREEN: Make the test pass.

    ·         REFACTOR: Improve the design while ensuring that all test passes

    Failing Test

    Add the following to the following HelloTDDWorldTestFixture

    [Test]

    public void GetGreeting_Should_return_HelloTDDWorld(){    HelloTDDWorld helloTDDWorld = new HelloTDDWorld();   

    Assert.AreEqual(helloTDDWorld.GetGreeting(), "HelloTDDWorld");

    }     

    This will obviously fails if you try to build.  First of all the HelloTDDWorld class is not even defined. This is our failing test (RED). Let us make it pass.

     Add a new project to the solution. This is the project we are testing. Create a new project and call it HelloWorld. Delete Class1.cs. Add a new item call it HelloTDDWorld.cs. Add the newly created project as a project reference to HelloTDDWorldTests. Add a using HelloWorld on the using directive. It should look like this now:

     

     using System;using System.Collections.Generic;using System.Text;using NUnit.Framework;using HelloWorld; 

    We are still failing because we don’t have GetGreeting method as yet. Let us fix that by adding the method to the class and return an empty string. The class should look like this now:

    using System;

    using System.Collections.Generic;using System.Text; namespace HelloWorld{    public class HelloTDDWorld    {        public string GetGreeting()        {            return string.Empty;        }    }} This should make our solution to build successful. Let us now run our test. Right click on GetGreeting_Should_return_HelloTDDWorld method and select Run Test(s) to run the test.Obviously the test will fail, beacause we are returning an empty string. To make the test pass. Go to HelloTDDWorld class in GetGreeting method and return the “HelloTDDWorld” string.

    The method should look like this now:

    using System;using System.Collections.Generic;using System.Text; namespace HelloWorld{    public class HelloTDDWorld    {        public string GetGreeting()        {            return "HelloTDDWorld";        }    }} Run the test and now it should pass. It is that easy. This get confusing when you have to designi an object that uses services from other objects.

    That’s where mock object comes into play. Will deal with it in the next post.

     Thats it for now.Thanks, hope you enjoyed this post. Develop with passion...

     

    Posted Jun 27 2008, 02:58 PM by themba with no comments
    Filed under:
Powered by Community Server (Commercial Edition), by Telligent Systems