using LobbyRelaySample; using System; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; namespace Test { /// /// Tests of the LogHandler overriding debug logging. /// public class LoggerTest { /// Reset the console between tests. [SetUp] public void ResetScene() { Debug.ClearDeveloperConsole(); } /// /// Only display Log messages when set to Verbose. /// [Test] public void TestLog() { LogHandler.Get().mode = LogMode.Critical; Debug.Log("CritLog"); LogAssert.NoUnexpectedReceived(); // Ensure that we haven't received any unexpected logs. LogHandler.Get().mode = LogMode.Warnings; Debug.Log("WarningLog"); LogAssert.NoUnexpectedReceived(); LogHandler.Get().mode = LogMode.Verbose; Debug.Log("VerbLog"); LogAssert.Expect(LogType.Log, "VerbLog"); } /// /// Only display Warning messages when set to Verbose or Warnings. /// [Test] public void TestWarning() { LogHandler.Get().mode = LogMode.Critical; Debug.LogWarning("CritWarning"); LogAssert.NoUnexpectedReceived(); LogHandler.Get().mode = LogMode.Warnings; Debug.LogWarning("WarningWarning"); LogAssert.Expect(LogType.Warning, "WarningWarning"); LogHandler.Get().mode = LogMode.Verbose; Debug.LogWarning("VerbWarning"); LogAssert.Expect(LogType.Warning, "VerbWarning"); } /// /// Always display Error messages. /// [Test] public void TestError() { LogHandler.Get().mode = LogMode.Critical; Debug.LogError("CritError"); LogAssert.Expect(LogType.Error, "CritError"); LogHandler.Get().mode = LogMode.Warnings; Debug.LogError("WarningError"); LogAssert.Expect(LogType.Error, "WarningError"); LogHandler.Get().mode = LogMode.Verbose; Debug.LogError("VerbError"); LogAssert.Expect(LogType.Error, "VerbError"); } /// /// Always display Assert messages. /// [Test] public void TestAssert() { LogHandler.Get().mode = LogMode.Critical; Debug.LogAssertion(true); LogAssert.Expect(LogType.Assert, "True"); LogHandler.Get().mode = LogMode.Warnings; Debug.LogAssertion(true); LogAssert.Expect(LogType.Assert, "True"); LogHandler.Get().mode = LogMode.Verbose; Debug.LogAssertion(true); LogAssert.Expect(LogType.Assert, "True"); } /// /// Always display Exception messages. /// [Test] public void TestException() { LogHandler.Get().mode = LogMode.Critical; LogAssert.Expect(LogType.Exception, "Exception: CriticalException"); Debug.LogException(new Exception("CriticalException")); LogHandler.Get().mode = LogMode.Warnings; LogAssert.Expect(LogType.Exception, "Exception: WarningException"); Debug.LogException(new Exception("WarningException")); LogHandler.Get().mode = LogMode.Verbose; LogAssert.Expect(LogType.Exception, "Exception: VerboseException"); Debug.LogException(new Exception("VerboseException")); } } }