public void Add_WithValidLocation_CallsAddOnDbcontext() { var contextMock = new Mock <EggProductionDbContext>(); var repo = new LocationRepository(contextMock.Object); var location = _locationTestHelper.ValidLocation(); repo.Add(location); contextMock.Verify(c => c.Add(location), Times.Once); }
public Location CreateVerify( ILocationRepository locationRepository = null, ILocationValidator validator = null) { locationRepository ??= new Mock <ILocationRepository>().Object; validator ??= new Mock <ILocationValidator>().Object; var service = new LocationService(locationRepository, validator) as ILocationService; var location = _locationTestHelper.ValidLocation(); service.Create(location); return(location); }