ConsoleLoggerTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Tests.Core ConsoleLoggerTests

Namespace: DeltaEngine.Tests.Core
Assembly: DeltaEngine.Tests (in DeltaEngine.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class ConsoleLoggerTests

The ConsoleLoggerTests type exposes the following members.

Constructors

  NameDescription
Public methodConsoleLoggerTests
Initializes a new instance of the ConsoleLoggerTests class
Top
Methods

  NameDescription
Public methodLogError
Public methodLogWarning
Public methodRedirectConsoleOutput
Public methodRegisteringLoggerInTheSameThreadTwiceIsNotAllowed
Public methodRestoreConsoleOutput
Public methodWriteInfo
Public methodWriteSkipMessages
Top
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