예제 #1
0
        public void ShouldOutputVerboseTrace()
        {
            // Arrange
            string testCategory = "Test";
            string expectedData = "From SayHello";
            string expectedTrace = string.Format("{0}: {1}", testCategory, expectedData);
            var listener = new TestTraceListener();
            var tracker = new TestTrackingParticipant();
            var profile = new TrackingProfile()
            {
                Name = "TestTrackingProfile",
                Queries = 
                {
                    new CustomTrackingQuery()
                    {
                        Name="Test",
                        ActivityName = "*"
                    }
                }
            };

            tracker.TrackingProfile = profile;

            Trace.Listeners.Add(listener);

            var target = new SayHello()
            {
                UserName = "******"
            };

            var workflow = new WorkflowInvoker(target);
            workflow.Extensions.Add(tracker);

            // Act
            workflow.Invoke();

            // Assert System.Diagnostics.Trace
            Assert.AreEqual(1, listener.Traces.Count);
            Assert.AreEqual(expectedTrace, listener.Traces[0]);

            // Assert Tracking Records
            Assert.AreEqual(1, tracker.Records.Count);
            var customRecord = tracker.Records[0] as CustomTrackingRecord;
            Assert.AreEqual(expectedData, customRecord.Data["Text"]);
            Assert.AreEqual(testCategory, customRecord.Data["Category"]);
        }
예제 #2
0
        public void ShouldOutputVerboseTrace()
        {
            var targetWorkflow = GetVerboseTraceWorkflow();
            var listener = new TestTraceListener();
            var tracker = new TestTrackingParticipant();
            var profile = new TrackingProfile()
            {
                Name = "TestTrackingProfile",
                Queries = 
                {
                    new CustomTrackingQuery()
                    {
                        Name=TestCategory,
                        ActivityName = "*"
                    }
                }
            };

            tracker.TrackingProfile = profile;

            Trace.Listeners.Add(listener);

            var workflow = new WorkflowInvoker(targetWorkflow);
            workflow.Extensions.Add(tracker);

            workflow.Invoke();

            // Assert System.Diagnostics.Trace
            Assert.AreEqual(1, listener.Traces.Count);
            Assert.AreEqual(TestOutput, listener.Traces[0]);

            // Assert Tracking Records
            Assert.AreEqual(1, tracker.Records.Count);
            var customRecord = tracker.Records[0] as CustomTrackingRecord;
            Assert.AreEqual(TestTrace, customRecord.Data["Text"]);
            Assert.AreEqual(TestCategory, customRecord.Data["Category"]);
        }