|
@ -157,3 +157,70 @@ async fn test_set_invalid_quest_group() { |
|
|
_ => panic!("Wrong quest category"),
|
|
|
_ => panic!("Wrong quest category"),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_get_room_info() {
|
|
|
|
|
|
let mut entity_gateway = InMemoryGateway::default();
|
|
|
|
|
|
let (_user1, mut _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
|
|
_char1.name = String::from("GODmar");
|
|
|
|
|
|
entity_gateway.save_character(&_char1).await.unwrap();
|
|
|
|
|
|
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
|
|
.build());
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a").await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
let _expectedmsg = String::from("1 Lv1 GODmar\nHUmar Pioneer 2\n");
|
|
|
|
|
|
let packets = ship.handle(ClientId(2), &RecvShipPacket::MenuDetail(MenuDetail{menu: 3, item: 0})).await.unwrap().collect::<Vec<_>>();
|
|
|
|
|
|
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::SmallLeftDialog(SmallLeftDialog{
|
|
|
|
|
|
padding: [17664, 1157645568],
|
|
|
|
|
|
msg: _expectedmsg,
|
|
|
|
|
|
}))));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_cannot_get_room_info_after_room_is_closed() {
|
|
|
|
|
|
let mut entity_gateway = InMemoryGateway::default();
|
|
|
|
|
|
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
|
|
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
|
|
.build());
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a").await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
leave_room(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
let _expectedmsg = String::from("Game is no longer active!\0");
|
|
|
|
|
|
let packets = ship.handle(ClientId(2), &RecvShipPacket::MenuDetail(MenuDetail{menu: 3, item: 0})).await.unwrap().collect::<Vec<_>>();
|
|
|
|
|
|
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::SmallLeftDialog(SmallLeftDialog{
|
|
|
|
|
|
padding: [17664, 1157645568],
|
|
|
|
|
|
msg: _expectedmsg,
|
|
|
|
|
|
}))));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
|
|
async fn test_cannot_join_room_after_its_closed() {
|
|
|
|
|
|
let mut entity_gateway = InMemoryGateway::default();
|
|
|
|
|
|
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
|
|
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
|
|
.build());
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
|
|
log_in_char(&mut ship, ClientId(2), "a2", "a").await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
join_lobby(&mut ship, ClientId(2)).await;
|
|
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
leave_room(&mut ship, ClientId(1)).await;
|
|
|
|
|
|
let _expectedmsg = String::from("This room no longer exists!\0");
|
|
|
|
|
|
let packets = ship.handle(ClientId(2), &RecvShipPacket::MenuSelect(MenuSelect{menu: 3, item: 0})).await.unwrap().collect::<Vec<_>>();
|
|
|
|
|
|
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::SmallDialog(SmallDialog{
|
|
|
|
|
|
padding: [0,0],
|
|
|
|
|
|
msg: _expectedmsg, // wow yes cool rust is so great literally the best i can't put a String::from() directly in here.
|
|
|
|
|
|
}))));
|
|
|
|
|
|
}
|