Mocking Entity Framework Updating Record

2 posts, 0 answers
  1. Dustyn
    Dustyn avatar
    2 posts
    Member since:
    Oct 2017

    Posted 03 May 2018 Link to this post

    I'm attempting to update (not add) a record in a mocked DB and am not succeeding. I have a FakeDbEntries that is an IList<LogEntry>. I have Mocked my DbContext as

    _mockLogRepo = Mock.Create<ILogRepo>();

    _mockLogRepo.Arrange(m => m.LogEntries).ReturnsCollection(FakeDbEntries());


    When I run the unit under test that calls the ILogRepo and does the update, the SaveChanges() never sticks.

  2. Mihail
    Mihail avatar
    265 posts

    Posted 08 May 2018 Link to this post

    Hello Dustyn,

    Once arranged the LogEntries should return the records from the FakeDbEntries method. In this case, I am not sure what is the exact problem.
    Would it be possible for you to provide a simple demo project with a minimum number of classes? This way we will be able to investigate the scenario and better assist you. Please have in mind that the system will allow archived attachments only in support tickets.

    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top