public void AddShipper_GivenANewShipper_AddsToDatabase() { // arrange Mock <DbSet <Shipper> > mockSet = new Mock <DbSet <Shipper> >(); Mock <ShippingDb> mockContext = new Mock <ShippingDb>(); mockContext.Setup(c => c.Shippers).Returns(mockSet.Object); ShipperRepository sut = new ShipperRepository(mockContext.Object); Shipper shipper = new Shipper() { ID = 200 }; // act sut.AddShipper(shipper); // assert mockSet.Verify(s => s.Add(It.Is <Shipper>(a => a.ID == 200)), Times.Once()); mockContext.Verify(c => c.SaveChanges(), Times.Once()); }