Hi,
I am new to TypeMock and am testing the product. Please answer my question from the Reflective mocks viewpoint.
Below, I have duplicated the code from the TypeMock API Reference for MockedInstance. I have a test scenario similar to this, but in the CreateAnObject() method instead of the TestClass being created with "new", it is created with a static factory method of a 3rd party library. For example, replace
TestClass theClass = new TestClass();
with:
TestClass theClass = ThirdPartyLibClass.CreateTestClass();
How do I get a mockedInstance of TestClass in this case ? When I try this, "theClass" comes back null. I don't have access to the source code of ThirdPartyLibClass. I just know it returns a TestClass object.
Thanks
--- Code below duplicated from TypeMock API Reference
public static void CreateAnObject()
{
TestClass theClass = new TestClass();
theClass.field = 5;
...
}
[Test]
public void VerifyFutureObject()
{
//Create new Mock for a future Object, no expectations
Mock mock = MockManager.Mock(typeof(TestClass));
// Call our code
TheClass.CreateAnObject();
// get the mocked object and test the field
TestClass theClass = mock.MockedInstance as TestClass;
Assert.AreEqual(5, theClass.field);
// Verify that all the expected calls have actually been called.
MockManager.Verify();
}