Skip to content

Commit

Permalink
Merge pull request #22 from JaimeStill/service
Browse files Browse the repository at this point in the history
initial processing library + service test
  • Loading branch information
JaimeStill authored Mar 2, 2023
2 parents 32449ef + 800ef7e commit ead905a
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Arma.Demo.Core/Processing/Package.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Arma.Demo.Core.Processing;
public class Package
{
public static Guid Key => Guid.NewGuid();
public string Name { get; set; }
}
7 changes: 7 additions & 0 deletions src/Arma.Demo.Core/Processing/Process.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Arma.Demo.Core.Processing;
public class Process
{
public string Name { get; set; }

public List<ProcessTask> Tasks { get; set; }
}
8 changes: 8 additions & 0 deletions src/Arma.Demo.Core/Processing/ProcessTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Arma.Demo.Core.Processing;
public class ProcessTask
{
public int Step { get; set; }
public string Name { get; set; }
public string Section { get; set; }
public int Duration { get; set; }
}
8 changes: 8 additions & 0 deletions tests/processing-test/PackageGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Arma.Demo.Core.Processing;

namespace Processor;
public static class PackageGenerator
{
public static Package ApprovalPackage() =>
new() { Name = "Demo Approval" };
}
49 changes: 49 additions & 0 deletions tests/processing-test/ProcessGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Arma.Demo.Core.Processing;

namespace Processor;
public static class ProcessGenerator
{
public static Process ApprovalProcess() =>
new()
{
Name = "Demo Approval Process",
Tasks = new()
{
new()
{
Name = "Security Review",
Section = "Cybersecurity",
Step = 1,
Duration = 800
},
new()
{
Name = "Legal Review",
Section = "Legal",
Step = 2,
Duration = 1100
},
new()
{
Name = "Informal Review",
Section = "Operational Review Board",
Step = 3,
Duration = 500
},
new()
{
Name = "Formal Review",
Section = "Command Review Board",
Step = 4,
Duration = 1800
},
new()
{
Name = "Final Approval",
Section = "Headquarters Commander",
Step = 5,
Duration = 1000
}
}
};
}
14 changes: 14 additions & 0 deletions tests/processing-test/Processor.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\src\Arma.Demo.Core\Arma.Demo.Core.csproj" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
21 changes: 21 additions & 0 deletions tests/processing-test/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Arma.Demo.Core.Processing;
using Processor;

Package package = PackageGenerator.ApprovalPackage();

Console.WriteLine($"Submitting package {package.Name} for approval");

await Task.Delay(1200);

Process process = ProcessGenerator.ApprovalProcess();

Console.WriteLine($"Package {package.Name} assigned process {process.Name}");

foreach (ProcessTask task in process.Tasks)
{
Console.WriteLine($"Current step: {task.Name}");
await Task.Delay(task.Duration);
Console.WriteLine($"Package {package.Name} was approved by {task.Section}");
}

Console.WriteLine($"Package {package.Name} was successfully approved");

0 comments on commit ead905a

Please sign in to comment.