< Summary

Class:Tests.UserProfileTests
Assembly:UserProfileTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/Tests/UserProfileTests.cs
Covered lines:37
Uncovered lines:0
Coverable lines:37
Total lines:116
Line coverage:100% (37 of 37)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
UserProfile_Creation()0%110100%
UserProfile_OwnProfile_Retrieval()0%110100%
UserProfile_Model_UpdateProperties()0%110100%
CreateSnapshotsWithFaceUrl(...)0%110100%
UserProfile_UpdateData_FromEmpty()0%110100%
UserProfile_UpdateData_FromFilled()0%110100%
UserProfile_GetItemAmount(...)0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/UserProfile/Tests/UserProfileTests.cs

#LineLine coverage
 1using NUnit.Framework;
 2using UnityEditor;
 3using UnityEngine;
 4
 5namespace Tests
 6{
 7    public class UserProfileTests : IntegrationTestSuite_Legacy
 8    {
 9        [Test]
 10        public void UserProfile_Creation()
 11        {
 112            var userProfile = ScriptableObject.CreateInstance<UserProfile>();
 13
 114            Assert.NotNull(userProfile);
 115        }
 16
 17        [Test]
 18        public void UserProfile_OwnProfile_Retrieval()
 19        {
 120            var ownUserProfile = UserProfile.GetOwnUserProfile();
 21
 122            Assert.NotNull(ownUserProfile);
 123            Assert.AreEqual(UserProfile.ownUserProfile, ownUserProfile);
 124            Assert.True(AssetDatabase.GetAssetPath(ownUserProfile).Contains("ScriptableObjects/OwnUserProfile"));
 125        }
 26
 27        [Test]
 28        public void UserProfile_Model_UpdateProperties()
 29        {
 130            var userProfile = ScriptableObject.CreateInstance<UserProfile>();
 31
 132            userProfile.UpdateData(new UserProfileModel()
 33            {
 34                name = "name",
 35                email = "mail",
 36                avatar = new AvatarModel(),
 37                snapshots = CreateSnapshotsWithFaceUrl("avatarPicURL")
 38            }, false);
 39
 140            Assert.AreEqual("name", userProfile.model.name);
 141            Assert.AreEqual("mail", userProfile.model.email);
 142            Assert.AreEqual("avatarPicURL", userProfile.model.snapshots.face256);
 143        }
 44
 45        private static UserProfileModel.Snapshots CreateSnapshotsWithFaceUrl(string faceUrl)
 46        {
 447            return new UserProfileModel.Snapshots()
 48            {
 49                face = faceUrl,
 50                face128 = faceUrl,
 51                face256 = faceUrl
 52            };
 53        }
 54
 55        [Test]
 56        public void UserProfile_UpdateData_FromEmpty()
 57        {
 158            var userProfile = ScriptableObject.CreateInstance<UserProfile>();
 59
 160            userProfile.UpdateData(new UserProfileModel()
 61            {
 62                name = "name2",
 63                email = "mail2",
 64                avatar = new AvatarModel(),
 65                snapshots = CreateSnapshotsWithFaceUrl("avatarPicURL2")
 66            }, false);
 67
 168            Assert.AreEqual("name2", userProfile.model.name);
 169            Assert.AreEqual("mail2", userProfile.model.email);
 170            Assert.AreEqual("avatarPicURL2", userProfile.model.snapshots.face256);
 171        }
 72
 73        [Test]
 74        public void UserProfile_UpdateData_FromFilled()
 75        {
 176            var userProfile = ScriptableObject.CreateInstance<UserProfile>();
 177            userProfile.UpdateData(new UserProfileModel()
 78            {
 79                name = "name",
 80                email = "mail",
 81                avatar = new AvatarModel(),
 82                snapshots = CreateSnapshotsWithFaceUrl("avatarPicURL")
 83            }, false);
 84
 185            userProfile.UpdateData(new UserProfileModel()
 86            {
 87                name = "name2",
 88                email = "mail2",
 89                avatar = new AvatarModel(),
 90                snapshots = CreateSnapshotsWithFaceUrl("avatarPicURL2")
 91            }, false);
 92
 193            Assert.AreEqual("name2", userProfile.model.name);
 194            Assert.AreEqual("mail2", userProfile.model.email);
 195            Assert.AreEqual("avatarPicURL2", userProfile.model.snapshots.face256);
 196        }
 97
 98        [Test]
 99        [TestCase(1)]
 100        [TestCase(5)]
 101        public void UserProfile_GetItemAmount(int amount)
 102        {
 2103            var userProfile = ScriptableObject.CreateInstance<UserProfile>();
 2104            var model = new UserProfileModel();
 2105            var inventory = new string[amount];
 16106            for (int i = 0; i < amount; i++)
 107            {
 6108                inventory[i] = "nft";
 109            }
 2110            userProfile.SetInventory(inventory);
 2111            userProfile.UpdateData(model);
 112
 2113            Assert.AreEqual(amount, userProfile.GetItemAmount("nft"));
 2114        }
 115    }
 116}