public async void Can_retrieve_existing_loan_application() { // Arrange var repositoryMock = new Mock <ILoanApplicationRepository>(MockBehavior.Strict); repositoryMock.Setup(m => m.RetrieveLoanApplication(It.IsNotNull <string>())) .ReturnsAsync((string id) => new LoanApplication { Id = id }); var handler = new RetrieveLoanApplicationHandler(repositoryMock.Object); var request = new RetrieveLoanApplication { LoanApplicationId = Guid.NewGuid().ToString() }; // Act var response = await handler.Handle(request, CancellationToken.None); // Assert Assert.Equal(request.LoanApplicationId, response.LoanApplication.Id); }
public async void Resource_exception_when_non_existent_loan_application() { // Arrange var repositoryMock = new Mock <ILoanApplicationRepository>(MockBehavior.Strict); repositoryMock.Setup(m => m.RetrieveLoanApplication(It.IsNotNull <string>())) .ReturnsAsync((string id) => null); var handler = new RetrieveLoanApplicationHandler(repositoryMock.Object); var request = new RetrieveLoanApplication { LoanApplicationId = Guid.NewGuid().ToString() }; // Act await Assert.ThrowsAsync <NotFoundResourceException>(() => handler.Handle(request, CancellationToken.None)); }