public void Execute_Should_Check_Errors_On_Xlsx(int idLine, string errorMessage) { var dt = new DataTransaction(); var results = dt.Execute(@"..\..\Datas\Business\FakeFiles\BadDatas.xlsx"); var message = results.Messages.FirstOrDefault(x => x.IdLine == idLine); Assert.IsNotNull(message); Assert.AreEqual(errorMessage, message.Messages.FirstOrDefault()); Assert.AreEqual(DataTransactionState.Ignored, message.State); Assert.AreEqual(0, Repositories.Informations.FindAll().Count); }
public void Execute_Should_Add_Information_On_Xlsx() { var dt = new DataTransaction(); var results = dt.Execute(@"..\..\Datas\Business\FakeFiles\GoodDatas.xlsx"); foreach (var dataTransaction in results.Messages) { Assert.IsNotNull(dataTransaction); Assert.AreEqual(0, dataTransaction.Messages.Count); Assert.AreEqual(DataTransactionState.Valid, dataTransaction.State); } var resultDatas = Repositories.Informations.FindAll(); Assert.AreEqual(1, resultDatas.Count); Assert.AreEqual(10.55, resultDatas.ElementAt(0).Amount); }
public ActionResult Upload(HttpPostedFileBase file) { ViewBag.Title = Common.Upload_Title; var response = new DataTransactionResponse(); if (ModelState.IsValid && file != null && file.IsValidForUpload()) { var dataTransaction = new DataTransaction(); response = dataTransaction.Execute(SaveFile(file)); ViewBag.Message = InformationMessage.Success_File_Uploaded; } else { ViewBag.Message = InformationMessage.Error_File_Is_Invalid; } return View(response); }