public async Task GetAllTariffAsync__An_unexpected_internal_error_occurred__Should_throw_Exception() { _tariffDbServiceMock.Setup(x => x.GetAllAsync()).ThrowsAsync(new Exception()); var controller = new VisitTariffsController(_tariffDbServiceMock.Object, _logger, _mapperMock.Object); Func <Task> result = async() => await controller.GetAllTariffsAsync(); await result.Should().ThrowExactlyAsync <Exception>(); }
public async Task GetAllTariffAsync__At_least_one_element_found__Should_return_200OK_response_with_not_empty_IEnumerable() { _tariffDbServiceMock.Setup(x => x.GetAllAsync()).ReturnsAsync(_tariffs); _mapperMock.Setup(x => x.Map <IEnumerable <VisitTariffDto> >(It.IsNotNull <IEnumerable <VisitTariff> >())).Returns(_tariffDtos.AsEnumerable()); var controller = new VisitTariffsController(_tariffDbServiceMock.Object, _logger, _mapperMock.Object); var result = await controller.GetAllTariffsAsync(); (result as ObjectResult).StatusCode.Should().Be(200); (((result as ObjectResult).Value as ResponseWrapper).Data as IEnumerable <VisitTariffDto>).Should().NotBeEmpty(); }
public async Task GetAllTariffAsync__An_internal_error_reffered_to_the_database_occurred__Should_throw_InternalDbServiceException() { // Example of these errors: database does not exist, table does not exist etc. _tariffDbServiceMock.Setup(x => x.GetAllAsync()).ThrowsAsync(new InternalDbServiceException()); var controller = new VisitTariffsController(_tariffDbServiceMock.Object, _logger, _mapperMock.Object); Func <Task> result = async() => await controller.GetAllTariffsAsync(); await result.Should().ThrowExactlyAsync <InternalDbServiceException>(); }