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); }
public void PaymentInstructionServiceShouldBeAbleToCreateOutPutDirectoryAndFile() { var payment = new Payment("someaccount", 100.50M, DateTime.Now); var paymentInstructionService = new PaymentInstructionService(); if (Directory.Exists(paymentInstructionService.OutputPath)) { Directory.Delete(paymentInstructionService.OutputPath, true); } paymentInstructionService.Generate(payment); Assert.True(Directory.Exists(paymentInstructionService.OutputPath)); Assert.True(File.Exists(paymentInstructionService.OutputPath + 1 + ".xml")); }
public void ShouldBeAbleToGenerateOutputWithValidPaymentObject() { var payment = new Payment("someaccount", 100.50M, DateTime.Parse("2011-03-01T17:01:37.9575406+05:30")); var paymentInstructionService = new PaymentInstructionService(); paymentInstructionService.Generate(payment); using (XmlReader xmlReader = new XmlTextReader(paymentInstructionService.OutputPath + 1 + ".xml")) { string name = ""; int elementCount = 0; while (xmlReader.Read()) { XmlNodeType xmlNodeType = xmlReader.NodeType; switch (xmlNodeType) { case XmlNodeType.Element: name = xmlReader.Name; break; case XmlNodeType.Text: switch (name) { case "account": Assert.AreEqual(payment.Account, xmlReader.Value); elementCount++; break; case "amount": Assert.AreEqual(Math.Abs(payment.Amount).ToString(), xmlReader.Value); elementCount++; break; case "date": Assert.AreEqual("2011-03-01T17:01:37.9575406+05:30", xmlReader.Value); elementCount++; break; case "type": Assert.AreEqual(payment.GetTransactionType(), xmlReader.Value); elementCount++; break; } break; } } Assert.AreEqual(4, elementCount); } }
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)); }