Sample of NUnit.Mock

using NUnit.Framework;
using NUnit.Mocks;

namespace ConsoleApplication1
{
[TestFixture]
public class Class1
{
public interface IExecutable
{
void Execute();
}

[Test]
public void ThisIsATest()
{
// This is not a good test of a mock but it shows how it works.
// The mock should be a Dependend Upon Component not the Subject Of Test
DynamicMock mockExecute = new DynamicMock(typeof(IExecutable));
mockExecute.Expect(“Execute”);
((IExecutable)mockExecute.MockInstance).Execute();
mockExecute.Verify();
}
}
}

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Connecting to %s