コード例 #1
0
        public void Customer_Should_Be_Registered_With_1_Account()
        {
            var entityFactory = new Infrastructure.PersistenceLayer.InMemory.EntityFactory();
            //
            // Arrange
            ICustomer sut = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Nocco Giovanni Emanuele")
                );

            var account = entityFactory.NewAccount(sut);

            // Act
            sut.Register(account);

            // Assert
            Assert.Single(sut.Accounts.GetAccountIds());
        }
コード例 #2
0
        public void New_Account_Should_Allow_Closing()
        {
            var entityFactory = new Infrastructure.PersistenceLayer.InMemory.EntityFactory();

            //
            // Arrange
            ICustomer customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Nocco Giovanni Emanuele")
                );

            IAccount sut = entityFactory.NewAccount(customer);

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

            //
            // Assert
            Assert.True(actual);
        }
コード例 #3
0
        public void Account_With_200_Balance_Should_Not_Allow_50000_Withdraw()
        {
            var entityFactory = new Infrastructure.PersistenceLayer.InMemory.EntityFactory();

            //
            // Arrange
            ICustomer customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Nocco Giovanni Emanuele")
                );

            IAccount sut = entityFactory.NewAccount(customer);

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

            // Act
            IDebit actual = sut.Withdraw(entityFactory, new PositiveMoney(5000));

            //
            // Act and Assert
            Assert.Null(actual);
        }
コード例 #4
0
        public void New_Account_Should_Have_100_Credit_After_Deposit()
        {
            var entityFactory = new Infrastructure.PersistenceLayer.InMemory.EntityFactory();
            //
            // Arrange
            PositiveMoney amount   = new PositiveMoney(100.0M);
            ICustomer     customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Nocco Giovanni Emanuele")
                );

            IAccount sut = entityFactory.NewAccount(customer);

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

            //
            // Assert
            Assert.Equal(100, actual.Amount.ToMoney().ToDecimal());
            Assert.Equal("Credit", actual.Description);
        }
コード例 #5
0
        public void New_Account_With_1000_Balance_Should_Have_900_Credit_After_Withdraw()
        {
            //
            // Arrange
            var entityFactory = new Infrastructure.PersistenceLayer.InMemory.EntityFactory();
            //
            // Arrange
            ICustomer customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Nocco Giovanni Emanuele")
                );

            IAccount sut = entityFactory.NewAccount(customer);

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

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

            //
            // Assert
            Assert.Equal(900, sut.GetCurrentBalance().ToDecimal());
        }