chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
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
asked by koimad (640 points)

3 Answers

0 votes
Hello,

Are you using ASP.NET MVC3 by a chance? There's an unfortunate bug with MVC3, which we are currently working on...

Could you try the same code in ASP.NET MVC2 application?

Also, please see if you have the AllowPartiallyTrustedCallers or SecurityTransparent attributes defined anywhere in your code?
answered by igal (5.7k points)
0 votes
I've checked the code and search for the secutiry attribute and cannot find any, I'm not using any ASP MVC technology, all i've done is created a silverlight project with RIA Services Enabled, added a EntityFrameWorkModel, built the projected and then added a domainservice from the new item menu and allowed it expose the EF Model.

I've then added a constructor to take the EF Model as a Parameter

A this point I then created a test project for the .Web side of the silverlight projected and updated the tests to pass in a Isolator instance of the EF model.

Brian
answered by koimad (640 points)
0 votes
Thank you very much for the info, Brian.

We'll get a repro going, and I will update you as soon as possible on the issue!
answered by igal (5.7k points)
...