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
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ public OperatorDomainService(Func<IAggregateService> aggregateService) {
public async Task<Result> CreateOperator(OperatorCommands.CreateOperatorCommand command, CancellationToken cancellationToken)
{
try {
// Check if we have been sent a merchant id to use
Guid operatorId = command.RequestDto.OperatorId switch {
_ when command.RequestDto.OperatorId == Guid.Empty => Guid.NewGuid(),
_ => command.RequestDto.OperatorId
};

Result<EstateAggregate> estateResult = await DomainServiceHelper.GetAggregateOrFailure(ct => this.AggregateService.Get<EstateAggregate>(command.EstateId, ct), command.EstateId, cancellationToken);
if (estateResult.IsFailed)
return ResultHelpers.CreateFailure(estateResult);

Result<OperatorAggregate> operatorResult = await DomainServiceHelper.GetAggregateOrFailure(ct => this.AggregateService.GetLatest<OperatorAggregate>(command.RequestDto.OperatorId, ct), command.RequestDto.OperatorId, cancellationToken, false);
Result<OperatorAggregate> operatorResult = await DomainServiceHelper.GetAggregateOrFailure(ct => this.AggregateService.GetLatest<OperatorAggregate>(operatorId, ct), operatorId, cancellationToken, false);
if (estateResult.IsFailed)
return ResultHelpers.CreateFailure(operatorResult);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,12 @@ public static List<CreateEstateRequest> ToCreateEstateRequests(this DataTableRow

EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName);
estateDetails.ShouldNotBeNull();

Guid operatorId = Guid.NewGuid();
var operatorIdString = ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorId");
Guid operatorId = Guid.Empty;
if (String.IsNullOrEmpty(operatorIdString) == false) {
operatorId = Guid.Parse(operatorIdString);
}

String operatorName = ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName");
Boolean requireCustomMerchantNumber = ReqnrollTableHelper.GetBooleanValue(tableRow, "RequireCustomMerchantNumber");
Boolean requireCustomTerminalNumber = ReqnrollTableHelper.GetBooleanValue(tableRow, "RequireCustomTerminalNumber");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,14 @@ await Retry.For(async () => {
operators.IsSuccess.ShouldBeTrue();
OperatorResponse? @operator = operators.Data.SingleOrDefault(o => o.Name == request.request.Name);
@operator.ShouldNotBeNull();
//@operator.OperatorId.ShouldNotBe();
if (request.request.OperatorId != Guid.Empty) {
@operator.OperatorId.ShouldBe(request.request.OperatorId);
}
else {
@operator.OperatorId.ShouldNotBe(Guid.Empty);
}

request.estate.AddOperator(@operator.OperatorId, request.request.Name);
results.Add((request.estate.EstateId,
new EstateOperatorResponse
Expand Down
10 changes: 6 additions & 4 deletions TransactionProcessor.IntegrationTests/Features/Operator.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ Background:
Scenario: Update Operator

Given I have created the following operators
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Test Operator 1 | True | True |
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | OperatorId |
| Test Estate 1 | Test Operator 1 | True | True | 27C722F6-208F-4F78-9A2F-993F8A8F24A3 |
| Test Estate 1 | Test Operator 2 | True | True | 00000000-0000-0000-0000-000000000000 |

When I update the operators with the following details
| UpdateOperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | EstateName | OperatorName |
| Update Operator 1 | False | False | Test Estate 1 | Test Operator 1 |

When I get all the operators the following details are returned
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Update Operator 1 | False | False |
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Update Operator 1 | False | False |
| Test Estate 1 | Test Operator 2 | True | True |
77 changes: 45 additions & 32 deletions TransactionProcessor.IntegrationTests/Features/Operator.feature.cs

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

Loading