| | 1 | | using NUnit.Framework; |
| | 2 | | using System.Collections; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.TestTools; |
| | 5 | |
|
| | 6 | | public class FriendEntryShould : IntegrationTestSuite_Legacy |
| | 7 | | { |
| 1 | 8 | | static string FRIEND_ENTRY_RESOURCE_NAME = "FriendEntry"; |
| | 9 | |
|
| | 10 | | FriendEntry entry; |
| | 11 | |
|
| | 12 | | [UnitySetUp] |
| | 13 | | protected override IEnumerator SetUp() |
| | 14 | | { |
| 3 | 15 | | GameObject go = Object.Instantiate((GameObject)Resources.Load(FRIEND_ENTRY_RESOURCE_NAME)); |
| 3 | 16 | | entry = go.GetComponent<FriendEntry>(); |
| 3 | 17 | | yield break; |
| | 18 | | } |
| | 19 | |
|
| | 20 | | protected override IEnumerator TearDown() |
| | 21 | | { |
| 3 | 22 | | Object.Destroy(entry.gameObject); |
| 3 | 23 | | yield break; |
| | 24 | | } |
| | 25 | |
|
| | 26 | | [Test] |
| | 27 | | public void BePopulatedCorrectly() |
| | 28 | | { |
| | 29 | |
|
| 1 | 30 | | 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 | |
|
| 1 | 41 | | entry.userId = "userId-1"; |
| 1 | 42 | | entry.Populate(model); |
| | 43 | |
|
| 1 | 44 | | Assert.AreEqual(model.userName, entry.playerNameText.text); |
| 1 | 45 | | Assert.AreEqual(entry.playerImage.texture, Texture2D.whiteTexture); |
| 1 | 46 | | } |
| | 47 | |
|
| | 48 | | [Test] |
| | 49 | | public void SendProperEventWhenWhisperButtonIsPressed() |
| | 50 | | { |
| 1 | 51 | | var model = new FriendEntry.Model() { }; |
| 1 | 52 | | entry.userId = "userId-1"; |
| 1 | 53 | | entry.Populate(model); |
| 1 | 54 | | bool buttonPressed = false; |
| 1 | 55 | | entry.OnWhisperClick += (x) => |
| | 56 | | { |
| 1 | 57 | | if (x == entry) |
| 1 | 58 | | buttonPressed = true; |
| 1 | 59 | | }; |
| 1 | 60 | | entry.whisperButton.onClick.Invoke(); |
| 1 | 61 | | Assert.IsTrue(buttonPressed); |
| 1 | 62 | | } |
| | 63 | |
|
| | 64 | | [Test] |
| | 65 | | public void SendProperEventWhenOnMenuToggleIsPressed() |
| | 66 | | { |
| 1 | 67 | | var model = new FriendEntry.Model() { }; |
| 1 | 68 | | entry.userId = "userId-1"; |
| 1 | 69 | | entry.Populate(model); |
| 1 | 70 | | bool buttonPressed = false; |
| 1 | 71 | | entry.OnMenuToggle += (x) => |
| | 72 | | { |
| 1 | 73 | | if (x == entry) |
| 1 | 74 | | buttonPressed = true; |
| 1 | 75 | | }; |
| 1 | 76 | | entry.menuButton.onClick.Invoke(); |
| 1 | 77 | | Assert.IsTrue(buttonPressed); |
| 1 | 78 | | } |
| | 79 | | } |