public void ConstructorProducesValidLogMessage() { using (new Tracer(Context, testCategory1, testActivityId1)) { } Assert.AreEqual(2, MockLogSink.Count); AssertLogEntryIsValid(MockLogSink.GetEntry(0), Tracer.startTitle, testCategory1, testActivityId1, true); AssertLogEntryIsValid(MockLogSink.GetEntry(1), Tracer.endTitle, testCategory1, testActivityId1, false); }
public void LogMessageContainsProperMethodName() { using (Tracer tracer = new Tracer(Context, Tracer.defaultCategory, null)) { Assert.IsNotNull(tracer); } Assert.AreEqual(2, MockLogSink.Count); AssertStringContainsString(MockLogSink.GetEntry(0).Message, MethodInfo.GetCurrentMethod().Name); AssertStringContainsString(MockLogSink.GetEntry(1).Message, MethodInfo.GetCurrentMethod().Name); }
public void NestedConstructorProducesFourCorrectLogMessages() { using (new Tracer(Context, testCategory1, null)) { string activityId = Tracer.CurrentActivityId; using (new Tracer(Context, testCategory1, null)) { Assert.AreEqual(activityId, Tracer.CurrentActivityId); } } Assert.AreEqual(4, MockLogSink.Count); AssertLogEntryIsValid(MockLogSink.GetEntry(0), Tracer.startTitle, testCategory1, null, true); AssertLogEntryIsValid(MockLogSink.GetEntry(1), Tracer.startTitle, testCategory1, null, true); AssertLogEntryIsValid(MockLogSink.GetEntry(2), Tracer.endTitle, testCategory1, null, false); AssertLogEntryIsValid(MockLogSink.GetEntry(3), Tracer.endTitle, testCategory1, null, false); }
public void ActivityIdsAreUniqueOnEachThread() { // This will put two events into the sink using testCategory2 and testActivityId2 using (new Tracer(Context, testCategory2, testActivityId2)) { // This will put two events into the sink using testCategory1 and testActivityId1 CrossThreadTestRunner t = new CrossThreadTestRunner(new ThreadStart(this.DoOtherThreadWork)); t.Run(); // Confirm that the Tracer on this thread has the expected activityID Assert.AreEqual(testActivityId2, Tracer.CurrentActivityId); } Assert.AreEqual(null, Tracer.CurrentActivityId); Assert.AreEqual(4, MockLogSink.Count); AssertLogEntryIsValid(MockLogSink.GetEntry(0), Tracer.startTitle, testCategory2, testActivityId2, true); AssertLogEntryIsValid(MockLogSink.GetEntry(1), Tracer.startTitle, testCategory1, testActivityId1, true); AssertLogEntryIsValid(MockLogSink.GetEntry(2), Tracer.endTitle, testCategory1, testActivityId1, false); AssertLogEntryIsValid(MockLogSink.GetEntry(3), Tracer.endTitle, testCategory2, testActivityId2, false); }