コード例 #1
0
ファイル: TracerFixture.cs プロジェクト: bnantz/NCS-V1-1
        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);
        }
コード例 #2
0
		public void ThreadsDoNotShareLogicalOperationsStack()
		{
			CrossThreadTestRunner t = new CrossThreadTestRunner(new ThreadStart(this.DoOtherThreadWork));
			t.Run();

			Assert.AreEqual(0, Trace.CorrelationManager.LogicalOperationStack.Count);
			Assert.IsFalse(testActivityId1 == Trace.CorrelationManager.ActivityId);
		}