Пример #1
0
    internal void UpdateContributors(string[] contributors)
    {
        if (contributors == null || contributors.Length == 0)
        {
            if (contributorsList.Count > 0)
            {
                contributorsList.Clear();
            }

            view.SetEmptyList(true);
            view.SetContributorsCount(0);
            return;
        }

        var newContributors = new List <string>(contributors);

        for (int i = 0; i < newContributors.Count; i++)
        {
            AddContributor(newContributors[i]);
            contributorsList.Remove(newContributors[i]);
        }

        for (int i = 0; i < contributorsList.Count; i++)
        {
            view.RemoveUser(contributorsList[i]);
        }

        contributorsList = newContributors;

        friendsSearchPromptController.SetUsersInRolList(contributorsList);
        view.SetEmptyList(false);
        view.SetContributorsCount(contributorsList.Count);
    }
Пример #2
0
    internal void SetAdmins(string[] usersId)
    {
        if (usersId == null || usersId.Length == 0)
        {
            if (admins.Count > 0)
            {
                admins.Clear();
            }

            view.SetAdminsEmptyList(true);
            view.SetAdminsCount(0);
            return;
        }

        var newAdmins = new List <string>(usersId);

        for (int i = 0; i < newAdmins.Count; i++)
        {
            AddAdmin(newAdmins[i]);
            admins.Remove(newAdmins[i]);
        }

        for (int i = 0; i < admins.Count; i++)
        {
            view.RemoveAdmin(admins[i]);
        }

        admins = newAdmins;

        friendsSearchPromptController.SetUsersInRolList(admins);
        view.SetAdminsEmptyList(false);
        view.SetAdminsCount(admins.Count);
    }
Пример #3
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();
        }