public void GetCategorizedTransactionsCreateAndStoreTagsTestCSV() { using (TextReader reader = new StreamReader(@"transactions.csv")) { IRepository repository = MockRepository.GenerateMock <IRepository>(); Dictionary <string, StandardTag> tagList = new Dictionary <string, StandardTag>(); IList <Operation> actual; actual = CSVProcessing.GetCategorizedTransactionsCreateAndStoreTags(reader, repository, tagList); Assert.IsTrue(actual.Count > 0); } }
public void GetCategorizedTransactionsCreateAndStoreTagsTest() { var text = "date,description,amount,category\n" + "25/11/2011,RETRAIT DAB 24/11/11 19H35 169770 BNP PARIBAS PARIS ,\"-60,00\",withdrawal\n" + "25/11/2011,VIREMENT RECU TIERS OCTO TECHNOLOGY VIREMENT SALAIRES NOVEMB ,\"2.023,96\",received payment"; var tagsBag = new Dictionary <String, StandardTag>(); IRepository repository = MockRepository.GenerateStub <IRepository>(); using (TextReader reader = new StringReader(text)) { var actual = CSVProcessing.GetCategorizedTransactionsCreateAndStoreTags(reader, repository, tagsBag).ToList(); Assert.IsTrue(actual.Count() == 2); Assert.AreEqual(actual.First().Amount, 60); Assert.AreEqual(tagsBag.Count, 2); } }
private static void AddAccountsAndOperations(Customer customer, Role[] roles, IRepository repository, IGenerationSession session) { //get the transaction data from csv file using (var reader = new StreamReader(@"Data\transactions.csv")) { _categorizedTransactions = CSVProcessing.GetCategorizedTransactionsCreateAndStoreTags(reader, repository, _tagsBag); } Account account = session.Single <Account>().Get(); account.Name = "Savings account"; account.RelatedCustomers.Add(customer, roles[0]); account.Iban = GenerationUtils.GenerateIban(account.Number, "12345", "12345", "FR"); account.Currency = "EUR"; Account account2 = session.Single <Account>().Get(); account2.Name = "Checking account"; account2.RelatedCustomers.Add(customer, roles[1]); account2.Currency = "EUR"; customer.RelatedAccounts.Add(account, roles[0]); customer.RelatedAccounts.Add(account2, roles[1]); repository.Save(account); repository.Save(account2); repository.Save(customer); repository.Flush(); //Get random transactions from the list Random rnd = new Random(); var randomTransactions = _categorizedTransactions.Where(x => x.Tag.Name != "Not set").OrderBy(x => rnd.Next()); //add the first half to the first account SelectForAccount(repository, account, rnd, randomTransactions); SelectForAccount(repository, account2, rnd, randomTransactions); //IList<Operation> operations = session.List<Operation>(20) // .Impose(x => x.TransactionCode, Guid.NewGuid().ToString()) // .Impose(x => x.Currency, "EUR") // .Impose(x=>x.Tag,EmptyTag) // .First(10) // .Impose(x => x.Account, account) // .Next(10) // .Impose(x => x.Account, account2) // .All() // .Get(); //operations.ForEach(x => repository.Save(x)); repository.Flush(); var paymentEvents = session.List <PaymentEvent>(20) .First(10) .Impose(x => x.Account, account) .Impose(x => x.Customer, customer) .Next(10) .Impose(x => x.Account, account2) .Impose(x => x.Customer, customer) .All() .Get(); paymentEvents.ForEach(x => repository.Save(x)); repository.Flush(); }