views:

186

answers:

1

Hi, i am using TypeMock Isolator to fake the tables on my DataContext like this:

Isolate.Swap.CallsOn(ctx.GetTable<TTable>()).WithCallsTo(content);

I now can fill the "database" with arbitrary data on each test. In order to get meaningful data for the test scenario into the DataContext i usually have to create 3-5 objects.

Now, the problem is that my business logic used the Linq-generated relation properties for example to get the customers orders. i now have to not only new up the object but i also have to connect them. Is anyone aware of some kind of solution to this problem? I spend 20 lines setting up the object graph and then testing for 5 lines. Thats kind of weird.

Thank you.

+1  A: 

Not sure if Swap.CallsOn is the correct way to solve this. Start by faking a root object. When you do that, all children objects are faked by default. So no need to new them or connect them. You just set behaviors on what matters for your test.

If you can, please post the code you're trying to fake.

Thanks, Gil Zilberfeld Typemock