I’m in the process of trialling Isolator 2010 for .Net, I’m using it on Windows 7 Ultimate x64 with Visual Studio 2010, and I’m trying to setup Isolator to Mock a EntityFrameWorkModel passed in to the constructor of a RIA DomainService Class as shown below.
public class DomainService1 : LinqToEntitiesDomainService<FrameworkDemoEntities>
{
private FrameworkDemoEntities _context;
public DomainService1(FrameworkDemoEntities context)
{
_context = context;
}
protected override FrameworkDemoEntities CreateObjectContext()
{
return _context;
}
In Visual Studio I added a Test Project and have followed you getting started instructions to create the following test Class
[TestClass()]
[Isolated()]
public class DomainService1Test
{
[TestMethod()]
public void GetBusinessDirectoriesTest()
{
FrameworkDemoEntities mock = Isolate.Fake.Instance<FrameworkDemoEntities>();
Isolate.WhenCalled( () => mock.BusinessDirectories).WillReturn(Isolate.Fake.Instance<ObjectSet<BusinessDirectory>>());
DomainService1 target = new DomainService1(mock);
target.Initialize(CreateDomainServiceContext());
IQueryable<BusinessDirectory> expected = null; // TODO: Initialize to an appropriate value
IQueryable<BusinessDirectory> actual;
actual = target.GetBusinessDirectories();
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
When I pass the mock object in into the Domain Service I Get a VerifiactionException “Operation could destabilize the runtime.”. Having looked on the web I cannot find a solution to the problem, can anyone offer any advice on how to fix the problem
Brian Wilkinson