Beispiel #1
0
        public void Given_NoBaseAccounts_When_Initialised_Then_IncomeAccountCreated()
        {
            // Arrange.
            // Act.
            AccountingManagerFactory.Create(out IAccountingDataAccess accountingDataAccess);

            // Assert.
            accountingDataAccess
            .Received(1)
            .AddAccount(Arg.Is <Account>(a =>
                                         a.AccountType.IsIncome &&
                                         a.QualifiedName.Equals(IncomeAccountName) &&
                                         a.Name.Equals(IncomeAccountName) &&
                                         a.Balance == 0m));

            accountingDataAccess
            .Received(1)
            .AddAccount(Arg.Is <Account>(a =>
                                         a.QualifiedName.Equals(IncomeAccountName) &&
                                         a.AccountTypesWithDebitPermission.Contains(AccountType.CreateFunds()) &&
                                         !a.AccountTypesWithDebitPermission.Contains(AccountType.CreateIncome()) &&
                                         !a.AccountTypesWithDebitPermission.Contains(AccountType.CreateExpense()) &&
                                         !a.AccountTypesWithDebitPermission.Contains(AccountType.CreateDebtor()) &&
                                         !a.AccountTypesWithDebitPermission.Contains(AccountType.CreateCreditor())));

            accountingDataAccess
            .Received(1)
            .AddAccount(Arg.Is <Account>(a =>
                                         a.QualifiedName.Equals(IncomeAccountName) &&
                                         !a.AccountTypesWithCreditPermission.Contains(AccountType.CreateFunds()) &&
                                         !a.AccountTypesWithCreditPermission.Contains(AccountType.CreateIncome()) &&
                                         !a.AccountTypesWithCreditPermission.Contains(AccountType.CreateExpense()) &&
                                         !a.AccountTypesWithCreditPermission.Contains(AccountType.CreateDebtor()) &&
                                         !a.AccountTypesWithCreditPermission.Contains(AccountType.CreateCreditor())));
        }
Beispiel #2
0
        public async Task Given_NewAccount_When_Added_Then_CreditWhitelistAccountTypesAreSameAsParents()
        {
            // Arrange.
            AccountingManager testObject = AccountingManagerFactory.Create(out IAccountingDataAccess accountingDataAccess);

            var newAccount = new NewAccountDto
            {
                Name = "SomeAccount",
                ParentAccountQualifiedName = FundsAccountName
            };

            // Act.
            await testObject.AddAccount(newAccount);

            // Assert.
            await accountingDataAccess
            .Received(1)
            .AddAccount(Arg.Is <Account>(a =>
                                         a.Name.Equals(newAccount.Name) &&
                                         a.AccountTypesWithCreditPermission.Contains(AccountType.CreateFunds()) &&
                                         a.AccountTypesWithCreditPermission.Contains(AccountType.CreateIncome()) &&
                                         a.AccountTypesWithCreditPermission.Contains(AccountType.CreateDebtor()) &&
                                         a.AccountTypesWithCreditPermission.Contains(AccountType.CreateCreditor())));

            await accountingDataAccess
            .Received(0)
            .AddAccount(Arg.Is <Account>(a =>
                                         a.Name.Equals(newAccount.Name) &&
                                         a.AccountTypesWithCreditPermission.Contains(AccountType.CreateExpense())));
        }