-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoggerTest.cs
More file actions
32 lines (26 loc) · 741 Bytes
/
LoggerTest.cs
File metadata and controls
32 lines (26 loc) · 741 Bytes
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
namespace Logger.UnitTest;
public class LoggerTest
{
[Fact]
public void GetInstance_ReturnsSameInstance()
{
var instance1 = ConsoleLogger.GetInstance();
var instance2 = ConsoleLogger.GetInstance();
Assert.Same(instance1, instance2);
}
[Fact]
public void Log_WritesMessageToConsole()
{
var logger = ConsoleLogger.GetInstance();
string message = "test";
string expected = $"Log Message: {message}";
string actual;
using (var writer = new StringWriter())
{
Console.SetOut(writer);
logger.Log(message);
actual = writer.ToString().Trim();
}
Assert.Equal(expected, actual);
}
}