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); }
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); }
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); }
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); }