Skip to content

Commit 6f78a3f

Browse files
Merge pull request #14 from TransactionProcessing/task/#3_processtopupcsv
Task/#3 processtopupcsv
2 parents b45308e + 1a74d1e commit 6f78a3f

53 files changed

Lines changed: 4870 additions & 74 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/createrelease.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ jobs:
2828
- name: Run Unit Tests
2929
run: |
3030
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
31-
dotnet test "FileProcessor.BusinessLogic.Tests\EstateManagement.BusinessLogic.Tests.csproj"
31+
dotnet test "FileProcessor.BusinessLogic.Tests\FileProcessor.BusinessLogic.Tests.csproj"
32+
dotnet test "FileProcessor.FileAggregate.Tests\FileProcessor.FileAggregate.Tests.csproj"
33+
dotnet test "FileProcessor.DomainEvents.Tests\FileProcessor.DomainEvents.Tests.csproj"
3234
3335
- name: Build Docker Images
3436
run: |

.github/workflows/pullrequest.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ jobs:
2626
run: |
2727
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
2828
dotnet test "FileProcessor.BusinessLogic.Tests\FileProcessor.BusinessLogic.Tests.csproj"
29-
30-
#dotnet test "EstateManagement.EstateAggregate.Tests\EstateManagement.EstateAggregate.Tests.csproj"
31-
#dotnet test "EstateManagement.MerchantAggregate.Tests\EstateManagement.MerchantAggregate.Tests.csproj"
32-
#dotnet test "EstateManagement.Tests\EstateManagement.Tests.csproj"
29+
dotnet test "FileProcessor.FileAggregate.Tests\FileProcessor.FileAggregate.Tests.csproj"
30+
dotnet test "FileProcessor.DomainEvents.Tests\FileProcessor.DomainEvents.Tests.csproj"
3331
34-
#- name: Build Docker Image
35-
# run: docker build . --file FileProcessor/Dockerfile --tag fileprocessor:latest
32+
- name: Build Docker Image
33+
run: docker build . --file FileProcessor/Dockerfile --tag fileprocessor:latest
3634

3735
#- name: Run Integration Tests
3836
# run: dotnet test "EstateManagement.IntegrationTests\EstateManagement.IntegrationTests.csproj" --filter Category=PRTe st
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<DebugType>None</DebugType>
6+
</PropertyGroup>
7+
8+
</Project>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
3+
namespace FIleProcessor.Models
4+
{
5+
using System.Collections.Generic;
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
/// <summary>
9+
///
10+
/// </summary>
11+
public class FileDetails
12+
{
13+
/// <summary>
14+
/// Gets or sets the file identifier.
15+
/// </summary>
16+
/// <value>
17+
/// The file identifier.
18+
/// </value>
19+
public Guid FileId { get; set; }
20+
21+
/// <summary>
22+
/// Gets or sets the estate identifier.
23+
/// </summary>
24+
/// <value>
25+
/// The estate identifier.
26+
/// </value>
27+
public Guid EstateId { get; set; }
28+
29+
/// <summary>
30+
/// Gets or sets the user identifier.
31+
/// </summary>
32+
/// <value>
33+
/// The user identifier.
34+
/// </value>
35+
public Guid UserId { get; set; }
36+
37+
/// <summary>
38+
/// Gets or sets the merchant identifier.
39+
/// </summary>
40+
/// <value>
41+
/// The merchant identifier.
42+
/// </value>
43+
public Guid MerchantId { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets the file profile identifier.
47+
/// </summary>
48+
/// <value>
49+
/// The file profile identifier.
50+
/// </value>
51+
public Guid FileProfileId { get; set; }
52+
53+
/// <summary>
54+
/// Gets or sets the name of the original file.
55+
/// </summary>
56+
/// <value>
57+
/// The name of the original file.
58+
/// </value>
59+
public String OriginalFileName { get; set; }
60+
61+
/// <summary>
62+
/// Gets or sets the file lines.
63+
/// </summary>
64+
/// <value>
65+
/// The file lines.
66+
/// </value>
67+
public List<FileLine> FileLines { get; set; }
68+
}
69+
}

FIleProcessor.Models/FileLine.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
namespace FIleProcessor.Models
2+
{
3+
using System;
4+
5+
/// <summary>
6+
///
7+
/// </summary>
8+
public class FileLine
9+
{
10+
#region Properties
11+
12+
/// <summary>
13+
/// Gets or sets the line data.
14+
/// </summary>
15+
/// <value>
16+
/// The line data.
17+
/// </value>
18+
public String LineData { get; set; }
19+
20+
/// <summary>
21+
/// Gets or sets the line number.
22+
/// </summary>
23+
/// <value>
24+
/// The line number.
25+
/// </value>
26+
public Int32 LineNumber { get; set; }
27+
28+
/// <summary>
29+
/// Gets or sets a value indicating whether [successfully processed].
30+
/// </summary>
31+
/// <value>
32+
/// <c>true</c> if [successfully processed]; otherwise, <c>false</c>.
33+
/// </value>
34+
public Boolean SuccessfullyProcessed { get; set; }
35+
36+
/// <summary>
37+
/// Gets or sets the transaction identifier.
38+
/// </summary>
39+
/// <value>
40+
/// The transaction identifier.
41+
/// </value>
42+
public Guid TransactionId { get; set; }
43+
44+
#endregion
45+
}
46+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
namespace FIleProcessor.Models
2+
{
3+
using System;
4+
5+
/// <summary>
6+
///
7+
/// </summary>
8+
/// <seealso cref="System.IEquatable{FIleProcessor.Models.FileProfile}" />
9+
public record FileProfile
10+
{
11+
/// <summary>
12+
/// Gets or sets the file profile identifier.
13+
/// </summary>
14+
/// <value>
15+
/// The file profile identifier.
16+
/// </value>
17+
public Guid FileProfileId { get; init; }
18+
19+
/// <summary>
20+
/// Gets or sets the name.
21+
/// </summary>
22+
/// <value>
23+
/// The name.
24+
/// </value>
25+
public String Name { get; init; }
26+
/// <summary>
27+
/// Gets or sets the name of the operator.
28+
/// </summary>
29+
/// <value>
30+
/// The name of the operator.
31+
/// </value>
32+
public String OperatorName { get; init; }
33+
34+
/// <summary>
35+
/// Gets or sets the listening directory.
36+
/// </summary>
37+
/// <value>
38+
/// The listening directory.
39+
/// </value>
40+
public String ListeningDirectory { get; init; }
41+
/// <summary>
42+
/// Gets or sets the processed directory.
43+
/// </summary>
44+
/// <value>
45+
/// The processed directory.
46+
/// </value>
47+
public String ProcessedDirectory { get; init; }
48+
/// <summary>
49+
/// Gets or sets the failed directory.
50+
/// </summary>
51+
/// <value>
52+
/// The failed directory.
53+
/// </value>
54+
public String FailedDirectory { get; init; }
55+
56+
/// <summary>
57+
/// Gets or sets a value indicating whether this instance has header row.
58+
/// </summary>
59+
/// <value>
60+
/// <c>true</c> if this instance has header row; otherwise, <c>false</c>.
61+
/// </value>
62+
public Boolean HasHeaderRow { get; init; }
63+
/// <summary>
64+
/// Gets or sets a value indicating whether this instance has trailer row.
65+
/// </summary>
66+
/// <value>
67+
/// <c>true</c> if this instance has trailer row; otherwise, <c>false</c>.
68+
/// </value>
69+
public Boolean HasTrailerRow { get; init; }
70+
/// <summary>
71+
/// Gets or sets the file format handler.
72+
/// </summary>
73+
/// <value>
74+
/// The file format handler.
75+
/// </value>
76+
public String FileFormatHandler { get; init; }
77+
/// <summary>
78+
/// Gets or sets the type of the request.
79+
/// </summary>
80+
/// <value>
81+
/// The type of the request.
82+
/// </value>
83+
public String RequestType { get; init; }
84+
85+
/// <summary>
86+
/// Initializes a new instance of the <see cref="FileProfile" /> class.
87+
/// </summary>
88+
/// <param name="fileProfileId">The file profile identifier.</param>
89+
/// <param name="name">The name.</param>
90+
/// <param name="listeningDirectory">The listening directory.</param>
91+
/// <param name="requestType">Type of the request.</param>
92+
/// <param name="operatorName">Name of the operator.</param>
93+
/// <param name="hasHeaderRow">if set to <c>true</c> [has header row].</param>
94+
/// <param name="hasTrailerRow">if set to <c>true</c> [has trailer row].</param>
95+
public FileProfile(Guid fileProfileId, String name, String listeningDirectory, String requestType, String operatorName, Boolean hasHeaderRow = false, Boolean hasTrailerRow = false)
96+
{
97+
this.FileProfileId = fileProfileId;
98+
this.Name = name;
99+
this.ListeningDirectory = listeningDirectory;
100+
this.ProcessedDirectory = $"{listeningDirectory}/processed";
101+
this.FailedDirectory = $"{listeningDirectory}/failed";
102+
this.RequestType = requestType;
103+
this.OperatorName = operatorName;
104+
this.HasHeaderRow = hasHeaderRow;
105+
this.HasTrailerRow = hasTrailerRow;
106+
}
107+
}
108+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace FileProcessor.BusinessLogic.Tests
8+
{
9+
using System.Threading;
10+
using EventHandling;
11+
using File.DomainEvents;
12+
using MediatR;
13+
using Moq;
14+
using Shouldly;
15+
using Shouldly.Configuration;
16+
using Testing;
17+
using Xunit;
18+
19+
public class DomainEventHandlerTests
20+
{
21+
[Fact]
22+
public void FileDomainEventHandler_FileLineAddedEvent_EventIsHandled()
23+
{
24+
Mock<IMediator> mediator = new Mock<IMediator>();
25+
FileDomainEventHandler eventHandler = new FileDomainEventHandler(mediator.Object);
26+
FileLineAddedEvent fileLineAddedEvent = TestData.FileLineAddedEvent;
27+
Should.NotThrow(async () =>
28+
{
29+
await eventHandler.Handle(fileLineAddedEvent, CancellationToken.None);
30+
});
31+
}
32+
}
33+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace FileProcessor.BusinessLogic.Tests
8+
{
9+
using System.Threading;
10+
using Managers;
11+
using Shouldly;
12+
using Testing;
13+
using Xunit;
14+
15+
public class FileProcessingManagerTests
16+
{
17+
[Fact]
18+
public async Task FileProcessingManager_GetAllFileProfiles_AllFileProfilesReturned()
19+
{
20+
var fileProfiles = TestData.FileProfiles;
21+
FileProcessorManager manager = new FileProcessorManager(fileProfiles);
22+
23+
var allFileProfiles = await manager.GetAllFileProfiles(CancellationToken.None);
24+
allFileProfiles.ShouldNotBeNull();
25+
allFileProfiles.ShouldNotBeEmpty();
26+
}
27+
28+
[Fact]
29+
public async Task FileProcessingManager_GetFileProfile_FIleProfileReturned()
30+
{
31+
var fileProfiles = TestData.FileProfiles;
32+
FileProcessorManager manager = new FileProcessorManager(fileProfiles);
33+
34+
var fileProfile = await manager.GetFileProfile(TestData.SafaricomFileProfileId, CancellationToken.None);
35+
fileProfile.ShouldNotBeNull();
36+
fileProfile.FileProfileId.ShouldBe(TestData.SafaricomFileProfileId);
37+
}
38+
}
39+
}

FileProcessor.BusinessLogic.Tests/FileProcessor.BusinessLogic.Tests.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5-
5+
<DebugType>None</DebugType>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
11+
<PackageReference Include="Moq" Version="4.16.1" />
12+
<PackageReference Include="Shouldly" Version="4.0.3" />
13+
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="13.2.29" />
1114
<PackageReference Include="xunit" Version="2.4.1" />
1215
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1316
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -21,6 +24,7 @@
2124

2225
<ItemGroup>
2326
<ProjectReference Include="..\FileProcessor.BusinessLogic\FileProcessor.BusinessLogic.csproj" />
27+
<ProjectReference Include="..\FileProcessor.Testing\FileProcessor.Testing.csproj" />
2428
</ItemGroup>
2529

2630
</Project>

0 commit comments

Comments
 (0)