Beispiel #1
0
        public void Customer_Should_Be_Registered_With_1_Account()
        {
            var entityFactory = new Manga.Infrastructure.InMemoryGateway.EntityFactory();
            //
            // Arrange
            ICustomer sut = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Ivan Paulovich")
                );

            var account = entityFactory.NewAccount(sut);

            // Act
            sut.Register(account);

            // Assert
            Assert.Single(sut.Accounts.GetAccountIds());
        }
        public void Account_With_Three_Transactions_Should_Be_Consistent()
        {
            var entityFactory = new Manga.Infrastructure.InMemoryGateway.EntityFactory();

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

            IAccount sut = entityFactory.NewAccount(customer);

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

            Assert.Equal(2, ((Account)sut).Credits.GetTransactions().Count);
            Assert.Equal(1, ((Account)sut).Debits.GetTransactions().Count);
        }
        public void New_Account_Should_Allow_Closing()
        {
            var entityFactory = new Manga.Infrastructure.InMemoryGateway.EntityFactory();

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

            IAccount sut = entityFactory.NewAccount(customer);

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

            //
            // Assert
            Assert.True(actual);
        }
        public void Account_With_200_Balance_Should_Not_Allow_50000_Withdraw()
        {
            var entityFactory = new Manga.Infrastructure.InMemoryGateway.EntityFactory();

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

            IAccount sut = entityFactory.NewAccount(customer);

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

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

            //
            // Act and Assert
            Assert.Null(actual);
        }
        public void New_Account_Should_Have_100_Credit_After_Deposit()
        {
            var entityFactory = new Manga.Infrastructure.InMemoryGateway.EntityFactory();
            //
            // Arrange
            PositiveAmount amount   = new PositiveAmount(100.0);
            ICustomer      customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Ivan Paulovich")
                );

            IAccount sut = entityFactory.NewAccount(customer);

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

            //
            // Assert
            Assert.Equal(100, actual.Amount.ToAmount().ToDouble());
            Assert.Equal("Credit", actual.Description);
        }
        public void New_Account_With_1000_Balance_Should_Have_900_Credit_After_Withdraw()
        {
            //
            // Arrange
            var entityFactory = new Manga.Infrastructure.InMemoryGateway.EntityFactory();
            //
            // Arrange
            ICustomer customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Ivan Paulovich")
                );

            IAccount sut = entityFactory.NewAccount(customer);

            sut.Deposit(entityFactory, new PositiveAmount(1000.0));

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

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