Esempio n. 1
0
        public void BusStopPunctualityHourMode_WhenTracesExist_ReturnsModeAsTimespan()
        {
            _busStops[0].BusStopTraces.Add(new BusStopTrace //two traces at 11:55
            {
                Id        = 10000,
                Hour      = new TimeSpan(11, 55, 0),
                BusStopId = 1
            });

            var result = PunctualityConverter.BusStopPunctualityHourMode(_busStops[0]);

            Assert.IsInstanceOf <TimeSpan>(result);
            Assert.AreEqual(new TimeSpan(11, 55, 0), result);
        }
Esempio n. 2
0
        private static void SetPunctualityForRoute(Route route, ref RoutesRouteDto routeDto)
        {
            for (int i = 0; i < route.BusStops.Count; i++)
            {
                routeDto.BusStops.ElementAt(i).PunctualityPercentage
                    = PunctualityConverter.BusStopPunctualityPercentage(route.BusStops.ElementAt(i));
                routeDto.BusStops.ElementAt(i).PunctualityMode
                    = PunctualityConverter.BusStopPunctualityHourMode(route.BusStops.ElementAt(i)).ToString(@"hh\:mm");

                var avgTuple = PunctualityConverter
                               .BusStopPunctualityHourAvgBeforeAvgAfterTime(route.BusStops.ElementAt(i));
                routeDto.BusStops.ElementAt(i).PunctualityAvgBeforeTime = avgTuple.avgTimeBefore.ToString();
                routeDto.BusStops.ElementAt(i).PunctualityAvgAfterTime  = avgTuple.avgTimeAfter.ToString();
            }

            var avgPunctuality =
                PunctualityConverter.RoutePunctualityHourAvgBeforeAvgAfterTime(route);

            routeDto.PunctualityAvgBeforeTime = avgPunctuality.avgTimeBefore.ToString();
            routeDto.PunctualityAvgAfterTime  = avgPunctuality.avgTimeAfter.ToString();
        }
Esempio n. 3
0
        public void BusStopPunctualityHourMode_WhenTracesDontExistOrNull_ReturnBusStopHour()
        {
            var busStop1 = new BusStop()
            {
                Id      = 1,
                Address = "Address",
                Hour    = new TimeSpan(12, 0, 0)
            };
            var busStop2 = new BusStop()
            {
                Id            = 1,
                Address       = "Address",
                BusStopTraces = new List <BusStopTrace>(),
                Hour          = new TimeSpan(14, 0, 0)
            };

            var result1 = PunctualityConverter.BusStopPunctualityHourMode(busStop1);
            var result2 = PunctualityConverter.BusStopPunctualityHourMode(busStop2);

            Assert.AreEqual(new TimeSpan(12, 0, 0), result1);
            Assert.AreEqual(new TimeSpan(14, 0, 0), result2);
        }