public void NavigationManagerShouldCatchProviderErrors() { var manager = new NavigationManager(new[] { new BrokenProvider() }, new IMenuProvider[] { }, new StubAuth(), new INavigationFilter[0], new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData())), new StubCoeveryServices(), new ShellSettings()); var menuItems = manager.BuildMenu("admin"); Assert.That(menuItems.Count(), Is.EqualTo(0)); }
public void NavigationManagerShouldMergeAndOrderNavigation() { var manager = new NavigationManager(new INavigationProvider[] { new StubProvider(), new Stub2Provider() }, new IMenuProvider[] { }, new StubAuth(), new INavigationFilter[0], new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData())), new StubCoeveryServices(), new ShellSettings()); var menuItems = manager.BuildMenu("admin"); Assert.That(menuItems.Count(), Is.EqualTo(3)); var item1 = menuItems.First(); var item2 = menuItems.Skip(1).First(); var item3 = menuItems.Skip(2).First(); Assert.That(item1.Text.TextHint, Is.EqualTo("Foo")); Assert.That(item1.Position, Is.EqualTo("1.0")); Assert.That(item2.Text.TextHint, Is.EqualTo("Bar")); Assert.That(item2.Position, Is.EqualTo("2.0")); Assert.That(item3.Text.TextHint, Is.EqualTo("Frap")); Assert.That(item3.Position, Is.EqualTo("3.0")); Assert.That(item2.Items.Count(), Is.EqualTo(2)); var subitem1 = item2.Items.First(); var subitem2 = item2.Items.Last(); Assert.That(subitem1.Text.TextHint, Is.EqualTo("Quad")); Assert.That(subitem1.Position, Is.EqualTo("1.a")); Assert.That(subitem2.Text.TextHint, Is.EqualTo("Frap")); Assert.That(subitem2.Position, Is.EqualTo("1.b")); }
public void EmptyMenuIfNameDoesntMatch() { var manager = new NavigationManager(new[] { new StubProvider() }, new IMenuProvider[] { }, new StubAuth(), new INavigationFilter[0], new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData())), new StubCoeveryServices(), new ShellSettings()); var menuItems = manager.BuildMenu("primary"); Assert.That(menuItems.Count(), Is.EqualTo(0)); }
public void NavigationManagerShouldUseProvidersToBuildNamedMenu() { var manager = new NavigationManager(new[] { new StubProvider() }, new IMenuProvider[] { }, new StubAuth(), new INavigationFilter[0], new UrlHelper(new RequestContext(new StubHttpContext("~/"), new RouteData())), new StubCoeveryServices(), new ShellSettings()); var menuItems = manager.BuildMenu("admin"); Assert.That(menuItems.Count(), Is.EqualTo(2)); Assert.That(menuItems.First(), Has.Property("Text").Property("TextHint").EqualTo("Foo")); Assert.That(menuItems.Last(), Has.Property("Text").Property("TextHint").EqualTo("Bar")); Assert.That(menuItems.Last().Items.Count(), Is.EqualTo(1)); Assert.That(menuItems.Last().Items.Single().Text.TextHint, Is.EqualTo("Frap")); }