コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }