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