コード例 #1
0
        public void SuccessfulAdjustment()
        {
            MockRepositoryService repositoryService = new MockRepositoryService();
            PaymentService        paymentService    = new PaymentService(repositoryService);

            paymentService.Pay(new PaymentInput()
            {
                AccountId     = 4755,
                MessageType   = "PAYMENT",
                TransactionId = 1,
                Origin        = "VISA",
                Amount        = 100
            });

            paymentService.Adjust(new PaymentInput()
            {
                AccountId     = 4755,
                MessageType   = "ADJUSTMENT",
                TransactionId = 1,
                Origin        = "VISA",
                Amount        = 50
            });

            decimal expectedResult = 950.88m;
            decimal amount         = repositoryService.GetAmount(4755);

            Assert.Equal(expectedResult, amount);
        }
コード例 #2
0
        public void InvalidMessageType()
        {
            MockRepositoryService repositoryService = new MockRepositoryService();
            PaymentService        paymentService    = new PaymentService(repositoryService);

            var exception = Assert.Throws <Exception>(() => paymentService.Pay(new PaymentInput()
            {
            }));

            Assert.Equal("Message Type is not valid", exception.Message);
        }
コード例 #3
0
        public void AccountNotFound()
        {
            MockRepositoryService repositoryService = new MockRepositoryService();
            PaymentService        paymentService    = new PaymentService(repositoryService);

            var exception = Assert.Throws <Exception>(() => paymentService.Pay(new PaymentInput()
            {
                AccountId   = 1289,
                MessageType = "PAYMENT"
            }));

            Assert.Equal("Account not found", exception.Message);
        }
コード例 #4
0
        public void TransactionNotFound()
        {
            MockRepositoryService repositoryService = new MockRepositoryService();
            PaymentService        paymentService    = new PaymentService(repositoryService);

            var exception = Assert.Throws <Exception>(() => paymentService.Adjust(new PaymentInput()
            {
                AccountId     = 4755,
                MessageType   = "ADJUSTMENT",
                TransactionId = 0
            }));

            Assert.Equal("Transaction not found", exception.Message);
        }