Пример #1
0
        public void BusStopPunctualityHourAvgBeforeAvgAfterTime_WhenBusStopHaveNotTraces_ReturnsTuple00()
        {
            var busStop1 = new BusStop()
            {
                BusStopTraces = new List <BusStopTrace>()
            };
            var busStop2 = new BusStop()
            {
                BusStopTraces = new List <BusStopTrace>()
            };

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

            Assert.AreEqual((0, 0), result1);
            Assert.AreEqual((0, 0), result2);
        }
Пример #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();
        }
Пример #3
0
        public void BusStopPunctualityHourAvgBeforeAvgAfterTime_WhenHaveOnlyAfterTraces_ReturnsTuple30()
        {
            var busStop = new BusStop
            {
                Hour          = new TimeSpan(12, 0, 0),
                BusStopTraces = new List <BusStopTrace>
                {
                    new BusStopTrace
                    {
                        Hour = new TimeSpan(11, 58, 0)
                    },
                    new BusStopTrace
                    {
                        Hour = new TimeSpan(11, 55, 0)
                    }
                }
            };

            var result = PunctualityConverter.BusStopPunctualityHourAvgBeforeAvgAfterTime(busStop);

            Assert.AreEqual((3, 0), result);
        }
Пример #4
0
        public void BusStopPunctualityHourAvgBeforeAvgAfterTime_WhenBusStopHaveTraces_ReturnsTuple()
        {
            var result = PunctualityConverter.BusStopPunctualityHourAvgBeforeAvgAfterTime(_busStops[0]);

            Assert.AreEqual((4, 9), result);
        }