public async void DriversService_GetAll_NoDrivers() { // Arrange var mockDriver = MockDriverData.GetEmptyEntityListAsync(); var mockDriverRepo = new MockDriverRepository().MockGetAll(mockDriver); var mockDriverLoggerRepo = new MockLoggerRepository <DriversService>(); var mockDriversService = new DriversService(mockDriverRepo.Object, mockDriverLoggerRepo.Object); // Act var drivers = await mockDriversService.GetDrivers(); // Assert Assert.Empty(drivers); mockDriverRepo.VerifyGetAllForDriver(Times.Once()); }
public async void DriversService_GetById_ValidId() { // Arrange var mockId = 13; var mockDriver = MockDriverData.GetSingleEntityAsync(); var mockDriverRepo = new MockDriverRepository().MockGetById(mockDriver); var mockDriverLoggerRepo = new MockLoggerRepository <DriversService>(); var mockDriversService = new DriversService(mockDriverRepo.Object, mockDriverLoggerRepo.Object); // Act var driver = await mockDriversService.GetDriver(mockId); // Assert Assert.Equal(mockId, driver.id); mockDriverRepo.VerifyGetByIdForDriver(Times.Once()); }
public async void DriversService_GetAllFilter_NoDrivers() { // Arrange var mockDriver = MockDriverData.GetEmptyEntityListAsync(); DriversResourceParameters parameters = new DriversResourceParameters { Name = "Vettel" }; var mockDriverRepo = new MockDriverRepository().MockGetByName(mockDriver); var mockDriverLoggerRepo = new MockLoggerRepository <DriversService>(); var mockDriversService = new DriversService(mockDriverRepo.Object, mockDriverLoggerRepo.Object); // Act var drivers = await mockDriversService.GetDrivers(parameters); //Assert Assert.Empty(drivers); mockDriverRepo.VerifyGetByNameForDriver(Times.Once()); }