public async void GetMenuHandlerFailure()
        {
            GetMenuQuery        getMenuQuery   = new GetMenuQuery();
            GetMenuQueryHandler getMenuHandler = new GetMenuQueryHandler();
            var actual = await getMenuHandler.Handle(getMenuQuery, new CancellationToken());

            Assert.NotEqual(5, actual.Count());
        }
        public async Task <GetMenuQueryResult <Menu> > Handle(GetMenuQuery request, CancellationToken cancellationToken)
        {
            var menu = new Page <Menu>();

            await menu.FetchMenu(_apiClient);

            return(new GetMenuQueryResult <Menu>
            {
                Page = menu,
            });
        }
Exemplo n.º 3
0
        public async Task Then_The_Api_Is_Called_And_The_Menu_Is_Returned(
            GetMenuQuery query,
            CmsContent apiResponse,
            MenuPageModel response,
            [Frozen] Mock <IContentService> contentService,
            [Frozen] Mock <IReliableCacheStorageService> service,
            GetMenuQueryHandler handler)
        {
            contentService.Setup(x => x.HasContent(It.IsAny <ApiResponse <CmsContent> >())).Returns(true);
            service.Setup(o =>
                          o.GetData <CmsContent>(
                              It.Is <GetMenuRequest>(c =>
                                                     c.GetUrl.Contains($"entries?content_type=navigationMenu&fields.type={query.MenuType}")),
                              $"{query.MenuType}_menu", contentService.Object.HasContent))
            .ReturnsAsync(apiResponse);

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

            actual.PageModel.Should().BeEquivalentTo(response.Build(apiResponse));
        }
        public async Task <List <MenuItem> > Handle(GetMenuQuery request, CancellationToken cancellationToken)
        {
            var getMenu = MockData.GetInstance();

            return(await Task.FromResult(getMenu.MenuList));
        }