Ejemplo n.º 1
0
        public void TransferFine()
        {
            var startSummaAccount1 = 120;
            var startSummaAccount2 = 10;
            var amount             = 100;
            var UnitOfWork         = new Mock <IUnitOfWork>();
            var Mapper             = new Mock <IMapper>();

            var TransactionServises = new TransactionServises(UnitOfWork.Object, Mapper.Object);
            var Account1            = new Account()
            {
                Balance = startSummaAccount1,
                Id      = 1
            };
            var Account2 = new Account()
            {
                Balance = startSummaAccount2,
                Id      = 1
            };

            UnitOfWork.Setup(e => e.Transaction).Returns(new Mock <ITransactionRepositories <Transaction> >().Object);
            UnitOfWork.Setup(e => e.Accounts.Get("Test_User_1")).Returns(Account1);
            UnitOfWork.Setup(e => e.Accounts.Get("Test_User_2")).Returns(Account2);
            TransactionServises.Transfer(amount, "Test_User_1", "Test_User_2");

            Assert.AreEqual(Account1.Balance, startSummaAccount1 - amount);
            Assert.AreEqual(Account2.Balance, startSummaAccount2 + amount);
        }
Ejemplo n.º 2
0
        public void DepositFine()
        {
            var amount     = 100;
            var UnitOfWork = new Mock <IUnitOfWork>();
            var Mapper     = new Mock <IMapper>();

            var TransactionServises = new TransactionServises(UnitOfWork.Object, Mapper.Object);
            var Account             = new Account()
            {
                Balance = 0,
                Id      = 1
            };

            UnitOfWork.Setup(e => e.Transaction).Returns(new Mock <ITransactionRepositories <Transaction> >().Object);
            UnitOfWork.Setup(e => e.Accounts.Get("Test_User_1")).Returns(Account);
            TransactionServises.Deposit("Test_User_1", amount);

            Assert.AreEqual(Account.Balance, amount);
        }
Ejemplo n.º 3
0
        public void WithdrawMoreThatBalance()
        {
            var startSumma = 120;
            var amount     = 150;
            var UnitOfWork = new Mock <IUnitOfWork>();
            var Mapper     = new Mock <IMapper>();

            var TransactionServises = new TransactionServises(UnitOfWork.Object, Mapper.Object);
            var Account             = new Account()
            {
                Balance = startSumma,
                Id      = 1
            };

            UnitOfWork.Setup(e => e.Transaction).Returns(new Mock <ITransactionRepositories <Transaction> >().Object);
            UnitOfWork.Setup(e => e.Accounts.Get("Test_User_1")).Returns(Account);
            TransactionServises.Withdraw("Test_User_1", amount);

            Assert.AreEqual(Account.Balance, startSumma);
        }