Alex,
look at the following test:
[Test]
public void GetData_MockContext()
{
List<ProjectOwner> fakeList = new List<ProjectOwner>();
fakeList.Add(new ProjectOwner());
using (RecordExpectations rec = new RecordExpectations())
{
AlexDreskoDataContext mockContext = RecorderManager.CreateMockedObject<AlexDreskoDataContext>();
var dum1 = mockContext.Skills;
rec.Return(null);
var dum2 = mockContext.ProjectOwners.OrderByDescending(c => c.StartDate).ToList();
rec.Return(fakeList);
DatabaseManager.GetContext();
rec.Return(mockContext);
}
ResumeData actual = ResumeManager.GetData();
Assert.IsNull(actual.Skills);
Assert.AreEqual(1, actual.ProjectOwners.Count);
}
I think this does most of what you need.
:arrow: Its really hard creating fake tables. The table class was not meant to be created from user code, and although it is possible, doing so will complicate your test code. The easier way is to try to convert the table into a list based objects as soon as possible. In your case I would do that when creating and populating the ResumaData object.
:!: I know that this test will not work outright on your code (mainly because I'm returning a list where you use a Table<>), but I'm sure that if you can wrap the code that you have into a small solution and send to us, i can tweak this specifically to your needs.
Anyway, I hope this help, but mocking LINQ is quite tricky so feel free to ask more questions if you have any.