Hello,
I have 1 issue with type data set when I pass to method typed datarow value and try to mock such a call. e.g.:
Isolate.WhenCalled( () => someObj.Do(typedDataRow.FooTypedProperty)).IgnoreCall();
FooTypedProperty property has been mocked as well as
Do method call and returns null when I try to read its value.
I was able to reproduce issue (or may be this is expected behavior?) in example below:
1. Classes definition:
public class FooClass
{
public void Do(string input)
{
//do some task
}
}
public class SubFooClass
{
public string Value { get; set; }
}
2. Tests:
[TestMethod]
[Isolated]
public void IsItValidMockTest()
{
//expectations
string expected = "faked value";
//prepare
FooClass foo = new FooClass();
SubFooClass subFoo = new SubFooClass() { Value = expected };
Isolate.WhenCalled(() => foo.Do(subFoo.Value)).IgnoreCall();
//run
foo.Do(subFoo.Value);
//assertations
Assert.AreEqual(expected, subFoo.Value); //assertation fails. value is null
Isolate.Verify.WasCalledWithExactArguments(() => foo.Do(subFoo.Value)); //verification fails. method wasn't called
}
More over when I try to make sure that
Do is called with exact arguments I get the following error:
"*** Cannot mock types from mscorlib assembly."
[TestMethod]
[Isolated]
public void IsItValidMockTestAnother()
{
//expectations
string expected = "faked value";
//prepare
FooClass foo = new FooClass();
SubFooClass subFoo = new SubFooClass() { Value = expected };
Isolate.WhenCalled(() => foo.Do(subFoo.Value)).WithExactArguments().IgnoreCall(); //fails with "*** Cannot mock types from mscorlib assembly."
//run
foo.Do(subFoo.Value);
//assertations
Assert.AreEqual(expected, subFoo.Value);
Isolate.Verify.WasCalledWithExactArguments(() => foo.Do(subFoo.Value));
}
Is it expected behavior? If yes then how should I mock such a method call?
TIA,
Grammer