示例#1
0
        public void FormatPrincipalNameTest()
        {
            string    categoryName = "test";
            LogLevel  logLevel     = LogLevel.Warning;
            EventId   eventId      = new EventId(5, "five");
            Exception?ex           = null;
            string    message      = "fnord";

            object[]? scopes = null;
            string template = "{Id}.{PrincipalName}";

            var    logTemplate = new LogTemplate(template);
            string actual;

            using (var scope = new UserResetScope("testuser"))
            {
                actual = logTemplate.Bind(categoryName, logLevel, eventId, message, ex, scopes);
            }

            string expected = "5.testuser";

            Assert.AreEqual(expected, actual);
        }
        public void FormatPrincipalNameTest()
        {
            var             traceFormatter    = new TraceFormatter();
            TraceListener   listener          = null;
            TraceEventCache eventCache        = null;
            string          source            = "test";
            TraceEventType  eventType         = TraceEventType.Warning;
            int             id                = 5;
            string          message           = "fnord";
            Guid?           relatedActivityId = null;

            object[] data     = null;
            string   template = "{Id}.{PrincipalName}";
            string   expected = "5.testuser";
            string   actual   = null;

            using (var scope = new UserResetScope("testuser"))
            {
                actual = traceFormatter.Format(template, listener, eventCache, source, eventType, id,
                                               message, relatedActivityId, data);
            }

            Assert.AreEqual(expected, actual);
        }