I want to test a class that uses Linq to SQL. I have faked the datacontext with TypeMock Isolator, but the datacontext also has a function that I don't know how to fake. This function is used in Linq to Sql-queries.
The function passes two arguments (int? a, string b), and returns an integer; DC.MyMethod(int? a, string b)
How to I fake this?
//Fake datacontext
var fakeDC = Isolate.Fake.Instance<MyDataContext>();
//Fake --> this doesn't work
Isolate.WhenCalled((int? a, string b) => fakeDC.MyFunction(a,b).... ?
Hope anyone can help
Isolator by default ignores arguments passed to functions. To fake yours, you could simply use:
If you need to make sure it was called with specific arguments, add
WithExactArguments()
, like this:Hope that helps.