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.Children.AddToEnd(new MenuNode(FakeKeys.Key2));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key3));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key4));


            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.º 2
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;
        }