This repository has been archived by the owner on Jan 1, 2024. It is now read-only.
forked from Jays2Kings/DS4Windows
-
Notifications
You must be signed in to change notification settings - Fork 812
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial unit test project to solution
- Loading branch information
Showing
4 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0-windows</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>disable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
<Platforms>AnyCPU;x64;x86</Platforms> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="3.0.4" /> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\DS4Windows\DS4WinWPF.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Microsoft.VisualStudio.TestTools.UnitTesting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using DS4Windows; | ||
|
||
namespace DS4WindowsTests | ||
{ | ||
[TestClass] | ||
public class MacroParserTests | ||
{ | ||
private int[] testMacro = new int[] | ||
{ | ||
87, // W key down | ||
330, // Wait period 30 ms | ||
1090220220, // Change lightbar (90, 220, 220) | ||
83, // S key down | ||
330, // Wait period 30 ms | ||
1000000000, // Reset lightbar | ||
83, // S key up | ||
330, // Wait period 30 ms | ||
87, // W key up | ||
}; | ||
|
||
private MacroParser parser; | ||
|
||
public MacroParserTests() | ||
{ | ||
Setup(); | ||
} | ||
|
||
private void Setup() | ||
{ | ||
parser = new MacroParser(testMacro); | ||
parser.LoadMacro(); | ||
} | ||
|
||
[TestMethod] | ||
public void CheckNumberSteps() | ||
{ | ||
List<MacroStep> steps = parser.MacroSteps; | ||
// Make sure parser interpreted all steps | ||
Assert.AreEqual(testMacro.Length, steps.Count); | ||
} | ||
|
||
[TestMethod] | ||
public void CheckStepTypes() | ||
{ | ||
List<MacroStep> steps = parser.MacroSteps; | ||
|
||
int waitStep = 1; | ||
Assert.AreEqual(MacroStep.StepType.Wait, steps[waitStep].ActType); | ||
|
||
int changeLightbarStep = 2; | ||
Assert.AreEqual(MacroStep.StepOutput.Lightbar, steps[changeLightbarStep].OutputType); | ||
Assert.AreEqual(MacroStep.StepType.ActDown, steps[changeLightbarStep].ActType); | ||
|
||
int resetLightbarStep = 5; | ||
Assert.AreEqual(MacroStep.StepOutput.Lightbar, steps[resetLightbarStep].OutputType); | ||
Assert.AreEqual(MacroStep.StepType.ActUp, steps[resetLightbarStep].ActType); | ||
|
||
int lastStep = testMacro.Length - 1; | ||
Assert.AreEqual(MacroStep.StepType.ActUp, steps[lastStep].ActType); | ||
|
||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters