Exemple #1
0
        public void ParseCsvFileTestReturnsNotHeadedModelForNotHeadedFile()
        {
            // Arrange
            var filePath = "InputData.csv";
            TestParserHelper parserHelper   = new TestParserHelper();
            TestFileHelper   tstHelper      = new TestFileHelper(filePath, parserHelper.notHeadedContent);
            CsvFileHandler   csvFileHandler = new CsvFileHandler(
                new ValidationService(), new FileService(tstHelper.config.Object),
                new ParsingService());

            // Expected result
            var expectedResult = new CsvHandleResult();

            expectedResult.Success          = true;
            expectedResult.ParsedCsvContent = parserHelper.expectedResultNoHeader;

            // Act
            var actualResult =
                csvFileHandler.ParseCsvFile(tstHelper.fileMock.Object, false);

            // Assert
            Assert.IsNotNull(actualResult);
            Assert.IsNotNull(actualResult.Result);
            Assert.AreEqual(expectedResult, actualResult.Result);
        }
Exemple #2
0
        public void ParseCsvFileTestWrongExtensionReturnsErrorMessage()
        {
            //Arrange
            var            txtFileName    = "Data.txt";
            TestFileHelper tstHelper      = new TestFileHelper(txtFileName, "");
            CsvFileHandler csvFileHandler = new CsvFileHandler(
                new ValidationService(), new FileService(tstHelper.config.Object),
                new ParsingService());

            // Expected result
            var expectedResult = new CsvHandleResult();

            expectedResult.ErrorMessage =
                $"Selected file, {txtFileName}, does not have supported format CSV";

            //Act
            var actualResult = csvFileHandler.ParseCsvFile(tstHelper.fileMock.Object, true);

            //Assert
            Assert.IsNotNull(actualResult);
            Assert.IsNotNull(actualResult.Result);
            Assert.AreEqual(expectedResult, actualResult.Result);
        }