Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
U-lis committed Aug 29, 2024
1 parent 5aa7a6a commit f7f14b3
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .Lib9c.Tests/Action/HackAndSlashSweepTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -705,5 +705,64 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2
throw new SheetRowNotFoundException(nameof(StageSheet), stageId);
}
}

[Theory]
[InlineData(0, -1)]
[InlineData(0, int.MinValue + 1)]
[InlineData(-1, 0)]
[InlineData(int.MinValue + 1, 0)]
public void Execute_ArgumentOutOfRangeException(int ap, int apPotion)
{
var avatarState = new AvatarState(
_avatarAddress,
_agentAddress,
0,
_initialState.GetAvatarSheets(),
_rankingMapAddress)
{
worldInformation =
new WorldInformation(0, _initialState.GetSheet<WorldSheet>(), 25),
level = 400,
};

IWorld state = _initialState.SetAvatarState(_avatarAddress, avatarState)
.SetActionPoint(_avatarAddress, 0);
var actionPoint = _initialState.GetActionPoint(_avatarAddress);

var stageSheet = _initialState.GetSheet<StageSheet>();
var (expectedLevel, expectedExp) = (0, 0L);
if (stageSheet.TryGetValue(2, out var stageRow))
{
var itemPlayCount =
DailyReward.ActionPointMax / stageRow.CostAP * 1;
var apPlayCount = actionPoint / stageRow.CostAP;
var playCount = apPlayCount + itemPlayCount;
(expectedLevel, expectedExp) = avatarState.GetLevelAndExp(
_tableSheets.CharacterLevelSheet,
2,
(int)playCount);

var (equipments, costumes) = GetDummyItems(avatarState);
var action = new HackAndSlashSweep
{
runeInfos = new List<RuneSlotInfo>(),
costumes = costumes,
equipments = equipments,
avatarAddress = _avatarAddress,
actionPoint = ap,
apStoneCount = apPotion,
worldId = 1,
stageId = 2,
};

Assert.Throws<ArgumentOutOfRangeException>(() =>
action.Execute(new ActionContext()
{
PreviousState = state,
Signer = _agentAddress,
RandomSeed = 0,
}));
}
}
}
}

0 comments on commit f7f14b3

Please sign in to comment.