Inheritance Hierarchy
DeltaEngine.Tests.Core ConsoleLoggerTests
Namespace: DeltaEngine.Tests.Core
Assembly: DeltaEngine.Tests (in DeltaEngine.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The ConsoleLoggerTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
ConsoleLoggerTests | Initializes a new instance of the ConsoleLoggerTests class |
Methods
Name | Description | |
---|---|---|
LogError | ||
LogWarning | ||
RedirectConsoleOutput | ||
RegisteringLoggerInTheSameThreadTwiceIsNotAllowed | ||
RestoreConsoleOutput | ||
WriteInfo | ||
WriteSkipMessages |
Examples
[Test] public void WriteInfo() { using (var logger = new ConsoleLogger()) { Assert.AreEqual("", console.ToString()); logger.Write(Logger.MessageType.Info, "Hello"); Assert.IsTrue(console.ToString().Contains("Hello"), console.ToString()); } }
[Test] public void LogWarning() { using (var logger = new ConsoleLogger()) { Assert.AreEqual("", console.ToString()); logger.Write(Logger.MessageType.Warning, "Ohoh"); Assert.IsTrue(console.ToString().Contains("Warning: Ohoh"), console.ToString()); logger.Write(Logger.MessageType.Warning, new NullReferenceException().ToString()); Assert.IsTrue(console.ToString().Contains("NullReferenceException"), console.ToString()); } }
[Test] public void LogError() { using (var logger = new ConsoleLogger()) { Assert.AreEqual("", console.ToString()); logger.Write(Logger.MessageType.Error, new NotSupportedException().ToString()); Assert.IsTrue(console.ToString().Contains("NotSupportedException"), console.ToString()); } }
[Test] public void RegisteringLoggerInTheSameThreadTwiceIsNotAllowed() { using (var logger = new ConsoleLogger()) { logger.DoNotSkipMessagesIfTooManyAreWrittenEachSecond = true; Logger.Info("La la la"); using (new ConsoleLogger()) { } }
[Test] public void WriteSkipMessages() { using (var logger = new ConsoleLogger()) { Assert.AreEqual("", console.ToString()); logger.Write(Logger.MessageType.Info, "FirstMessage"); logger.DoNotSkipMessagesIfTooManyAreWrittenEachSecond = false; Assert.IsFalse(logger.DoNotSkipMessagesIfTooManyAreWrittenEachSecond); Time.Total = -1; logger.Write(Logger.MessageType.Info, "Hello"); Assert.IsTrue(console.ToString().Contains("FirstMessage"), console.ToString()); } }
See Also