Browse Source

fix tests

pbs
jake 4 years ago
parent
commit
e3e5bff300
  1. 124
      tests/test_bank.rs
  2. 4
      tests/test_character.rs
  3. 72
      tests/test_item_pickup.rs
  4. 22
      tests/test_item_use.rs
  5. 20
      tests/test_mags.rs
  6. 52
      tests/test_shops.rs

124
tests/test_bank.rs

@ -33,7 +33,7 @@ async fn test_bank_items_sent_in_character_login() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -72,7 +72,7 @@ async fn test_request_bank_items() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -117,7 +117,7 @@ async fn test_request_stacked_bank_items() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -165,7 +165,7 @@ async fn test_request_bank_items_sorted() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Tool (
@ -177,7 +177,7 @@ async fn test_request_bank_items_sorted() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Weapon(
@ -194,7 +194,7 @@ async fn test_request_bank_items_sorted() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -243,7 +243,7 @@ async fn test_deposit_individual_item() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Weapon(
@ -261,7 +261,7 @@ async fn test_deposit_individual_item() {
slot: 1,
equipped: false,
}
}).await;
}).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -295,7 +295,7 @@ async fn test_deposit_individual_item() {
&& player_no_longer_has_item.amount == 0
));
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -329,7 +329,7 @@ async fn test_deposit_stacked_item() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -364,7 +364,7 @@ async fn test_deposit_stacked_item() {
&& player_no_longer_has_item.amount == 3
));
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -398,7 +398,7 @@ async fn test_deposit_partial_stacked_item() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -433,7 +433,7 @@ async fn test_deposit_partial_stacked_item() {
&& player_no_longer_has_item.amount == 2
));
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -480,7 +480,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
entity_gateway.create_item(
item::NewItemEntity {
@ -493,7 +493,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() {
character_id: char1.id,
name: item::BankName("".into()),
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -528,7 +528,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() {
&& player_no_longer_has_item.amount == 2
));
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -561,7 +561,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
}
for _ in 0..10 {
@ -576,7 +576,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() {
character_id: char1.id,
name: item::BankName("".into()),
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -604,7 +604,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() {
assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -653,7 +653,7 @@ async fn test_deposit_individual_item_in_full_bank() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
for _ in 0..200 {
entity_gateway.create_item(
@ -672,7 +672,7 @@ async fn test_deposit_individual_item_in_full_bank() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -700,7 +700,7 @@ async fn test_deposit_individual_item_in_full_bank() {
assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -745,7 +745,7 @@ async fn test_deposit_stacked_item_in_full_bank() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
}
for _ in 0..200 {
@ -765,7 +765,7 @@ async fn test_deposit_stacked_item_in_full_bank() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -793,7 +793,7 @@ async fn test_deposit_stacked_item_in_full_bank() {
assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -838,7 +838,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
}
for _ in 0..199 {
@ -858,7 +858,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
}
for _ in 0..2 {
@ -873,7 +873,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -899,7 +899,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() {
unknown: 0,
})))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -931,7 +931,7 @@ async fn test_deposit_meseta() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.meseta = 300;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -956,7 +956,7 @@ async fn test_deposit_meseta() {
unknown: 0,
})))).await.unwrap().for_each(drop);
let characters = entity_gateway.get_characters_by_user(&user1).await;
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let char = characters[0].as_ref().unwrap();
assert!(char.meseta == 277);
assert!(char.bank_meseta == 23);
@ -969,7 +969,7 @@ async fn test_deposit_too_much_meseta() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.meseta = 300;
char1.bank_meseta = 999980;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -994,7 +994,7 @@ async fn test_deposit_too_much_meseta() {
unknown: 0,
})))).await.unwrap().for_each(drop);
let characters = entity_gateway.get_characters_by_user(&user1).await;
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let char = characters[0].as_ref().unwrap();
assert!(char.meseta == 300);
assert!(char.bank_meseta == 999980);
@ -1033,7 +1033,7 @@ async fn test_deposit_meseta_when_bank_is_maxed() {
unknown: 0,
})))).await.unwrap().for_each(drop);
let characters = entity_gateway.get_characters_by_user(&user1).await;
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let char = characters[0].as_ref().unwrap();
assert!(char.meseta == 300);
assert!(char.bank_meseta == 999999);
@ -1063,7 +1063,7 @@ async fn test_withdraw_individual_item() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -1096,7 +1096,7 @@ async fn test_withdraw_individual_item() {
if create_item.item_id == 0x20000
));
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let inventory_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Inventory{..} = item.location {
@ -1129,7 +1129,7 @@ async fn test_withdraw_stacked_item() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -1163,7 +1163,7 @@ async fn test_withdraw_stacked_item() {
if create_item.item_id == 0x10002
));
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let inventory_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Inventory {..} = item.location {
@ -1196,7 +1196,7 @@ async fn test_withdraw_partial_stacked_item() {
character_id: char1.id,
name: item::BankName("".into())
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -1230,7 +1230,7 @@ async fn test_withdraw_partial_stacked_item() {
if create_item.item_id == 0x10002
));
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -1276,7 +1276,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
entity_gateway.create_item(
item::NewItemEntity {
@ -1289,7 +1289,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() {
character_id: char1.id,
name: item::BankName("".into()),
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -1323,7 +1323,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() {
if create_item.item_id == 0x10000
));
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let inventory_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Inventory {..} = item.location {
@ -1355,7 +1355,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() {
character_id: char1.id,
name: item::BankName("".into()),
}
}).await;
}).await.unwrap();
}
for _ in 0..10 {
@ -1371,7 +1371,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -1399,7 +1399,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() {
assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -1447,7 +1447,7 @@ async fn test_withdraw_individual_item_in_full_inventory() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
for i in 0..30 {
entity_gateway.create_item(
@ -1467,7 +1467,7 @@ async fn test_withdraw_individual_item_in_full_inventory() {
slot: i,
equipped: false,
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -1495,7 +1495,7 @@ async fn test_withdraw_individual_item_in_full_inventory() {
assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -1539,7 +1539,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
}
for i in 0..30 {
@ -1560,7 +1560,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() {
slot: i,
equipped: false,
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -1588,7 +1588,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() {
assert!(packets.is_err());
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -1632,7 +1632,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
character_id: char1.id,
name: item::BankName("".to_string())
}
}).await;
}).await.unwrap();
}
for i in 0..29 {
@ -1653,7 +1653,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
slot: i,
equipped: false,
}
}).await;
}).await.unwrap();
}
for _ in 0..2 {
@ -1669,7 +1669,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
slot: 29,
equipped: false,
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -1695,7 +1695,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
unknown: 0,
})))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let bank_item_ids = items.iter()
.filter_map(|item| {
if let item::ItemLocation::Bank {..} = item.location {
@ -1727,7 +1727,7 @@ async fn test_withdraw_meseta() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.bank_meseta = 300;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -1752,7 +1752,7 @@ async fn test_withdraw_meseta() {
unknown: 0,
})))).await.unwrap().for_each(drop);
let characters = entity_gateway.get_characters_by_user(&user1).await;
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let char = characters[0].as_ref().unwrap();
assert!(char.meseta == 23);
assert!(char.bank_meseta == 277);
@ -1765,7 +1765,7 @@ async fn test_withdraw_too_much_meseta() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.meseta = 999980;
char1.bank_meseta = 300;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -1790,7 +1790,7 @@ async fn test_withdraw_too_much_meseta() {
unknown: 0,
})))).await.unwrap().for_each(drop);
let characters = entity_gateway.get_characters_by_user(&user1).await;
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let char = characters[0].as_ref().unwrap();
assert!(char.meseta == 999980);
assert!(char.bank_meseta == 300);
@ -1803,7 +1803,7 @@ async fn test_withdraw_meseta_inventory_is_maxed() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.meseta = 999999;
char1.bank_meseta = 300;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -1828,7 +1828,7 @@ async fn test_withdraw_meseta_inventory_is_maxed() {
unknown: 0,
})))).await.unwrap().for_each(drop);
let characters = entity_gateway.get_characters_by_user(&user1).await;
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let char = characters[0].as_ref().unwrap();
assert!(char.meseta == 999999);
assert!(char.bank_meseta == 300);

4
tests/test_character.rs

@ -24,8 +24,8 @@ async fn test_save_options() {
options: 12345,
})).await.unwrap().for_each(drop);
let characters = entity_gateway.get_characters_by_user(&user1).await;
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let char = characters[0].as_ref().unwrap();
assert!(char.option_flags == 12345);
}
}

72
tests/test_item_pickup.rs

@ -29,7 +29,7 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
for (slot, tool) in vec![item::tool::ToolType::Monomate, item::tool::ToolType::Monofluid].into_iter().enumerate() {
for _ in 0..5 {
@ -45,7 +45,7 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() {
slot: slot,
equipped: false,
}
}).await;
}).await.unwrap();
}
}
@ -80,7 +80,7 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() {
unknown: [0; 3]
})))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(p1_items.len() == 6);
let p1_item_ids = p1_items.iter().map(|item| {
@ -116,7 +116,7 @@ async fn test_pick_up_item_stack_of_items_not_already_held() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -149,7 +149,7 @@ async fn test_pick_up_item_stack_of_items_not_already_held() {
unknown: [0; 3]
})))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(p1_items.len() == 1);
let first_item = p1_items.get(0).unwrap();
@ -184,11 +184,11 @@ async fn test_pick_up_meseta_when_inventory_full() {
slot: slot,
equipped: false,
}
}).await;
}).await.unwrap();
}
char2.meseta = 300;
entity_gateway.save_character(&char2).await;
entity_gateway.save_character(&char2).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -227,12 +227,12 @@ async fn test_pick_up_meseta_when_inventory_full() {
unknown: [0; 3]
})))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(p1_items.len() == 30);
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
let characters2 = entity_gateway.get_characters_by_user(&user2).await;
let characters2 = entity_gateway.get_characters_by_user(&user2).await.unwrap();
let c2 = characters2.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta == 23);
assert!(c2.meseta == 277);
@ -263,7 +263,7 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
slot: slot,
equipped: false,
}
}).await;
}).await.unwrap();
}
entity_gateway.create_item(
@ -278,7 +278,7 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
slot: 29,
equipped: false,
}
}).await;
}).await.unwrap();
entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Tool(
@ -291,7 +291,7 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -324,7 +324,7 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() {
unknown: [0; 3]
})))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(p1_items.len() == 31);
let monomate1 = p1_items.get(29).unwrap();
@ -362,7 +362,7 @@ async fn test_can_not_pick_up_item_when_inventory_full() {
slot: slot,
equipped: false,
}
}).await;
}).await.unwrap();
}
entity_gateway.create_item(
@ -382,7 +382,7 @@ async fn test_can_not_pick_up_item_when_inventory_full() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -415,10 +415,10 @@ async fn test_can_not_pick_up_item_when_inventory_full() {
unknown: [0; 3]
})))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(p1_items.len() == 30);
let p2_items = entity_gateway.get_items_by_character(&char2).await;
let p2_items = entity_gateway.get_items_by_character(&char2).await.unwrap();
assert!(p2_items.len() == 0);
ship.handle(ClientId(2), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
@ -429,7 +429,7 @@ async fn test_can_not_pick_up_item_when_inventory_full() {
unknown: [0; 3]
})))).await.unwrap().for_each(drop);
let p2_items = entity_gateway.get_items_by_character(&char2).await;
let p2_items = entity_gateway.get_items_by_character(&char2).await.unwrap();
assert!(p2_items.len() == 1);
}
@ -440,7 +440,7 @@ async fn test_can_not_drop_more_meseta_than_is_held() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.meseta = 300;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -469,7 +469,7 @@ async fn test_can_not_drop_more_meseta_than_is_held() {
})))).await;
assert!(split_attempt.is_err());
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta == 300);
}
@ -494,7 +494,7 @@ async fn test_pick_up_stack_that_would_exceed_stack_limit() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
}
for _ in 0..6 {
entity_gateway.create_item(
@ -509,7 +509,7 @@ async fn test_pick_up_stack_that_would_exceed_stack_limit() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -544,10 +544,10 @@ async fn test_pick_up_stack_that_would_exceed_stack_limit() {
})))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 0);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(p1_items.len() == 6);
let p2_items = entity_gateway.get_items_by_character(&char2).await;
let p2_items = entity_gateway.get_items_by_character(&char2).await.unwrap();
assert!(p2_items.len() == 0);
}
@ -559,9 +559,9 @@ async fn test_can_not_pick_up_meseta_when_full() {
let (user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
char1.meseta = 999999;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
char2.meseta = 300;
entity_gateway.save_character(&char2).await;
entity_gateway.save_character(&char2).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -601,9 +601,9 @@ async fn test_can_not_pick_up_meseta_when_full() {
})))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 0);
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
let characters2 = entity_gateway.get_characters_by_user(&user2).await;
let characters2 = entity_gateway.get_characters_by_user(&user2).await.unwrap();
let c2 = characters2.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta == 999999);
assert!(c2.meseta == 277);
@ -617,9 +617,9 @@ async fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() {
let (user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
char1.meseta = 999998;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
char2.meseta = 300;
entity_gateway.save_character(&char2).await;
entity_gateway.save_character(&char2).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -658,9 +658,9 @@ async fn test_meseta_caps_at_999999_when_trying_to_pick_up_more() {
unknown: [0; 3]
})))).await.unwrap().for_each(drop);
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
let characters2 = entity_gateway.get_characters_by_user(&user2).await;
let characters2 = entity_gateway.get_characters_by_user(&user2).await.unwrap();
let c2 = characters2.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta == 999999);
assert!(c2.meseta == 277);
@ -686,7 +686,7 @@ async fn test_player_drops_partial_stack_and_other_player_picks_it_up() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -726,7 +726,7 @@ async fn test_player_drops_partial_stack_and_other_player_picks_it_up() {
unknown: [0; 3]
})))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(p1_items.len() == 3);
let p1_item_ids = p1_items.iter().map(|item| {
@ -742,7 +742,7 @@ async fn test_player_drops_partial_stack_and_other_player_picks_it_up() {
});
assert!(all_items_are_monomates);
let p2_items = entity_gateway.get_items_by_character(&char2).await;
let p2_items = entity_gateway.get_items_by_character(&char2).await.unwrap();
assert!(p2_items.len() == 2);
let p2_item_ids = p2_items.iter().map(|item| {

22
tests/test_item_use.rs

@ -32,7 +32,7 @@ async fn test_use_monomate() {
slot: slot,
equipped: false,
}
}).await;
}).await.unwrap();
}
}
@ -49,7 +49,7 @@ async fn test_use_monomate() {
item_id: 0x10000,
})))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(items.iter().filter(|item| {
if let item::ItemDetail::Tool(t) = item.item {
t.tool == item::tool::ToolType::Monomate
@ -88,7 +88,7 @@ async fn test_use_monomate_twice() {
slot: slot,
equipped: false,
}
}).await;
}).await.unwrap();
}
}
@ -110,7 +110,7 @@ async fn test_use_monomate_twice() {
item_id: 0x10000,
})))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(items.iter().filter(|item| {
if let item::ItemDetail::Tool(t) = item.item {
t.tool == item::tool::ToolType::Monomate
@ -149,7 +149,7 @@ async fn test_use_last_monomate() {
slot: slot,
equipped: false,
}
}).await;
}).await.unwrap();
}
}
@ -166,7 +166,7 @@ async fn test_use_last_monomate() {
item_id: 0x10000,
})))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(items.iter().filter(|item| {
if let item::ItemDetail::Tool(t) = item.item {
t.tool == item::tool::ToolType::Monomate
@ -203,7 +203,7 @@ async fn test_use_nonstackable_tool() {
slot: 0,
equipped: false,
}
}).await;
}).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -218,7 +218,7 @@ async fn test_use_nonstackable_tool() {
item_id: 0x10000,
})))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(items.len() == 0);
}
@ -242,7 +242,7 @@ async fn test_use_materials() {
slot: slot,
equipped: false,
}
}).await;
}).await.unwrap();
}
}
@ -269,7 +269,7 @@ async fn test_use_materials() {
item_id: 0x10001,
})))).await.unwrap().for_each(drop);
let items = entity_gateway.get_items_by_character(&char1).await;
let items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(items.iter().filter(|item| {
if let item::ItemDetail::Tool(t) = item.item {
t.tool == item::tool::ToolType::PowerMaterial
@ -287,7 +287,7 @@ async fn test_use_materials() {
}
}).count() == 3);
let characters = entity_gateway.get_characters_by_user(&user1).await;
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let char = characters[0].as_ref().unwrap();
assert!(char.materials.power == 1);

20
tests/test_mags.rs

@ -27,7 +27,7 @@ async fn test_mag_feed() {
slot: 0,
equipped: true,
}
}).await;
}).await.unwrap();
for _ in 0..7 {
entity_gateway.create_item(
item::NewItemEntity {
@ -41,7 +41,7 @@ async fn test_mag_feed() {
slot: 1,
equipped: false,
}
}).await;
}).await.unwrap();
}
let mut ship = ShipServerState::builder()
@ -60,7 +60,7 @@ async fn test_mag_feed() {
})))).await.unwrap().for_each(drop);
}
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let mag = p1_items.get(0).unwrap();
match &mag.item {
item::ItemDetail::Mag(mag) => {
@ -82,10 +82,10 @@ async fn test_mag_change_owner() {
let (_user2, mut char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
char1.char_class = CharacterClass::RAmarl;
char1.section_id = SectionID::Redria;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
char2.char_class = CharacterClass::FOmarl;
char2.section_id = SectionID::Whitill;
entity_gateway.save_character(&char2).await;
entity_gateway.save_character(&char2).await.unwrap();
entity_gateway.create_item(
item::NewItemEntity {
@ -97,7 +97,7 @@ async fn test_mag_change_owner() {
slot: 0,
equipped: true,
}
}).await;
}).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -128,7 +128,7 @@ async fn test_mag_change_owner() {
unknown: [0; 3]
})))).await.unwrap().for_each(drop);
let p2_items = entity_gateway.get_items_by_character(&char2).await;
let p2_items = entity_gateway.get_items_by_character(&char2).await.unwrap();
let mag = p2_items.get(0).unwrap();
match &mag.item {
item::ItemDetail::Mag(mag) => {
@ -170,7 +170,7 @@ async fn test_mag_cell() {
mag: mag.id,
}
}).await.unwrap();
entity_gateway.feed_mag(&mag.id, &fed_tool.id).await;
entity_gateway.feed_mag(&mag.id, &fed_tool.id).await.unwrap();
}
entity_gateway.create_item(
item::NewItemEntity {
@ -184,7 +184,7 @@ async fn test_mag_cell() {
slot: 1,
equipped: false,
}
}).await;
}).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -199,7 +199,7 @@ async fn test_mag_cell() {
item_id: 0x10001,
})))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
let mag = p1_items.get(0).unwrap();
match &mag.item {
item::ItemDetail::Mag(mag) => {

52
tests/test_shops.rs

@ -17,7 +17,7 @@ async fn test_player_opens_weapon_shop() {
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -47,7 +47,7 @@ async fn test_player_opens_tool_shop() {
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -77,7 +77,7 @@ async fn test_player_opens_armor_shop() {
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.exp = 80000000;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -108,7 +108,7 @@ async fn test_player_buys_from_weapon_shop() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.exp = 80000000;
char1.meseta = 999999;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -132,10 +132,10 @@ async fn test_player_buys_from_weapon_shop() {
unknown1: 0,
})))).await.unwrap().for_each(drop);
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta < 999999);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert_eq!(p1_items.len(), 1);
}
@ -146,7 +146,7 @@ async fn test_player_buys_from_tool_shop() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.exp = 80000000;
char1.meseta = 999999;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -170,10 +170,10 @@ async fn test_player_buys_from_tool_shop() {
unknown1: 0,
})))).await.unwrap().for_each(drop);
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta < 999999);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert_eq!(p1_items.len(), 1);
}
@ -184,7 +184,7 @@ async fn test_player_buys_multiple_from_tool_shop() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.exp = 80000000;
char1.meseta = 999999;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -208,10 +208,10 @@ async fn test_player_buys_multiple_from_tool_shop() {
unknown1: 0,
})))).await.unwrap().for_each(drop);
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta < 999999);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert_eq!(p1_items.len(), 5);
}
@ -222,7 +222,7 @@ async fn test_player_buys_from_armor_shop() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.exp = 80000000;
char1.meseta = 999999;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -246,10 +246,10 @@ async fn test_player_buys_from_armor_shop() {
unknown1: 0,
})))).await.unwrap().for_each(drop);
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta < 999999);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert_eq!(p1_items.len(), 1);
}
@ -265,7 +265,7 @@ async fn test_other_clients_see_purchase() {
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
char1.exp = 80000000;
char1.meseta = 999999;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -308,7 +308,7 @@ async fn test_other_clients_see_stacked_purchase() {
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
char1.exp = 80000000;
char1.meseta = 999999;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Tool(
@ -385,10 +385,10 @@ async fn test_buying_item_without_enough_mseseta() {
})))).await;
assert!(packets.is_err());
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert_eq!(c1.meseta, 0);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert_eq!(p1_items.len(), 0);
}
@ -399,7 +399,7 @@ async fn test_player_double_buys_from_tool_shop() {
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.exp = 80000000;
char1.meseta = 999999;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -441,10 +441,10 @@ async fn test_player_double_buys_from_tool_shop() {
unknown1: 0,
})))).await.unwrap().for_each(drop);
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
assert!(c1.meseta < 999999);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert_eq!(p1_items.len(), 9);
}
@ -456,7 +456,7 @@ async fn test_techs_disappear_from_shop_when_bought() {
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.exp = 80000000;
char1.meseta = 999999;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -502,7 +502,7 @@ async fn test_techs_disappear_from_shop_when_bought() {
unknown1: 0,
})))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(p1_items[0].item != p1_items[1].item);
}
@ -514,7 +514,7 @@ async fn test_units_disappear_from_shop_when_bought() {
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
char1.exp = 80000000;
char1.meseta = 999999;
entity_gateway.save_character(&char1).await;
entity_gateway.save_character(&char1).await.unwrap();
let mut ship = ShipServerState::builder()
.gateway(entity_gateway.clone())
@ -560,6 +560,6 @@ async fn test_units_disappear_from_shop_when_bought() {
unknown1: 0,
})))).await.unwrap().for_each(drop);
let p1_items = entity_gateway.get_items_by_character(&char1).await;
let p1_items = entity_gateway.get_items_by_character(&char1).await.unwrap();
assert!(p1_items[0].item != p1_items[1].item);
}
Loading…
Cancel
Save