|
1 |
| -using NSubstitute; |
| 1 | +using NSubstitute; |
2 | 2 | using NUnit.Framework;
|
3 | 3 | using UnityEngine;
|
4 | 4 |
|
@@ -43,8 +43,59 @@ public void LogDebugFull()
|
43 | 43 |
|
44 | 44 | ILogHandler mockHandler = Substitute.For<ILogHandler>();
|
45 | 45 | logger.logHandler = mockHandler;
|
46 |
| - logger.Log("This message be logged"); |
47 |
| - mockHandler.Received().LogFormat(LogType.Log, null, "{0}", "This message be logged"); |
| 46 | + const string msg = "This message be logged"; |
| 47 | + logger.Log(msg); |
| 48 | + mockHandler.Received().LogFormat(LogType.Log, null, "{0}", msg); |
| 49 | + } |
| 50 | + |
| 51 | + [Test] |
| 52 | + public void LogWarningIgnore() |
| 53 | + { |
| 54 | + ILogger logger = LogFactory.GetLogger<LogFactoryTests>(); |
| 55 | + logger.filterLogType = LogType.Error; |
| 56 | + |
| 57 | + ILogHandler mockHandler = Substitute.For<ILogHandler>(); |
| 58 | + logger.logHandler = mockHandler; |
| 59 | + logger.LogWarning("This message should not be logged"); |
| 60 | + mockHandler.DidNotReceiveWithAnyArgs().LogFormat(default, null, null); |
| 61 | + } |
| 62 | + |
| 63 | + [Test] |
| 64 | + public void LogWarningFull() |
| 65 | + { |
| 66 | + ILogger logger = LogFactory.GetLogger<LogFactoryTests>(); |
| 67 | + logger.filterLogType = LogType.Warning; |
| 68 | + |
| 69 | + ILogHandler mockHandler = Substitute.For<ILogHandler>(); |
| 70 | + logger.logHandler = mockHandler; |
| 71 | + const string msg = "This message be logged"; |
| 72 | + logger.LogWarning(msg); |
| 73 | + mockHandler.Received().LogFormat(LogType.Warning, null, "{0}", msg); |
| 74 | + } |
| 75 | + |
| 76 | + [Test] |
| 77 | + public void LogErrorIgnore() |
| 78 | + { |
| 79 | + ILogger logger = LogFactory.GetLogger<LogFactoryTests>(); |
| 80 | + logger.filterLogType = LogType.Exception; |
| 81 | + |
| 82 | + ILogHandler mockHandler = Substitute.For<ILogHandler>(); |
| 83 | + logger.logHandler = mockHandler; |
| 84 | + logger.LogError("This message should not be logged"); |
| 85 | + mockHandler.DidNotReceiveWithAnyArgs().LogFormat(default, null, null); |
| 86 | + } |
| 87 | + |
| 88 | + [Test] |
| 89 | + public void LogErrorFull() |
| 90 | + { |
| 91 | + ILogger logger = LogFactory.GetLogger<LogFactoryTests>(); |
| 92 | + logger.filterLogType = LogType.Error; |
| 93 | + |
| 94 | + ILogHandler mockHandler = Substitute.For<ILogHandler>(); |
| 95 | + logger.logHandler = mockHandler; |
| 96 | + const string msg = "This message be logged"; |
| 97 | + logger.LogError(msg); |
| 98 | + mockHandler.Received().LogFormat(LogType.Error, null, "{0}", msg); |
48 | 99 | }
|
49 | 100 | }
|
50 | 101 | }
|
0 commit comments