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());
            }
        }
Beispiel #2
0
        public void CheckGetTrafficViolationRegisteredByParticularPolice()
        {
            // 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 particulet police registered infractions
            int valueCount = trafficViolationDetection.GetUsingRegisteredByParticularPolice("PC102", listOfTrafficViolation).Count;
            // Invalid data
            int dataNotFoundCount = trafficViolationDetection.GetUsingRegisteredByParticularPolice("PC110", listOfTrafficViolation).Count;

            Assert.AreEqual(3, 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.GetUsingRegisteredByParticularPolice("PC101", list);
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", ex.Message.ToString());
            }
        }
Beispiel #3
0
        public void CheckTrafficViolationListCreation()
        {
            // 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 first index of driver name
            string driverName = listOfTrafficViolation[0].GetDriver().GetName();

            Assert.AreEqual("RAHMAN", driverName);
        }
Beispiel #4
0
        public void CheckCreateTrafficViolationList()
        {
            try
            {
                TrafficViolationDetection trafficViolationDetection = new TrafficViolationDetection();
                // duplicate records
                string          csvFilePath                = @"\\tsclient\E\vinothkanth\Assesment\GovernmentOfIndia\TrafficViolence\dummyRecord.csv";
                List <string>   trafficViolationDatas      = trafficViolationDetection.LoadCsvFile(csvFilePath);
                List <string[]> listOfTrafficViolationData = trafficViolationDetection.Split(trafficViolationDatas, ',');

                // it will be throw an Index out of boundary exception
                trafficViolationDetection.CreateTrafficViolationList(listOfTrafficViolationData);
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Array Index Out Of Bounce", ex.Message.ToString());
            }
        }