public void Customer_Should_Be_Registered_With_1_Account() { var entityFactory = new Manga.Infrastructure.InMemoryDataAccess.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.InMemoryDataAccess.EntityFactory(); // // Arrange ICustomer customer = entityFactory.NewCustomer( new SSN("198608179922"), new Name("Ivan Paulovich") ); IAccount sut = entityFactory.NewAccount(customer); 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); }
public void New_Account_Should_Allow_Closing() { var entityFactory = new Manga.Infrastructure.InMemoryDataAccess.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 New_Account_Should_Have_100_Credit_After_Deposit() { var entityFactory = new Manga.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); // // Act Credit actual = (Credit)sut.Deposit(entityFactory, amount); // // Assert Assert.Equal(100, actual.Amount.ToMoney().ToDecimal()); Assert.Equal("Credit", actual.Description); }
public void Account_With_200_Balance_Should_Not_Allow_50000_Withdraw() { var entityFactory = new Manga.Infrastructure.InMemoryDataAccess.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 Account_With_200_Balance_Should_Not_Allow_50000_Withdraw() { var entityFactory = new Manga.Infrastructure.InMemoryDataAccess.EntityFactory(); // // Arrange ICustomer customer = entityFactory.NewCustomer( new SSN("198608179922"), new Name("Ivan Paulovich") ); IAccount sut = entityFactory.NewAccount(customer); 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); }
public void New_Account_With_1000_Balance_Should_Have_900_Credit_After_Withdraw() { // // Arrange var entityFactory = new Manga.Infrastructure.InMemoryDataAccess.EntityFactory(); // // Arrange ICustomer customer = entityFactory.NewCustomer( new SSN("198608179922"), new Name("Ivan Paulovich") ); 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()); }