Beispiel #1
0
        public void GivenCSVFile_WhenWrongDelimiter_ShouldThrowCustomException()
        {
            string filePath  = @"C:\Users\punee\source\repos\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCensusData.csv";
            var    exception = Assert.Throws <CSVException>(() => CSVStateCensusRecords.GetDelimiters(filePath));

            Assert.AreEqual(CSVException.ExceptionType.DELIMITER_INCORRECT, exception.type);
        }
Beispiel #2
0
        public void GivenCSVFile_WhenHeadersDoNotMatch_ShouldThrowCustomException()
        {
            string filePath      = @"C:\Users\punee\source\repos\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCensusData.csv";
            string otherFilePath = @"C:\Users\punee\source\repos\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCode.csv";
            var    exception     = Assert.Throws <CSVException>(() => CSVStateCensusRecords.GetFileHeaders(filePath, otherFilePath));

            Assert.AreEqual(CSVException.ExceptionType.HEADERS_DONOT_MATCH, exception.type);
        }
Beispiel #3
0
        public void GivenCSVFile_WhenWrongFilePath_ShouldThrowCustomException()
        {
            string filePath = @"C:\punee\StateCensusAnalyser\IndiaStateCensusData.csv";

            var exception = Assert.Throws <CSVException>(() => CSVStateCensusRecords.GetRecords(filePath));

            Assert.AreEqual(CSVException.ExceptionType.FILE_PATH_INCORRECT, exception.type);
        }
Beispiel #4
0
        public void GivenCSVFile_WhenNumberOfRecordsMatches_ShouldReturnTrue()
        {
            string filePath   = @"C:\Users\punee\source\repos\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCensusData.csv";
            int    CSVRecords = CSVStateCensusRecords.GetRecords(filePath);
            int    records    = StateCensusAnalyserUtility.GetStateCensusRecords(filePath);

            Assert.AreEqual(CSVRecords, records);
        }