-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add IUIComponentLogger dependency to UIComponent
- Loading branch information
Showing
10 changed files
with
151 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using NUnit.Framework; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
|
||
namespace UIComponents.Tests | ||
{ | ||
[TestFixture] | ||
public class UIComponentDebugLoggerTests | ||
{ | ||
private class TestComponent : UIComponent {} | ||
|
||
private TestComponent _testComponent; | ||
|
||
private UIComponentDebugLogger _logger; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_testComponent = new TestComponent(); | ||
_logger = new UIComponentDebugLogger(); | ||
} | ||
|
||
[Test] | ||
public void Log_Uses_Debug_Log() | ||
{ | ||
_logger.Log("Hello world", _testComponent); | ||
|
||
LogAssert.Expect(LogType.Log, "[TestComponent] Hello world"); | ||
} | ||
|
||
[Test] | ||
public void LogWarning_Uses_Debug_LogWarning() | ||
{ | ||
_logger.LogWarning("Hello warning", _testComponent); | ||
|
||
LogAssert.Expect(LogType.Warning, "[TestComponent] Hello warning"); | ||
} | ||
|
||
[Test] | ||
public void LogError_Uses_Debug_LogError() | ||
{ | ||
_logger.LogError("Error message", _testComponent); | ||
|
||
LogAssert.Expect(LogType.Error, "[TestComponent] Error message"); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Assets/UIComponents.Tests/UIComponentDebugLoggerTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 @@ | ||
namespace UIComponents | ||
{ | ||
public interface IUIComponentLogger | ||
{ | ||
void Log(string message, UIComponent component); | ||
|
||
void LogWarning(string message, UIComponent component); | ||
|
||
void LogError(string message, UIComponent component); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using UnityEngine; | ||
|
||
namespace UIComponents | ||
{ | ||
public class UIComponentDebugLogger : IUIComponentLogger | ||
{ | ||
public void Log(string message, UIComponent component) | ||
{ | ||
Debug.LogFormat("[{0}] {1}", component.GetTypeName(), message); | ||
} | ||
|
||
public void LogWarning(string message, UIComponent component) | ||
{ | ||
Debug.LogWarningFormat("[{0}] {1}", component.GetTypeName(), message); | ||
} | ||
|
||
public void LogError(string message, UIComponent component) | ||
{ | ||
Debug.LogErrorFormat("[{0}] {1}", component.GetTypeName(), message); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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