Beispiel #1
0
        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());
            }
        }