Skip to content

Commit b343867

Browse files
committed
Added UnitTests for WorldAnchor.
1 parent c13595f commit b343867

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using UnityEngine;
3+
4+
namespace HoloToolkit.Unity.Tests.Extensions
5+
{
6+
/// <summary>
7+
/// This class extends the world anchor manager with methods constrained to test logic.
8+
/// </summary>
9+
public static class WorldAnchorManagerExtensions
10+
{
11+
internal static string GenerateAnchorName(this WorldAnchorManager anchorManager, GameObject gameObjectToAnchor, string anchorName = null)
12+
{
13+
return string.IsNullOrEmpty(anchorName) ? gameObjectToAnchor.name : anchorName;
14+
}
15+
}
16+
}

Assets/HoloToolkit-UnitTests/Editor/Utilities/Extensions/WorldAnchorManagerExtensions.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using UnityEngine;
2+
using NUnit.Framework;
3+
using HoloToolkit.Unity.Tests.Extensions;
4+
5+
namespace HoloToolkit.Unity.Tests
6+
{
7+
public class WorldAnchorManagerTests
8+
{
9+
[Test]
10+
public void TestGenerateAnchorNameFromGameObject()
11+
{
12+
const string expected = "AnchorName";
13+
var gameObject = new GameObject(expected);
14+
var result = WorldAnchorManager.Instance.GenerateAnchorName(gameObject);
15+
Assert.That(result, Is.EqualTo(expected));
16+
}
17+
18+
[Test]
19+
public void TestGenerateAnchorNameFromParameter()
20+
{
21+
const string expected = "AnchorName";
22+
var gameObject = new GameObject();
23+
var result = WorldAnchorManager.Instance.GenerateAnchorName(gameObject, expected);
24+
Assert.That(result, Is.EqualTo(expected));
25+
}
26+
}
27+
}

Assets/HoloToolkit-UnitTests/Editor/Utilities/WorldAnchorManagerTests.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)