public async Task LastUserLeavingCausesRoomDisband() { SetUserContext(ContextUser); await Hub.JoinRoom(ROOM_ID); Database.Verify(db => db.AddRoomParticipantAsync(It.IsAny <MultiplayerRoom>(), It.IsAny <MultiplayerRoomUser>()), Times.Exactly(1)); SetUserContext(ContextUser2); await Hub.JoinRoom(ROOM_ID); Database.Verify(db => db.AddRoomParticipantAsync(It.IsAny <MultiplayerRoom>(), It.IsAny <MultiplayerRoomUser>()), Times.Exactly(2)); SetUserContext(ContextUser); await Hub.LeaveRoom(); Database.Verify(db => db.RemoveRoomParticipantAsync(It.IsAny <MultiplayerRoom>(), It.IsAny <MultiplayerRoomUser>()), Times.Exactly(1)); // room still exists even though the original host left Assert.True(Hub.CheckRoomExists(ROOM_ID)); SetUserContext(ContextUser2); await Hub.LeaveRoom(); Database.Verify(db => db.RemoveRoomParticipantAsync(It.IsAny <MultiplayerRoom>(), It.IsAny <MultiplayerRoomUser>()), Times.Exactly(2)); // room is gone. Assert.False(Hub.CheckRoomExists(ROOM_ID)); }