public void Customer_Should_Be_Registered_With_1_Account()
        {
            var entityFactory = new Infrastructure.InMemoryDataAccess.EntityFactory();

            // Arrange
            ICustomer sut = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Ivan Paulovich"));

            var account = entityFactory.NewAccount(sut.Id);

            // Act
            sut.Register(account.Id);

            // Assert
            Assert.Single(sut.Accounts.GetAccountIds());
        }
示例#2
0
        public void New_Account_Should_Allow_Closing()
        {
            var entityFactory = new Infrastructure.InMemoryDataAccess.EntityFactory();

            // Arrange
            ICustomer customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Ivan Paulovich"));

            IAccount sut = entityFactory.NewAccount(customer.Id);

            // Act
            bool actual = sut.IsClosingAllowed();

            // Assert
            Assert.True(actual);
        }
示例#3
0
        public void Account_With_Three_Transactions_Should_Be_Consistent()
        {
            var entityFactory = new Infrastructure.InMemoryDataAccess.EntityFactory();

            // Arrange
            ICustomer customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Ivan Paulovich"));

            IAccount sut = entityFactory.NewAccount(customer.Id);

            sut.Deposit(entityFactory, new PositiveMoney(200));
            sut.Withdraw(entityFactory, new PositiveMoney(100));
            sut.Deposit(entityFactory, new PositiveMoney(50));

            Assert.Equal(2, ((Account)sut).Credits.GetTransactions().Count);
            Assert.Equal(1, ((Account)sut).Debits.GetTransactions().Count);
        }
示例#4
0
        public void New_Account_Should_Have_100_Credit_After_Deposit()
        {
            var entityFactory = new Infrastructure.InMemoryDataAccess.EntityFactory();

            // Arrange
            PositiveMoney amount   = new PositiveMoney(100.0M);
            ICustomer     customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Ivan Paulovich"));

            IAccount sut = entityFactory.NewAccount(customer.Id);

            // Act
            Credit actual = (Credit)sut.Deposit(entityFactory, amount);

            // Assert
            Assert.Equal(100, actual.Amount.ToMoney().ToDecimal());
        }
示例#5
0
        public void New_Account_With_1000_Balance_Should_Have_900_Credit_After_Withdraw()
        {
            // Arrange
            var entityFactory = new Infrastructure.InMemoryDataAccess.EntityFactory();

            ICustomer customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Ivan Paulovich"));

            IAccount sut = entityFactory.NewAccount(customer.Id);

            sut.Deposit(entityFactory, new PositiveMoney(1000.0M));

            // Act
            sut.Withdraw(entityFactory, new PositiveMoney(100));

            // Assert
            Assert.Equal(900, sut.GetCurrentBalance().ToDecimal());
        }
示例#6
0
        public void Account_With_200_Balance_Should_Not_Allow_50000_Withdraw()
        {
            var entityFactory = new Infrastructure.InMemoryDataAccess.EntityFactory();

            // Arrange
            ICustomer customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Ivan Paulovich"));

            IAccount sut = entityFactory.NewAccount(customer.Id);

            ICredit credit = sut.Deposit(entityFactory, new PositiveMoney(200));

            // Act
            var ex = Record.Exception(() => sut.Withdraw(entityFactory, new PositiveMoney(5000)));

            // Act and Assert
            Assert.NotNull(ex);
            Assert.IsType <MoneyShouldBePositiveException>(ex);
        }