public void GetArenaInfos_By_Upper_And_Lower_Range(int infoCount, int targetRank, int upperRange, int lowerRange, int expected) { var tableState = TableSheets.FromTableSheetsState(TableSheetsImporter.ImportTableSheets()); var weeklyArenaState = new WeeklyArenaState(new PrivateKey().ToAddress()); Address targetAddress; for (var i = 0; i < infoCount; i++) { var avatarAddress = new PrivateKey().ToAddress(); if (i + 1 == targetRank) { targetAddress = avatarAddress; } var avatarState = new AvatarState( avatarAddress, new PrivateKey().ToAddress(), 0L, tableState, new GameConfigState(), i.ToString()); weeklyArenaState.Add( new PrivateKey().ToAddress(), new ArenaInfo(avatarState, tableState.CharacterSheet, true)); } var arenaInfos = weeklyArenaState.GetArenaInfos(targetAddress, upperRange, lowerRange); Assert.Equal(expected, arenaInfos.Count); }
private void UpdateArenaInfo(WeeklyArenaState weeklyArenaState) { var avatarAddress = States.Instance.CurrentAvatarState?.address; if (avatarAddress == null) { winCount.text = "-"; loseCount.text = "-"; return; } var arenaInfos = weeklyArenaState .GetArenaInfos(avatarAddress.Value, 0, 0); if (arenaInfos.Count == 0) { winCount.text = "-"; loseCount.text = "-"; return; } var record = arenaInfos[0].arenaInfo.ArenaRecord; winCount.text = record.Win.ToString(); loseCount.text = record.Lose.ToString(); }
public void GetArenaInfos_By_FirstRank_And_Count_Throw(int infoCount, int firstRank) { var tableState = TableSheets.FromTableSheetsState(TableSheetsImporter.ImportTableSheets()); var weeklyArenaState = new WeeklyArenaState(new PrivateKey().ToAddress()); for (var i = 0; i < infoCount; i++) { var avatarState = new AvatarState( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), 0L, tableState, new GameConfigState(), i.ToString()); weeklyArenaState.Add( new PrivateKey().ToAddress(), new ArenaInfo(avatarState, tableState.CharacterSheet, true)); } Assert.Throws <ArgumentOutOfRangeException>(() => weeklyArenaState.GetArenaInfos(firstRank, 100)); }
public void GetArenaInfos_By_FirstRank_And_Count(int infoCount, int firstRank, int count, int expected) { var tableState = TableSheets.FromTableSheetsState(TableSheetsImporter.ImportTableSheets()); var weeklyArenaState = new WeeklyArenaState(new PrivateKey().ToAddress()); for (var i = 0; i < infoCount; i++) { var avatarState = new AvatarState( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), 0L, tableState, new GameConfigState(), i.ToString()); weeklyArenaState.Add( new PrivateKey().ToAddress(), new ArenaInfo(avatarState, tableState.CharacterSheet, true)); } var arenaInfos = weeklyArenaState.GetArenaInfos(firstRank, count); Assert.Equal(expected, arenaInfos.Count); }