Пример #1
0
        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();
        }
Пример #2
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;
    }
        protected override IEnumerator SetUp()
        {
            yield return(base.SetUp());

            ExploreHUDController.isTest = true;

            SetupUserProfileController();

            friendsController = new FriendsController_Mock();
            controller        = new ExploreHUDController();
            controller.Initialize(friendsController);
        }
Пример #4
0
    public static FriendEntry FakeAddFriend(FriendsController_Mock controller, FriendsHUDView hudView, string id, FriendshipAction action = FriendshipAction.APPROVED)
    {
        UserProfileModel model = new UserProfileModel()
        {
            userId = id,
            name   = id,
        };

        UserProfileController.i.AddUserProfileToCatalog(model);
        controller.RaiseUpdateFriendship(id, action);
        return(hudView.friendsList.GetEntry(id) as FriendEntry);
    }
Пример #5
0
    public static IEnumerator FakeAddFriend(FriendsController_Mock controller, FriendsHUDView hudView, string id, FriendshipAction action = FriendshipAction.APPROVED)
    {
        UserProfileModel model = new UserProfileModel()
        {
            userId = id,
            name   = id,
        };

        UserProfileController.i.AddUserProfileToCatalog(model);
        controller.RaiseUpdateFriendship(id, action);
        yield return(new WaitUntil(() => hudView.friendsList.creationQueue.Count == 0));
    }
Пример #6
0
        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();
        }
Пример #7
0
    protected override IEnumerator SetUp()
    {
        yield return(base.SetUp());

        NotificationsController.i.Initialize(new NotificationHUDController());

        controller        = new FriendsHUDController();
        friendsController = new FriendsController_Mock();
        controller.Initialize(friendsController, UserProfile.GetOwnUserProfile());
        this.view = controller.view;

        Assert.IsTrue(view != null, "Friends hud view is null?");
        Assert.IsTrue(controller != null, "Friends hud controller is null?");
    }
Пример #8
0
        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();
        }
Пример #9
0
        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();
        }
 private void SetupFriendController()
 {
     friendsController = new FriendsController_Mock();
 }