How can I generate a unique instance of a mock for a given type?
Essentially, this is what I want:
[Test]
public void GenerateUniqueMockInstances()
{
Assert.AreNotEqual(
new MockRepository().DynamicMock<IFoo>(),
new MockRepository().DynamicMock<IFoo>(),
"Instance Comparison");
Assert.AreNotEqual(
new MockRepository().DynamicMock<IFoo>()
.GetType().Name,
new MockRepository().DynamicMock<IFoo>()
.GetType().Name,
"Proxy Type Name Comparison");
}
This fails:
Proxy Type Name Comparison
Expected: not "IFooProxyb713a0865e7b40098bb37f4a66c4aece"
But was: "IFooProxyb713a0865e7b40098bb37f4a66c4aece"
For context, I'm writing several test methods that require different behavior for the same mocked object (IFoo) so instead of trying to ensure the mock is completely cleaned up after every test method, I'd like to just blow it away and create a new one.
Aucun commentaire:
Enregistrer un commentaire