| | 1 | | using AvatarShape_Tests; |
| | 2 | | using DCL; |
| | 3 | | using DCL.Helpers; |
| | 4 | | using NUnit.Framework; |
| | 5 | | using System.Collections; |
| | 6 | | using UnityEngine; |
| | 7 | | using UnityEngine.TestTools; |
| | 8 | |
|
| | 9 | | namespace Tests |
| | 10 | | { |
| | 11 | | public class AvatarVisibilityShould |
| | 12 | | { |
| | 13 | |
|
| | 14 | | private GameObject parentGameObject; |
| | 15 | | private AvatarVisibility visibility; |
| | 16 | | private GameObject toggledGameObject; |
| | 17 | |
|
| | 18 | | [SetUp] |
| | 19 | | protected void SetUp() |
| | 20 | | { |
| | 21 | | // Prepare both game objects |
| 2 | 22 | | parentGameObject = new GameObject(); |
| 2 | 23 | | visibility = parentGameObject.AddComponent<AvatarVisibility>(); |
| 2 | 24 | | toggledGameObject = new GameObject(); |
| 2 | 25 | | toggledGameObject.transform.parent = parentGameObject.transform; |
| 2 | 26 | | visibility.gameObjectsToToggle = new[] { toggledGameObject }; |
| 2 | 27 | | } |
| | 28 | |
|
| | 29 | | [TearDown] |
| 4 | 30 | | protected void TearDown() { Object.Destroy(parentGameObject); } |
| | 31 | |
|
| | 32 | | [Test] |
| | 33 | | public void DeactivateGameObjectsWhenVisibilityIsSetToFalse() |
| | 34 | | { |
| | 35 | |
|
| 1 | 36 | | Assert.IsTrue(toggledGameObject.activeSelf); |
| | 37 | |
|
| 1 | 38 | | visibility.SetVisibility("Caller1", true); |
| 1 | 39 | | visibility.SetVisibility("Caller2", false); |
| 1 | 40 | | Assert.IsFalse(toggledGameObject.activeSelf); |
| 1 | 41 | | } |
| | 42 | |
|
| | 43 | | [Test] |
| | 44 | | public void ReactivateGameObjectsWhenVisibilityIsSetToTrue() |
| | 45 | | { |
| 1 | 46 | | visibility.SetVisibility("Caller1", false); |
| 1 | 47 | | Assert.IsFalse(toggledGameObject.activeSelf); |
| | 48 | |
|
| 1 | 49 | | visibility.SetVisibility("Caller1", true); |
| 1 | 50 | | Assert.True(toggledGameObject.activeSelf); |
| 1 | 51 | | } |
| | 52 | | } |
| | 53 | | } |