public void Fail() { var listener = new TestDefaultTraceListener(); listener.Fail("FAIL"); Assert.Contains("FAIL", listener.Output); }
public void TraceEvent() { var listener = new TestDefaultTraceListener(); listener.TraceEvent(new TraceEventCache(), "Test", TraceEventType.Critical, 1); Assert.Contains("Test", listener.Output); }
public void Fail_WithoutWriteLineOverride() { var listener = new TestDefaultTraceListener(); listener.ShouldOverrideWriteLine = false; listener.Fail("FAIL"); Assert.False(listener.Output.Contains("FAIL")); }
public void Fail_LogFileDirectoryNotFound() { // Exception should be handled by DefaultTraceListener.WriteLine so no need to assert. var listener = new TestDefaultTraceListener(); listener.LogFileName = $"{Guid.NewGuid().ToString("N")}\\LogFile.txt"; listener.ShouldOverrideWriteLine = false; listener.Fail("FAIL"); }
public void EntryAssemblyName_Default_IncludedInTrace() { RemoteExecutor.Invoke(() => { var listener = new TestDefaultTraceListener(); Trace.Listeners.Add(listener); Trace.TraceError("hello world"); Assert.Equal(Assembly.GetEntryAssembly()?.GetName().Name + " Error: 0 : hello world", listener.Output.Trim()); }).Dispose(); }
public void Fail_WithLogFile() { var listener = new TestDefaultTraceListener(); string pathToLogFile = GetTestFilePath(); listener.LogFileName = pathToLogFile; listener.ShouldOverrideWriteLine = false; listener.Fail("FAIL"); Assert.True(File.Exists(pathToLogFile)); Assert.Contains("FAIL", File.ReadAllText(pathToLogFile)); }
public void EntryAssemblyName_Null_NotIncludedInTrace() { RemoteExecutor.Invoke(() => { MakeAssemblyGetEntryAssemblyReturnNull(); var listener = new TestDefaultTraceListener(); Trace.Listeners.Add(listener); Trace.TraceError("hello world"); Assert.Equal("Error: 0 : hello world", listener.Output.Trim()); }).Dispose(); }