public void DoNotCallFactoryIfCollectorExists()
        {
            var registry          = new CollectorRegistry();
            var originalCollector = new DummyCollector("testName", "metric");
            var fn = Substitute.For <Func <CollectorConfiguration, ICollector> >();

            registry.Add(originalCollector);
            var result = registry.GetOrAdd(originalCollector.Configuration, fn);

            Assert.Equal(originalCollector, result);
            fn.DidNotReceiveWithAnyArgs();
        }
Ejemplo n.º 2
0
        public void DoNotCallFactoryIfCollectorExists()
        {
            var registry          = new CollectorRegistry();
            var originalCollector = Substitute.For <ICollector>();

            originalCollector.MetricNames.Returns(new[] { "metric" });
            var fn  = Substitute.For <Func <CollectorConfiguration, ICollector> >();
            var cfg = new CollectorConfiguration("testName");

            registry.Add("testName", originalCollector);
            var result = registry.GetOrAdd(cfg, fn);

            Assert.Equal(originalCollector, result);
            fn.DidNotReceiveWithAnyArgs();
        }