This is a migrated thread and some comments may be shown as answers.

EF 6 Alpha 3 Mocking

2 Answers 24 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
James Legan
Top achievements
Rank 1
James Legan asked on 06 Mar 2013, 02:21 PM
I grabbed Alpha 3 this morning from NuGet and I seem to be unable to mock EF6 the way I would normally mock OpenAccess. When I try a simple:

var test = Mock.Create<DemoEntities>();

I get a TypeLoadException:

Method 'CallValidateEntity' on type 'DemoEntitiesProxy+53c69f86fe444525a693c487adc77799' from assembly 'Telerik.JustMock.Dynamic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is overriding a method that is not visible from that assembly.

Any thoughts?

2 Answers, 1 is accepted

Sort by
0
James Legan
Top achievements
Rank 1
answered on 06 Mar 2013, 06:26 PM
Posted on CodePlex to the EF6 team as well: http://entityframework.codeplex.com/discussions/435618
0
Kaloyan
Telerik team
answered on 11 Mar 2013, 02:58 PM
Hi James,

I managed to reproduce the issue. It seems that it is a bug in JustMock, which prevents us from being able to mock internal virtual methods with proxy. However, our developers are currently investigating the matter for its cause.

As a workaround, I could suggest you to use the Elevated Automocking feature of our product. With it, I was able to write the following test and it passed:
// Arrange
var mockContainer = new MockingContainer<Model1Container>();
 
var fakeEntity = new Entity1();
 
mockContainer.Arrange<Entity1>(x => x.Id).IgnoreInstance().Returns(555);
 
// Act
var actual = fakeEntity.Id;
 
// Assert
Assert.AreEqual(555, actual);

I hope this helps. I will keep you nottified when we would be able to provide you with a solution, containing the bug fix.

P.S. For reporting such bug in our product, I have granted you some Telerik points.

 

Kind regards,
Kaloyan
the Telerik team
Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
Tags
General Discussions
Asked by
James Legan
Top achievements
Rank 1
Answers by
James Legan
Top achievements
Rank 1
Kaloyan
Telerik team
Share this question
or