Add() public method

public Add ( Account newAccount ) : void
newAccount Account
return void
Example #1
0
        public void ShouldBeAbleToFindIfTwoStructuresHaveSharedAccounts()
        {
            var clientId = new ClientId("ABC123");
            var account1 = new Account(new AccountId(12341234), clientId);
            var account2 = new Account(new AccountId(12341235), clientId);
            var account3 = new Account(new AccountId(12341236), clientId);
            var account4 = new Account(new AccountId(12341237), clientId);

            var clientAccounts1 = new ClientAccounts();
            clientAccounts1.Add(account1);
            clientAccounts1.Add(account2);
            var structure1 = new Structure(clientAccounts1);

            var clientAccounts2 = new ClientAccounts();
            clientAccounts2.Add(account1);
            clientAccounts2.Add(account3);
            var structure2 = new Structure(clientAccounts2);

            var clientAccounts3 = new ClientAccounts();
            clientAccounts3.Add(account4);
            clientAccounts3.Add(account3);
            var structure3 = new Structure(clientAccounts3);

            Assert.IsTrue(structure1.SharesASourceAccountWith(structure2));
            Assert.IsFalse(structure1.SharesASourceAccountWith(structure3));
        }
Example #2
0
        public void ShouldBeAbleToFindIfTwoStructuresHaveSharedAccounts()
        {
            var clientId = new ClientId("ABC123");
            var account1 = new Account(new AccountId(12341234), clientId);
            var account2 = new Account(new AccountId(12341235), clientId);
            var account3 = new Account(new AccountId(12341236), clientId);
            var account4 = new Account(new AccountId(12341237), clientId);

            var clientAccounts1 = new ClientAccounts();
            clientAccounts1.Add(account1);
            clientAccounts1.Add(account2);

            var allocations = new List<Allocation> { new Allocation(new Account(new AccountId(54321439), clientId), 100) };

            var structure1 = new Structure(clientAccounts1, allocations, null, null);

            var clientAccounts2 = new ClientAccounts();
            clientAccounts2.Add(account1);
            clientAccounts2.Add(account3);
            var structure2 = new Structure(clientAccounts2, allocations, null, null);

            var clientAccounts3 = new ClientAccounts();
            clientAccounts3.Add(account4);
            clientAccounts3.Add(account3);
            var structure3 = new Structure(clientAccounts3, allocations, null, null);

            Assert.IsTrue(structure1.SharesASourceAccountWith(structure2));
            Assert.IsFalse(structure1.SharesASourceAccountWith(structure3));
        }
 public void ShouldNotBeAbleToCreatAStructureWithAccountsFromTwoDifferentClients()
 {
     var clientId1 = new ClientId("ABC123");
     var clientId2 = new ClientId("ABC124");
     var account1 = new Account(new AccountId(12341234), clientId1);
     var account2 = new Account(new AccountId(12341235), clientId2);
     var clientAccounts = new ClientAccounts();
     clientAccounts.Add(account1);
     Assert.Throws<ArgumentException>(() => clientAccounts.Add(account2));
 }
Example #4
0
 public void ShouldBeAbleAddAStructure()
 {
     var clientId = new ClientId("ABC123");
     var account1 = new Account(new AccountId(12341234), clientId);
     var account2 = new Account(new AccountId(12341235), clientId);
     var clientAccounts = new ClientAccounts();
     clientAccounts.Add(account1);
     clientAccounts.Add(account2);
     var structure = new Structure(clientAccounts);
     var client = new Client(clientId, clientAccounts);
     client.AddStructure(structure);
     Assert.IsTrue(client.Contains(structure));
 }
Example #5
0
        public void ShouldCalculateNetBalance()
        {
            var account1 = new Account(new AccountId(12341234), new ClientId("ABC123"));
            var account2 = new Account(new AccountId(12341235), new ClientId("ABC123"));

            account1.Balance = 1000.0;
            account2.Balance = -500.0;
            var clientAccounts = new ClientAccounts();
            clientAccounts.Add(account1);
            clientAccounts.Add(account2);

            Assert.AreEqual(500.0, clientAccounts.NetBalance());
        }
Example #6
0
        public void ShouldBeAbleToAddAStructure()
        {
            var clientId = new ClientId("ABC123");
            var account1 = new Account(new AccountId(12341234), clientId);
            var account2 = new Account(new AccountId(12341235), clientId);
            var clientAccounts = new ClientAccounts();
            clientAccounts.Add(account1);
            clientAccounts.Add(account2);
            var structure = new Structure(clientAccounts, getAllocation(), null, null);
            var structures = new Structures();
            structures.Add(structure);

            Assert.True(structures.Contains(structure));
        }
Example #7
0
 public void ShouldNotBeAbleToCreateAStructureWithLessThanTwoSourceAccounts()
 {
     var clientId = new ClientId("ABC123");
     var account1 = new Account(new AccountId(12341234), clientId);
     var clientAccounts = new ClientAccounts();
     clientAccounts.Add(account1);
     Assert.Throws<ArgumentException>(() => new Structure(clientAccounts));
 }
        public void ShouldBeAbleToFindTwoClientAccountsShareACommonAccount()
        {
            var account1 = new Account(new AccountId(12341234), new ClientId("ABC123"));
            var account2 = new Account(new AccountId(12341235), new ClientId("ABC123"));
            var account3 = new Account(new AccountId(12341236), new ClientId("ABC123"));
            var account4 = new Account(new AccountId(12341237), new ClientId("ABC123"));

            var clientAccounts1 = new ClientAccounts();
            clientAccounts1.Add(account1);
            clientAccounts1.Add(account2);

            var clientAccounts2 = new ClientAccounts();
            clientAccounts2.Add(account1);
            clientAccounts2.Add(account3);

            var clientAccounts3 = new ClientAccounts();
            clientAccounts3.Add(account3);
            clientAccounts3.Add(account4);

            Assert.IsTrue(clientAccounts1.SharesAccountWith(clientAccounts2));
            Assert.IsFalse(clientAccounts1.SharesAccountWith(clientAccounts3));
        }
Example #9
0
        public void ShouldNotBeAbleToCreateClientStructuresWithTwoRepeatingAccounts()
        {
            var clientId = new ClientId("ABC123");
            var account1 = new Account(new AccountId(12341234), clientId);
            var account2 = new Account(new AccountId(12341235), clientId);
            var account3 = new Account(new AccountId(12341236), clientId);
            var clientAccounts1 = new ClientAccounts();
            clientAccounts1.Add(account1);
            clientAccounts1.Add(account2);

            var clientAccounts2 = new ClientAccounts();
            clientAccounts2.Add(account1);
            clientAccounts2.Add(account3);

            var structure1 = new Structure(clientAccounts1);
            var structure2 = new Structure(clientAccounts2);

            var structures = new Structures();
            structures.Add(structure1);

            Assert.Throws<ArgumentException>(() => structures.Add(structure2));
        }
Example #10
0
        private static Structure GetTestStructure(double balance1, double balance2, List<Allocation> allocations, InterestRates interestRates, PaymentInstructionService paymentInstructionService)
        {
            var clientId = new ClientId("ABC123");
            var account1 = new Account(new AccountId(12341234), clientId);
            var account2 = new Account(new AccountId(12341235), clientId);
            account1.Balance = balance1;
            account2.Balance = balance2;

            var clientAccounts = new ClientAccounts();
            clientAccounts.Add(account1);
            clientAccounts.Add(account2);
            return new Structure(clientAccounts, allocations, interestRates, paymentInstructionService);
        }