public void Import() { var filename = "imports@[email protected]"; var t = filename.Replace("@", "/"); Assert.That(System.IO.Path.GetDirectoryName(t), Is.EqualTo("imports\\asb")); Assert.That(System.IO.Path.GetFileName(t), Is.EqualTo("export20120825200829.csv")); _importDetector.SetupGet(x => x.Name).Returns("Mock"); _importDetector.Setup(x => x.Matches(It.IsRegex("export20120825200829.csv$"))) .Returns(true); var i1 = new WestpacVisaCsvImportRow { ProcessDate = DateTime.Now.Date, Amount = 10M, OtherParty = "COUNTDOWN" }; var i2 = new WestpacVisaCsvImportRow { ProcessDate = DateTime.Now.Date, Amount = 20M, OtherParty = "MERCURY ENERGY" }; _importDetector.Setup(x => x.Import(It.IsAny<Stream>())) .Returns<Stream>(_ => new[] { i1, i2 }); var result = _controller.Import(_bank.Id, filename, _unclassifiedExpense.Id, new Dictionary<string, ImportRowOptions>()); Assert.That(result, Is.InstanceOf<PartialViewResult>()); var model = ((PartialViewResult)result).Model; Assert.That(model, Is.InstanceOf<IEnumerable<Transaction>>()); var transactions = (IEnumerable<Transaction>) model; Assert.That(transactions.Count(), Is.EqualTo(2)); Assert.That(transactions.First().Amount, Is.EqualTo(10)); Assert.That(transactions.Last().Amount, Is.EqualTo(20)); }
public void VisaImportRow() { IImportRow visa = new WestpacVisaCsvImportRow { ForeignDetails = "Foreign Details", CreditPlanName = "Credit Plan Name", OtherParty = "Other Party", City = "City", CountryCode = "NZ", TransactionDate = DateTime.Parse("2000-1-1") }; Assert.That(visa.Properties.Select(x => x.Key), Is.EquivalentTo(WestpacVisaCsvImportDetector.PropertyNames)); Assert.That(visa.Properties.Select(x => x.Value), Is.EquivalentTo(new[] { "Foreign Details", "2000-01-01", "Credit Plan Name", "Other Party", "City", "NZ" })); }