Esempio n. 1
0
        public void EventSourceFakeInvalidPayloadTest()
        {
            using FakeMisbehavingSqlEventSource fakeSqlEventSource = new FakeMisbehavingSqlEventSource();

            var activityProcessor = new Mock <ActivityProcessor>();

            using var shutdownSignal = OpenTelemetrySdk.CreateTracerProvider(b =>
            {
                b.AddProcessorPipeline(c => c.AddProcessor(ap => activityProcessor.Object));
                b.AddSqlClientDependencyInstrumentation();
            });

            fakeSqlEventSource.WriteBeginExecuteEvent("arg1");

            fakeSqlEventSource.WriteEndExecuteEvent("arg1", "arg2", "arg3", "arg4");

            Assert.Equal(0, activityProcessor.Invocations.Count);
        }
        public void EventSourceFakeInvalidPayloadTest()
        {
            using FakeMisbehavingSqlEventSource fakeSqlEventSource = new FakeMisbehavingSqlEventSource();

            var activityProcessor = new Mock <ActivityProcessor>();

            using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
                                       .AddProcessor(activityProcessor.Object)
                                       .AddSqlClientInstrumentation()
                                       .Build();

            fakeSqlEventSource.WriteBeginExecuteEvent("arg1");

            fakeSqlEventSource.WriteEndExecuteEvent("arg1", "arg2", "arg3", "arg4");
            shutdownSignal.Dispose();

            Assert.Equal(2, activityProcessor.Invocations.Count); // OnShutdown/Dispose called.
        }