293 lines
10 KiB
C#
293 lines
10 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using NUnit.Framework;
|
|
|
|
namespace Assets.Data
|
|
{
|
|
[TestFixture]
|
|
public class TestTraitsMapping
|
|
{
|
|
[Test]
|
|
[TestCaseSource(typeof(TraitsMappingCase), "ChampCombination")]
|
|
public void TestChampCombination(
|
|
long mandatoryChamps,
|
|
long possibleChamps,
|
|
int n,
|
|
List<long> expected
|
|
)
|
|
{
|
|
List<long> output = TraitsMapping.GenerateCombinations(
|
|
mandatoryChamps,
|
|
possibleChamps,
|
|
n
|
|
);
|
|
foreach (long champ in expected)
|
|
{
|
|
Assert.IsTrue(output.Contains(champ));
|
|
}
|
|
|
|
foreach (long champ in output)
|
|
{
|
|
Assert.IsTrue(expected.Contains(champ));
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
[TestCaseSource(typeof(TraitsMappingCase), "TestFilteringChampCombination")]
|
|
public void TestFilteringChampCombination(
|
|
long accessibleChampions,
|
|
long subselectedChampions,
|
|
long expected
|
|
)
|
|
{
|
|
var output = TraitsMapping.SelectSublistOfChampion(accessibleChampions, subselectedChampions);
|
|
Assert.AreEqual(expected, output);
|
|
}
|
|
}
|
|
|
|
public class TraitsMappingCase
|
|
{
|
|
public static IEnumerable ChampCombination
|
|
{
|
|
get
|
|
{
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.ASHE,
|
|
ChampionsEnum.BLITZCRANK,
|
|
}
|
|
),
|
|
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() { ChampionsEnum.ELISE }),
|
|
3,
|
|
new List<long>()
|
|
{
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.ASHE,
|
|
ChampionsEnum.BLITZCRANK,
|
|
ChampionsEnum.ELISE,
|
|
}
|
|
),
|
|
}
|
|
);
|
|
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.ASHE,
|
|
ChampionsEnum.BLITZCRANK,
|
|
}
|
|
),
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.ELISE,
|
|
ChampionsEnum.AHRI,
|
|
ChampionsEnum.CASSIOPEIA,
|
|
ChampionsEnum.EZREAL,
|
|
}
|
|
),
|
|
5,
|
|
new List<long>()
|
|
{
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.ASHE,
|
|
ChampionsEnum.BLITZCRANK,
|
|
ChampionsEnum.ELISE,
|
|
ChampionsEnum.AHRI,
|
|
ChampionsEnum.CASSIOPEIA,
|
|
}
|
|
),
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.ASHE,
|
|
ChampionsEnum.BLITZCRANK,
|
|
ChampionsEnum.ELISE,
|
|
ChampionsEnum.AHRI,
|
|
ChampionsEnum.EZREAL,
|
|
}
|
|
),
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.ASHE,
|
|
ChampionsEnum.BLITZCRANK,
|
|
ChampionsEnum.ELISE,
|
|
ChampionsEnum.CASSIOPEIA,
|
|
ChampionsEnum.EZREAL,
|
|
}
|
|
),
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.ASHE,
|
|
ChampionsEnum.BLITZCRANK,
|
|
ChampionsEnum.AHRI,
|
|
ChampionsEnum.CASSIOPEIA,
|
|
ChampionsEnum.EZREAL,
|
|
}
|
|
),
|
|
}
|
|
);
|
|
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>() { ChampionsEnum.AHRI, ChampionsEnum.AKALI }
|
|
),
|
|
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() { ChampionsEnum.ELISE }),
|
|
3,
|
|
new List<long>()
|
|
{
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.AHRI,
|
|
ChampionsEnum.AKALI,
|
|
ChampionsEnum.ELISE,
|
|
}
|
|
),
|
|
}
|
|
);
|
|
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.AHRI,
|
|
ChampionsEnum.POPPY,
|
|
ChampionsEnum.SORAKA,
|
|
ChampionsEnum.XERATH,
|
|
}
|
|
),
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.SMOLDER,
|
|
ChampionsEnum.MORDEKAISER,
|
|
}
|
|
),
|
|
4,
|
|
new List<long>()
|
|
{
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.AHRI,
|
|
ChampionsEnum.POPPY,
|
|
ChampionsEnum.SORAKA,
|
|
ChampionsEnum.XERATH,
|
|
}
|
|
),
|
|
}
|
|
);
|
|
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.RUMBLE,
|
|
ChampionsEnum.GALIO,
|
|
ChampionsEnum.AKALI,
|
|
ChampionsEnum.BARD,
|
|
}
|
|
),
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.MORGANA,
|
|
ChampionsEnum.FIORA,
|
|
ChampionsEnum.VARUS,
|
|
}
|
|
),
|
|
7,
|
|
new List<long>()
|
|
{
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.RUMBLE,
|
|
ChampionsEnum.GALIO,
|
|
ChampionsEnum.AKALI,
|
|
ChampionsEnum.BARD,
|
|
ChampionsEnum.MORGANA,
|
|
ChampionsEnum.FIORA,
|
|
ChampionsEnum.VARUS
|
|
}
|
|
),
|
|
}
|
|
);
|
|
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.RUMBLE,
|
|
ChampionsEnum.GALIO,
|
|
ChampionsEnum.AKALI,
|
|
ChampionsEnum.BARD,
|
|
ChampionsEnum.MORGANA,
|
|
ChampionsEnum.FIORA,
|
|
ChampionsEnum.VARUS
|
|
}
|
|
),
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.XERATH
|
|
}
|
|
),
|
|
7,
|
|
new List<long>()
|
|
{
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.RUMBLE,
|
|
ChampionsEnum.GALIO,
|
|
ChampionsEnum.AKALI,
|
|
ChampionsEnum.BARD,
|
|
ChampionsEnum.MORGANA,
|
|
ChampionsEnum.FIORA,
|
|
ChampionsEnum.VARUS
|
|
}
|
|
),
|
|
}
|
|
);
|
|
}
|
|
}
|
|
|
|
public static IEnumerable TestFilteringChampCombination
|
|
{
|
|
get
|
|
{
|
|
yield return new TestCaseData(
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.ASHE,
|
|
ChampionsEnum.BLITZCRANK,
|
|
ChampionsEnum.ELISE,
|
|
ChampionsEnum.JAX
|
|
}
|
|
),
|
|
0b0101,
|
|
ChampionUtils.ToLong(
|
|
new HashSet<ChampionsEnum>()
|
|
{
|
|
ChampionsEnum.ASHE,
|
|
ChampionsEnum.ELISE
|
|
}
|
|
)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|