From 114ed07adc54fa5baac19c1a60e5b3113936e275 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 2 Oct 2020 22:17:00 -0300 Subject: [PATCH] tests! --- tests/test_character.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/test_character.rs diff --git a/tests/test_character.rs b/tests/test_character.rs new file mode 100644 index 0000000..c6196b8 --- /dev/null +++ b/tests/test_character.rs @@ -0,0 +1,31 @@ +use elseware::common::serverstate::{ClientId, ServerState}; +use elseware::entity::gateway::{EntityGateway, InMemoryGateway}; +use elseware::ship::ship::{ShipServerState, RecvShipPacket}; + +use libpso::packet::ship::*; + +#[path = "common.rs"] +mod common; +use common::*; + +#[async_std::test] +pub async fn test_save_options(ship: &mut ShipServerState, id: ClientId, options: u32) { + let mut entity_gateway = InMemoryGateway::new(); + + let (user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await; + + let mut ship = ShipServerState::builder() + .gateway(entity_gateway.clone()) + .build(); + log_in_char(&mut ship, ClientId(1), "a1", "a").await; + join_lobby(&mut ship, ClientId(1)).await; + + ship.handle(ClientId(1), &RecvShipPacket::SaveOptions(SaveOptions{ + options: 12345, + })).await.unwrap().for_each(drop); + + let characters = entity_gateway.get_characters_by_user(&user1).await; + let char = characters[0].as_ref().unwrap(); + + assert!(char.option_flags == 12345); +}