Add more actionset tests
This commit is contained in:
@@ -36,11 +36,11 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
dotnet build --configuration Release
|
||||
dotnet build --configuration Release --no-restore
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
dotnet test --configuration Release --logger "trx;logfilename=results.trx" --logger "html;logfilename=results.html" --logger "console;verbosity=detailed" --results-directory="TestResults"
|
||||
dotnet test --configuration Release --logger "trx;logfilename=results.trx" --logger "html;logfilename=results.html" --logger "console;verbosity=detailed" --no-build --results-directory="TestResults"
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ActionSetTests
|
||||
var lut = Craftimizer.Solver.Simulator.AcceptedActionsLUT;
|
||||
|
||||
Assert.IsTrue(actions.Length <= 32);
|
||||
foreach(var i in Enum.GetValues<ActionType>())
|
||||
foreach (var i in Enum.GetValues<ActionType>())
|
||||
{
|
||||
var idx = lut[(byte)i];
|
||||
if (idx != 0)
|
||||
@@ -29,7 +29,7 @@ public class ActionSetTests
|
||||
|
||||
set.AddAction(ActionType.BasicSynthesis);
|
||||
set.AddAction(ActionType.WasteNot2);
|
||||
|
||||
|
||||
Assert.AreEqual(2, set.Count);
|
||||
Assert.IsFalse(set.IsEmpty);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ActionSetTests
|
||||
|
||||
Assert.IsTrue(set.RemoveAction(ActionType.BasicSynthesis));
|
||||
Assert.IsFalse(set.RemoveAction(ActionType.BasicSynthesis));
|
||||
|
||||
|
||||
Assert.IsTrue(set.AddAction(ActionType.BasicSynthesis));
|
||||
Assert.IsTrue(set.AddAction(ActionType.WasteNot2));
|
||||
|
||||
@@ -101,4 +101,34 @@ public class ActionSetTests
|
||||
Assert.AreEqual(ActionType.ByregotsBlessing, set.ElementAt(1));
|
||||
Assert.AreEqual(ActionType.BasicSynthesis, set.ElementAt(2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestRandomIndex()
|
||||
{
|
||||
var actions = new[]
|
||||
{
|
||||
ActionType.BasicTouch,
|
||||
ActionType.BasicSynthesis,
|
||||
ActionType.GreatStrides,
|
||||
ActionType.TrainedFinesse,
|
||||
};
|
||||
|
||||
var set = new ActionSet();
|
||||
foreach(var action in actions)
|
||||
set.AddAction(action);
|
||||
|
||||
var counts = new Dictionary<ActionType, int>();
|
||||
var rng = new Random(0);
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var action = set.SelectRandom(rng);
|
||||
|
||||
Assert.IsTrue(actions.Contains(action));
|
||||
|
||||
counts[action] = counts.GetValueOrDefault(action) + 1;
|
||||
}
|
||||
|
||||
foreach (var action in actions)
|
||||
Assert.IsTrue(counts.GetValueOrDefault(action) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user