| | 1 | | using System.Collections; |
| | 2 | | using DCL.Components; |
| | 3 | | using DCL.Helpers; |
| | 4 | | using DCL.Models; |
| | 5 | | using NUnit.Framework; |
| | 6 | | using UnityEngine; |
| | 7 | | using UnityEngine.TestTools; |
| | 8 | |
|
| | 9 | | public class BoxShapeShould : IntegrationTestSuite_Legacy |
| | 10 | | { |
| | 11 | | [UnityTest] |
| | 12 | | public IEnumerator BeUpdatedCorrectly() |
| | 13 | | { |
| 1 | 14 | | string entityId = "3"; |
| 1 | 15 | | TestHelpers.InstantiateEntityWithShape(scene, entityId, DCL.Models.CLASS_ID.BOX_SHAPE, Vector3.zero); |
| | 16 | |
|
| 1 | 17 | | var meshName = scene.entities[entityId].gameObject.GetComponentInChildren<MeshFilter>().mesh.name; |
| 1 | 18 | | Assert.AreEqual("DCL Box Instance", meshName); |
| 1 | 19 | | yield break; |
| | 20 | | } |
| | 21 | |
|
| | 22 | | [UnityTest] |
| | 23 | | public IEnumerator UpdateUVsCorrectly() |
| | 24 | | { |
| 1 | 25 | | float[] uvs = new float[] |
| | 26 | | { |
| | 27 | | 0, 0.75f, 0.25f, 0.75f, 0.25f, 1, 0, 1, |
| | 28 | | 0, 0.75f, 0.25f, 0.75f, 0.25f, 1, 0, 1, |
| | 29 | | 0, 0.75f, 0.25f, 0.75f, 0.25f, 1, 0, 1, |
| | 30 | | 0, 0.75f, 0.25f, 0.75f, 0.25f, 1, 0, 1, |
| | 31 | | 0, 0.75f, 0.25f, 0.75f, 0.25f, 1, 0, 1, |
| | 32 | | 0, 0.75f, 0.25f, 0.75f, 0.25f, 1, 0, 1 |
| | 33 | | }; |
| | 34 | |
|
| | 35 | | IDCLEntity entity; |
| | 36 | |
|
| 1 | 37 | | BoxShape box = TestHelpers.InstantiateEntityWithShape<BoxShape, BoxShape.Model>( |
| | 38 | | scene, |
| | 39 | | DCL.Models.CLASS_ID.BOX_SHAPE, |
| | 40 | | Vector3.zero, |
| | 41 | | out entity, |
| | 42 | | new BoxShape.Model() |
| | 43 | | { |
| | 44 | | uvs = uvs |
| | 45 | | }); |
| | 46 | |
|
| 1 | 47 | | yield return box.routine; |
| | 48 | |
|
| 1 | 49 | | Assert.IsTrue(entity != null); |
| 1 | 50 | | Assert.IsTrue(box != null); |
| 1 | 51 | | Assert.IsTrue(box.currentMesh != null); |
| 1 | 52 | | CollectionAssert.AreEqual(Utils.FloatArrayToV2List(uvs), box.currentMesh.uv); |
| 1 | 53 | | } |
| | 54 | |
|
| | 55 | | [UnityTest] |
| | 56 | | public IEnumerator DefaultMissingValuesOnUpdate() |
| | 57 | | { |
| 1 | 58 | | var component = |
| | 59 | | TestHelpers.SharedComponentCreate<BoxShape, BoxShape.Model>(scene, CLASS_ID.BOX_SHAPE); |
| 1 | 60 | | yield return component.routine; |
| | 61 | |
|
| 1 | 62 | | Assert.IsFalse(component == null); |
| | 63 | |
|
| 1 | 64 | | yield return TestHelpers.TestSharedComponentDefaultsOnUpdate<BoxShape.Model, BoxShape>(scene, |
| | 65 | | CLASS_ID.BOX_SHAPE); |
| 1 | 66 | | } |
| | 67 | |
|
| | 68 | | [UnityTest] |
| | 69 | | public IEnumerator BeReplacedCorrectlyWhenAnotherComponentIsAttached() |
| | 70 | | { |
| 1 | 71 | | yield return TestHelpers.TestAttachedSharedComponentOfSameTypeIsReplaced<BoxShape.Model, BoxShape>( |
| | 72 | | scene, CLASS_ID.BOX_SHAPE); |
| 1 | 73 | | } |
| | 74 | | } |