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; }
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; }
public void PerformanceTestForStructureProcessing() { var repositoryStub = new RepositoryStub(); var interestRate = new Mock<InterestRates>(); interestRate.Setup(ir => ir.PositiveInterestRate()).Returns(2.0); interestRate.Setup(ir => ir.NegativeInterestRate()).Returns(3.0); var feedProcessor = new FeedProcessor(repositoryStub, "../../../Pickup/testdata/feed.csv"); feedProcessor.Process(); var paymentInstructionService = new PaymentInstructionService(); var structures = repositoryStub.Accounts.GroupBy(a => a.GetClientId()) .Select(g => new { ClientAccount = new ClientAccounts(g), Allocation=GetAllocation(g.ToList()) }) .Select(cs=>new Structure(cs.ClientAccount, cs.Allocation, interestRate.Object, paymentInstructionService)); var structureList = structures.ToList(); var start = DateTime.Now.Ticks; structureList.ForEach(s=>s.GeneratePaymentInstruction()); var stop = DateTime.Now.Ticks; Console.WriteLine((stop-start)/10000); }
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); }