Exemple #1
0
        public void GivenFilePathIncorrect_WhenCheckFilePath_ShouldReturnsFileNotFoundException()
        {
            Factory factory = new Factory();
            DelegateCsvStateDataLoadDAO deleget = new DelegateCsvStateDataLoadDAO(Builder.Construct);
            var ex = Assert.Throws <FileNotFoundException>(() => deleget(factory.GetObjectCSVStateCensus(), "Wrong_File_Path", "State,Population,AreaInSqKm,DensityPerSqKm"));

            Assert.That(ex.Message, Is.EqualTo(CensusException.Wrong_File_Path.ToString()));
        }
Exemple #2
0
        public void GivenWrongHeader_WhenHeaderDontMatch_ShouldPassWrongHeader()
        {
            string  path    = @"C:\Users\Srinidhi\source\repos\CensersAnaliserProblem\CensersAnaliserProblem\sateCensusAnalyser.csv";
            Factory factory = new Factory();
            DelegateCsvStateDataLoadDAO deleget = new DelegateCsvStateDataLoadDAO(Builder.Construct);
            var ex = Assert.Throws <CensusAnalyserException>(() => deleget(factory.GetObjectCSVStateCensus(), path, "Wrong_Header"));

            Assert.That(ex.mgs, Is.EqualTo(CensusException.Wrong_Header.ToString()));
        }
Exemple #3
0
        public void GivenWrong_Delimiter_WhenDelimiterIsWrong_ShouldPassWrongDelimiter()
        {
            string  path    = @"C:\Users\Srinidhi\source\repos\CensersAnaliserProblem\CensersAnaliserProblem\wrongCSVStateCensus.csv";
            Factory factory = new Factory();
            DelegateCsvStateDataLoadDAO deleget = new DelegateCsvStateDataLoadDAO(Builder.Construct);
            var ex = Assert.Throws <CensusAnalyserException>(() => deleget(factory.GetObjectCSVStateCensus(), path, "State,Population,AreaInSqKm,DensityPerSqKm"));

            Assert.That(ex.mgs, Is.EqualTo(CensusException.Wrong_Delimiter.ToString()));
        }
Exemple #4
0
 public void GivenFileExtansionIncorrect_WhenCheckFilePath_ShouldReturnsFileNotFoundException()
 {
     try
     {
         string  path    = @"C:\Users\Srinidhi\source\repos\CensersAnaliserProblem\CensersAnaliserProblem\sateCensusAnalyser.txt";
         Factory factory = new Factory();
         DelegateCsvStateDataLoadDAO deleget = new DelegateCsvStateDataLoadDAO(Builder.Construct);
         var ex = Assert.Throws <FileNotFoundException>(() => deleget(factory.GetObjectCSVStateCensus(), path, "State,Population,AreaInSqKm,DensityPerSqKm"));
         Assert.That(ex.Message, Is.EqualTo(CensusException.Wrong_File_Path.ToString()));
     }
     catch (FileNotFoundException e)
     {
         _ = e.StackTrace;
     }
 }
Exemple #5
0
 public void GivenNoOfRecords_WhenNumOfRecoder_ShouldReturnsNoOfRecordesInCSV()
 {
     try
     {
         string  path    = @"C:\Users\Srinidhi\source\repos\CensersAnaliserProblem\CensersAnaliserProblem\sateCensusAnalyser.csv";
         Factory factory = new Factory();
         DelegateCsvStateDataLoadDAO deleget = new DelegateCsvStateDataLoadDAO(Builder.Construct);
         int expected = StateCensusAnalyser.CSVLoadData(path);
         Assert.AreEqual(expected.ToString(), deleget(factory.GetObjectCSVStateCensus(), path, ""));
     }
     catch (Exception e)
     {
         _ = e.StackTrace;
     }
 }