public void GivenCSVFile_WhenNumberOfRecordsMatches_ShoulReturnTrue() { string filePath = @"E:\CodinClub\Assignments_Fellowship\Census_Analyser_Problem\CensusAnalyser\CensusAnalyser\IndiaStateCensusData.csv"; int CSVRecords = CSVStateCensusAnalyser.GetRecords(filePath); int records = StateCensusAnalyser.GetStateCensusRecords(filePath); Assert.AreEqual(CSVRecords, records); }
public void GivenCSVFile_WhenHeadersDoNotMatch_ShouldThrowCustomException() { string filePath = @"E:\CodinClub\Assignments_Fellowship\Indian-State-Census-Analyzer-Problem\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCensusData.csv"; string alternateFilePath = @"E:\CodinClub\Assignments_Fellowship\Indian-State-Census-Analyzer-Problem\StateCensusAnalyser\StateCensusAnalyser\data.csv"; var exception = Assert.Throws <StateCensusAnalyserException>(() => CSVStateCensusAnalyser.HeaderException(filePath, alternateFilePath)); Assert.AreEqual(StateCensusAnalyserException.ExceptionType.HEADERS_MISSMATCH, exception.type); }
public void GivenCSVFileName_WhenIncorrectTypeOfFile_ShouldThrowCustomException() { try { string filePath = @"E:\CodinClub\Census_Analyser_Problem\CensusAnalyser\CensusAnalyser\IndiaStateCensusData.txt"; int CSVRecords = CSVStateCensusAnalyser.GetRecords(filePath); int records = StateCensusAnalyser.GetStateCensusRecords(filePath); Assert.AreEqual(CSVRecords, records); } catch (StateCensusAnalyserException e) { Assert.AreEqual("Name of the file is incorrect", e.Message); } }
public void GivenCSVFileName_WhenIncorrectTypeOfFile_ShouldThrowCustomException() { try { string filePath = @"E:\CodinClub\Assignments_Fellowship\Indian-State-Census-Analyzer-Problem\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCensusData.txt"; int CSVRecords = CSVStateCensusAnalyser.GetRecords(filePath); int records = StateCensusAnalyser.StateCensusAnalyser.GetStateCensusRecords(filePath); Assert.AreEqual(CSVRecords, records); } catch (StateCensusAnalyserException e) { Assert.AreEqual(StateCensusAnalyserException.ExceptionType.INVALID_EXTENSION, e.type); } }
public void GivenCSVFilePath_WhenIncorrect_ShouldThrowCustomException() { try { string filePath = @"E:\CodinClub\Census_Analyser_Problem\CensusAnalyser\CensusAnalyser\IndiaStateCensusData.csv"; int CSVRecords = CSVStateCensusAnalyser.GetRecords(filePath); int records = StateCensusAnalyser.GetStateCensusRecords(filePath); Assert.AreEqual(CSVRecords, records); } catch (StateCensusAnalyserException e) { Assert.AreEqual(StateCensusAnalyserException.ExceptionType.INVALID_PATH, e.Type); //Assert.AreEqual(e.Message,"Entered wrong path"); } }
public void GivenCSVFile_WhenIncorrectDelimiter_ShouldThrowCustomException() { try { string filePath = @"E:\CodinClub\Assignments_Fellowship\Indian-State-Census-Analyzer-Problem\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCensusData.csv"; int CSVRecords = CSVStateCensusAnalyser.GetRecords(filePath); int records = StateCensusAnalyser.StateCensusAnalyser.GetStateCensusRecords(filePath); Assert.AreEqual(CSVRecords, records); } catch (StateCensusAnalyserException e) { Assert.AreEqual(StateCensusAnalyserException.ExceptionType.DELIMITER_INCORRECT, e.type); } }