Goal

Create a method that first creates a file and then deletes it. Sounds pretty useless but it makes a good example.

This tutorial is written in C#. You can use any mock object and unit test frameworks of your choice. In this example we're using Rhino Mocks and MbUnit v3.

Steps

  1. Create sample project.
  2. Create unit test.
  3. Create actual method.

Create sample project.

  1. Create new Class Library project and name it SysWrapSample.
  2. Add reference to your mock object framework. If you're using Rhino mocks, click on Browse tab in Add Reference dialog and reference to Rhino.Mocks.dll.
  3. Add reference to your unit test framework. If you're using MbUnit v3, click on .NET tab in Add Reference dialog and select Gallio and MbUnit.
  4. Add the last reference to SystemWrapper.dll.
  5. Rename Class1 class into FileInfoSample.
  6. Add using statements for SystemWrapper.IO, MbUnit.Framework, and Rhino.Mocks. Your class should look like this:
using SystemWrapper.IO;
using MbUnit.Framework;
using Rhino.Mocks;
 
namespace SysWrapSample
{
    public class FileInfoSample
    {
    }
}

Create unit test.

Last edited Nov 28, 2008 at 12:12 PM by vkreynin, version 11

Comments

No comments yet.