Is there a way to create a layout instead of a real instance when testing code that calls the constructor?
For instance:
public class ClassToTest
{
public void MethodToTest()
{
MyObject foo = new MyObject();
Console.WriteLine(foo.ToString());
}
}
In this example, I need to create a unit test that confirms that a call to the MethodToTest method on an instance of ClassToTest really outputs the result of the ToString () method of the newly created instance of MyObject.
I do not see a way to realistically test the ClassToTest class in isolation; testing this method will actually test the myObject.ToString () method as well as the MethodToTest method.
source
share