< Summary

Class:FriendEntryShould
Assembly:FriendsHUDTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/FriendsHUD/Tests/FriendEntryShould.cs
Covered lines:34
Uncovered lines:0
Coverable lines:34
Total lines:79
Line coverage:100% (34 of 34)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
FriendEntryShould()0%110100%
SetUp()0%220100%
TearDown()0%220100%
BePopulatedCorrectly()0%110100%
SendProperEventWhenWhisperButtonIsPressed()0%110100%
SendProperEventWhenOnMenuToggleIsPressed()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/FriendsHUD/Tests/FriendEntryShould.cs

#LineLine coverage
 1using NUnit.Framework;
 2using System.Collections;
 3using UnityEngine;
 4using UnityEngine.TestTools;
 5
 6public class FriendEntryShould : IntegrationTestSuite_Legacy
 7{
 18    static string FRIEND_ENTRY_RESOURCE_NAME = "FriendEntry";
 9
 10    FriendEntry entry;
 11
 12    [UnitySetUp]
 13    protected override IEnumerator SetUp()
 14    {
 315        GameObject go = Object.Instantiate((GameObject)Resources.Load(FRIEND_ENTRY_RESOURCE_NAME));
 316        entry = go.GetComponent<FriendEntry>();
 317        yield break;
 18    }
 19
 20    protected override IEnumerator TearDown()
 21    {
 322        Object.Destroy(entry.gameObject);
 323        yield break;
 24    }
 25
 26    [Test]
 27    public void BePopulatedCorrectly()
 28    {
 29
 130        FriendEntry.Model model = new FriendEntry.Model()
 31        {
 32            coords = Vector2.one,
 33            avatarImage = Texture2D.whiteTexture,
 34            realm = "realm-test",
 35            realmServerName = "realm-test",
 36            realmLayerName = "realm-layer-test",
 37            status = PresenceStatus.ONLINE,
 38            userName = "test-name"
 39        };
 40
 141        entry.userId = "userId-1";
 142        entry.Populate(model);
 43
 144        Assert.AreEqual(model.userName, entry.playerNameText.text);
 145        Assert.AreEqual(entry.playerImage.texture, Texture2D.whiteTexture);
 146    }
 47
 48    [Test]
 49    public void SendProperEventWhenWhisperButtonIsPressed()
 50    {
 151        var model = new FriendEntry.Model() { };
 152        entry.userId = "userId-1";
 153        entry.Populate(model);
 154        bool buttonPressed = false;
 155        entry.OnWhisperClick += (x) =>
 56        {
 157            if (x == entry)
 158                buttonPressed = true;
 159        };
 160        entry.whisperButton.onClick.Invoke();
 161        Assert.IsTrue(buttonPressed);
 162    }
 63
 64    [Test]
 65    public void SendProperEventWhenOnMenuToggleIsPressed()
 66    {
 167        var model = new FriendEntry.Model() { };
 168        entry.userId = "userId-1";
 169        entry.Populate(model);
 170        bool buttonPressed = false;
 171        entry.OnMenuToggle += (x) =>
 72        {
 173            if (x == entry)
 174                buttonPressed = true;
 175        };
 176        entry.menuButton.onClick.Invoke();
 177        Assert.IsTrue(buttonPressed);
 178    }
 79}