public void is_file_valid_should_return_true_if_file_extension_is_the_same() { const string extension = ".csv"; var file = Substitute.For <HttpPostedFileBase>(); file.FileName.Returns("test.csv"); _fileImportService.IsFileValid(extension, file).Should().BeTrue(); }
public virtual ActionResult ImportStudent(HttpPostedFileBase file) { if (!_fileService.IsFileValid(".csv", file)) { ModelState.AddModelError("file", _fileService.errorMessage); return(View(MVC.Coordinator.Views.ViewNames.ImportStudent)); } var importStudentsViewModel = _fileService.ImportStudentInformationsFromFile(file); if (importStudentsViewModel == null || importStudentsViewModel.Count() < 1) { ModelState.AddModelError("file", _fileService.errorMessage); return(View(MVC.Coordinator.Views.ViewNames.ImportStudent)); } return(View(MVC.Coordinator.Views.ValidateImport, importStudentsViewModel)); }