Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }