Пример #1
0
  @Test
  public void testCreateRoomByUser() {
    when(service.getUserBySession(anyString())).thenReturn(null);
    Room endRoom = gameServer.createRoom("aaa", "aaa", null);
    assertNull(endRoom);

    Room room = new RoomFFA("aaa");
    UserProfile profile = spy(new UserProfile("aa", "bb"));
    when(service.getUserBySession(anyString())).thenReturn(profile);
    when(profile.getCurrentroom()).thenReturn(room);

    endRoom = gameServer.createRoom("aaa", "aaa", null);
    assertNull(endRoom);
  }
Пример #2
0
  @Test
  public void testCreateRoomAlreadyExist() {
    UserProfile profile = spy(new UserProfile("aa", "bb"));
    when(service.getUserBySession(anyString())).thenReturn(profile);
    when(profile.getCurrentroom()).thenReturn(null);
    when(rooms.containsKey(anyString())).thenReturn(true);

    Room room = gameServer.createRoom("aaa", "aaa", null);

    assertNull(room);
  }