forked from sarbian/ModuleManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnityLoggerTest.cs
More file actions
65 lines (53 loc) · 1.62 KB
/
Copy pathUnityLoggerTest.cs
File metadata and controls
65 lines (53 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using Xunit;
using NSubstitute;
using UnityEngine;
using ModuleManager.Logging;
namespace ModuleManagerTests.Logging
{
public class UnityLoggerTest
{
private ILogger innerLogger;
private UnityLogger logger;
public UnityLoggerTest()
{
innerLogger = Substitute.For<ILogger>();
logger = new UnityLogger(innerLogger);
}
[Fact]
public void TestConstructor__LoggerNull()
{
ArgumentNullException e = Assert.Throws<ArgumentNullException>(delegate
{
new UnityLogger(null);
});
Assert.Equal("logger", e.ParamName);
}
[Fact]
public void TestLog__Info()
{
logger.Log(LogType.Log, "well hi there");
innerLogger.Received().Log(LogType.Log, "well hi there");
}
[Fact]
public void TestLog__Warning()
{
logger.Log(LogType.Warning, "I'm warning you");
innerLogger.Received().Log(LogType.Warning, "I'm warning you");
}
[Fact]
public void TestLog__Error()
{
logger.Log(LogType.Error, "You have made a grave mistake");
innerLogger.Received().Log(LogType.Error, "You have made a grave mistake");
}
[Fact]
public void TestException()
{
Exception e = new Exception();
logger.Exception("An exception was thrown", e);
innerLogger.Received().Log(LogType.Error, "An exception was thrown");
innerLogger.Received().LogException(e);
}
}
}