public async Task GetPayment_ShouldRequestPaymentForTransactionIdAndCompanyId() { //Arrange var companyId = Guid.NewGuid(); var paymentId = Guid.NewGuid(); var sut = new GetPaymentService(_paymentsRepositoryMock.Object, _loggerMock.Object); //Act await sut.GetPaymentAsync(paymentId, companyId); //Assert _paymentsRepositoryMock.Verify(x => x.GetPaymentAsync(paymentId, companyId), Times.Once); }
public async Task GetPayment_WhenPaymentDoesNotExist_ShouldLogDetails() { //Arrange var companyId = Guid.NewGuid(); var paymentId = Guid.NewGuid(); var sut = new GetPaymentService(_paymentsRepositoryMock.Object, _loggerMock.Object); //Act await sut.GetPaymentAsync(paymentId, companyId); //Assert _loggerMock.Verify( x => x.Write(LogLevel.Warning, $"{EventCodes.PaymentRequestedNotFound} - TransactionId: {paymentId}, CompanyId: {companyId}"), Times.Once); }
public async Task GetPayment_ShouldReturnPaymentReturnedByRepository() { //Arrange var companyId = Guid.NewGuid(); var paymentId = Guid.NewGuid(); var expectedPaymentRecord = GeneratePaymentRecord(companyId, paymentId); _paymentsRepositoryMock.Setup(x => x.GetPaymentAsync(It.IsAny <Guid>(), It.IsAny <Guid>())) .ReturnsAsync(expectedPaymentRecord); var sut = new GetPaymentService(_paymentsRepositoryMock.Object, _loggerMock.Object); //Act var result = await sut.GetPaymentAsync(paymentId, companyId); //Assert result.Should().BeEquivalentTo(expectedPaymentRecord); }