public void AddVehicle() { var mockSet = new Mock <DbSet <Car> >(); var mockContext = new Mock <CarsContext>(); mockContext.Setup(m => m.Cars).Returns(mockSet.Object); //mockContext.Setup var service = new CarsService(mockContext.Object); service.AddVehicle(new Car { Id = 0, Make = "TestMake", Model = "TestModel" }); mockSet.Verify(m => m.Add(It.IsAny <Car>()), Times.Once()); mockContext.Verify(m => m.SaveChanges(), Times.Once()); }
public Task AddNewVehicle(Car newVehicle) { _carSrv.AddVehicle(newVehicle); SendVehicleCollection(); return(Task.CompletedTask); }