I am currently evaluating TypeMock and performing a simple test to check if it suitible for my unit testing needs.
The thing that makes type mock appealing is that you do not have to compromise your design, being force to implement IoC patterns when you don't want/need to. Anyway that's another debate. :wink:
I have a legacy component that I reference in my .NET project. This creates a runtime callable wrapper around the COM component.
When I try to mock this object's RWC it don't seem to work.
[Test]
public void Test()
{
Mock deviceMock = MockManager.Mock(typeof(MyLegacyClass));
deviceMock.ExpectCall("MyLegacyMethod");
unit = new Unit();
unit.Do();
MockManager.Verify();
}
public class Unit
{
private MyLegacyClass legacyObject;
public Unit()
{
this.legacyObject = new MyLegacyClass ();
}
public void Do()
{
this.legacyObject.MyLegacyMethod();
}
}
This is the message I get
TypeMock.VerifyException :
TypeMock Verification: Expected a new instance of MyLegacyNamespace.MyLegacyClass (try using MockAll)
Any help on whether this is possible in TypeMock or if there is anything wrong with my code is much appreciated.