예제 #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);
        }
예제 #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;
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
 }
예제 #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));
 }
예제 #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));
 }
예제 #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());
        }
예제 #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));
        }
예제 #10
0
파일: Structure.cs 프로젝트: habib/AnujBank
        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;
        }
예제 #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));
        }
예제 #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));
        }
예제 #13
0
 public bool SharesAccountWith(ClientAccounts clientAccounts)
 {
     return(accounts.Overlaps(clientAccounts.accounts));
 }
예제 #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);
        }
예제 #15
0
 public bool SharesAccountWith(ClientAccounts clientAccounts)
 {
     return accounts.Overlaps(clientAccounts.accounts);
 }
예제 #16
0
파일: Client.cs 프로젝트: habib/AnujBank
 public Client(ClientId clientId, ClientAccounts holdings)
 {
     this.clientId = clientId;
     this.holdings = holdings;
     structures    = new Structures();
 }
예제 #17
0
파일: Client.cs 프로젝트: habib/AnujBank
 public Client(ClientId clientId, ClientAccounts holdings)
 {
     this.clientId = clientId;
     this.holdings = holdings;
     structures = new Structures();
 }
예제 #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;
 }