MsCorLib faking support – With some creative thinking, and benefiting from our experience developing Typemock Racer, we discovered ways to fake MsCorLib types.
Anyone who has worked with unit testing in .Net languages has probably repeatedly run into problems with faking objects from mscorlib.dll.
I know I certainly did.
Most problems surrounding this can be overcome with some refactoring, but this isn't always an option. In my problem (working on a MVP project) I wanted to fake my view - but have the dataTable property swapped with a concrete instance. This would allow me to call a method in my presenter which I use to populate the table and then test the values in my substituted table.
var Table = new DataTable();
var FakeView = Isolate.Fake.Instance
Isolate.WhenCalled(() => FakeView.dataTable).WillReturn(Table);
var presenter = new DemoPresenter();
Assert.IsTrue((Table.Rows.Count >= 1));
Running Typemock 5.3.4 this didn't work, remembering that email, I jumped onto the typemock site and had a look around. I was surprised that I didn't see a great deal of fanfare about this and other features, I did notice that a new version 5.3.5 was out. Taking my chances I downloaded it and the above code worked perfectly.