Пример #1
0
 public async Task Then_The_Api_Is_Called_With_The_Request_And_Sectors_Returned_And_Added_To_Cache(
     GetRoutesQuery query,
     GetRoutesListResponse apiResponse,
     [Frozen] Mock <ICoursesApiClient <CoursesApiConfiguration> > apiClient,
     [Frozen] Mock <ICacheStorageService> cacheStorageService,
     GetRoutesQueryHandler handler
     )
 {
     //Arrange
     cacheStorageService.Setup(x => x.RetrieveFromCache <GetRoutesListResponse>(nameof(GetRoutesListResponse)))
     .ReturnsAsync((GetRoutesListResponse) default);
        public async Task Then_Gets_Routes_From_Service(
            GetRoutesQuery query,
            List <Route> routesFromService,
            [Frozen] Mock <IRouteService> routeService,
            GetRoutesQueryHandler handler)
        {
            routeService
            .Setup(service => service.GetRoutes())
            .ReturnsAsync(routesFromService);

            var result = await handler.Handle(query, CancellationToken.None);

            result.Routes.Should().BeEquivalentTo(routesFromService);
        }
        public async Task Then_The_Service_Called_And_Data_Returned(
            GetRoutesQuery query,
            GetRoutesListResponse response,
            [Frozen] Mock <ICourseService> service,
            GetRoutesQueryHandler handler)
        {
            //Arrange
            service.Setup(x => x.GetRoutes())
            .ReturnsAsync(response);

            //Act
            var actual = await handler.Handle(query, CancellationToken.None);

            //Assert
            actual.Routes.Should().BeEquivalentTo(response.Routes);
        }