Sladescross's Blog

Blogging about Sharepoint related stuff

Sharepoint Test Driven Development December 18, 2010

Filed under: Isolator,Test Driven Development,Tool — sladescross @ 3:05 pm

  • You are not allowed to write any production code unless it is to make a failing unit test pass.
  • You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
  • You are not allowed to write any more production code than is sufficient to pass the one failing unit test
  •  Isolator for SharePoint which is an essential component for anyone doing unit testing in a SharePoint environment.

    • In order to test the behaviour here, we have one of two choices, We can either use the extract and overide method, or we can use TypeMock to isolate the randomiser and replace it’s behaviour.
    • The extract and overide method requires us to create a new FakeBall class in our test namespace, that inherits from our Ball class. We then adjust the Ball class to make it’s randomiser method to be protected virtual rather than private. This allows us to override it’s behaviour in our FakeBall class.
    • In our FakeBall class, we want to pass it in a value that will be passed back to the Base ball object, thus choosing which index to return.
    About these ads

    Leave a Reply

    Fill in your details below or click an icon to log in: Logo

    You are commenting using your account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s


    Get every new post delivered to your Inbox.

    Join 63 other followers