Ejemplo n.º 1
0
        public void ShouldCreateClientAccountsFromAccountCollection()
        {
            var clientId1 = new ClientId("ABC123");
            var clientAccounts = new ClientAccounts(new List<Account> { new Account(new AccountId(12341234), clientId1), new Account(new AccountId(12341235), clientId1) });

            Assert.AreEqual(2, clientAccounts.Count);
        }
Ejemplo n.º 2
0
        public Structure(ClientAccounts sourceClientAccounts, List <Allocation> allocations, InterestRates interestRates, PaymentInstructionService paymentInstructionService)
        {
            if (sourceClientAccounts.Count < 2)
            {
                throw new ArgumentException("A structure must have at least 2 source accounts.");
            }

            float totalPercentage = 0;

            allocations.ForEach(al => totalPercentage += al.GetAllocationPercentage());

            if (totalPercentage != 100)
            {
                throw new ArgumentException("A structure should have 100% allocation.");
            }

            if (allocations.Count != 1 && allocations.Exists(al => !sourceClientAccounts.Contains(al.GetAccount())))
            {
                throw new ArgumentException("All allocations should be in pooled account or there should be only one allocation account.");
            }

            this.sourceClientAccounts      = sourceClientAccounts;
            this.allocations               = allocations;
            this.interestRates             = interestRates;
            this.paymentInstructionService = paymentInstructionService;
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
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));
 }
Ejemplo n.º 6
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));
 }
Ejemplo n.º 7
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));
 }
Ejemplo n.º 8
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());
        }
Ejemplo n.º 9
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));
        }
Ejemplo n.º 10
0
        public Structure(ClientAccounts sourceClientAccounts, List<Allocation> allocations, InterestRates interestRates, PaymentInstructionService paymentInstructionService)
        {
            if(sourceClientAccounts.Count < 2) throw new ArgumentException("A structure must have at least 2 source accounts.");

            float totalPercentage = 0;
            allocations.ForEach(al => totalPercentage += al.GetAllocationPercentage());

            if (totalPercentage != 100)
                throw new ArgumentException("A structure should have 100% allocation.");

            if (allocations.Count != 1 && allocations.Exists(al => !sourceClientAccounts.Contains(al.GetAccount())))
                    throw new ArgumentException("All allocations should be in pooled account or there should be only one allocation account.");

            this.sourceClientAccounts = sourceClientAccounts;
            this.allocations = allocations;
            this.interestRates = interestRates;
            this.paymentInstructionService = paymentInstructionService;
        }
Ejemplo n.º 11
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));
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
0
 public bool SharesAccountWith(ClientAccounts clientAccounts)
 {
     return(accounts.Overlaps(clientAccounts.accounts));
 }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
 public bool SharesAccountWith(ClientAccounts clientAccounts)
 {
     return accounts.Overlaps(clientAccounts.accounts);
 }
Ejemplo n.º 16
0
 public Client(ClientId clientId, ClientAccounts holdings)
 {
     this.clientId = clientId;
     this.holdings = holdings;
     structures    = new Structures();
 }
Ejemplo n.º 17
0
 public Client(ClientId clientId, ClientAccounts holdings)
 {
     this.clientId = clientId;
     this.holdings = holdings;
     structures = new Structures();
 }
Ejemplo n.º 18
0
 public Structure(ClientAccounts sourceClientAccounts)
 {
     if(sourceClientAccounts.Count < 2) throw new ArgumentException("A structure must have at least 2 source accounts.");
     this.sourceClientAccounts = sourceClientAccounts;
 }