Esempio n. 1
0
        public async Task UserCantLeaveWhenNotAlreadyJoined()
        {
            await Assert.ThrowsAsync <NotJoinedRoomException>(() => Hub.LeaveRoom());

            // ensure no state was left behind.
            await Assert.ThrowsAsync <KeyNotFoundException>(() => UserStates.GetForUse(USER_ID));
        }
Esempio n. 2
0
        public async Task UserCantJoinWhenRestricted()
        {
            Database.Setup(db => db.IsUserRestrictedAsync(It.IsAny <int>())).ReturnsAsync(true);

            await Assert.ThrowsAsync <InvalidStateException>(() => Hub.JoinRoom(ROOM_ID));

            // ensure no state was left behind.
            await Assert.ThrowsAsync <KeyNotFoundException>(() => UserStates.GetForUse(USER_ID));
        }
Esempio n. 3
0
        public async Task UserJoinPreRetrievalFailureCleansUpRoom()
        {
            SetUserContext(ContextUser2); // not the correct user to join the game first; triggers host mismatch failure.
            await Assert.ThrowsAnyAsync <Exception>(() => Hub.JoinRoom(ROOM_ID));

            await Assert.ThrowsAsync <KeyNotFoundException>(() => Rooms.GetForUse(ROOM_ID));

            await Assert.ThrowsAsync <KeyNotFoundException>(() => UserStates.GetForUse(USER_ID));
        }
Esempio n. 4
0
        public async Task UserJoinPostJoinFailureCleansUpRoomAndUser()
        {
            Database.Setup(db => db.AddRoomParticipantAsync(It.IsAny <MultiplayerRoom>(), It.IsAny <MultiplayerRoomUser>()))
            .ThrowsAsync(new Exception("error"));

            await Assert.ThrowsAnyAsync <Exception>(() => Hub.JoinRoom(ROOM_ID));

            await Assert.ThrowsAsync <KeyNotFoundException>(() => Rooms.GetForUse(ROOM_ID));

            await Assert.ThrowsAsync <KeyNotFoundException>(() => UserStates.GetForUse(USER_ID));
        }
Esempio n. 5
0
        public async Task UserJoinPreJoinFailureCleansUpRoom()
        {
            Database.Setup(db => db.MarkRoomActiveAsync(It.IsAny <MultiplayerRoom>()))
            .ThrowsAsync(new Exception("error"));

            await Assert.ThrowsAnyAsync <Exception>(() => Hub.JoinRoom(ROOM_ID));

            await Assert.ThrowsAsync <KeyNotFoundException>(() => Rooms.GetForUse(ROOM_ID));

            await Assert.ThrowsAsync <KeyNotFoundException>(() => UserStates.GetForUse(USER_ID));
        }
Esempio n. 6
0
        public async Task UserCantJoinAlreadyEnded()
        {
            Database.Setup(db => db.GetRoomAsync(It.IsAny <long>()))
            .ReturnsAsync(new multiplayer_room
            {
                ends_at = DateTimeOffset.Now.AddMinutes(-5),
                user_id = USER_ID
            });

            await Assert.ThrowsAsync <InvalidStateException>(() => Hub.JoinRoom(ROOM_ID));

            // ensure no state was left behind.
            await Assert.ThrowsAsync <KeyNotFoundException>(() => UserStates.GetForUse(USER_ID));
        }