Exemplo n.º 1
0
        public void FriendsManager_AddDuplicate_RetrieveOnlyOne()
        {
            var client = new GameClient(GameServer.Instance)
            {
                Account = new Account()
                {
                    Characters = new [] { new DOLCharacters() }
                },
                Out = new TestPacketLib()
            };
            var gameplayer = new GamePlayer(client, client.Account.Characters[0]);

            GameServer.Instance.PlayerManager.Friends.AddPlayerFriendsListToCache(gameplayer);
            gameplayer.AddFriend("buddy");
            Assert.IsFalse(gameplayer.AddFriend("buddy"));
            gameplayer.AddFriend("someone");

            CollectionAssert.AreEquivalent(gameplayer.GetFriends(), gameplayer.SerializedFriendsList);
            CollectionAssert.AreEquivalent(gameplayer.GetFriends(), new [] { "buddy", "someone" });
            GameServer.Instance.PlayerManager.Friends.RemovePlayerFriendsListFromCache(gameplayer);
        }
Exemplo n.º 2
0
        public void FriendsManager_RemoveFriends_RetrieveEmpty()
        {
            var client = new GameClient(GameServer.Instance)
            {
                Account = new Account()
                {
                    Characters = new [] { new DOLCharacters() }
                },
                Out = new TestPacketLib()
            };
            var gameplayer = new GamePlayer(client, client.Account.Characters[0]);

            GameServer.Instance.PlayerManager.Friends.AddPlayerFriendsListToCache(gameplayer);
            gameplayer.AddFriend("buddy");
            gameplayer.AddFriend("mate");
            gameplayer.AddFriend("someone");
            CollectionAssert.IsNotEmpty(gameplayer.GetFriends());
            gameplayer.RemoveFriend("buddy");
            gameplayer.RemoveFriend("mate");
            gameplayer.RemoveFriend("someone");
            CollectionAssert.IsEmpty(gameplayer.GetFriends());
            GameServer.Instance.PlayerManager.Friends.RemovePlayerFriendsListFromCache(gameplayer);
        }
Exemplo n.º 3
0
		public void FriendsManager_RemoveNonExisting_RetrieveOne()
		{
			var client = new GameClient(GameServer.Instance) {
				Account = new Account() { Characters = new [] { new DOLCharacters() } },
				Out = new TestPacketLib()
			};
			var gameplayer = new GamePlayer(client, client.Account.Characters[0]);
			
			GameServer.Instance.PlayerManager.Friends.AddPlayerFriendsListToCache(gameplayer);
			gameplayer.AddFriend("buddy");
			CollectionAssert.IsNotEmpty(gameplayer.GetFriends());
			Assert.IsFalse(gameplayer.RemoveFriend("mate"));
			CollectionAssert.AreEquivalent(gameplayer.GetFriends(), new [] { "buddy" });
			GameServer.Instance.PlayerManager.Friends.RemovePlayerFriendsListFromCache(gameplayer);
		}
Exemplo n.º 4
0
		public void FriendsManager_AddDuplicate_RetrieveOnlyOne()
		{
			var client = new GameClient(GameServer.Instance) {
				Account = new Account() { Characters = new [] { new DOLCharacters() } },
				Out = new TestPacketLib()
			};
			var gameplayer = new GamePlayer(client, client.Account.Characters[0]);
			
			GameServer.Instance.PlayerManager.Friends.AddPlayerFriendsListToCache(gameplayer);
			gameplayer.AddFriend("buddy");
			Assert.IsFalse(gameplayer.AddFriend("buddy"));
			gameplayer.AddFriend("someone");

			CollectionAssert.AreEquivalent(gameplayer.GetFriends(), gameplayer.SerializedFriendsList);
			CollectionAssert.AreEquivalent(gameplayer.GetFriends(), new [] { "buddy", "someone" });
			GameServer.Instance.PlayerManager.Friends.RemovePlayerFriendsListFromCache(gameplayer);
		}