示例#1
0
        public void WriteError_ShouldWriteCorrectSourceToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Error))
            {
                CompositionTraceSource.WriteError(0, "format", "arguments");

                Assert.AreEqual("System.ComponentModel.Composition", context.LastTraceEvent.Source);
            }
        }
示例#2
0
        public void WriteError_ShouldWriteTraceEventTypeWarningToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Error))
            {
                CompositionTraceSource.WriteError(0, "format", "arguments");

                Assert.AreEqual(TraceEventType.Error, context.LastTraceEvent.EventType);
            }
        }
示例#3
0
        internal static void MemberMarkedWithMultipleImportAndImportMany(ReflectionItem item)
        {
            Assumes.NotNull(item);

            if (CompositionTraceSource.CanWriteError)
            {
                CompositionTraceSource.WriteError(CompositionTraceId.Discovery_MemberMarkedWithMultipleImportAndImportMany,
                                                  Strings.CompositionTrace_Discovery_MemberMarkedWithMultipleImportAndImportMany,
                                                  item.GetDisplayName());
            }
        }
示例#4
0
        public void WriteError_ValueAsArgs_ShouldWriteArgsToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Error))
            {
                var expectations = Expectations.GetObjectArraysWithNull();
                foreach (var e in expectations)
                {
                    CompositionTraceSource.WriteError(0, "format", e);

                    Assert.AreSame(e, context.LastTraceEvent.Args);
                }
            }
        }
示例#5
0
        public void WriteError_ValueAsFormat_ShouldWriteFormatToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Error))
            {
                var expectations = Expectations.GetExceptionMessages();
                foreach (var e in expectations)
                {
                    CompositionTraceSource.WriteError(0, e, "arguments");

                    Assert.AreEqual(e, context.LastTraceEvent.Format);
                }
            }
        }
示例#6
0
        public void WriteError_ValueAsTraceId_ShouldWriteIdToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Error))
            {
                var expectations = Expectations.GetEnumValues <CompositionTraceId>();
                foreach (var e in expectations)
                {
                    CompositionTraceSource.WriteError(e, "format", "arguments");

                    Assert.AreEqual(e, (CompositionTraceId)context.LastTraceEvent.Id);
                }
            }
        }
示例#7
0
        public void WriteError_WhenSwitchLevelGreaterThanOrEqualToError_ShouldWriteToTraceListener()
        {
            var levels = GetSourceLevelsGreaterThanOrEqualTo(SourceLevels.Error);

            foreach (var level in levels)
            {
                using (TraceContext context = new TraceContext(level))
                {
                    CompositionTraceSource.WriteError(0, "format", "arguments");

                    Assert.IsNotNull(context.LastTraceEvent);
                }
            }
        }
示例#8
0
        public void WriteError_WhenSwitchLevelLessThanError_ShouldThrowInternalError()
        {
            var levels = GetSourceLevelsLessThan(SourceLevels.Error);

            foreach (var level in levels)
            {
                using (TraceContext context = new TraceContext(level))
                {
                    ThrowsInternalError(() =>
                    {
                        CompositionTraceSource.WriteError(0, "format", "arguments");
                    });
                }
            }
        }