public void PerformTransferCreateActivities()
        {
            //Arrange
            var customer = GetCustomer();

            var source = BankAccountFactory.CreateBankAccount(
                customer,
                new BankAccountNumber("1111", "2222", "3333333333", "01"));

            source.DepositMoney(1000, "initial load");

            var target = BankAccountFactory.CreateBankAccount(
                customer,
                new BankAccountNumber("1111", "2222", "12312321322", "01"));

            //Act

            var activities = source.BankAccountActivity.Count;

            var bankTransferService = new BankTransferService();

            bankTransferService.PerformTransfer(50, source, target);

            //Assert
            Assert.IsNotNull(source.BankAccountActivity);
            Assert.AreEqual(++activities, source.BankAccountActivity.Count);
        }
        public void PerformTransferThrowExceptionIfSourceCantWithdrawedWithExceedAmoung()
        {
            //Arrange
            var customer = GetCustomer();

            var source = BankAccountFactory.CreateBankAccount(customer, new BankAccountNumber("1111", "2222", "3333333333", "01"));

            source.DepositMoney(1000, "initial load");

            var target = BankAccountFactory.CreateBankAccount(customer, new BankAccountNumber("1111", "2222", "12312321322", "01"));


            //Act
            var bankTransferService = new BankTransferService();

            bankTransferService.PerformTransfer(2000, source, target);
        }
        public void PerformTransferThrowExceptionIfTargetBankAccountNumberIsEqualToSourceBankAccountNumber()
        {
            //Arrange
            var customer = GetCustomer();

            var source = BankAccountFactory.CreateBankAccount(customer, new BankAccountNumber("1111", "2222", "3333333333", "01"));

            source.DepositMoney(1000, "initial load");
            source.Lock();

            var target = BankAccountFactory.CreateBankAccount(customer, new BankAccountNumber("1111", "2222", "3333333333", "01"));


            //Act
            var bankTransferService = new BankTransferService();

            bankTransferService.PerformTransfer(10, source, target);
        }
예제 #4
0
        public void PerformTransferThrowExceptionIfTargetIsLockedAccount()
        {
            //Arrange
            var customer = GetCustomer();

            var source = BankAccountFactory.CreateBankAccount(customer, new BankAccountNumber("1111", "2222", "3333333333", "01"));

            source.DepositMoney(1000, "initial load");

            var target = BankAccountFactory.CreateBankAccount(customer, new BankAccountNumber("1111", "2222", "12312321322", "01"));

            target.Lock();

            //Act
            var       bankTransferService = new BankTransferService();
            Exception ex = Assert.Throws <InvalidOperationException>(() => bankTransferService.PerformTransfer(10, source, target));

            Assert.IsType <InvalidOperationException>(ex);
        }
        public void PerformTransferThrowExceptionIfSourceCantWithdrawedWithExceedAmoung()
        {
            //Arrange
            var customer = GetCustomer();

            var source = BankAccountFactory.CreateBankAccount(customer, new BankAccountNumber("1111", "2222", "3333333333", "01"));

            source.DepositMoney(1000, "initial load");

            var target = BankAccountFactory.CreateBankAccount(customer, new BankAccountNumber("1111", "2222", "12312321322", "01"));


            //Act
            var bankTransferService = new BankTransferService();

            Exception ex = Assert.Throws <InvalidOperationException>(() => bankTransferService.PerformTransfer(2000, source, target));

            Assert.IsType(typeof(InvalidOperationException), ex);
        }