Esempio n. 1
0
        public async Task GetAllinfoAsync__An_unexpected_internal_error_occurred__Should_throw_Exception()
        {
            _infoDbServiceMock.Setup(x => x.GetAllAsync()).ThrowsAsync(new Exception());
            var controller = new SDCWebApp.Controllers.VisitInfoController(_infoDbServiceMock.Object, _logger, _mapperMock.Object);

            Func <Task> result = async() => await controller.GetAllInfoAsync();

            await result.Should().ThrowExactlyAsync <Exception>();
        }
Esempio n. 2
0
        public async Task GetAllinfoAsync__At_least_one_element_found__Should_return_200OK_response_with_not_empty_IEnumerable()
        {
            _infoDbServiceMock.Setup(x => x.GetAllAsync()).ReturnsAsync(new VisitInfo[] { _info });
            _mapperMock.Setup(x => x.Map <IEnumerable <VisitInfoDto> >(It.IsNotNull <IEnumerable <VisitInfo> >())).Returns(_infoDtos.AsEnumerable());
            var controller = new SDCWebApp.Controllers.VisitInfoController(_infoDbServiceMock.Object, _logger, _mapperMock.Object);

            var result = await controller.GetAllInfoAsync();

            (result as ObjectResult).StatusCode.Should().Be(200);
            (((result as ObjectResult).Value as ResponseWrapper).Data as IEnumerable <VisitInfoDto>).Should().NotBeEmpty();
        }
Esempio n. 3
0
        public async Task GetAllinfoAsync__An_internal_error_reffered_to_the_database_occurred__Should_throw_InternalDbServiceException()
        {
            // Example of these errors: database does not exist, table does not exist etc.

            _infoDbServiceMock.Setup(x => x.GetAllAsync()).ThrowsAsync(new InternalDbServiceException());
            var controller = new SDCWebApp.Controllers.VisitInfoController(_infoDbServiceMock.Object, _logger, _mapperMock.Object);

            Func <Task> result = async() => await controller.GetAllInfoAsync();

            await result.Should().ThrowExactlyAsync <InternalDbServiceException>();
        }