Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions FileProcessor.IntegrationTests/Features/FileProfile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ Background:
Scenario: Create, update and list file profiles
When I create the following file profiles
| Alias | FileProfileId | Name | ListeningDirectory | RequestType | OperatorName | LineTerminator | FileFormatHandler |
| Profile A | 11111111-1111-1111-1111-111111111111 | Profile A | /home/txnproc/bulkfiles/profile-a | ProfileARequest | Operator A | \n | ProfileAHandler |
| Profile B | 22222222-2222-2222-2222-222222222222 | Profile B | /home/txnproc/bulkfiles/profile-b | ProfileBRequest | Operator B | \r\n | ProfileBHandler |
| Profile A | 11111111-1111-1111-1111-111111111111 | Profile A | /home/txnproc/bulkfiles/profile-a | ProfileARequest | Operator A | 1 | ProfileAHandler |
| Profile B | 22222222-2222-2222-2222-222222222222 | Profile B | /home/txnproc/bulkfiles/profile-b | ProfileBRequest | Operator B | 2 | ProfileBHandler |
And I update the following file profiles
| Alias | Name | ListeningDirectory | RequestType | OperatorName | LineTerminator | FileFormatHandler |
| Profile A | Profile A Updated | /home/txnproc/bulkfiles/profile-a-updated | ProfileARequestUpdated | Operator A Updated | \r\n | ProfileAHandlerUpdated |
| Profile A | Profile A Updated | /home/txnproc/bulkfiles/profile-a-updated | ProfileARequestUpdated | Operator A Updated | 2 | ProfileAHandlerUpdated |
Then the file profiles list should contain 2 items
And the file profiles should have the following values
| Alias | Name | ListeningDirectory | RequestType | OperatorName | LineTerminator | FileFormatHandler |
| Profile A | Profile A Updated | /home/txnproc/bulkfiles/profile-a-updated | ProfileARequestUpdated | Operator A Updated | \r\n | ProfileAHandlerUpdated |
| Profile B | Profile B | /home/txnproc/bulkfiles/profile-b | ProfileBRequest | Operator B | \r\n | ProfileBHandler |
| Profile A | Profile A Updated | /home/txnproc/bulkfiles/profile-a-updated | ProfileARequestUpdated | Operator A Updated | 2 | ProfileAHandlerUpdated |
| Profile B | Profile B | /home/txnproc/bulkfiles/profile-b | ProfileBRequest | Operator B | 2 | ProfileBHandler |

Scenario: Reject duplicate file profile name and request type
When I create the following file profiles
| Alias | FileProfileId | Name | ListeningDirectory | RequestType | OperatorName | LineTerminator | FileFormatHandler |
| Profile A | 33333333-3333-3333-3333-333333333333 | Profile A | /home/txnproc/bulkfiles/profile-a | ProfileARequest | Operator A | \n | ProfileAHandler |
| Profile B | 44444444-4444-4444-4444-444444444444 | Profile B | /home/txnproc/bulkfiles/profile-b | ProfileBRequest | Operator B | \r\n | ProfileBHandler |
| Profile A | 33333333-3333-3333-3333-333333333333 | Profile A | /home/txnproc/bulkfiles/profile-a | ProfileARequest | Operator A | 1 | ProfileAHandler |
| Profile B | 44444444-4444-4444-4444-444444444444 | Profile B | /home/txnproc/bulkfiles/profile-b | ProfileBRequest | Operator B | 2 | ProfileBHandler |
And I try to create the following duplicate file profiles
| DuplicateType | BasedOn |
| Name | Profile A |
| RequestType | Profile B |
And the file profiles list should contain 2 items
#And the file profiles list should contain 2 items
17 changes: 7 additions & 10 deletions FileProcessor.IntegrationTests/Features/FileProfile.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion FileProcessor.IntegrationTests/Features/FileProfileSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public async Task ThenTheFileProfilesShouldHaveTheFollowingValues(DataTable tabl
fileProfile.ListeningDirectory.ShouldBe(row["ListeningDirectory"]);
fileProfile.RequestType.ShouldBe(row["RequestType"]);
fileProfile.OperatorName.ShouldBe(row["OperatorName"]);
fileProfile.LineTerminator.ShouldBe(row["LineTerminator"]);
fileProfile.LineTerminator.ShouldBe(FormatLineTerminator(ParseLineTerminator(row["LineTerminator"])));
fileProfile.FileFormatHandler.ShouldBe(row["FileFormatHandler"]);
}
}
Expand Down Expand Up @@ -170,6 +170,17 @@ _ when Enum.TryParse<LineTerminatorType>(lineTerminator, true, out LineTerminato
};
}

private static string FormatLineTerminator(LineTerminatorType? lineTerminator)
{
return lineTerminator switch
{
LineTerminatorType.LineFeed => "\n",
LineTerminatorType.CarriageReturnLineFeed => "\r\n",
LineTerminatorType.CarriageReturn => "\r",
_ => throw new ArgumentOutOfRangeException(nameof(lineTerminator), lineTerminator, "Unsupported line terminator value")
};
}

private async Task UpdateProfile(string alias, UpdateFileProfileRequest request)
{
Guid fileProfileId = this.FileProfileIds[alias];
Expand Down
Loading