-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn some semi-redundant methods into extensions
Keeps having to reimplement them for every IBasicLogger implementation
- Loading branch information
1 parent
94af6b8
commit 30fd490
Showing
11 changed files
with
104 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using UnityEngine; | ||
using ModuleManager.Logging; | ||
|
||
namespace ModuleManager.Extensions | ||
{ | ||
public static class IBasicLoggerExtensions | ||
{ | ||
public static void Info(this IBasicLogger logger, string message) => logger.Log(LogType.Log, message); | ||
public static void Warning(this IBasicLogger logger, string message) => logger.Log(LogType.Warning, message); | ||
public static void Error(this IBasicLogger logger, string message) => logger.Log(LogType.Error, message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
ModuleManagerTests/Extensions/IBasicLoggerExtensionsTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using Xunit; | ||
using NSubstitute; | ||
using UnityEngine; | ||
using ModuleManager.Logging; | ||
using ModuleManager.Extensions; | ||
|
||
namespace ModuleManagerTests.Extensions | ||
{ | ||
public class IBasicLoggerExtensionsTest | ||
{ | ||
private IBasicLogger logger; | ||
|
||
public IBasicLoggerExtensionsTest() | ||
{ | ||
logger = Substitute.For<IBasicLogger>(); | ||
} | ||
|
||
[Fact] | ||
public void TestInfo() | ||
{ | ||
logger.Info("well hi there"); | ||
logger.Received().Log(LogType.Log, "well hi there"); | ||
} | ||
|
||
[Fact] | ||
public void TestWarning() | ||
{ | ||
logger.Warning("I'm warning you"); | ||
logger.Received().Log(LogType.Warning, "I'm warning you"); | ||
} | ||
|
||
[Fact] | ||
public void TestError() | ||
{ | ||
logger.Error("You have made a grave mistake"); | ||
logger.Received().Log(LogType.Error, "You have made a grave mistake"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.