Ejemplo n.º 1
0
        protected override void beforeEach()
        {
            theChain       = new BehaviorChain();
            theChain.Route = new RouteDefinition("something")
            {
                Input = new RouteInput <FakeInput>("somepattern")
            };


            theNode = new MenuNode(FakeKeys.Key1, r => theChain);
            theNode.Resolve(null);
            theNode.BehaviorChain.ShouldBeTheSameAs(theChain);
            theNode.UrlInput = new object();

            theNode.Icon("some image");

            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key2));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key3));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key4));

            theIconUrl = "test.png";
            MockFor <IAssetUrls>().Stub(x => x.UrlForAsset(AssetFolder.images, theNode.Icon())).Return(theIconUrl);

            theUrls = new StubUrlRegistry();
            Services.Inject <IUrlRegistry>(theUrls);

            MockFor <IMenuStateService>().Stub(x => x.DetermineStateFor(theNode))
            .Return(MenuItemState.Available);

            MockFor <IChainUrlResolver>().Stub(x => x.UrlFor(theNode.UrlInput, theNode.BehaviorChain))
            .Return("the full url");
        }
        public void set_the_icon()
        {
            var node = new MenuNode(FakeKeys.Key9);
            node.Icon("something.png").ShouldBeTheSameAs(node);

            node.Icon().ShouldEqual("something.png");
        }
        public void set_the_icon()
        {
            var node = new MenuNode(FakeKeys.Key9);

            node.Icon("something.png").ShouldBeTheSameAs(node);

            node.Icon().ShouldEqual("something.png");
        }
Ejemplo n.º 4
0
        protected override void beforeEach()
        {
            theChain       = new BehaviorChain();
            theChain.Route = new RouteDefinition("something")
            {
                Input = new RouteInput <FakeInput>("somepattern")
            };


            theNode = new MenuNode(FakeKeys.Key1, r => theChain);
            theNode.Resolve(null);
            theNode.BehaviorChain.ShouldBeTheSameAs(theChain);
            theNode.UrlInput = new object();

            theNode.Icon("some image");

            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key2));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key3));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key4));

            theUrls = new StubUrlRegistry();
            Services.Inject <IUrlRegistry>(theUrls);

            MockFor <IMenuStateService>().Stub(x => x.DetermineStateFor(theNode))
            .Return(MenuItemState.Available);

            MockFor <ICurrentHttpRequest>().Stub(x => x.ToFullUrl(theNode.CreateUrl()))
            .Return("the full url");

            theToken = ClassUnderTest.BuildToken(theNode);
        }
Ejemplo n.º 5
0
        // TODO -- this could really use some more end to end testing
        public MenuItemToken BuildToken(MenuNode node)
        {
            var token = new MenuItemToken {
                Children = node.Children.Select(BuildToken).ToArray(),
                Key = node.Key.Key,
                Text = node.Key.ToString(),

                MenuItemState = _stateService.DetermineStateFor(node)
            };

            if (node.Icon().IsNotEmpty())
            {
                token.IconUrl = _urls.UrlForAsset(AssetFolder.images, node.Icon());
            }

            if (node.Type == MenuNodeType.Leaf)
            {
                token.Url = _request.ToFullUrl(node.CreateUrl());
            }

            return token;
        }
        // TODO -- this could really use some more end to end testing
        public MenuItemToken BuildToken(MenuNode node)
        {
            var token = new MenuItemToken {
                Children = node.Children.Select(BuildToken).ToArray(),
                Key = node.Key.Key,
                Text = node.Key.ToString(),
                Category = node.Category,
                MenuItemState = _stateService.DetermineStateFor(node)
            };

            if (node.Icon().IsNotEmpty())
            {
                token.IconUrl = _urls.UrlForAsset(AssetFolder.images, node.Icon());
            }

            if (node.Type == MenuNodeType.Leaf)
            {
	            token.Url = _urlResolver.UrlFor(node.UrlInput, node.BehaviorChain);
            }

			node.ForData(token.Set);

            return token;
        }
Ejemplo n.º 7
0
 public void will_resolve_the_asset_url_for_the_icon_if_it_exists()
 {
     theToken.IconUrl.ShouldEqual(theUrls.UrlForAsset(AssetFolder.images, theNode.Icon()));
 }