Ejemplo n.º 1
0
        public void AttributeDelimiter_IgnoredAfterDelimiterRead_Test(string delimiter, TraceFilter filter, TraceEventCache eventCache, string source, TraceEventType eventType, int id, object[] data)
        {
            string newDelimiter = "||";

            using (var target = GetListener())
            {
                target.Filter             = filter;
                target.TraceOutputOptions = TraceOptions.ProcessId | TraceOptions.ThreadId | TraceOptions.DateTime | TraceOptions.Timestamp | TraceOptions.LogicalOperationStack | TraceOptions.Callstack;

                // Getting target.Delimiter here should initialize the delimiter
                // so that future delimiter attributes aren't used.
                Assert.Equal(CommonUtilities.DefaultDelimiter, target.Delimiter);

                target.Attributes.Add("delimiter", newDelimiter);
                target.TraceData(eventCache, source, eventType, id, data);

                // Expclitly setting the delimiter property will update it, though.
                target.Delimiter = delimiter;
                Assert.Equal(delimiter, target.Delimiter);
            }

            string expected = CommonUtilities.ExpectedTraceDataOutput(CommonUtilities.DefaultDelimiter, filter, eventCache, source, eventType, id, data);

            Assert.Equal(expected, File.Exists(_fileName) ? File.ReadAllText(_fileName) : "");
        }
        public void TraceData_Object_Test(TraceFilter filter, TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
        {
            using (var target = GetListener())
            {
                target.Filter             = filter;
                target.TraceOutputOptions = TraceOptions.ProcessId | TraceOptions.ThreadId | TraceOptions.DateTime | TraceOptions.Timestamp | TraceOptions.LogicalOperationStack;
                target.TraceData(eventCache, source, eventType, id, data);
            }

            string expected = CommonUtilities.ExpectedTraceDataOutput(filter, eventCache, source, eventType, id, data);

            Assert.Equal(expected, File.Exists(_fileName) ? File.ReadAllText(_fileName) : "");
        }
        public void TraceData_Object_Test(TraceFilter filter, TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
        {
            using (var target = new DelimitedListTraceListener(_stream))
            {
                target.Filter             = filter;
                target.TraceOutputOptions = TraceOptions.ProcessId | TraceOptions.ThreadId | TraceOptions.DateTime | TraceOptions.Timestamp;
                target.TraceData(eventCache, source, eventType, id, data);
            }

            string expected = CommonUtilities.ExpectedTraceDataOutput(filter, eventCache, source, eventType, id, data);

            Assert.Equal(expected, File.ReadAllText(_fileName));
        }
Ejemplo n.º 4
0
        public void AttributeDelimiter_ChangesDelimiter_Test(string delimiter, TraceFilter filter, TraceEventCache eventCache, string source, TraceEventType eventType, int id, object[] data)
        {
            string newDelimiter = "||";

            using (var target = GetListener())
            {
                target.Filter             = filter;
                target.TraceOutputOptions = TraceOptions.ProcessId | TraceOptions.ThreadId | TraceOptions.DateTime | TraceOptions.Timestamp | TraceOptions.LogicalOperationStack | TraceOptions.Callstack;
                target.Attributes.Add("delimiter", newDelimiter);
                target.TraceData(eventCache, source, eventType, id, data);
                Assert.Equal(newDelimiter, target.Delimiter);

                target.Delimiter = delimiter;
                Assert.Equal(delimiter, target.Delimiter);
            }

            string expected = CommonUtilities.ExpectedTraceDataOutput(newDelimiter, filter, eventCache, source, eventType, id, data);

            Assert.Equal(expected, File.Exists(_fileName) ? File.ReadAllText(_fileName) : "");
        }