< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
FriendRequestEntryShould()0%110100%
SetUp()0%220100%
TearDown()0%220100%
BePopulatedCorrectly()0%110100%
SendProperEventWhenOnAcceptedIsPressed()0%110100%
SendProperEventWhenOnCancelledIsPressed()0%110100%
SendProperEventWhenOnMenuToggleIsPressed()0%110100%
SendProperEventWhenOnRejectedIsPressed()0%110100%

File(s)

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

#LineLine coverage
 1using NUnit.Framework;
 2using System.Collections;
 3using UnityEngine;
 4using UnityEngine.TestTools;
 5
 6public class FriendRequestEntryShould : IntegrationTestSuite_Legacy
 7{
 18    static string FRIEND_REQUEST_ENTRY_RESOURCE_NAME = "FriendRequestEntry";
 9
 10    FriendRequestEntry entry;
 11
 12    [UnitySetUp]
 13    protected override IEnumerator SetUp()
 14    {
 515        GameObject go = Object.Instantiate((GameObject)Resources.Load(FRIEND_REQUEST_ENTRY_RESOURCE_NAME));
 516        entry = go.GetComponent<FriendRequestEntry>();
 517        yield break;
 18    }
 19
 20    protected override IEnumerator TearDown()
 21    {
 522        Object.Destroy(entry.gameObject);
 523        yield break;
 24    }
 25
 26    [Test]
 27    public void BePopulatedCorrectly()
 28    {
 129        var model1 = new FriendEntry.Model() { userName = "test1", avatarImage = Texture2D.whiteTexture };
 130        var model2 = new FriendEntry.Model() { userName = "test2", avatarImage = Texture2D.blackTexture };
 31
 132        entry.userId = "userId1";
 133        entry.Populate(model1);
 134        entry.SetReceived(true);
 35
 136        Assert.AreEqual(model1.userName, entry.playerNameText.text);
 137        Assert.AreEqual(model1.avatarImage, entry.playerImage.texture);
 38
 139        Assert.IsFalse(entry.cancelButton.gameObject.activeSelf);
 140        Assert.IsTrue(entry.acceptButton.gameObject.activeSelf);
 141        Assert.IsTrue(entry.rejectButton.gameObject.activeSelf);
 42
 143        entry.userId = "userId2";
 144        entry.Populate(model2);
 145        entry.SetReceived(false);
 46
 147        Assert.AreEqual(model2.userName, entry.playerNameText.text);
 148        Assert.AreEqual(model2.avatarImage, entry.playerImage.texture);
 49
 150        Assert.IsTrue(entry.cancelButton.gameObject.activeSelf);
 151        Assert.IsFalse(entry.acceptButton.gameObject.activeSelf);
 152        Assert.IsFalse(entry.rejectButton.gameObject.activeSelf);
 153    }
 54
 55    [Test]
 56    public void SendProperEventWhenOnAcceptedIsPressed()
 57    {
 158        var model = new FriendEntry.Model() { };
 159        entry.userId = "userId-1";
 160        entry.Populate(model);
 61
 162        bool buttonPressed = false;
 163        entry.OnAccepted += (x) =>
 64        {
 165            if (x == entry)
 166                buttonPressed = true;
 167        };
 168        entry.acceptButton.onClick.Invoke();
 169        Assert.IsTrue(buttonPressed);
 170    }
 71
 72    [Test]
 73    public void SendProperEventWhenOnCancelledIsPressed()
 74    {
 175        var model = new FriendEntry.Model() { };
 176        entry.userId = "userId-1";
 177        entry.Populate(model);
 178        bool buttonPressed = false;
 179        entry.OnCancelled += (x) =>
 80        {
 181            if (x == entry)
 182                buttonPressed = true;
 183        };
 184        entry.cancelButton.onClick.Invoke();
 185        Assert.IsTrue(buttonPressed);
 186    }
 87
 88    [Test]
 89    public void SendProperEventWhenOnMenuToggleIsPressed()
 90    {
 191        var model = new FriendEntry.Model() { };
 192        entry.userId = "userId-1";
 193        entry.Populate(model);
 194        bool buttonPressed = false;
 195        entry.OnMenuToggle += (x) =>
 96        {
 197            if (x == entry)
 198                buttonPressed = true;
 199        };
 1100        entry.menuButton.onClick.Invoke();
 1101        Assert.IsTrue(buttonPressed);
 1102    }
 103
 104    [Test]
 105    public void SendProperEventWhenOnRejectedIsPressed()
 106    {
 1107        var model = new FriendEntry.Model() { };
 1108        entry.userId = "userId-1";
 1109        entry.Populate(model);
 1110        bool buttonPressed = false;
 1111        entry.OnRejected += (x) =>
 112        {
 1113            if (x == entry)
 1114                buttonPressed = true;
 1115        };
 1116        entry.rejectButton.onClick.Invoke();
 1117        Assert.IsTrue(buttonPressed);
 1118    }
 119
 120}