public void TraceInputShouldOverrideTraceSingleData()
        {
            IConfiguration configuration = (new ConfigurationBuilder()).AddInMemoryCollection(new Dictionary <string, string>()
            {
                ["type"]       = "Trace",
                ["traceLevel"] = "All"
            }).Build();
            var healthReporterMock = new Mock <IHealthReporter>();
            var subject            = new Mock <IObserver <EventData> >();

            using (TraceInput target = new TraceInput(configuration, healthReporterMock.Object))
                using (target.Subscribe(subject.Object))
                {
                    string message = "Message";
                    int    id      = (new Random()).Next();
                    target.TraceData(null, null, TraceEventType.Warning, id, message);
                    subject.Verify(s =>
                                   s.OnNext(It.Is <EventData>(data => data.Payload["Message"].Equals(message) && data.Payload["EventId"].Equals(id))),
                                   Times.Exactly(1));
                }
        }
Beispiel #2
0
        public void TraceInputTracksActivityID()
        {
            IConfiguration configuration = (new ConfigurationBuilder()).AddInMemoryCollection(new Dictionary <string, string>()
            {
                ["type"]       = "Trace",
                ["traceLevel"] = "All"
            }).Build();
            var healthReporterMock = new Mock <IHealthReporter>();
            var subject            = new Mock <IObserver <EventData> >();

            using (TraceInput target = new TraceInput(configuration, healthReporterMock.Object))
                using (target.Subscribe(subject.Object))
                {
                    string message    = GetRandomString();
                    int    id         = (new Random()).Next();
                    Guid   activityID = Guid.NewGuid();
                    Trace.CorrelationManager.ActivityId = activityID;

                    target.TraceData(null, null, TraceEventType.Information, id, message);
                    subject.Verify(s =>
                                   s.OnNext(It.Is <EventData>(data => data.Payload["EventId"].Equals(id) && data.Payload["ActivityID"].Equals(activityID) && data.Payload["Message"].Equals(message))),
                                   Times.Exactly(1));
                }
        }