예제 #1
0
        public void TestLogger()
        {
            LogAssert.ignoreFailingMessages = true;

            Logger.Log("1");
            Logger.LogWarning("2");
            Logger.LogError("3");

            Logger.OnWarning += (message) =>
            {
                Logger.Log($"Dispatched warning: {message}");
            };
            Logger.OnError += (message) =>
            {
                Logger.Log($"Dispatched error: {message}");
            };

            Logger.Log("a");
            Logger.LogWarning("b");
            Logger.LogError("c");
        }
예제 #2
0
        public void TestDummyLogger()
        {
            LogAssert.ignoreFailingMessages = true;

            var dummy = new DummyLogService();

            Logger.Register(dummy);

            Assert.IsFalse(dummy.LoggedNormal);
            Assert.IsFalse(dummy.LoggedWarning);
            Assert.IsFalse(dummy.LoggedError);

            Logger.Log("AA");
            Logger.LogWarning("BB");
            try
            {
                Logger.LogError("CC");
            }
            catch (Exception) {}

            Assert.IsTrue(dummy.LoggedNormal);
            Assert.IsTrue(dummy.LoggedWarning);
            Assert.IsTrue(dummy.LoggedError);
        }