Ejemplo n.º 1
0
        public void PlayerCanLeaveAGameRoom()
        {
            CreateRoomResponse roomResponse = client.CreateNewRoom(createRoomRequest("My room!"));

            Assert.AreEqual(roomResponse.Status.IsSuccess, true);
            Assert.IsTrue(roomResponse.CreatedRoom.Id != null);
            var roomId = roomResponse.CreatedRoom.Id;

            authHelper.loginToAccount("userTwo");

            // View open rooms.
            OpenLobbiesResponse openLobbiesResponse = client.GetOpenLobbies(new OpenLobbiesRequest());

            Assert.AreEqual(openLobbiesResponse.Status.IsSuccess, true);
            Assert.AreEqual(1, openLobbiesResponse.Rooms.Count);
            Assert.AreEqual(roomId, openLobbiesResponse.Rooms[0].Id);
            // Ensure the creator is a member of the game
            Assert.AreEqual(1, openLobbiesResponse.Rooms[0].Players.Count);
            Assert.AreEqual("userOne", openLobbiesResponse.Rooms[0].Players[0].Username);

            JoinRoomRequest joinRequest = new JoinRoomRequest()
            {
                RoomId = roomId,
            };

            JoinRoomResponse joinResponse = client.JoinRoom(joinRequest);

            Assert.AreEqual(joinResponse.Status.IsSuccess, true);

            // View open rooms.
            OpenLobbiesResponse openLobbiesResponsAfterJoin = client.GetOpenLobbies(new OpenLobbiesRequest());

            Assert.AreEqual(openLobbiesResponsAfterJoin.Status.IsSuccess, true);
            Assert.AreEqual(1, openLobbiesResponsAfterJoin.Rooms.Count);
            Assert.AreEqual(roomId, openLobbiesResponsAfterJoin.Rooms[0].Id);
            Assert.AreEqual(2, openLobbiesResponsAfterJoin.Rooms[0].Players.Count);

            LeaveRoomRequest leaveRequest = new LeaveRoomRequest()
            {
                RoomId = roomId
            };

            LeaveRoomResponse leaveResponse = client.LeaveRoom(leaveRequest);

            Assert.AreEqual(leaveResponse.Status.IsSuccess, true);

            // Ensure that the player has left the game.
            // View open rooms.
            OpenLobbiesResponse openLobbiesResponsAfterLeave = client.GetOpenLobbies(new OpenLobbiesRequest());

            Assert.AreEqual(openLobbiesResponsAfterLeave.Status.IsSuccess, true);
            Assert.AreEqual(1, openLobbiesResponsAfterLeave.Rooms.Count);
            Assert.AreEqual(roomId, openLobbiesResponsAfterLeave.Rooms[0].Id);
            Assert.AreEqual(1, openLobbiesResponsAfterLeave.Rooms[0].Players.Count);
        }
Ejemplo n.º 2
0
        public void PlayerCanLeaveAGameRoom()
        {
            CreateRoomRequest createRequest = new CreateRoomRequest()
            {
                Anonymous          = false,
                Goal               = Goal.Domination,
                MaxPlayers         = 5,
                IsRanked           = false,
                RoomName           = "My Room!",
                AllowedSpecialists = { "a", "b", "c" },
            };

            CreateRoomResponse roomResponse = client.CreateNewRoom(createRequest);

            Assert.AreEqual(roomResponse.Status.IsSuccess, true);
            Assert.IsTrue(roomResponse.CreatedRoom.RoomId != null);
            var roomId = roomResponse.CreatedRoom.RoomId;

            authHelper.loginToAccount("userTwo");

            // View open rooms.
            OpenLobbiesResponse openLobbiesResponse = client.GetOpenLobbies(new OpenLobbiesRequest());

            Assert.AreEqual(openLobbiesResponse.Status.IsSuccess, true);
            Assert.AreEqual(1, openLobbiesResponse.Rooms.Count);
            Assert.AreEqual(roomId, openLobbiesResponse.Rooms[0].RoomId);
            // Ensure the creator is a member of the game
            Assert.AreEqual(1, openLobbiesResponse.Rooms[0].Players.Count);
            Assert.AreEqual("userOne", openLobbiesResponse.Rooms[0].Players[0].Username);

            JoinRoomRequest joinRequest = new JoinRoomRequest()
            {
                RoomId = roomId,
            };

            JoinRoomResponse joinResponse = client.JoinRoom(joinRequest);

            Assert.AreEqual(joinResponse.Status.IsSuccess, true);

            // View open rooms.
            OpenLobbiesResponse openLobbiesResponsAfterJoin = client.GetOpenLobbies(new OpenLobbiesRequest());

            Assert.AreEqual(openLobbiesResponsAfterJoin.Status.IsSuccess, true);
            Assert.AreEqual(1, openLobbiesResponsAfterJoin.Rooms.Count);
            Assert.AreEqual(roomId, openLobbiesResponsAfterJoin.Rooms[0].RoomId);
            Assert.AreEqual(2, openLobbiesResponsAfterJoin.Rooms[0].Players.Count);

            LeaveRoomRequest leaveRequest = new LeaveRoomRequest()
            {
                RoomId = roomId
            };

            LeaveRoomResponse leaveResponse = client.LeaveRoom(leaveRequest);

            Assert.AreEqual(leaveResponse.Status.IsSuccess, true);

            // Ensure that the player has left the game.
            // View open rooms.
            OpenLobbiesResponse openLobbiesResponsAfterLeave = client.GetOpenLobbies(new OpenLobbiesRequest());

            Assert.AreEqual(openLobbiesResponsAfterLeave.Status.IsSuccess, true);
            Assert.AreEqual(1, openLobbiesResponsAfterLeave.Rooms.Count);
            Assert.AreEqual(roomId, openLobbiesResponsAfterLeave.Rooms[0].RoomId);
            Assert.AreEqual(1, openLobbiesResponsAfterLeave.Rooms[0].Players.Count);
        }