Skip to content

Commit ead905a

Browse files
authored
Merge pull request #22 from JaimeStill/service
initial processing library + service test
2 parents 32449ef + 800ef7e commit ead905a

File tree

7 files changed

+113
-0
lines changed

7 files changed

+113
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Arma.Demo.Core.Processing;
2+
public class Package
3+
{
4+
public static Guid Key => Guid.NewGuid();
5+
public string Name { get; set; }
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Arma.Demo.Core.Processing;
2+
public class Process
3+
{
4+
public string Name { get; set; }
5+
6+
public List<ProcessTask> Tasks { get; set; }
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Arma.Demo.Core.Processing;
2+
public class ProcessTask
3+
{
4+
public int Step { get; set; }
5+
public string Name { get; set; }
6+
public string Section { get; set; }
7+
public int Duration { get; set; }
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Arma.Demo.Core.Processing;
2+
3+
namespace Processor;
4+
public static class PackageGenerator
5+
{
6+
public static Package ApprovalPackage() =>
7+
new() { Name = "Demo Approval" };
8+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Arma.Demo.Core.Processing;
2+
3+
namespace Processor;
4+
public static class ProcessGenerator
5+
{
6+
public static Process ApprovalProcess() =>
7+
new()
8+
{
9+
Name = "Demo Approval Process",
10+
Tasks = new()
11+
{
12+
new()
13+
{
14+
Name = "Security Review",
15+
Section = "Cybersecurity",
16+
Step = 1,
17+
Duration = 800
18+
},
19+
new()
20+
{
21+
Name = "Legal Review",
22+
Section = "Legal",
23+
Step = 2,
24+
Duration = 1100
25+
},
26+
new()
27+
{
28+
Name = "Informal Review",
29+
Section = "Operational Review Board",
30+
Step = 3,
31+
Duration = 500
32+
},
33+
new()
34+
{
35+
Name = "Formal Review",
36+
Section = "Command Review Board",
37+
Step = 4,
38+
Duration = 1800
39+
},
40+
new()
41+
{
42+
Name = "Final Approval",
43+
Section = "Headquarters Commander",
44+
Step = 5,
45+
Duration = 1000
46+
}
47+
}
48+
};
49+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<ItemGroup>
4+
<ProjectReference Include="..\..\src\Arma.Demo.Core\Arma.Demo.Core.csproj" />
5+
</ItemGroup>
6+
7+
<PropertyGroup>
8+
<OutputType>Exe</OutputType>
9+
<TargetFramework>net7.0</TargetFramework>
10+
<ImplicitUsings>enable</ImplicitUsings>
11+
<Nullable>enable</Nullable>
12+
</PropertyGroup>
13+
14+
</Project>

tests/processing-test/Program.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Arma.Demo.Core.Processing;
2+
using Processor;
3+
4+
Package package = PackageGenerator.ApprovalPackage();
5+
6+
Console.WriteLine($"Submitting package {package.Name} for approval");
7+
8+
await Task.Delay(1200);
9+
10+
Process process = ProcessGenerator.ApprovalProcess();
11+
12+
Console.WriteLine($"Package {package.Name} assigned process {process.Name}");
13+
14+
foreach (ProcessTask task in process.Tasks)
15+
{
16+
Console.WriteLine($"Current step: {task.Name}");
17+
await Task.Delay(task.Duration);
18+
Console.WriteLine($"Package {package.Name} was approved by {task.Section}");
19+
}
20+
21+
Console.WriteLine($"Package {package.Name} was successfully approved");

0 commit comments

Comments
 (0)