public void CheckPreValidations() { _readerLogInfo = new CsvToObjectReader <ServerLogFileInfo>(null, null, null, _loggerFactoryCsvReaderMock); bool preExtractValidation = _readerLogInfo.PreExtractValidation(); preExtractValidation.Should().Be(false, " all the mandatory supplied parameters were not supplied"); _readerLogInfo.ErrorsOccured.Count.Should().BeGreaterThan(0, "at least one error should be recorded"); _readerLogInfo.ErrorsOccured.Any(errors => errors.ErrorCode == ErrorCodes.NullPath).Should() .Be(true, "we passed null parameters"); _readerLogInfo.ErrorsOccured.Any(errors => errors.ErrorDescription == "Please supply the file content or provide the path to the file in constructor argument").Should() .Be(true, "we passed null parameters"); _readerLogInfo.ErrorsOccured.Any(errors => errors.ErrorDescription == @"Constructor parameter '_mapper' cannot be null").Should() .Be(true, "we haven't passed mapper instance to constructor"); }
public void InvalidPathShouldNotbeAccepted() { _readerLogInfo = new CsvToObjectReader <ServerLogFileInfo>($@"X:\InvalidFolder\InvalidFile.csv", new FileService(), null, _loggerFactoryCsvReaderMock); bool preExtractValidation = _readerLogInfo.PreExtractValidation(); preExtractValidation.Should().Be(false, "Invalid Path was supplied"); _readerLogInfo.ErrorsOccured.Count.Should().BeGreaterThan(0, "at least one error should be recorded"); _readerLogInfo.ErrorsOccured.Any(errors => errors.ErrorDescription == @"X:\InvalidFolder\InvalidFile.csv does not exists").Should() .Be(true, "we passed Invalid file path as constructor parameter"); _readerLogInfo = new CsvToObjectReader <ServerLogFileInfo>($@"X:\InvalidFolder\InvalidFile.pdf", new FileService(), null, _loggerFactoryCsvReaderMock); preExtractValidation = _readerLogInfo.PreExtractValidation(); _readerLogInfo.ErrorsOccured.Any(errors => errors.ErrorDescription.Contains(@"Invalid file extension")).Should() .Be(true, "we passed Invalid file extension"); }