Skip to content

Commit

Permalink
feat(UIComponent): add GetTypeName method
Browse files Browse the repository at this point in the history
  • Loading branch information
jonisavo committed Jun 18, 2022
1 parent b4cccca commit b8a089c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Assets/UIComponents.Tests/UIComponentTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using NUnit.Framework;

namespace UIComponents.Tests
{
[TestFixture]
public class UIComponentTests
{
[TestFixture]
public class GetTypeName
{
private class TestComponent : UIComponent {}

[Test]
public void ShouldReturnTypeName()
{
var component = new TestComponent();
Assert.That(nameof(TestComponent), Is.EqualTo(component.GetTypeName()));
}
}
}
}
3 changes: 3 additions & 0 deletions Assets/UIComponents.Tests/UIComponentTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/UIComponents/Core/UIComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ public IEnumerable<string> GetAssetPaths()
for (var i = 0; i < assetPathCount; i++)
yield return assetPathAttributes[i].Path;
}

/// <summary>
/// Returns the component's type's name.
/// </summary>
/// <returns>Type name</returns>
public string GetTypeName()
{
return _componentType.Name;
}

/// <summary>
/// Returns a dependency. Throws a <see cref="MissingProviderException"/>
Expand Down

0 comments on commit b8a089c

Please sign in to comment.