public void ShowIfFriendsIsAddedToRolCorrectly()
        {
            FriendsController_Mock friendsController = new FriendsController_Mock();

            friendsController.AddFriend(new FriendsController.UserStatus()
            {
                userId = "1", friendshipStatus = FriendshipStatus.FRIEND
            });
            friendsController.AddFriend(new FriendsController.UserStatus()
            {
                userId = "2", friendshipStatus = FriendshipStatus.FRIEND
            });
            friendsController.AddFriend(new FriendsController.UserStatus()
            {
                userId = "3", friendshipStatus = FriendshipStatus.FRIEND
            });

            var profile = ScriptableObject.CreateInstance <UserProfile>();

            profile.UpdateData(new UserProfileModel()
            {
                name = "Temp", userId = "1"
            });
            UserProfileController.userProfilesCatalog.Add(profile.userId, profile);
            profile = ScriptableObject.CreateInstance <UserProfile>();
            profile.UpdateData(new UserProfileModel()
            {
                name = "ta", userId = "2"
            });
            UserProfileController.userProfilesCatalog.Add(profile.userId, profile);
            profile = ScriptableObject.CreateInstance <UserProfile>();
            profile.UpdateData(new UserProfileModel()
            {
                name = "tion", userId = "3"
            });
            UserProfileController.userProfilesCatalog.Add(profile.userId, profile);

            FriendsSearchPromptController controller = new FriendsSearchPromptController(promptView, friendsController);

            controller.Show();
            controller.SetUsersInRolList(new List <string>()
            {
                "1"
            });

            Assert.IsTrue(controller.userViewsHandler.userElementViews["1"].removeButton.gameObject.activeSelf);
            Assert.IsTrue(controller.userViewsHandler.userElementViews["2"].addButton.gameObject.activeSelf);
            Assert.IsTrue(controller.userViewsHandler.userElementViews["3"].addButton.gameObject.activeSelf);

            controller.Dispose();
        }
        public void SearchFriendsCorrectly()
        {
            FriendsController_Mock friendsController = new FriendsController_Mock();

            friendsController.AddFriend(new FriendsController.UserStatus()
            {
                userId = "1", friendshipStatus = FriendshipStatus.FRIEND
            });
            friendsController.AddFriend(new FriendsController.UserStatus()
            {
                userId = "2", friendshipStatus = FriendshipStatus.FRIEND
            });
            friendsController.AddFriend(new FriendsController.UserStatus()
            {
                userId = "3", friendshipStatus = FriendshipStatus.FRIEND
            });

            var profile = ScriptableObject.CreateInstance <UserProfile>();

            profile.UpdateData(new UserProfileModel()
            {
                name = "Temp", userId = "1"
            });
            UserProfileController.userProfilesCatalog.Add(profile.userId, profile);
            profile = ScriptableObject.CreateInstance <UserProfile>();
            profile.UpdateData(new UserProfileModel()
            {
                name = "ta", userId = "2"
            });
            UserProfileController.userProfilesCatalog.Add(profile.userId, profile);
            profile = ScriptableObject.CreateInstance <UserProfile>();
            profile.UpdateData(new UserProfileModel()
            {
                name = "tion", userId = "3"
            });
            UserProfileController.userProfilesCatalog.Add(profile.userId, profile);

            FriendsSearchPromptController controller = new FriendsSearchPromptController(promptView, friendsController);

            controller.Show();
            promptView.searchInputField.OnSubmit("Temp");

            Assert.IsTrue(controller.userViewsHandler.userElementViews["1"].gameObject.activeSelf);
            Assert.IsFalse(controller.userViewsHandler.userElementViews["2"].gameObject.activeSelf);
            Assert.IsFalse(controller.userViewsHandler.userElementViews["3"].gameObject.activeSelf);

            controller.Dispose();
        }
        public void ShowFriendsCorrectly()
        {
            FriendsController_Mock friendsController = new FriendsController_Mock();

            friendsController.AddFriend(new FriendsController.UserStatus()
            {
                userId = "1", friendshipStatus = FriendshipStatus.FRIEND
            });
            friendsController.AddFriend(new FriendsController.UserStatus()
            {
                userId = "2", friendshipStatus = FriendshipStatus.FRIEND
            });
            friendsController.AddFriend(new FriendsController.UserStatus()
            {
                userId = "3", friendshipStatus = FriendshipStatus.FRIEND
            });

            var profile = ScriptableObject.CreateInstance <UserProfile>();

            profile.UpdateData(new UserProfileModel()
            {
                name = "Temp", userId = "1"
            });
            UserProfileController.userProfilesCatalog.Add(profile.userId, profile);
            profile = ScriptableObject.CreateInstance <UserProfile>();
            profile.UpdateData(new UserProfileModel()
            {
                name = "ta", userId = "2"
            });
            UserProfileController.userProfilesCatalog.Add(profile.userId, profile);
            profile = ScriptableObject.CreateInstance <UserProfile>();
            profile.UpdateData(new UserProfileModel()
            {
                name = "tion", userId = "3"
            });
            UserProfileController.userProfilesCatalog.Add(profile.userId, profile);

            FriendsSearchPromptController controller = new FriendsSearchPromptController(promptView, friendsController);

            controller.Show();

            Assert.AreEqual(3, promptView.friendListParent.childCount);
            Assert.AreEqual("Temp", controller.userViewsHandler.userElementViews["1"].textUserName.text);
            Assert.AreEqual("ta", controller.userViewsHandler.userElementViews["2"].textUserName.text);
            Assert.AreEqual("tion", controller.userViewsHandler.userElementViews["3"].textUserName.text);

            controller.Dispose();
        }
        public void TriggerRemoveButtonCorrectlyOnClick()
        {
            FriendsController_Mock friendsController = new FriendsController_Mock();

            friendsController.AddFriend(new FriendsController.UserStatus()
            {
                userId = "1", friendshipStatus = FriendshipStatus.FRIEND
            });

            var profile = ScriptableObject.CreateInstance <UserProfile>();

            profile.UpdateData(new UserProfileModel()
            {
                name = "Temptation", userId = "1"
            });
            UserProfileController.userProfilesCatalog.Add(profile.userId, profile);

            FriendsSearchPromptController controller = new FriendsSearchPromptController(promptView, friendsController);

            controller.Show();

            bool triggered = false;

            void OnButtonPressed(string id)
            {
                triggered = id == "1";
            }

            controller.userViewsHandler.userElementViews["1"].OnRemovePressed += OnButtonPressed;
            controller.userViewsHandler.userElementViews["1"].removeButton.onClick.Invoke();

            Assert.IsTrue(triggered);
            controller.Dispose();
        }
Beispiel #5
0
    protected override IEnumerator SetUp()
    {
        Vector2 testCoords = new Vector2(5, 20);

        friendsController = new FriendsController_Mock();
        friendsController.AddFriend(new FriendsController.UserStatus
        {
            userId           = TEST_USER_ID,
            friendshipStatus = FriendshipStatus.FRIEND,
            position         = testCoords,
            presence         = PresenceStatus.ONLINE,
            realm            = new FriendsController.UserStatus.Realm
            {
                serverName = TEST_SERVER_NAME,
                layer      = TEST_LAYER_NAME
            }
        });

        GameObject go = Object.Instantiate((GameObject)Resources.Load(JUMP_IN_BUTTON_RESOURCE_NAME));

        jumpInButton = go.GetComponent <JumpInButton>();
        jumpInButton.Initialize(friendsController, TEST_USER_ID);

        Assert.AreEqual(testCoords, jumpInButton.currentCoords, "Position coords should match with [testCoords]");
        Assert.AreEqual(PresenceStatus.ONLINE, jumpInButton.currentPresenceStatus, "Presence status should be ONLINE");
        Assert.AreEqual(TEST_SERVER_NAME, jumpInButton.currentRealmServerName, "Server name should match with [TEST_SERVER_NAME]");
        Assert.AreEqual(TEST_LAYER_NAME, jumpInButton.currentRealmLayerName, "Server layer should match with [TEST_LAYER_NAME]");
        Assert.AreEqual(true, jumpInButton.gameObject.activeSelf, "JumpInButton game object should be actived");

        yield break;
    }