Exemple #1
0
        public void GivenCensusCSVFileAndCSVState_WhenNumberOfRecordMatch_ThenItShouldReturnTrue()
        {
            int CSVStateRecord    = CSVStates.GetRecord(FILE_PATH);
            int StateCensusRecord = StateCensusAnalyser.GetStateCensusRecord(STATE_CODE_FILE_PATH);

            Assert.AreEqual(CSVStateRecord, StateCensusRecord);
        }
Exemple #2
0
        public void GivenCSVSTateCodeFile_WhenHeadersDoNotMatch_ShouldThrowCustomException()
        {
            string filePath  = @"E:\CodinClub\Assignments_Fellowship\Indian-State-Census-Analyzer-Problem\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCensusData.csv";
            var    exception = Assert.Throws <StateCensusAnalyserException>(() => CSVStates.HeaderException(filePath));

            Assert.AreEqual(StateCensusAnalyserException.ExceptionType.HEADERS_MISSMATCH, exception.type);
        }
Exemple #3
0
        public void GivenCSVStateCodeFile_WhenIncorrectDelimiter_ShouldThrowCustomException()
        {
            string filePath  = @"E:\CodinClub\Assignments_Fellowship\Indian-State-Census-Analyzer-Problem\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCode.csv";
            var    exception = Assert.Throws <StateCensusAnalyserException>(() => CSVStates.checkDelimiters(filePath));

            Assert.AreEqual(StateCensusAnalyserException.ExceptionType.DELIMITER_INCORRECT, exception.type);
        }
Exemple #4
0
        public void GivenCSVStateCodeFile_WhenNumberOfRecordsMatches_ShoulReturnTrue()
        {
            string filePath   = @"E:\CodinClub\Assignments_Fellowship\Indian-State-Census-Analyzer-Problem\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCode.csv";
            int    CSVRecords = CSVStates.GetRecords(filePath);
            int    records    = StateCensusAnalyser.StateCodeAnalyser.GetStateCodeRecords(filePath);

            Assert.AreEqual(CSVRecords, records);
        }
Exemple #5
0
 public void GivenCSVStateCodeFilePath_WhenIncorrect_ShouldThrowCustomException()
 {
     try
     {
         string filePath   = @"C:\Assignments_Fellowship\Indian-State-Census-Analyzer-Problem\StateCensusAnalyser\StateCensusAnalyser\IndiaStateCode.csv";
         int    CSVRecords = CSVStates.GetRecords(filePath);
         int    records    = StateCensusAnalyser.StateCodeAnalyser.GetStateCodeRecords(filePath);
         Assert.AreEqual(CSVRecords, records);
     }
     catch (StateCensusAnalyserException e)
     {
         Assert.AreEqual(StateCensusAnalyserException.ExceptionType.INVALID_PATH, e.type);
     }
 }
Exemple #6
0
        public void GivenInvalidFileHeaderAndCSVState_WhenCompiled_ThenReturnsException()
        {
            CensusAnalyserException exception = Assert.ThrowsException <CensusAnalyserException>(() => CSVStates.GetFileHeader(STATE_CODE_FILE_PATH));

            Assert.AreEqual(CensusAnalyserException.ExceptionType.HEADER_NOT_MATCH, exception.type);
        }
Exemple #7
0
        public void GivenIncorrectDelimiterAndCSVState_WhenCompiled_ThenReturnsException()
        {
            CensusAnalyserException exception = Assert.ThrowsException <CensusAnalyserException>(() => CSVStates.GetRecord(STATE_CODE_FILE_PATH));

            Assert.AreEqual(CensusAnalyserException.ExceptionType.DELIMITER_INCORRECT, exception.type);
        }
Exemple #8
0
        public void GivenIncorrectFileTypeAndCSVState_WhenCompiled_ThenReturnsException()
        {
            CensusAnalyserException exception = Assert.ThrowsException <CensusAnalyserException>(() => CSVStates.GetRecord(WRONG_FILETYPE));

            Assert.AreEqual(CensusAnalyserException.ExceptionType.INCORRECT_FILETYPE, exception.type);
        }
Exemple #9
0
        public void GivenIncorrectPathAndCSVState_WhenCompiled_ThenReturnsException()
        {
            CensusAnalyserException exception = Assert.ThrowsException <CensusAnalyserException>(() => CSVStates.WrongPath(FILE_PATH, WRONG_FILEPATH));

            Assert.AreEqual(CensusAnalyserException.ExceptionType.INVALID_FILEPATH, exception.type);
        }