Hi Soon Hui,
I see a couple of limitations we have in testing the code you posted. One is that Math is a class in MSCorLib, and currently Isolator cannot fake behavior for types in MSCorLib. The second is that the AAA API does not support calling a c'tor with specific arguments yet.
If the code was something like
public abstract class VeryAbstract
{
public int MyInt
{
get; private set;
}
public VeryAbstract()
{
MyInt = MyClass.Foo(Random.Next());
}
}
we could do:
[TestMethod]
public void Test()
{
Isolate.Fake.WhenCalled(() => MyClass.Foo(0)).WillReturn(10);
// creating a fake object with CallOriginal causes its c'tor to be called
var underTest = Isolate.Fake.Instance<VeryAbstract>(Members.CallOriginal);
Assert.AreEqual(10, underTest.MyInt);
}
I hope this helps; I will update you once we have the c'tor arguments feature implemented with the syntax and its usage.
Thanks,
Doron
Typemock support