public void FromGivenStateCensusCSVFile_IfCorrect_ShouldReturnNoOfRecords()
        {
            CensusAnalyser censusAnalyser = (CensusAnalyser)csvFactory.getIndianCensusAnalyser();

            csvFileData          = new CSVFileData(censusAnalyser.LoadCSVFileData);
            totalNumberOfRecords = (List <string>)csvFileData(CSVStateCodeFilePath, StateCodeFileHeaders);
            Assert.AreEqual(37, totalNumberOfRecords.Count);
        }
Exemple #2
0
 public void GivenUsCensusCSVData__WhenIncorrectHeader_ShouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(usaFilePath);
         censusAnalyser.LoadUsCencusData();
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.HEADER_INCORRECT, e.Type);
     }
 }
Exemple #3
0
 public void GivenIndianStateCode_WhenPassNull_shouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(null);
         censusAnalyser.LoadIndiaStateCode();
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
Exemple #4
0
 public void GivenUsCensusData_WhenPassEmptyString_shouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(" ");
         censusAnalyser.LoadUsCencusData();
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.UNEXPECTED_ERROR, e.Type);
     }
 }
Exemple #5
0
 public void GivenUsCensusData_WhenWrongPathName_shouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(usaCensusWrongJsonPath);
         censusAnalyser.LoadUsCencusData();
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.UNEXPECTED_ERROR, e.Type);
     }
 }
Exemple #6
0
 public void GivenIndianStateCode_WhenIncorrectHeader_ShouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(indiaStateCodePath);
         censusAnalyser.LoadIndiaStateCode();
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.HEADER_INCORRECT, e.Type);
     }
 }
Exemple #7
0
 public void GivenUsCensusData_WhenDelimeterIncorrect_shouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(wrongCsvFileExtension);
         censusAnalyser.LoadUsCencusData();
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.UNEXPECTED_ERROR, e.Type);
     }
 }
Exemple #8
0
 public void GivenIndianStateCode_WhenWrongExtension_shouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(wrongStateCodeFileExtension);
         censusAnalyser.LoadIndiaStateCode();
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.UNEXPECTED_ERROR, e.Type);
     }
 }
Exemple #9
0
 public void GivenIndiaStateCode_WhenDelimeterIncorrect_shouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(indiaStateCodePath);
         censusAnalyser.LoadIndiaStateCode();
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.DELIMETER_INCORRECT_EXCEPTION, e.Type);
     }
 }
Exemple #10
0
 public void GivenUsCencusData_WhenPassNull_shouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(null);
         censusAnalyser.LoadUsCencusData();
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
 public void FromGivenStateCodesCSVFile_IfIncorrectHeadersPresentInFile_ShouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = (CensusAnalyser)csvFactory.getIndianCensusAnalyser();
         csvFileData = new CSVFileData(censusAnalyser.LoadCSVFileData);
         var exception = Assert.Throws <CensusAnalyserException>(() => csvFileData(InvalidHeaderFilePath, StateCodeFileHeaders));
     }
     catch (CensusAnalyserException ex)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.INVALID_HEADERS, ex.type);
     }
 }
Exemple #12
0
 public void GivenIndianCensusData_CSVFile_ShouldReturnsCorrectRecords()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(indiaCensusCsvFilePath);
         int            csvDatacount   = censusAnalyser.LoadIndiaCensusData();
         Assert.AreEqual(29, csvDatacount);
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
Exemple #13
0
 public void GivenUsCensusCSVData_WhenSorting_WhenAnalyseCsvtoJson_ReturnThrowException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(usaFilePath);
         censusAnalyser.LoadUsCencusData();
         JArray sortedData = censusAnalyser.GetSortedCensusData(usaCensusJsonPath, " ", 50);
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.INDEX_NOT_FOUND, e.Type);
     }
 }
Exemple #14
0
 public void GivenIndianStateCode_CSVFile_ShouldReturnsCorrectRecords()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(indiaStateCodePath);
         int            csvstateData   = censusAnalyser.LoadIndiaStateCode();
         Assert.AreEqual(37, csvstateData);
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
 public void FromGivenIndianCensusCSVFile_IfIncorrectDeliminatorPresentInFile_ShouldThrowException()
 {
     try
     {
         CensusAnalyser censusAnalyser = (CensusAnalyser)csvFactory.getIndianCensusAnalyser();
         csvFileData = new CSVFileData(censusAnalyser.LoadCSVFileData);
         var exception = Assert.Throws <CensusAnalyserException>(() => csvFileData(InvalidDeliminatorFilePath, StateCensusFileHeaders));
     }
     catch (CensusAnalyserException ex)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.INVALID_DELIMITER, ex.type);
     }
 }
 public void FromGivenIndianCensusCSVFile_IfIncorrectFileType_ShouldThrowAnException()
 {
     try
     {
         CensusAnalyser censusAnalyser = (CensusAnalyser)csvFactory.getIndianCensusAnalyser();
         csvFileData = new CSVFileData(censusAnalyser.LoadCSVFileData);
         var exception = Assert.Throws <CensusAnalyserException>(() => csvFileData(InvalidCSVTypeFilePath, StateCensusFileHeaders));
     }
     catch (CensusAnalyserException ex)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.INCORRECT_FILE_TYPE, ex.type);
     }
 }
 public void FromGivenIndianCensusCSVFile_WhenNotFound_ShouldThrowAnException()
 {
     try
     {
         CensusAnalyser censusAnalyser = (CensusAnalyser)csvFactory.getIndianCensusAnalyser();
         csvFileData = new CSVFileData(censusAnalyser.LoadCSVFileData);
         var exception = Assert.Throws <CensusAnalyserException>(() => csvFileData(InvalidFilePath, StateCensusFileHeaders));
     }
     catch (CensusAnalyserException ex)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, ex.type);
     }
 }
Exemple #18
0
 public void GivenUsCencusData_CSVFile_ShouldReturnsCorrectRecords()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(usaFilePath);
         int            csvstateData   = censusAnalyser.LoadUsCencusData();
         Assert.AreEqual(51, csvstateData);
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
Exemple #19
0
 public void GivenUsCensusCSVData_WhenSorting_WhenAnalyseCsvtoJson_ReturnHighesttotalArea()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(usaFilePath);
         censusAnalyser.LoadUsCencusData();
         JArray sortedData = censusAnalyser.GetSortedCensusData(usaCensusJsonPath, "TotalArea", 50);
         Assert.AreEqual("1723338.01", sortedData[50]["TotalArea"].ToString());
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
Exemple #20
0
 public void GivenUsCensusCSVData_WhenSorting_WhenAnalyseCsvtoJson_ReturnLowestPopulation()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(usaFilePath);
         censusAnalyser.LoadUsCencusData();
         JArray sortedData = censusAnalyser.GetSortedCensusData(usaCensusJsonPath, "Population", 0);
         Assert.AreEqual("563626", sortedData[0]["Population"].ToString());
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
Exemple #21
0
 public void GivenIndianCensusCSVData_WhenSorting_WhenAnalyseCsvtoJson_ReturnPopulationDencity()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(indiaCensusCsvFilePath);
         censusAnalyser.LoadIndiaCensusData();
         JArray sortedData = censusAnalyser.GetpopulationDencityWiseSortedUsCensusDataAndIndianStateCensusData(indiaStateCensusJsonPath, "DencityPerSqKm", 0);
         Assert.AreEqual("50", sortedData[0]["DencityPerSqKm"].ToString());
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
 public void FromGivenIndianCensusCSVFile_IfCorrect_ShouldReturnNoOfRecords()
 {
     try
     {
         CensusAnalyser censusAnalyser = (CensusAnalyser)csvFactory.getIndianCensusAnalyser();
         csvFileData          = new CSVFileData(censusAnalyser.LoadCSVFileData);
         totalNumberOfRecords = (List <string>)csvFileData(CSVFilePath, StateCensusFileHeaders);
         Assert.AreEqual(29, totalNumberOfRecords.Count);
     }
     catch (Exception ex)
     {
         System.Console.WriteLine(ex.Message);
     }
 }
Exemple #23
0
 public void GivenIndianStateCodeCSVData_WhenSorting_WhenAnalyseCsvtoJson_ReturnLastState()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(indiaStateCodePath);
         censusAnalyser.LoadIndiaStateCode();
         JArray sortedData = censusAnalyser.GetSortedCensusData(indianStateCodeJsonPath, "State", 36);
         Assert.AreEqual("West Bengal", sortedData[36]["State"].ToString());
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
Exemple #24
0
 public void GivenUsCensusCSVData_WhenSorting_WhenAnalyseCsvtoJson_ReturnSmallestPopulationDencity()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(usaFilePath);
         censusAnalyser.LoadUsCencusData();
         JArray sortedData = censusAnalyser.GetpopulationDencityWiseSortedUsCensusDataAndIndianStateCensusData(usaCensusJsonPath, "PopulationDencity", 50);
         Assert.AreEqual("2.24", sortedData[50]["PopulationDencity"].ToString());
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
Exemple #25
0
 public void GivenIndianCensusCSVData_WhenSorting_WhenAnalyseCsvtoJson_ReturnFirstState()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(indiaCensusCsvFilePath);
         censusAnalyser.LoadIndiaCensusData();
         JArray sortedData = censusAnalyser.GetSortedCensusData(indiaStateCensusJsonPath, "State", 0);
         Assert.AreEqual("Andhra Pradesh", sortedData[0]["State"].ToString());
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
Exemple #26
0
 public void GivenIndianCensusCSVData_WhenSorting_WhenAnalyseCsvtoJson_ReturnLargetArea()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(indiaCensusCsvFilePath);
         censusAnalyser.LoadIndiaCensusData();
         JArray sortedData = censusAnalyser.GetSortedCensusData(indiaStateCensusJsonPath, "AreaInSqKm", 28);
         Assert.AreEqual("342239", sortedData[28]["AreaInSqKm"].ToString());
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.FILE_NOT_FOUND, e.Type);
     }
 }
 public void Setup()
 {
     censusAnalyser = new CensusAnalyser();
     totalRecord    = new Dictionary <string, CensusDTO>();
 }
Exemple #28
0
 public void Setup()
 {
     censusAnalyser = new CensusAnalyser();
 }
Exemple #29
0
 public void Setup()
 {
     censusAnalyser = new StateCensusAnalyser.CensusAnalyser();
     toatlRecord    = new Dictionary <string, CensusDTO>();
     stateRecord    = new Dictionary <string, CensusDTO>();
 }
 public void Setup()
 {
     this.censusAnalyser = new CensusAnalyser();
     this.totalRecords   = new Dictionary <string, dynamic>();
 }