local ICharaEquipStyle = require("api.chara.aspect.ICharaEquipStyle")
local TestUtil = require("api.test.TestUtil")
local Assert = require("api.test.Assert")

function test_ICharaEquipStyle_refresh_melee_equip_style__dual_wield()
   local chara = TestUtil.stripped_chara("elona.asura")
   local aspect = chara:get_aspect(ICharaEquipStyle)

   Assert.eq(false, aspect:calc(chara, "is_dual_wielding"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_two_handed"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_shield"))

   local dagger = TestUtil.stripped_item("elona.dagger", chara)
   Assert.is_truthy(chara:equip_item(dagger))
   chara:refresh()
   Assert.eq(false, aspect:calc(chara, "is_dual_wielding"))
   Assert.eq(true, aspect:calc(chara, "is_wielding_two_handed"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_shield"))

   local sword = TestUtil.stripped_item("elona.long_sword", chara)
   Assert.is_truthy(chara:equip_item(sword))
   chara:refresh()
   Assert.eq(true, aspect:calc(chara, "is_dual_wielding"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_two_handed"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_shield"))

   local axe = TestUtil.stripped_item("elona.battle_axe", chara)
   Assert.is_truthy(chara:equip_item(axe))
   chara:refresh()
   Assert.eq(true, aspect:calc(chara, "is_dual_wielding"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_two_handed"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_shield"))

   Assert.is_truthy(chara:unequip_item(dagger))
   Assert.is_truthy(chara:unequip_item(sword))
   Assert.is_truthy(chara:unequip_item(axe))
   chara:refresh()
   Assert.eq(false, aspect:calc(chara, "is_dual_wielding"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_two_handed"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_shield"))
end

function test_ICharaEquipStyle_refresh_melee_equip_style__shield()
   local chara = TestUtil.stripped_chara("elona.asura")
   local aspect = chara:get_aspect(ICharaEquipStyle)

   Assert.eq(false, aspect:calc(chara, "is_dual_wielding"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_two_handed"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_shield"))

   local dagger = TestUtil.stripped_item("elona.dagger", chara)
   Assert.is_truthy(chara:equip_item(dagger))
   chara:refresh()
   Assert.eq(false, aspect:calc(chara, "is_dual_wielding"))
   Assert.eq(true, aspect:calc(chara, "is_wielding_two_handed"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_shield"))

   local shield = TestUtil.stripped_item("elona.small_shield", chara)
   Assert.is_truthy(chara:equip_item(shield))
   chara:refresh()
   Assert.eq(false, aspect:calc(chara, "is_dual_wielding"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_two_handed"))
   Assert.eq(true, aspect:calc(chara, "is_wielding_shield"))

   local axe = TestUtil.stripped_item("elona.battle_axe", chara)
   Assert.is_truthy(chara:equip_item(axe))
   chara:refresh()
   Assert.eq(false, aspect:calc(chara, "is_dual_wielding"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_two_handed"))
   Assert.eq(true, aspect:calc(chara, "is_wielding_shield"))

   Assert.is_truthy(chara:unequip_item(dagger))
   Assert.is_truthy(chara:unequip_item(shield))
   Assert.is_truthy(chara:unequip_item(axe))
   chara:refresh()
   Assert.eq(false, aspect:calc(chara, "is_dual_wielding"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_two_handed"))
   Assert.eq(false, aspect:calc(chara, "is_wielding_shield"))
end
