public void Should_get_metric_path_and_root_path() { Assert.Equal("/", MetricMenu.GetMetricRootPath(type1)); Assert.Equal("/Summary", MetricMenu.GetMetricPath(type1)); Assert.Equal("/", MetricMenu.GetMetricRootPath(type2)); Assert.Equal("/Files", MetricMenu.GetMetricPath(type2)); Assert.Equal("/Charts/LOC", MetricMenu.GetMetricRootPath(type3)); Assert.Equal("/Charts/LOC/Summary", MetricMenu.GetMetricPath(type3)); }
public void Should_create_metric_menu() { var menus = MetricMenu.GetMetricMenu(new Type[] { type1, type2, type3 }); menus.Count .Should().Be(2); menus.Select(x => x.Key) .Should().BeEquivalentTo(new string[] { "/", "/Charts/LOC" }); menus["/"].Select(x => x.Path) .Should().BeEquivalentTo(new string[] { "/Summary", "/Files" }); menus["/Charts/LOC"].Select(x => x.Path) .Should().BeEquivalentTo(new string[] { "/Charts/LOC/Summary" }); }
private void RegisterMetricsAndMenusForThem(ContainerBuilder builder) { var metrics = Assembly.GetExecutingAssembly().GetTypes() .Where(t => t.IsClass && !t.IsAbstract && t.IsAssignableTo <IMetric>()) .ToArray(); foreach (var metric in metrics) { var metricPath = MetricMenu.GetMetricPath(metric); builder.RegisterType(metric) .Keyed <IMetric>(metricPath); } var menus = MetricMenu.GetLinkedMetricMenu(metrics); foreach (var m in menus) { builder.RegisterInstance(m.Value) .Keyed <List <MetricMenu.MetricMenuItem> >(m.Key); } }