public void AvgSpeedBucketCollectionTest() { List <CycleSpeed> cycles = new List <CycleSpeed>(); AvgSpeedBucketCollection asbc = new AvgSpeedBucketCollection(DateTime.Now.AddDays(-1), DateTime.Now, 5, 5, cycles); List <Common.Models.Speed_Events> lse = new List <Common.Models.Speed_Events>(); Common.Models.Speed_Events se1 = new Common.Models.Speed_Events(); se1.DetectorID = "100001"; se1.MPH = 30; se1.timestamp = Convert.ToDateTime("10/26/2017 12:01"); Common.Models.Speed_Events se2 = new Common.Models.Speed_Events(); se2.DetectorID = "100001"; se2.MPH = 30; se2.timestamp = Convert.ToDateTime("10/26/2017 12:02"); Common.Models.Speed_Events se3 = new Common.Models.Speed_Events(); se3.DetectorID = "100001"; se3.MPH = 30; se3.timestamp = Convert.ToDateTime("10/26/2017 12:03"); lse.Add(se1); lse.Add(se2); lse.Add(se3); int testAverage = asbc.GetAverageSpeed(lse); Assert.IsTrue(testAverage == 30); }
public DetectorSpeed(Models.Detector detector, DateTime startDate, DateTime endDate, int binSize, bool getPermissivePhase) { StartDate = startDate; EndDate = endDate; Cycles = CycleFactory.GetSpeedCycles(startDate, endDate, getPermissivePhase, detector); TotalDetectorHits = Cycles.Sum(c => c.SpeedEvents.Count); Plans = PlanFactory.GetSpeedPlans(Cycles, startDate, endDate, detector.Approach); var movementDelay = 0; if (detector.MovementDelay != null) { movementDelay = detector.MovementDelay.Value; } AvgSpeedBucketCollection = new AvgSpeedBucketCollection(startDate, endDate, binSize, movementDelay, Cycles); }