public void Update_Order() { // Arrange var orderDataService = new OrderDataService(sourceService.Object, iLoggerFactory.Object.CreateLogger <OrderDataService>()); var requestOrder = new Order() { Id = 1, Amount = 29.99M, DateCreated = DateTime.UtcNow }; var itms = new List <DbOrder>() { requestOrder.OrderToDbOrder() }; var ordersMock = TestHelper.ToDbSetMock(itms); ordersMock.Setup(d => d.UpdateRange(It.IsAny <DbOrder[]>())).Callback <DbOrder[]>((s) => { s.ToList().ForEach(fe => { var fod = itms.FirstOrDefault(v => v.Id == fe.Id); if (fod != null) { fod.DateCreated = fe.DateCreated; fod.Amount = fe.Amount; } }); }); sourceService.Setup(x => x.Orders).Returns(ordersMock.Object); sourceService.Setup(x => x.Set <DbOrder>()).Returns(ordersMock.Object); var ord = new Order() { Id = 1, Amount = 77.77M, DateCreated = DateTime.UtcNow.AddDays(15) }.OrderToDbOrder(); var badOrder = new Order() { Id = Int32.MaxValue, Amount = 1.1M, DateCreated = DateTime.UtcNow.AddDays(30) }.OrderToDbOrder(); // Action orderDataService.Update(ord); orderDataService.Update(badOrder); // Assert ordersMock.Verify(x => x.UpdateRange(It.IsAny <DbOrder[]>()), Times.Exactly(2)); Assert.AreEqual(1, itms.Count); var updatedItem = itms.First(); Assert.AreEqual(ord.Amount, updatedItem.Amount); Assert.AreEqual(ord.DateCreated, updatedItem.DateCreated); }