コード例 #1
0
        public void GetInstrumentationSet_UsesSuppliedInitialContext()
        {
            var context = new InstrumentAttribute { Metric = Metric.Scoped, MetricName = "Test metric", Scopes = InstrumentationScopes.All };

            _testDiscoverer.GetInstrumentationSet("dummy path", context, x => true);

            EqualityHelper.AreObjectsEquivalentByPublicProperties(_testDiscoverer.FirstContext, context, false);
        }
コード例 #2
0
        public void GetEffectiveInstrumentationContext_ReturnsContextEquivalentToSupplied_IfOnlyOneNonNullContextSuppliedWithNullsAfter()
        {
            var attr = new InstrumentAttribute {
                IncludeCompilerGeneratedCode = true, Metric = Metric.Scoped, MetricName = "Metric name", Scopes = InstrumentationScopes.All
            };
            var effective = InstrumentAttribute.GetEffectiveInstrumentationContext(attr, null, null);

            Assert.IsTrue(EqualityHelper.AreObjectsEquivalentByPublicProperties(attr, effective, false));
        }
コード例 #3
0
        public void GetInstrumentationSet_UsesAssemblyLevelContext_IfNoneExplicitlySupplied()
        {
            var assyContext = new InstrumentAttribute { Metric = Metric.Scoped, MetricName = "Test metric", Scopes = InstrumentationScopes.All };
            DummyAssembly.Instance.InstrumentationContext = assyContext;

            _testDiscoverer.GetInstrumentationSet("dummy path", null, x => true);

            EqualityHelper.AreObjectsEquivalentByPublicProperties(_testDiscoverer.FirstContext, assyContext, false);
        }
コード例 #4
0
        public void GetInstrumentationSet_UsesOuterTypeContext_WhenNestedTypeHasNoExplicitContext()
        {
            var typeContext = new InstrumentAttribute { Scopes = InstrumentationScopes.All };
            _classType.InstrumentationContext = typeContext;

            _testDiscoverer.GetInstrumentationSet("dummy path", new InstrumentAttribute(), x => true);

            Assert.IsTrue(EqualityHelper.AreObjectsEquivalentByPublicProperties(typeContext, _testDiscoverer.ScannedTypes[_nestedType], false));
        }
コード例 #5
0
        public void GetInstrumentationSet_MergesInitialAndAssemblyLevelContext_IfBothSupplied()
        {
            var initialContext = new InstrumentAttribute { Metric = Metric.Unscoped, MetricName = "Initial metric", Scopes = InstrumentationScopes.All, IncludeCompilerGeneratedCode = true };
            var assyContext = new InstrumentAttribute { Metric = Metric.Scoped, MetricName = "Assy metric", Scopes = InstrumentationScopes.All };
            var expectedContext = new InstrumentAttribute { Metric = NRConfig.Metric.Scoped, MetricName = "Assy metric", Scopes = InstrumentationScopes.All, IncludeCompilerGeneratedCode = true };

            DummyAssembly.Instance.InstrumentationContext = assyContext;

            _testDiscoverer.GetInstrumentationSet("dummy path", initialContext, x => true);

            EqualityHelper.AreObjectsEquivalentByPublicProperties(_testDiscoverer.FirstContext, expectedContext, false);
        }
コード例 #6
0
        public void CciAndReflectedStrategies_ProduceSameOutput_WithNoExplicitInitialContext()
        {
            var cci       = new NRConfigManager.Infrastructure.Cci.CciInstrumentationDiscoverer();
            var reflected = new NRConfigManager.Infrastructure.Reflected.ReflectedInstrumentationDiscoverer();

            var cciSet       = cci.GetInstrumentationSet("TestAssembly.dll", null, x => true);
            var reflectedSet = reflected.GetInstrumentationSet("TestAssembly.dll", null, x => true);

            // Render both
            var cciSetRendered       = NRConfigManager.Rendering.Renderer.Render(cciSet);
            var reflectedSetRendered = NRConfigManager.Rendering.Renderer.Render(reflectedSet);

            Assert.IsTrue(EqualityHelper.AreObjectsEquivalentByPublicProperties(cciSetRendered, reflectedSetRendered, true));
        }