コード例 #1
0
        public void Test5()
        {
            Bank   bank1   = new Bank(10000, 4, 500, 5);
            Client client1 = new Client("Petya", "Petrov", "Nevsiy pr.", 401223, 1);

            bank1.CreateAccount(client1, 50000, AccountType.DebitAccount);

            Participants participants = new Participants(client1.GetAccount(0), 20000);
            Transaction  tr           = new TakeMoneyTransactionDebit(participants);

            tr.Do();

            Participants participants2 = new Participants(client1.GetAccount(0), 10000);
            Transaction  tr2           = new TakeMoneyTransactionDebit(participants2);

            tr2.Do();

            tr.Do();

            Participants participants3 = new Participants(client1.GetAccount(0), 5000);
            Transaction  tr3           = new RechargeTransactionDebit(participants3);

            tr3.Do();

            tr3.Undo();
            //tr3.Undo(); //будет ошибка, тк нельзя отметить действие, которого не было

            Assert.AreEqual(0, client1.GetAccount(0).sum);
        }
コード例 #2
0
        public void Test1()
        {
            Bank   bank1   = new Bank(10000, 4, 500, 5);
            Client client1 = new Client("Petya", "Petrov", 1);
            Client client2 = new Client("Ivanov", "Ivan", "Voznesenskiy pr.", 401358, 2);

            bank1.CreateAccount(client1, 50000, AccountType.DebitAccount);
            bank1.CreateAccount(client2, 12000, AccountType.DebitAccount);

            Assert.AreEqual(true, client1.GetAccount(0).isDoubtful);


            Participants participants = new Participants(client1.GetAccount(0), 9000);
            Transaction  tr           = new TakeMoneyTransactionDebit(participants);

            tr.Do();
            Assert.AreEqual(41000, client1.GetAccount(0).sum);

            client1.AddAddress("Nevskiy pr.", bank1);
            Assert.AreEqual(false, client1.GetAccount(0).isDoubtful);



            Participants participants2 = new Participants(client1.GetAccount(0), client2.GetAccount(0), 1000);
            Transaction  tr2           = new TransferTransactionDebit(participants2);

            tr2.Do();
            Assert.AreEqual(40000, client1.GetAccount(0).sum);
            Assert.AreEqual(13000, client2.GetAccount(0).sum);
        }
コード例 #3
0
        public void Test4()
        {
            Bank   bank1   = new Bank(10000, 4, 500, 5);
            Client client1 = new Client("Petya", "Petrov", 401223);

            bank1.CreateAccount(client1, 50000, AccountType.DebitAccount);


            Participants participants = new Participants(client1.GetAccount(0), 20000);
            Transaction  tr           = new TakeMoneyTransactionDebit(participants);

            tr.Do();
            Assert.AreEqual(30000, client1.GetAccount(0).sum);
        }