Friday, January 28, 2011

Moq - Matching types to assert true

This is for using Moq when the method you are unit testing has an output of a particular type (as opposed to a boolean or string).

This code is really rough (the statement in green is the most important statement and does work)


[Test Method]
public void MyTest()
{
....Setup stuff
myType result = CallSomeMethod();
Assert.IsTrue(result.GetType() == typeof(myType));
}