public void TransferRaportTest() { //Arrange CKIR KIR = new CKIR(); CBank bank = new CBank(KIR); bank.AddCustomer("Ivan", "Pavlov", 1); bank.StoreAccount(1, 1); bank.AddCustomer("Rafal", "Swierczewsky", 2); bank.StoreAccount(2, 2); bank.PayIn(bank.GetAccount(1), 600m); bank.Transfer(bank.GetAccount(1), bank.GetAccount(2), 500m); //TRANSFER bank.PayIn(bank.GetAccount(1), 500m); bank.PayIn(bank.GetAccount(1), 500m); bank.Transfer(bank.GetAccount(1), bank.GetAccount(2), 500m); //TRANSFER bank.WithDraw(bank, bank.GetAccount(1), 500m); bank.PayIn(bank.GetAccount(1), 500m); bank.PayIn(bank.GetAccount(1), 500m); bank.WithDraw(bank, bank.GetAccount(1), 500m); IRaport transferraport = new CTransferRaport(); string temp = transferraport.accept(new CRaportDisplayVisitor(), bank.GetAccount(1).GetHistory()); string expected = "500-TRANSFER...500-TRANSFER"; //Assert Assert.AreEqual(temp, expected); }
public void NoUSTransferResponsibilityTest() { //Arrange CKIR KIR = new CKIR(); CBank bank = new CBank(KIR); bank.AddCustomer("Ivan", "Pavlov", 1); bank.StoreAccount(1, 1); bank.AddCustomer("Rafal", "Swierczewsky", 2); bank.StoreAccount(2, 2); US us = new US(); ITransferResposibility transferNormal = new CNormalTransfer(); ITransferResposibility transferBig = new CBigTransfer(); transferNormal.setNextTransferResp(transferBig); transferBig.SetUS(us); bank.PayIn(bank.GetAccount(1), 30000m); Transfer test = bank.Transfer(bank.GetAccount(1), bank.GetAccount(2), 2500m); transferNormal.transfer(test); //Assert Assert.AreEqual(bank.GetAccount(2).GetSaldo(), 2500m); Assert.IsNotNull(bank.GetAccount(1).GetHistory()); Assert.AreEqual(bank.GetAccount(1).GetSaldo(), 27500m); Assert.AreEqual(us.GetTransferList().Count, 0); //not logged in US, transfer < 20000 }
public void OuterTransferTest() { //Arrange CKIR KIR = new CKIR(); CBank bank1 = new CBank(KIR); CBank bank2 = new CBank(KIR); KIR.AddBank(bank1); KIR.AddBank(bank2); bank1.AddCustomer("Ivan", "Pavlov", 1); bank1.StoreAccount(1, 1); bank2.AddCustomer("Rafal", "Swierczewsky", 2); bank2.StoreAccount(2, 2); bank1.PayIn(bank1.GetAccount(1), 600m); bank1.Transfer(bank1.GetAccount(1), bank2.GetAccount(2), 500m); bank1.Send(); KIR.Send(); //Assert Assert.AreEqual(bank2.GetAccount(2).GetSaldo(), 500m); Assert.AreEqual(bank1.GetAccount(1).GetSaldo(), 100m); }
public void PayInTest() { //Arrange CKIR KIR = new CKIR(); CBank bank = new CBank(KIR); bank.AddCustomer("Ivan", "Pavlov", 1); bank.StoreAccount(1, 1); bank.PayIn(bank.GetAccount(1), 500m); //Assert Assert.AreEqual(bank.GetAccount(1).GetSaldo(), 500m); }
public void PayInRaportTest() { //Arrange CKIR KIR = new CKIR(); CBank bank = new CBank(KIR); bank.AddCustomer("Ivan", "Pavlov", 1); bank.StoreAccount(1, 1); bank.PayIn(bank.GetAccount(1), 500m); //PAYIN bank.PayIn(bank.GetAccount(1), 500m); //PAYIN bank.WithDraw(bank, bank.GetAccount(1), 500m); bank.PayIn(bank.GetAccount(1), 500m); //PAYIN bank.PayIn(bank.GetAccount(1), 500m); //PAYIN bank.WithDraw(bank, bank.GetAccount(1), 500m); IRaport payinraport = new CPayInRaport(); string temp = payinraport.accept(new CRaportDisplayVisitor(), bank.GetAccount(1).GetHistory()); string expected = "500-PAYIN...500-PAYIN...500-PAYIN...500-PAYIN"; //Assert Assert.AreEqual(bank.GetAccount(1).GetSaldo(), 1000m); Assert.AreEqual(temp, expected); }
public void LowInterestTest() { CKIR KIR = new CKIR(); CBank bank = new CBank(KIR); bank.AddCustomer("Ivan", "Pavlov", 1); bank.StoreAccount(1, 1); bank.PayIn(bank.GetAccount(1), 500m); //Assert Assert.AreEqual(bank.GetAccount(1).GetSaldo(), 500m); bank.GetAccount(1).Request(); Assert.AreEqual(bank.GetAccount(1).GetSaldo(), 550m); }
public void WithDrawDebitTest() { //Arrange CKIR KIR = new CKIR(); CBank bank = new CBank(KIR); bank.AddCustomer("Ivan", "Pavlov", 1); bank.StoreAccount(1, 1); bank.PayIn(bank.GetAccount(1), 500m); IAccount decBank = new DecoratorDebit(bank); decBank.WithDraw(bank, bank.GetAccount(1), 600m); //Assert Assert.AreEqual(bank.GetAccount(1).GetSaldo(), -100m); }
public void InnerTransferTest() { //Arrange CKIR KIR = new CKIR(); CBank bank = new CBank(KIR); bank.AddCustomer("Ivan", "Pavlov", 1); bank.StoreAccount(1, 1); bank.AddCustomer("Rafal", "Swierczewsky", 2); bank.StoreAccount(2, 2); bank.PayIn(bank.GetAccount(1), 600m); bank.Transfer(bank.GetAccount(1), bank.GetAccount(2), 500m); //Assert Assert.AreEqual(bank.GetAccount(2).GetSaldo(), 500m); Assert.IsNotNull(bank.GetAccount(1).GetHistory()); Assert.AreEqual(bank.GetAccount(1).GetSaldo(), 100m); }