예제 #1
0
        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));
        }
예제 #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));
        }
예제 #3
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, getAllocation(), null, null);
            var structure2 = new Structure(clientAccounts2, getAllocation(), null, null);

            var structures = new Structures();

            structures.Add(structure1);

            Assert.Throws <ArgumentException>(() => structures.Add(structure2));
        }
예제 #4
0
        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));
        }
예제 #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());
        }
예제 #6
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, getAllocation(), null, null);
            var client    = new Client(clientId, clientAccounts);

            client.AddStructure(structure);
            Assert.IsTrue(client.Contains(structure));
        }
예제 #7
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));
        }
예제 #8
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, null, null, null));
        }
예제 #9
0
        public ClientAccount AddClientAccount(string clientName)
        {
            var id            = Guid.NewGuid();
            var clientAccount = new ClientAccount().CreateAccount(id, clientName);

            ClientAccounts.Add(id, clientAccount);

            return(clientAccount);
        }