public async Task <IActionResult> UploadFile(IFormFile file) { var path = await _fileUploader.UploadFileAsync(file); var processFileResult = _csvProcessor.ProcessFile(path); var processFileResultModel = _processFileResultMapper.Map(processFileResult); return(View(processFileResultModel)); }
public void ProcessFile_FilenameIsEmpty_ReturnsAnEmptyListOfItems() { //Arrange var expected = new List <ProcessResultItem>(); var sut = new CsvProcessor(new FilesystemWrapperStub()); //Act var actual = sut.ProcessFile(string.Empty); //Assert actual.Items.Should().AllBeEquivalentTo(expected); }
public void ProcessFile_FilenameIsEmpty_ReturnsErrorStatus() { //Arrange var expected = ProcessFileStatuses.Error; var sut = new CsvProcessor(); //Act var result = sut.ProcessFile(string.Empty); //Assert Assert.AreEqual(expected, result.Status); }
public void ProcessFile_FileDoesNotExist_ReturnsAnEmptyListOfItems() { //Arrange var expected = new List <ProcessResultItem>(); var fileSystemWrapperStub = new FilesystemWrapperStub(); fileSystemWrapperStub.Exists = false; fileSystemWrapperStub.Path = "path"; fileSystemWrapperStub.Lines = new[] { "blah" }; var sut = new CsvProcessor(fileSystemWrapperStub); //Act var actual = sut.ProcessFile("filename"); //Assert actual.Items.Should().AllBeEquivalentTo(expected); }