An association between a Connexionz Platform Tag and a list of arrivals for the stop which corresponds to that tag.
        public void TestLateScheduledTimesOrderedAfterEstimates()
        {
            DateTimeOffset testTime = new DateTime(year: 2015, month: 10, day: 3, hour: 12, minute: 00, second: 00);

            var testSchedule = new Dictionary<int, IEnumerable<BusStopRouteSchedule>>
            {
                {
                    12345,
                    new List<BusStopRouteSchedule>
                    {
                        new BusStopRouteSchedule
                        {
                            RouteNo = "TEST1",
                            DaySchedules = new List<BusStopRouteDaySchedule>
                            {
                                new BusStopRouteDaySchedule
                                {
                                    Days = DaysOfWeek.All,
                                    Times = new List<TimeSpan>
                                    {
                                        new TimeSpan(12, 24, 0),
                                        new TimeSpan(13, 24, 0),
                                        new TimeSpan(14, 24, 0),
                                        new TimeSpan(15, 24, 0),
                                    }
                                }
                            }
                        },
                        new BusStopRouteSchedule
                        {
                            RouteNo = "TEST2",
                            DaySchedules = new List<BusStopRouteDaySchedule>
                            {
                                new BusStopRouteDaySchedule
                                {
                                    Days = DaysOfWeek.All,
                                    Times = new List<TimeSpan>
                                    {
                                        new TimeSpan(12, 25, 0),
                                        new TimeSpan(13, 25, 0),
                                        new TimeSpan(14, 25, 0),
                                        new TimeSpan(15, 25, 0),
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var mockRepo = new Mock<ITransitRepository>();
            mockRepo.Setup(repo => repo.GetStaticDataAsync()).Returns(
                Task.FromResult(
                    new BusStaticData
                    {
                        Routes = new Dictionary<string, BusRoute>
                        {
                        },
                        Stops = new Dictionary<int, BusStop>
                        {
                            { 12345, new BusStop { RouteNames = new List<string> { "TEST1", "TEST2" } } }
                        }
                    }));

            mockRepo.Setup(repo => repo.GetScheduleAsync()).Returns(Task.FromResult(testSchedule));
            mockRepo.Setup(repo => repo.GetPlatformTagsAsync()).Returns(
                Task.FromResult(
                    new Dictionary<int, int>
                    {
                        { 12345, 123 }
                    }));

            var testEstimate = new ConnexionzPlatformET
            {
                PlatformTag = 123,
                RouteEstimatedArrivals = new List<ConnexionzRouteET>
                {
                    new ConnexionzRouteET
                    {
                        RouteNo = "TEST1",
                        EstimatedArrivalTime = new List<int> { }
                    },
                    new ConnexionzRouteET
                    {
                        RouteNo = "TEST2",
                        EstimatedArrivalTime = new List<int> { 25 }
                    }
                }
            };

            var mockClient = new Mock<ITransitClient>();
            mockClient.Setup(client => client.GetEta(123)).Returns(Task.FromResult(testEstimate));

            var expected = new List<RouteArrivalsSummary>
            {
                new RouteArrivalsSummary
                {
                    RouteName = "TEST2",
                    ArrivalsSummary = "25 minutes, 1:25 PM",
                    ScheduleSummary = "Hourly until 3:25 PM"
                },
                new RouteArrivalsSummary
                {
                    RouteName = "TEST1",
                    ArrivalsSummary = "Over 30 minutes, 1:24 PM",
                    ScheduleSummary = "Hourly until 3:24 PM"
                }
            };

            var actual = TransitManager.GetArrivalsSummary(mockRepo.Object, mockClient.Object, testTime, new List<int> { 12345 }).Result;

            Assert.IsTrue(Enumerable.SequenceEqual(expected, actual[12345]));
        }
        public void TestEstimatePrependedToScheduledTimes()
        {
            DateTimeOffset testTime = new DateTime(2015, 10, 20, 12, 00, 00);

            var testSchedule = new Dictionary<int, IEnumerable<BusStopRouteSchedule>>
            {
                {
                    12345,
                    new List<BusStopRouteSchedule>
                    {
                        new BusStopRouteSchedule
                        {
                            RouteNo = "TEST",
                            DaySchedules = new List<BusStopRouteDaySchedule>
                            {
                                new BusStopRouteDaySchedule
                                {
                                    Days = DaysOfWeek.All,
                                    Times = new List<TimeSpan>
                                    {
                                        new TimeSpan(12, 25, 0),
                                        new TimeSpan(12, 55, 0),
                                        new TimeSpan(13, 25, 0),
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var mockRepo = new Mock<ITransitRepository>();
            mockRepo.Setup(repo => repo.GetScheduleAsync()).Returns(Task.FromResult(testSchedule));
            mockRepo.Setup(repo => repo.GetPlatformTagsAsync()).Returns(Task.FromResult(new Dictionary<int, int> { { 12345, 123 } }));

            var testEstimate = new ConnexionzPlatformET
            {
                PlatformTag = 123,
                RouteEstimatedArrivals = new List<ConnexionzRouteET>
                {
                    new ConnexionzRouteET
                    {
                        RouteNo = "TEST",
                        EstimatedArrivalTime = new List<int> { 3 }
                    }
                }
            };

            var mockClient = new Mock<ITransitClient>();
            mockClient.Setup(client => client.GetEta(123)).Returns(Task.FromResult(testEstimate));

            var expectedArrivalTimes = new List<BusArrivalTime> {
                new BusArrivalTime(3, isEstimate: true),
                new BusArrivalTime(25, isEstimate: false),
                new BusArrivalTime(55, isEstimate: false),
                new BusArrivalTime(85, isEstimate: false)
            };
            var actual = TransitManager.GetSchedule(mockRepo.Object, mockClient.Object, testTime, new List<int> { 12345 }).Result;

            Assert.IsTrue(Enumerable.SequenceEqual(expectedArrivalTimes, actual[12345]["TEST"]));
        }
        public void TestArrivalTimesAfterMidnightRenderCorrectly()
        {
            // This happens to be a Sunday morning.
            DateTimeOffset testTime = new DateTime(2015, 10, 4, 1, 00, 00);

            var testSchedule = new Dictionary<int, IEnumerable<BusStopRouteSchedule>>
            {
                {
                    12345,
                    new List<BusStopRouteSchedule>
                    {
                        new BusStopRouteSchedule
                        {
                            RouteNo = "TEST",
                            DaySchedules = new List<BusStopRouteDaySchedule>
                            {
                                new BusStopRouteDaySchedule
                                {
                                    Days = DaysOfWeek.NightOwl,
                                    Times = new List<TimeSpan>
                                    {
                                        new TimeSpan(23, 25, 0),
                                        new TimeSpan(24, 25, 0),
                                        new TimeSpan(25, 25, 0),
                                        new TimeSpan(26, 25, 0),
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var mockRepo = new Mock<ITransitRepository>();
            mockRepo.Setup(repo => repo.GetScheduleAsync()).Returns(Task.FromResult(testSchedule));
            mockRepo.Setup(repo => repo.GetPlatformTagsAsync()).Returns(Task.FromResult(new Dictionary<int, int> { { 12345, 123 } }));

            var testEstimate = new ConnexionzPlatformET
            {
                PlatformTag = 123,
                RouteEstimatedArrivals = new List<ConnexionzRouteET>
                {
                    new ConnexionzRouteET
                    {
                        RouteNo = "TEST",
                        EstimatedArrivalTime = new List<int> { 28 }
                    }
                }
            };

            var mockClient = new Mock<ITransitClient>();
            mockClient.Setup(client => client.GetEta(123)).Returns(Task.FromResult(testEstimate));

            var expectedArrivalTimes = new List<BusArrivalTime> {
                new BusArrivalTime(28, isEstimate: true),
                new BusArrivalTime(85, isEstimate: false)
            };
            var actual = TransitManager.GetSchedule(mockRepo.Object, mockClient.Object, testTime, new List<int> { 12345 }).Result;

            Assert.IsTrue(Enumerable.SequenceEqual(expectedArrivalTimes, actual[12345]["TEST"]));
        }