Skip to content

Commit 043bad5

Browse files
author
Jani Giannoudis
committed
payrun test runner and payrun employee test runner: added test run mode for mock data generation
updated version to 0.6.0-beta.7
1 parent 66089fc commit 043bad5

File tree

6 files changed

+82
-34
lines changed

6 files changed

+82
-34
lines changed

Client.Test/PayrollEngine.Client.Test.csproj

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.6.0" />
20-
<PackageReference Include="PayrollEngine.Client.Core" Version="0.6.0-beta.6" />
20+
<PackageReference Include="PayrollEngine.Client.Core" Version="0.6.0-beta.7" />
2121
</ItemGroup>
2222

2323
<!-- include xml documention files and json schemas to the nuget package -->
@@ -29,27 +29,11 @@
2929
<PackageCopyToOutput>true</PackageCopyToOutput>
3030
</None>
3131
</ItemGroup>
32-
<ItemGroup>
33-
<Compile Remove="ExchangeFileTestDataProvider.cs" />
34-
<Compile Remove="FileTestDataProvider.cs" />
35-
<Compile Remove="FileTestRunner.cs" />
36-
<Compile Remove="ITestDataProvider.cs" />
37-
<Compile Remove="ResourceTestDataProvider.cs" />
38-
<Compile Remove="StreamTestDataProvider.cs" />
39-
<Compile Remove="StringTestDataProvider.cs" />
40-
</ItemGroup>
4132
<ItemGroup>
4233
<None Include="..\README.md">
4334
<Pack>True</Pack>
4435
<PackagePath>\</PackagePath>
4536
</None>
46-
<None Include="ExchangeFileTestDataProvider.cs" />
47-
<None Include="FileTestDataProvider.cs" />
48-
<None Include="FileTestRunner.cs" />
49-
<None Include="ITestDataProvider.cs" />
50-
<None Include="ResourceTestDataProvider.cs" />
51-
<None Include="StreamTestDataProvider.cs" />
52-
<None Include="StringTestDataProvider.cs" />
5337
</ItemGroup>
5438

5539
<!-- build json schemas -->

Client.Test/PayrollEngine.Client.Test.xml

Lines changed: 32 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Client.Test/Payrun/PayrunEmployeeTestRunner.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,29 @@ public class PayrunEmployeeTestRunner : PayrunTestRunnerBase
2121
/// <summary>The employee test mode</summary>
2222
public EmployeeTestMode EmployeeMode { get; }
2323

24+
/// <summary>The test running mode</summary>
25+
public TestRunMode RunMode { get; }
26+
2427
/// <summary>Initializes a new instance of the <see cref="PayrunEmployeeTestRunner"/> class</summary>
2528
/// <param name="httpClient">The payroll engine http client</param>
2629
/// <param name="scriptParser">The script parser</param>
2730
/// <param name="owner">The test owner</param>
2831
/// <param name="testPrecision">The testing precision</param>
29-
/// <param name="employeeMode">The employee test mode</param>
32+
/// <param name="employeeMode">The test running mode</param>
33+
/// <param name="runMode">The employee test mode</param>
3034
public PayrunEmployeeTestRunner(PayrollHttpClient httpClient, IScriptParser scriptParser,
3135
TestPrecision testPrecision = TestPrecision.TestPrecision2, string owner = null,
32-
EmployeeTestMode employeeMode = EmployeeTestMode.InsertEmployee) :
36+
EmployeeTestMode employeeMode = EmployeeTestMode.InsertEmployee,
37+
TestRunMode runMode = TestRunMode.RunTests) :
3338
base(httpClient, testPrecision, owner)
3439
{
3540
ScriptParser = scriptParser ?? throw new ArgumentNullException(nameof(scriptParser));
3641
EmployeeMode = employeeMode;
42+
RunMode = runMode;
3743
}
3844

3945
/// <summary>Start the test</summary>
46+
/// <param name="exchange">The exchange model</param>
4047
/// <returns>A list of payrun job results</returns>
4148
public override async Task<Dictionary<Tenant, List<PayrollTestResult>>> TestAllAsync(Model.Exchange exchange)
4249
{
@@ -60,6 +67,12 @@ public override async Task<Dictionary<Tenant, List<PayrollTestResult>>> TestAllA
6067
var import = new ExchangeImport(HttpClient, exchange, ScriptParser);
6168
await import.ImportAsync();
6269

70+
// test skip
71+
if (RunMode != TestRunMode.RunTests)
72+
{
73+
continue;
74+
}
75+
6376
// all payrun jobs should be executed
6477
if (DelayBetweenCreateAndTest > 0)
6578
{

Client.Test/Payrun/PayrunTestRunner.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class PayrunTestRunner : PayrunTestRunnerBase
2222
/// <summary>The test result mode</summary>
2323
public TestResultMode ResultMode { get; }
2424

25+
/// <summary>The test running mode</summary>
26+
public TestRunMode RunMode { get; }
27+
2528
/// <summary>The delay between creation and test</summary>
2629
public int DelayBetweenCreateAndTest { get; set; }
2730

@@ -32,15 +35,18 @@ public class PayrunTestRunner : PayrunTestRunnerBase
3235
/// <param name="owner">The test owner</param>
3336
/// <param name="importMode">The data import mode (default: single)</param>
3437
/// <param name="resultMode">The test result mode (default: clean)</param>
38+
/// <param name="runMode">The employee test mode</param>
3539
public PayrunTestRunner(PayrollHttpClient httpClient, IScriptParser scriptParser,
3640
TestPrecision testPrecision = TestPrecision.TestPrecision2,
3741
string owner = null, DataImportMode importMode = DataImportMode.Single,
38-
TestResultMode resultMode = TestResultMode.CleanTest) :
42+
TestResultMode resultMode = TestResultMode.CleanTest,
43+
TestRunMode runMode = TestRunMode.RunTests) :
3944
base(httpClient, testPrecision, owner)
4045
{
4146
ScriptParser = scriptParser ?? throw new ArgumentNullException(nameof(scriptParser));
4247
ImportMode = importMode;
4348
ResultMode = resultMode;
49+
RunMode = runMode;
4450
}
4551

4652
/// <summary>Start the test</summary>
@@ -68,18 +74,22 @@ public override async Task<Dictionary<Tenant, List<PayrollTestResult>>> TestAllA
6874
var import = new ExchangeImport(HttpClient, exchange, ScriptParser, importMode: ImportMode);
6975
await import.ImportAsync();
7076

71-
// all payrun jobs should be executed
72-
if (DelayBetweenCreateAndTest > 0)
77+
// not test skip
78+
if (RunMode == TestRunMode.RunTests)
7379
{
74-
Task.Delay(DelayBetweenCreateAndTest).Wait();
75-
}
80+
// all payrun jobs should be executed
81+
if (DelayBetweenCreateAndTest > 0)
82+
{
83+
Task.Delay(DelayBetweenCreateAndTest).Wait();
84+
}
7685

77-
// test tenants
78-
foreach (var tenant in exchange.Tenants)
79-
{
80-
// test results
81-
var payrunJobResult = await TestPayrunJobAsync(tenant, JobResultMode.Single);
82-
results.Add(tenant, payrunJobResult.ToList());
86+
// test tenants
87+
foreach (var tenant in exchange.Tenants)
88+
{
89+
// test results
90+
var payrunJobResult = await TestPayrunJobAsync(tenant, JobResultMode.Single);
91+
results.Add(tenant, payrunJobResult.ToList());
92+
}
8393
}
8494
}
8595
finally

Client.Test/Payrun/TestRunMode.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+

2+
namespace PayrollEngine.Client.Test.Payrun;
3+
4+
/// <summary>The test running mode</summary>
5+
public enum TestRunMode
6+
{
7+
/// <summary>Runt the tests</summary>
8+
RunTests,
9+
10+
/// <summary>Skip all test</summary>
11+
SkipTests
12+
}

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net7.0</TargetFramework>
5-
<Version>0.6.0-beta.6</Version>
5+
<Version>0.6.0-beta.7</Version>
66
<FileVersion>0.6.0</FileVersion>
77
<InformationalVersion></InformationalVersion>
88
<Authors>Jani Giannoudis</Authors>

0 commit comments

Comments
 (0)