77 lines
2.4 KiB
C#
77 lines
2.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using NUnit.Framework;
|
|
|
|
namespace Assets.Data
|
|
{
|
|
[TestFixture]
|
|
public class TestChampionUtils
|
|
{
|
|
[Test]
|
|
[TestCaseSource(typeof(ChampionCase), "championsEnum")]
|
|
public void TestIntChampion(long champlong)
|
|
{
|
|
var champs = ChampionUtils.FromLong(champlong);
|
|
long output = ChampionUtils.ToLong(champs);
|
|
Assert.IsTrue(champlong == output);
|
|
}
|
|
|
|
[Test]
|
|
[TestCaseSource(typeof(ChampionCase), "championsNth")]
|
|
public void TestGetNthChampion(long champlons, int n, long expected)
|
|
{
|
|
long output = ChampionUtils.GetNthChampion(champlons, n);
|
|
Assert.IsTrue(output == expected);
|
|
}
|
|
}
|
|
|
|
public class ChampionCase
|
|
{
|
|
public static IEnumerable championsEnum
|
|
{
|
|
get
|
|
{
|
|
yield return 1223456L;
|
|
yield return 3422L;
|
|
yield return 97352L;
|
|
yield return 67855324254L;
|
|
yield return 432742125L;
|
|
yield return 76578256785L;
|
|
yield return 12345678912345678L;
|
|
}
|
|
}
|
|
|
|
public static IEnumerable championsNth
|
|
{
|
|
get
|
|
{
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(ChampionsEnum.ASHE),
|
|
0,
|
|
ChampionUtils.ToLong(ChampionsEnum.ASHE)
|
|
);
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(ChampionsEnum.SMOLDER),
|
|
0,
|
|
ChampionUtils.ToLong(ChampionsEnum.SMOLDER)
|
|
);
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() { ChampionsEnum.AHRI }),
|
|
0,
|
|
ChampionUtils.ToLong(ChampionsEnum.AHRI)
|
|
);
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() {
|
|
ChampionsEnum.AHRI,
|
|
ChampionsEnum.POPPY,
|
|
ChampionsEnum.SORAKA,
|
|
ChampionsEnum.HWEI }),
|
|
1,
|
|
ChampionUtils.ToLong(ChampionsEnum.SORAKA)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|