예제 #1
0
            public async Task ShouldReturnScheduleForBusStopOne()
            {
                GetMockOf <IDateTimeHelper>()
                .Setup(m =>
                       m.GetDateTimeNow())
                .Returns(new DateTime(2020, 9, 18, 18, 32, 0));

                var expectedSchedule = new GetScheduleByBusStopId.BusStopSchedule()
                {
                    Id     = 1,
                    Route1 = new List <string> {
                        "6:45 PM", "7:00 PM"
                    },
                    Route2 = new List <string> {
                        "6:47 PM", "7:02 PM"
                    },
                    Route3 = new List <string> {
                        "6:49 PM", "7:04 PM"
                    }
                };

                var page = await Get <Handler>()
                           .Handle(
                    new Query {
                    Id = 1
                }, CancellationToken.None);

                page.Id.Should().Be(expectedSchedule.Id);
                page.Route1.Should()
                .Contain(expectedSchedule.Route1);
            }
예제 #2
0
            public async Task ShouldReturnTheResultOfMediatorSend()
            {
                var expectedBusStopQuery = new GetScheduleByBusStopId.Query()
                {
                    Id = 1
                };
                var expectedSchedule = new GetScheduleByBusStopId.BusStopSchedule()
                {
                    Id     = 1,
                    Route1 = null,
                    Route2 = null,
                    Route3 = null
                };

                // Arrange
                GetMockOf <IMediator>()
                .Setup(m =>
                       m.Send(
                           It.Is <GetScheduleByBusStopId.Query>(q => q.Id == expectedBusStopQuery.Id),
                           It.IsAny <CancellationToken>()))
                .ReturnsAsync(expectedSchedule);

                // Act
                var actionResult = await Get <BusStopScheduleController>().GetScheduleByBusStopId(expectedBusStopQuery);

                // Assert
                actionResult.Should().Be(expectedSchedule);
            }