public void CheckLoadCsvFileTest() { TrafficViolationDetection trafficViolationDetection = new TrafficViolationDetection(); try { // To check invalid file path trafficViolationDetection.LoadCsvFile(@"\\tsclient\E\vinothkanth\Assesment\GovernmentOfIndia\TrafficViolence\TrafficVionRecord.csv"); } catch (FileNotFoundException exception) { string expected = "File Not Found"; Assert.AreEqual(expected, exception.Message); } // To check the function can be read the data string csvFilePath = @"C:\Users\vinothkanth\Desktop\GovernmentOfIndia\TrafficViolence\TrafficViolationRecord.csv"; List <string> listOfFileData = trafficViolationDetection.LoadCsvFile(csvFilePath); string infractionId = listOfFileData[0].Split('#')[0].Split(',')[0]; Assert.AreEqual("001/2018", infractionId); }
public void CheckGetTrafficViolationByVehicleCategory() { // Load Traffic violation datas TrafficViolationDetection trafficViolationDetection = new TrafficViolationDetection(); string csvFilePath = @"C:\Users\vinothkanth\Desktop\GovernmentOfIndia\TrafficViolence\TrafficViolationRecord.csv"; List <string> trafficViolationDatas = trafficViolationDetection.LoadCsvFile(csvFilePath); List <string[]> listOfTrafficViolationData = trafficViolationDetection.Split(trafficViolationDatas, '#'); List <TrafficViolation> listOfTrafficViolation = trafficViolationDetection.CreateTrafficViolationList(listOfTrafficViolationData); // it will be return the count of traffic violation of specified vehicle category int valueCount = trafficViolationDetection.GetUsingVehicleCategory("HMV", listOfTrafficViolation).Count; // Invalid data int dataNotFoundCount = trafficViolationDetection.GetUsingVehicleCategory("RRT", listOfTrafficViolation).Count; Assert.AreEqual(7, valueCount); Assert.AreEqual(0, dataNotFoundCount); // To check exception case try { List <TrafficViolation> list = new List <TrafficViolation>() { new TrafficViolation(null, null, null) }; // It will be throw an object instance null exception trafficViolationDetection.GetUsingVehicleCategory("TN56195145", list); } catch (Exception ex) { Assert.AreEqual("Object reference not set to an instance of an object.", ex.Message.ToString()); } }