EF 6 Alpha 3 Mocking

3 posts, 0 answers
  1. James Legan
    James Legan avatar
    54 posts
    Member since:
    Sep 2008

    Posted 06 Mar 2013 Link to this post

    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. James Legan
    James Legan avatar
    54 posts
    Member since:
    Sep 2008

    Posted 06 Mar 2013 Link to this post

    Posted on CodePlex to the EF6 team as well: http://entityframework.codeplex.com/discussions/435618
  3. DevCraft R3 2016 release webinar banner
  4. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 11 Mar 2013 Link to this post

    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.
Back to Top