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

Mocking Entity Framework Updating Record

1 Answer 96 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dustyn
Top achievements
Rank 1
Dustyn asked on 03 May 2018, 07:42 PM

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.

1 Answer, 1 is accepted

Sort by
0
Mihail
Telerik team
answered on 08 May 2018, 08:01 AM
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.

Regards,
Mihail
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
Tags
General Discussions
Asked by
Dustyn
Top achievements
Rank 1
Answers by
Mihail
Telerik team
Share this question
or