Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
 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");
     }
 }
Exemplo n.º 6
0
        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);
            }
        }