public void GivenAnExistingEntity_WhenUpdating_ThePersistedEntityIsUpdated() { var fakeEntity = new Entity { Id = 2 }; var fakeUpdate = new Entity { Id = 2, Name = "N1", PrimaryEmail = "p1", RegistrationNumber = "r1", Url = "U1" }; var entityList = Enumerable.Range(0, 100) .Select(r => r == fakeEntity.Id ? fakeEntity : new Entity { Id = r }); contextMock.SetupGet(r => r.Entities).Returns(entityList.ToDbSet()); var response = entitiesController.UpdateEntity(fakeUpdate.Id, fakeUpdate); contextMock.Verify(r => r.SaveChanges(), Times.Once); Assert.AreEqual(fakeUpdate.Name, fakeEntity.Name); Assert.AreEqual(fakeUpdate.PrimaryEmail, fakeEntity.PrimaryEmail); Assert.AreEqual(fakeUpdate.RegistrationNumber, fakeEntity.RegistrationNumber); }