Rename test project folder

This commit is contained in:
Asriel Camora
2023-11-06 16:31:51 -08:00
parent 80a758e24b
commit 9a490c1653
5 changed files with 1 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<Platforms>x64</Platforms>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Simulator\Craftimizer.Simulator.csproj" />
<ProjectReference Include="..\Solver\Craftimizer.Solver.csproj" />
</ItemGroup>
<PropertyGroup Condition="'$(IS_BENCH)'=='1'">
<DefineConstants>$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
</PropertyGroup>
</Project>
+233
View File
@@ -0,0 +1,233 @@
using Craftimizer.Simulator.Actions;
namespace Craftimizer.Test.Simulator;
[TestClass]
public class SimulatorTests
{
// https://craftingway.app/rotation/loud-namazu-jVe9Y
// Chondrite Saw
private static SimulationInput Input1 { get; } =
new(new()
{
Craftsmanship = 3304,
Control = 3374,
CP = 575,
Level = 90,
CanUseManipulation = true,
HasSplendorousBuff = false,
IsSpecialist = false,
CLvl = 560,
},
new()
{
IsExpert = false,
ClassJobLevel = 90,
RLvl = 560,
ConditionsFlag = 0b1111,
MaxDurability = 80,
MaxQuality = 7200,
MaxProgress = 3500,
QualityModifier = 80,
QualityDivider = 115,
ProgressModifier = 90,
ProgressDivider = 130
});
// Conflicting Info:
// https://craftingway.app/rotation/sandy-fafnir-doVCs
// Classical Longsword
private static SimulationInput Input2 { get; } =
new(new()
{
Craftsmanship = 3290,
Control = 3541,
CP = 649,
Level = 90,
CanUseManipulation = true,
HasSplendorousBuff = false,
IsSpecialist = false,
CLvl = 560,
},
new()
{
IsExpert = false,
ClassJobLevel = 90,
RLvl = 580,
ConditionsFlag = 0b1111,
MaxDurability = 70,
MaxQuality = 10920,
MaxProgress = 3900,
QualityModifier = 70,
QualityDivider = 115,
ProgressModifier = 80,
ProgressDivider = 130
});
private static SimulationState AssertCraft(SimulationInput input, IEnumerable<ActionType> actions,
int progress, int quality,
int durability, int cp)
{
var simulator = new SimulatorNoRandom(new(input));
var (_, state, _) = simulator.ExecuteMultiple(new(input), actions);
Assert.AreEqual(progress, state.Progress);
Assert.AreEqual(quality, state.Quality);
Assert.AreEqual(durability, state.Durability);
Assert.AreEqual(cp, state.CP);
return state;
}
[TestMethod]
public void BasicActions()
{
AssertCraft(
Input1,
new[] {
ActionType.BasicTouch,
ActionType.BasicSynthesis,
ActionType.MastersMend
},
276, 262, 80, 469);
}
[TestMethod]
public void BasicTouchCombo()
{
AssertCraft(
Input1,
new[] {
ActionType.Innovation,
ActionType.BasicTouch,
ActionType.StandardTouch,
ActionType.AdvancedTouch,
ActionType.StandardTouch,
ActionType.AdvancedTouch
},
0, 2828, 30, 425);
}
[TestMethod]
public void WithBuffs1()
{
AssertCraft(
Input1,
new[] {
ActionType.Reflect,
ActionType.Manipulation,
ActionType.PreparatoryTouch,
ActionType.WasteNot2
},
0, 890, 60, 335);
}
[TestMethod]
public void WithBuffs2()
{
AssertCraft(
Input1,
new[] {
ActionType.MuscleMemory,
ActionType.GreatStrides,
ActionType.PrudentTouch,
ActionType.DelicateSynthesis
},
1150, 812, 55, 480);
}
[TestMethod]
public void WithBuffs3()
{
AssertCraft(
Input1,
new[] {
ActionType.MuscleMemory,
ActionType.Manipulation,
ActionType.MastersMend,
ActionType.WasteNot2,
ActionType.Innovation,
ActionType.DelicateSynthesis,
ActionType.BasicTouch,
ActionType.GreatStrides,
ActionType.ByregotsBlessing
},
1150, 1925, 80, 163);
}
[TestMethod]
public void TrainedFinesseProcs()
{
var state = AssertCraft(
Input1,
new[] {
ActionType.Reflect,
ActionType.WasteNot,
ActionType.PreparatoryTouch,
ActionType.PreparatoryTouch,
ActionType.BasicTouch,
ActionType.StandardTouch,
ActionType.PrudentTouch,
ActionType.PreparatoryTouch
},
0, 4064, 15, 332);
Assert.AreEqual(10, state.ActiveEffects.InnerQuiet);
Assert.IsTrue(ActionType.TrainedFinesse.Base().CanUse(new SimulatorNoRandom(state)));
}
[TestMethod]
public void TestCompletedCraft1()
{
AssertCraft(
Input1,
new[] {
ActionType.Reflect,
ActionType.Manipulation,
ActionType.PreparatoryTouch,
ActionType.WasteNot2,
ActionType.PreparatoryTouch,
ActionType.Innovation,
ActionType.PreparatoryTouch,
ActionType.PreparatoryTouch,
ActionType.GreatStrides,
ActionType.ByregotsBlessing,
ActionType.Veneration,
ActionType.Groundwork,
ActionType.Groundwork,
ActionType.Groundwork,
},
3726, 8224, 5, 69);
}
[TestMethod]
public void TestCompletedCraft2()
{
Console.WriteLine($"{Input2.BaseProgressGain} {Input2.BaseProgressGain * (3.6f * 2.5f)}");
Console.WriteLine($"{(int)(Input2.BaseProgressGain * (3.6f * 2.5f))} {(int)MathF.Floor(Input2.BaseProgressGain * (3.6f * 2.5f))}");
AssertCraft(
Input2,
new[] {
ActionType.MuscleMemory,
ActionType.Manipulation,
ActionType.Veneration,
ActionType.WasteNot2,
ActionType.Groundwork,
ActionType.Groundwork,
ActionType.StandardTouch,
ActionType.Innovation,
ActionType.PreparatoryTouch,
ActionType.PreparatoryTouch,
ActionType.PreparatoryTouch,
ActionType.PreparatoryTouch,
ActionType.GreatStrides,
ActionType.Innovation,
ActionType.PreparatoryTouch,
ActionType.TrainedFinesse,
ActionType.GreatStrides,
ActionType.ByregotsBlessing
},
// Conflicting Info:
// TC https://ffxivteamcraft.com/simulator/35020/34800/4PTlwTV6w1aGCUdO2BRl
3549, 10932, 5, 7);
// Craftingway https://craftingway.app/rotation/sandy-fafnir-doVCs
//3548, 10931, 5, 7);
}
}
+139
View File
@@ -0,0 +1,139 @@
using Craftimizer.Simulator.Actions;
namespace Craftimizer.Test.Solver;
[TestClass]
public class ActionSetTests
{
[TestMethod]
public void TestAcceptedActions()
{
var actions = ActionSet.AcceptedActions;
var lut = ActionSet.AcceptedActionsLUT;
Assert.IsTrue(actions.Length <= 32);
foreach (var i in Enum.GetValues<ActionType>())
{
var idx = lut[(byte)i];
if (idx != -1)
Assert.AreEqual(i, actions[idx]);
}
}
[TestMethod]
public void TestSize()
{
var set = new ActionSet();
Assert.IsTrue(set.IsEmpty);
Assert.AreEqual(0, set.Count);
set.AddAction(ActionType.BasicSynthesis);
set.AddAction(ActionType.WasteNot2);
Assert.AreEqual(2, set.Count);
Assert.IsFalse(set.IsEmpty);
set.RemoveAction(ActionType.BasicSynthesis);
set.RemoveAction(ActionType.WasteNot2);
Assert.IsTrue(set.IsEmpty);
Assert.AreEqual(0, set.Count);
}
[TestMethod]
public void TestAddRemove()
{
var set = new ActionSet();
Assert.IsTrue(set.AddAction(ActionType.BasicSynthesis));
Assert.IsFalse(set.AddAction(ActionType.BasicSynthesis));
Assert.IsTrue(set.RemoveAction(ActionType.BasicSynthesis));
Assert.IsFalse(set.RemoveAction(ActionType.BasicSynthesis));
Assert.IsTrue(set.AddAction(ActionType.BasicSynthesis));
Assert.IsTrue(set.AddAction(ActionType.WasteNot2));
Assert.IsTrue(set.RemoveAction(ActionType.BasicSynthesis));
Assert.IsTrue(set.RemoveAction(ActionType.WasteNot2));
}
[TestMethod]
public void TestHasAction()
{
var set = new ActionSet();
set.AddAction(ActionType.BasicSynthesis);
Assert.IsTrue(set.HasAction(ActionType.BasicSynthesis));
Assert.IsFalse(set.HasAction(ActionType.WasteNot2));
set.AddAction(ActionType.WasteNot2);
Assert.IsTrue(set.HasAction(ActionType.BasicSynthesis));
Assert.IsTrue(set.HasAction(ActionType.WasteNot2));
set.RemoveAction(ActionType.BasicSynthesis);
Assert.IsFalse(set.HasAction(ActionType.BasicSynthesis));
Assert.IsTrue(set.HasAction(ActionType.WasteNot2));
}
[TestMethod]
public void TestElementAt()
{
var set = new ActionSet();
set.AddAction(ActionType.BasicSynthesis);
set.AddAction(ActionType.ByregotsBlessing);
set.AddAction(ActionType.DelicateSynthesis);
set.AddAction(ActionType.FocusedTouch);
Assert.AreEqual(4, set.Count);
Assert.AreEqual(ActionType.DelicateSynthesis, set.ElementAt(0));
Assert.AreEqual(ActionType.FocusedTouch, set.ElementAt(1));
Assert.AreEqual(ActionType.ByregotsBlessing, set.ElementAt(2));
Assert.AreEqual(ActionType.BasicSynthesis, set.ElementAt(3));
set.RemoveAction(ActionType.FocusedTouch);
Assert.AreEqual(3, set.Count);
Assert.AreEqual(ActionType.DelicateSynthesis, set.ElementAt(0));
Assert.AreEqual(ActionType.ByregotsBlessing, set.ElementAt(1));
Assert.AreEqual(ActionType.BasicSynthesis, set.ElementAt(2));
}
[TestMethod]
public void TestRandomIndex()
{
#if IS_DETERMINISTIC
Assert.Inconclusive("Craftimizer is currently built for determinism; all random actions are not actually random.");
#endif
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);
CollectionAssert.Contains(actions, action);
counts[action] = counts.GetValueOrDefault(action) + 1;
}
foreach (var action in actions)
Assert.IsTrue(counts.GetValueOrDefault(action) > 0);
}
}
+3
View File
@@ -0,0 +1,3 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;
global using Craftimizer.Solver;
global using Craftimizer.Simulator;