< Summary

Class:AvatarShape_Tests.FacialFeatureControllerShould
Assembly:AvatarShapeTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/Tests/FacialFeatureControllerShould.cs
Covered lines:33
Uncovered lines:0
Coverable lines:33
Total lines:127
Line coverage:100% (33 of 33)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%330100%
LoadProperly()0%330100%
FailsGracefully_BadURL()0%330100%
FailsGracefully_EmptyContent()0%330100%
LoadMouthWithMaskProperly()0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/Tests/FacialFeatureControllerShould.cs

#LineLine coverage
 1using System.Collections;
 2using DCL;
 3using NSubstitute;
 4using NUnit.Framework;
 5using UnityEngine;
 6using UnityEngine.TestTools;
 7using WaitUntil = DCL.WaitUntil;
 8
 9namespace AvatarShape_Tests
 10{
 11    public class FacialFeatureControllerShould : IntegrationTestSuite_Legacy
 12    {
 13        private const string EYES_ID = "urn:decentraland:off-chain:base-avatars:f_eyes_01";
 14        private const string DRACULA_MOUTH_ID = "urn:decentraland:off-chain:base-avatars:dracula_mouth";
 15        private BaseDictionary<string, WearableItem> catalog;
 16        private IBodyShapeController bodyShapeController;
 17
 18        [UnitySetUp]
 19        protected override IEnumerator SetUp()
 20        {
 421            yield return base.SetUp();
 422            bodyShapeController = Substitute.For<IBodyShapeController>();
 423            bodyShapeController.bodyShapeId.Returns(WearableLiterals.BodyShapes.FEMALE);
 24
 425            catalog = AvatarAssetsTestHelpers.CreateTestCatalogLocal();
 426        }
 27
 28        [UnityTest]
 29        public IEnumerator LoadProperly()
 30        {
 31            //Arrange
 132            catalog.TryGetValue(EYES_ID, out WearableItem wereableItem);
 133            FacialFeatureController controller = new FacialFeatureController(wereableItem, new Material(Shader.Find("DCL
 34
 35            //Act
 136            controller.Load(bodyShapeController, Color.red);
 437            yield return new WaitUntil(() => controller.isReady);
 38
 39            //Assert
 140            Assert.NotNull(controller.mainTexture);
 141            Assert.NotNull(controller.maskTexture);
 142        }
 43
 44        [UnityTest]
 45        public IEnumerator FailsGracefully_BadURL()
 46        {
 47            //Arrange
 148            WearableItem fakeWearable = new WearableItem
 49            {
 50                baseUrl = "http://nothing_here.nope",
 51                data = new WearableItem.Data()
 52                {
 53                    category = WearableLiterals.Categories.EYES,
 54                    representations = new []
 55                    {
 56                        new WearableItem.Representation()
 57                        {
 58                            bodyShapes = new [] { WearableLiterals.BodyShapes.FEMALE },
 59                            contents = new []
 60                            {
 61                                new WearableItem.MappingPair { key = "fake.png", hash = "nope" },
 62                                new WearableItem.MappingPair { key = "fake_mask.png", hash = "nope2" }
 63                            },
 64                        }
 65                    }
 66                }
 67            };
 168            FacialFeatureController controller = new FacialFeatureController(fakeWearable, new Material(Shader.Find("DCL
 69
 70            //Act
 171            controller.Load(bodyShapeController, Color.red);
 972            yield return new WaitUntil(() => controller.isReady);
 73
 74            //Assert
 175            Assert.Null(controller.mainTexture);
 176            Assert.Null(controller.maskTexture);
 177        }
 78
 79        [UnityTest]
 80        public IEnumerator FailsGracefully_EmptyContent()
 81        {
 82            //Arrange
 183            WearableItem fakeWearable = new WearableItem
 84            {
 85                baseUrl = "http://nothing_here.nope",
 86                data = new WearableItem.Data()
 87                {
 88                    category = WearableLiterals.Categories.EYES,
 89                    representations = new []
 90                    {
 91                        new WearableItem.Representation
 92                        {
 93                            bodyShapes = new [] { WearableLiterals.BodyShapes.FEMALE },
 94                            contents = new WearableItem.MappingPair[0],
 95                        }
 96                    }
 97                }
 98            };
 199            FacialFeatureController controller = new FacialFeatureController(fakeWearable, new Material(Shader.Find("DCL
 100
 101            //Act
 1102            controller.Load(bodyShapeController, Color.red);
 4103            yield return new WaitUntil(() => controller.isReady);
 104
 105            //Assert
 1106            Assert.Null(controller.mainTexture);
 1107            Assert.Null(controller.maskTexture);
 1108        }
 109
 110        [UnityTest]
 111        public IEnumerator LoadMouthWithMaskProperly()
 112        {
 113            //Arrange
 1114            catalog.TryGetValue(DRACULA_MOUTH_ID, out WearableItem wereableItem);
 115
 1116            FacialFeatureController controller = new FacialFeatureController(wereableItem, new Material(Shader.Find("DCL
 117
 118            //Act
 1119            controller.Load(bodyShapeController, Color.red);
 4120            yield return new WaitUntil(() => controller.isReady);
 121
 122            //Assert
 1123            Assert.NotNull(controller.mainTexture);
 1124            Assert.NotNull(controller.maskTexture);
 1125        }
 126    }
 127}