Пример #1
0
        public void Should_make_metric_menu_linked()
        {
            var menus = MetricMenu.GetLinkedMetricMenu(new Type[] { type1, type2, type3 });

            menus.Count
            .Should().Be(3);
            menus.Select(x => x.Key)
            .Should().BeEquivalentTo(new string[] { "/", "/Charts", "/Charts/LOC" });
            menus["/"].Select(x => x.Path)
            .Should().BeEquivalentTo(new string[] { "/Summary", "/Files", "/Charts" });
            menus["/Charts"].Select(x => x.Path)
            .Should().BeEquivalentTo(new string[] { "/Charts/LOC", "/" });
            menus["/Charts/LOC"].Select(x => x.Path)
            .Should().BeEquivalentTo(new string[] { "/Charts/LOC/Summary", "/Charts" });
        }
Пример #2
0
        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);
            }
        }