Exemple #1
0
        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);
        }
Exemple #2
0
        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
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        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);
        }