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())); }
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())); }
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())); }
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; } }
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; } }