< Summary

Class:ChatEntryShould
Assembly:ChatHUDTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ChatWidgetHUD/Tests/ChatEntryShould.cs
Covered lines:25
Uncovered lines:0
Coverable lines:25
Total lines:58
Line coverage:100% (25 of 25)
Covered branches:0
Total branches:0

Metrics

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

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ChatWidgetHUD/Tests/ChatEntryShould.cs

#LineLine coverage
 1using DCL.Interface;
 2using NUnit.Framework;
 3using System.Collections;
 4using UnityEngine;
 5
 6public class ChatEntryShould : IntegrationTestSuite_Legacy
 7{
 8    ChatEntry entry;
 9    Canvas canvas;
 10    protected override IEnumerator SetUp()
 11    {
 112        var canvasgo = new GameObject("canvas");
 113        canvas = canvasgo.AddComponent<Canvas>();
 114        (canvas.transform as RectTransform).sizeDelta = new Vector2(500, 500);
 115        var go = Object.Instantiate(Resources.Load("Chat Entry"), canvas.transform, false) as GameObject;
 116        entry = go.GetComponent<ChatEntry>();
 117        yield break;
 18    }
 19
 20    protected override IEnumerator TearDown()
 21    {
 122        Object.Destroy(entry.gameObject);
 123        Object.Destroy(canvas.gameObject);
 124        yield break;
 25    }
 26
 27    [Test]
 28    public void BePopulatedCorrectly()
 29    {
 130        var message = new ChatEntry.Model()
 31        {
 32            messageType = ChatMessage.Type.PUBLIC,
 33            senderName = "user-test",
 34            recipientName = "",
 35            bodyText = "test message",
 36        };
 37
 138        entry.Populate(message);
 39
 140        Assert.AreEqual(entry.worldMessageColor, entry.body.color);
 141        Assert.AreEqual("<b>user-test:</b>", entry.username.text);
 142        Assert.AreEqual("<b>user-test:</b> test message", entry.body.text);
 43
 144        message.messageType = ChatMessage.Type.PRIVATE;
 145        message.subType = ChatEntry.Model.SubType.PRIVATE_TO;
 46
 147        entry.Populate(message);
 148        Assert.AreEqual(entry.privateToMessageColor, entry.username.color);
 49
 150        message.subType = ChatEntry.Model.SubType.PRIVATE_FROM;
 151        entry.Populate(message);
 152        Assert.AreEqual(entry.privateFromMessageColor, entry.username.color);
 53
 154        message.messageType = ChatMessage.Type.SYSTEM;
 155        entry.Populate(message);
 156        Assert.AreEqual(entry.systemColor, entry.body.color);
 157    }
 58}