public void NotBeValid_GivenNotBacsPaymentSchemes(AllowedPaymentSchemes allowedPaymentSchemes) { _account.AllowedPaymentSchemes = allowedPaymentSchemes; var isValid = _validator.IsPaymentValid(_account, _makePaymentRequest.Amount); isValid.Should().BeFalse(); }
public void IsValid_ShouldReturnFalseIfAccountDoesNotAllowScheme(AllowedPaymentSchemes accountPaymentSchemes) { _account.AllowedPaymentSchemes = accountPaymentSchemes; var result = _validatorInTest.IsValid(_account, _makePaymentRequest); Assert.That(result, Is.False); }
public void WhenPaymentSchemeAllowedValidationReturnTrue(AllowedPaymentSchemes scheme) { _account.AllowedPaymentSchemes = scheme; var result = _validationStrategy.ValidatePayment(_account, _request); Assert.IsTrue(result); }
public void IsValid_ShouldOnlyReturnTrueIfAccountAllowsScheme(AllowedPaymentSchemes accountPaymentSchemes) { _account.AllowedPaymentSchemes = accountPaymentSchemes; var result = _validatorInTest.IsValid(_account, _makePaymentRequest); Assert.That(result, Is.True); }
public void IsAccountInValidState_WhenAccountAllowedPaymentSchemesSetToSpecificValue_ReturnsCorrectResponse (AllowedPaymentSchemes allowedPaymentSchemes, bool expectedValidity) { var sut = new BacsPaymentSchemeValidator(new Account { AllowedPaymentSchemes = allowedPaymentSchemes }); sut.IsAccountInValidState().Should().Be(expectedValidity); }
public bool IsAccountSuitable(Account account, AllowedPaymentSchemes scheme) { if (account.AllowedPaymentSchemes.HasFlag(scheme)) { return(true); } return(false); }
public AccountBuilder() { status = AccountStatus.Live; scheme = AllowedPaymentSchemes.Bacs; transactions = new List <Transaction> { new Transaction(123, TransactionType.Deposit) }; }
public Account(string accountNumber, decimal balance, AccountStatus status, AllowedPaymentSchemes allowedPaymentSchemes) { AccountNumber = accountNumber; Balance = balance; AccountStatus = status; AllowedPaymentSchemes = allowedPaymentSchemes; }
public Account( string accountNumber, AccountStatus status, AllowedPaymentSchemes scheme, List <Transaction> transactions) { AccountNumber = accountNumber; Status = status; AllowedPaymentSchemes = scheme; this.transactions = transactions ?? new List <Transaction>(); }
public void DoesNotAllowChapsFailsValidation(AllowedPaymentSchemes schemes) { ChapsPaymentValidator sut = GetSystemUnderTest(); Account account = _fixture.Create <Account>(); account.AllowedPaymentSchemes = schemes; bool result = sut.ValidatePayment(account, It.IsAny <decimal>()); Assert.False(result); }
public void AllowsBacsPassessValidation(AllowedPaymentSchemes schemes) { BacsPaymentValidator sut = GetSystemUnderTest(); Account account = _fixture.Create <Account>(); account.AllowedPaymentSchemes = schemes; bool result = sut.ValidatePayment(account, It.IsAny <decimal>()); Assert.True(result); }
public void IsValid_NonPaymentFasterPaymentsSchemes_ReturnsFalse(AllowedPaymentSchemes paymentSchemes) { //Arrange _account.AllowedPaymentSchemes = paymentSchemes; //Act var isValid = _fasterPaymentsValidator.IsValid(_account, _makePaymentRequest); //Assert Assert.That(isValid, Is.False); }
public Account GetAccount(string accountNumber) { // Access backup data base to retrieve account, code removed for brevity Dictionary <String, Object> accountDetails = DataStore.GetAccountDetails(accountNumber); string accountNo = accountDetails["AccountNumber"].ToString(); decimal balance = decimal.Parse(accountDetails["Balance"].ToString()); AccountStatus status = (AccountStatus)accountDetails["AccountStatus"]; AllowedPaymentSchemes allowedPaymentSchemes = (AllowedPaymentSchemes)accountDetails["AllowedPaymentSchemes"]; return(new Account(accountNo, balance, status, allowedPaymentSchemes)); }
public void IsValid_NotBacsPaymentSchemes_ReturnsFalse(AllowedPaymentSchemes allowedPaymentSchemes) { //Arrange _account.AllowedPaymentSchemes = allowedPaymentSchemes; //Act var isValid = _bacsValidator.IsValid(_account, _makePaymentRequest); //Assert Assert.That(isValid, Is.False); }
public void ChangeBalanceForChaps_InvalidInformation_BalanceIsNotChangedAndExceptionIsThrown( Account account, decimal amount, decimal initialBalance, AllowedPaymentSchemes requestSchema) { var exception = Record.Exception(() => account.ChangeBalance(amount, requestSchema.ToString())); exception.Should().BeOfType <InvalidBalanceChangeException>(); account.Balance.Should().Be(initialBalance); }
public void AllowsFasterPassessValidation(AllowedPaymentSchemes schemes) { FasterPaymentValidator sut = GetSystemUnderTest(); Account account = _fixture.Create <Account>(); account.Balance = decimal.MaxValue; account.AllowedPaymentSchemes = schemes; bool result = sut.ValidatePayment(account, 10); Assert.True(result); }
/// <summary> /// Get Dummy Test Account /// </summary> /// <param name="status"></param> /// <param name="schemes"></param> /// <param name="balance"></param> /// <returns></returns> private Account GetDummyAccount(AccountStatus status, AllowedPaymentSchemes schemes, decimal balance) { Account account = new Account { AccountNumber = "1233456", Balance = balance, Status = status, AllowedPaymentSchemes = schemes }; return(account); }
public void IsAccountInValidState_WhenAccountAllowedPaymentSchemesSetToSpecificValue_ReturnsCorrectResponse (AllowedPaymentSchemes allowedPaymentSchemes, decimal balance, decimal paymentAmount, bool expectedValidity) { var sut = new FasterPaymentsPaymentSchemeValidator( new Account { AllowedPaymentSchemes = allowedPaymentSchemes, Balance = balance }, new MakePaymentRequest { Amount = paymentAmount }); sut.IsAccountInValidState().Should().Be(expectedValidity); }
public void Test_Verify_ChapsPaymentSchemeValidator_Result(AllowedPaymentSchemes paymentScheme, bool validationResult) { // arrange ChapsPaymentSchemeValidator chapsPaymentSchemeValidator = new ChapsPaymentSchemeValidator(); _account.AllowedPaymentSchemes = paymentScheme; // act MakePaymentResult makePaymentResult = chapsPaymentSchemeValidator.IsAccountValid(_account, _makePaymentRequest); // assert Assert.AreEqual(makePaymentResult.Success, validationResult); }
public void Validates(AllowedPaymentSchemes allowedPaymentSchemes, bool expectedValidity) { // Arrange var account = new Account { AllowedPaymentSchemes = allowedPaymentSchemes }; var validator = new BacsValidator(); // Act bool isValid = validator.AccountCanMakePayment(account); // Assert Assert.AreEqual(expectedValidity, isValid); }
public void Validates(AllowedPaymentSchemes allowedPaymentSchemes, decimal balance, decimal amount, bool expectedValidity) { // Arrange var account = new Account { AllowedPaymentSchemes = allowedPaymentSchemes, Balance = balance }; var validator = new FasterPaymentsValidator(amount); // Act bool isValid = validator.AccountCanMakePayment(account); // Assert Assert.AreEqual(expectedValidity, isValid); }
public void WhenRequestIsValid_AndAccountExists_AndHasMatchingAllowedPaymentScheme_UpdatesBalanceInDatastore( PaymentScheme requestedScheme, AllowedPaymentSchemes allowedScheme) { var storedAccount = ExistingStoredAccount(balance: 1000m, allowedScheme: allowedScheme); _mockDataStore.Setup(dataStore => dataStore.GetAccount(ExistingDebtorAccountNumber)) .Returns((true, storedAccount)); var makePaymentRequest = new MakePaymentRequest( "creditorAccount", ExistingDebtorAccountNumber, 100.0m, DateTime.Now, requestedScheme); _ = _paymentService.MakePayment(makePaymentRequest); _mockDataStore.Verify(datastore => datastore.UpdateAccount( It.Is <Account>(account => account.AccountNumber.Equals(ExistingDebtorAccountNumber) && account.Balance.Equals(900m) ))); }
public void PaymentFailed_InvalidPaymentScheme_ShouldReturnFalse_Test(AllowedPaymentSchemes allowedPaymentScheme, PaymentScheme paymentScheme) { var testAccount = new Account() { AccountNumber = AccountNumber, AllowedPaymentSchemes = allowedPaymentScheme, Balance = 5000, Status = AccountStatus.Live }; _mockAccountDataStore.Setup(x => x.GetAccount(AccountNumber)).Returns(() => testAccount); var actualResult = _paymentService.MakePayment(new MakePaymentRequest() { DebtorAccountNumber = AccountNumber, PaymentScheme = paymentScheme, Amount = 1000 }); Assert.IsFalse(actualResult.Success); }
public void Should_ReduceBalance_WhenRequestingAllowedPayment(AllowedPaymentSchemes allowedPaymentScheme, PaymentScheme requestedPaymentScheme) { // Arrange decimal balance = 1000; decimal amount = 100; decimal expectedRemainingBalance = balance - amount; var account = new Account() { AllowedPaymentSchemes = allowedPaymentScheme, Balance = balance }; _target = MockAccountAndGet(account); //act _target.MakePayment(new MakePaymentRequest() { PaymentScheme = requestedPaymentScheme, Amount = amount }); //assert Assert.AreEqual(expectedRemainingBalance, account.Balance); }
public AccountBuilder WithAllowedPaymentSchemes(AllowedPaymentSchemes withAllowedPaymentSchemes) { allowedPaymentSchemes = withAllowedPaymentSchemes; return(this); }
protected PaymentValidator(AllowedPaymentSchemes paymentScheme) { _paymentScheme = paymentScheme; }
public bool HasFlag(Account account, AllowedPaymentSchemes paymentScheme) { return(account.AllowedPaymentSchemes.HasFlag(paymentScheme)); }
private static Account ExistingStoredAccount( AllowedPaymentSchemes allowedScheme = AllowedPaymentSchemes.FasterPayments, decimal balance = 100m) { return(new(ExistingDebtorAccountNumber, balance, AccountStatus.Live, allowedScheme)); }
public PaymentSchemeRule(AllowedPaymentSchemes paymentScheme) { _paymentScheme = paymentScheme; }
public void GivenIHaveAnAccount(string accountNumber, Decimal balance, AccountStatus accountStatus, AllowedPaymentSchemes allowedPaymentScheme) { var account = new Account() { AccountNumber = accountNumber, Balance = balance, Status = accountStatus, AllowedPaymentSchemes = allowedPaymentScheme }; ScenarioContext.Current["DebtorAccount"] = account; }