예제 #1
0
        public async Task GetSingleByIdAsync_Should_Fail_Gracefully_On_Exception()
        {
            //Arrange
            _sut = new CustomerQuery(DbContextBuilder.InitEmptyContext(), loggerMock.Object, mapper.CreateMapper());

            //Act
            var result = await _sut.GetSingleByIdAsync(1);

            //Assert
            result.IsSuccess.ShouldBeFalse();
            //loggerMock.Verify(x => x.LogInformation("An error was thrown"),Times.Once);
        }
예제 #2
0
        public async Task GetAllAsync_Should_Return_Valid_List()
        {
            //Arrange
            dbContextMock = DbContextBuilder.InitContextWithInMemoryDbSupport();

            _sut = new CustomerQuery(dbContextMock, loggerMock.Object, mapper.CreateMapper());
            //Act
            var result = await _sut.GetAllAsync();

            //Assert
            result.IsSuccess.ShouldBeTrue();
            result.Customers.ShouldNotBeNull();
            result.Customers.Any().ShouldBeTrue();
            result.Customers.FirstOrDefault().Id.ShouldBe(1);
            result.ErrorMessage.ShouldBeNull();
        }