Пример #1
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);
     }
 }
Пример #2
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);
     }
 }
Пример #3
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);
     }
 }
Пример #4
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);
     }
 }
Пример #5
0
 public void GivenIndiaStateCodeData_WhenPassEmptyString_shouldThrowCustomException()
 {
     try
     {
         CensusAnalyser censusAnalyser = new CensusAnalyser(" ");
         censusAnalyser.LoadIndiaStateCode();
     }
     catch (CensusAnalyserException e)
     {
         Assert.AreEqual(CensusAnalyserException.ExceptionType.UNEXPECTED_ERROR, e.Type);
     }
 }
Пример #6
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);
     }
 }
Пример #7
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);
     }
 }