Beispiel #1
0
        public void CheckGetTrafficViolationByDriver()
        {
            // 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 driver violation
            int valueCount = trafficViolationDetection.GetUsingDriver("TN5619951232345", listOfTrafficViolation).Count;
            // Invalid data
            int dataNotFoundCount = trafficViolationDetection.GetUsingDriver("TN56195145", listOfTrafficViolation).Count;

            Assert.AreEqual(2, valueCount);
            Assert.AreEqual(0, dataNotFoundCount);

            try
            {
                List <TrafficViolation> list = new List <TrafficViolation>()
                {
                    new TrafficViolation(null, null, null)
                };

                // It will be throw an object instance null  exception
                trafficViolationDetection.GetUsingDriver("TN56195145", list);
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", ex.Message.ToString());
            }
        }