public void WriteError_ShouldWriteCorrectSourceToTraceListener() { using (var context = new TraceContext(SourceLevels.Error)) { CompositionTraceSource.WriteError(0, "format", "arguments"); Assert.AreEqual("System.ComponentModel.Composition", context.LastTraceEvent.Source); } }
public void WriteError_ShouldWriteTraceEventTypeWarningToTraceListener() { using (var context = new TraceContext(SourceLevels.Error)) { CompositionTraceSource.WriteError(0, "format", "arguments"); Assert.AreEqual(TraceEventType.Error, context.LastTraceEvent.EventType); } }
internal static void MemberMarkedWithMultipleImportAndImportMany(ReflectionItem item) { Assumes.NotNull(item); if (CompositionTraceSource.CanWriteError) { CompositionTraceSource.WriteError(CompositionTraceId.Discovery_MemberMarkedWithMultipleImportAndImportMany, Strings.CompositionTrace_Discovery_MemberMarkedWithMultipleImportAndImportMany, item.GetDisplayName()); } }
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); } } }
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); } } }
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); } } }
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); } } }
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"); }); } } }