Inheritance Hierarchy
DeltaEngine.Logging.Tests NetworkLoggerTests
Namespace: DeltaEngine.Logging.Tests
Assembly: DeltaEngine.Logging.Tests (in DeltaEngine.Logging.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The NetworkLoggerTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
NetworkLoggerTests | Initializes a new instance of the NetworkLoggerTests class |
Methods
Name | Description | |
---|---|---|
LogError | ||
LogInfoMessage | ||
LogWarning | ||
NotLoggingIfSettingFalse | ||
ShutdownLogServer | ||
StartLogServer |
Examples
[TestFixtureSetUp] public void StartLogServer() { server = new LocalhostLogServer(new TcpServer()); server.Start(); new MockSettings(); var ready = false; var connection = new OnlineServiceConnection(); connection.DataReceived += o => ready = true; connection.Connect("localhost", LocalhostLogServer.Port); connection.Send(new LoginRequest("", "DeltaEngine.Logging.Tests")); logger = new NetworkLogger(connection); for (int timeoutMs = 1000; timeoutMs > 0 && !ready; timeoutMs -= 10) Thread.Sleep(10); Assert.IsTrue(ready); }
[TestFixtureTearDown] public void ShutdownLogServer() { logger.Dispose(); server.Dispose(); }
[Test] public void LogInfoMessage() { logger.Write(Logger.MessageType.Info, "Hello"); ExpectThatServerHasReceivedMessage("Hello"); }
[Test] public void LogWarning() { logger.Write(Logger.MessageType.Warning, "Ohoh"); ExpectThatServerHasReceivedMessage("Ohoh"); logger.Write(Logger.MessageType.Warning, new NullReferenceException().ToString()); ExpectThatServerLastMessageContains("NullReferenceException"); }
[Test] public void LogError() { logger.Write(Logger.MessageType.Error, new ArgumentException().ToString()); Thread.Sleep(100); ExpectThatServerLastMessageContains("ArgumentException"); }
[Test] public void NotLoggingIfSettingFalse() { var logRecieved = false; Settings.Current.UseOnlineLogging = false; server.Server.ClientDataReceived += (client, o) => logRecieved = true; logger.Write(Logger.MessageType.Error, new ArgumentException().ToString()); Assert.IsFalse(logRecieved); Settings.Current.UseOnlineLogging = true; }
See Also