The assertion in the below test fails, because the expected call isn't mocked:
TestCase 'Test.TestGenericMock'
failed: TypeMock.VerifyException :
TypeMock Verification: Method OtherClass`1.GetInstance() has 1 more expected calls
at TypeMock.MockManager.Verify()
Test.cs(305,0): at Test.TestGenericMock()
Is there a way to do this?
Thanks! :)
[TestFixture]
public class Test
{
[Test]
public void TestGenericMock()
{
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
OtherClass<string> mockedInstance = RecorderManager.CreateMockedObject<OtherClass<string>>();
recorder.ExpectAndReturn(OtherClass<string>.GetInstance(), mockedInstance);
}
string data = TestedClass.GetData();
MockManager.Verify();
Assert.IsNull(data);
}
}
public class TestedClass
{
public static string GetData()
{
return OtherClass<string>.GetInstance().Data;
}
}
public class OtherClass<T>
{
private string data = null;
public string Data
{
get { return data; }
set { data = value; }
}
public static OtherClass<T> GetInstance()
{
OtherClass<T> instance = new OtherClass<T>();
instance.Data = "i was not mocked";
return instance;
}
}