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 @@ -130,6 +130,8 @@ public async Task MerchantDomainService_CreateMerchant_EstateNotFound_ErrorThrow
public async Task MerchantDomainService_AssignOperatorToMerchant_OperatorAssigned() {
this.AggregateService.Setup(m => m.GetLatest<MerchantAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success(TestData.Aggregates.CreatedMerchantAggregate()));
this.AggregateService.Setup(m => m.GetLatest<OperatorAggregate>(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success(TestData.Aggregates.CreatedOperatorAggregate()));
this.AggregateService
.Setup(m => m.Save(It.IsAny<MerchantAggregate>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(Result.Success);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public async Task<Result> AssignOperatorToMerchant(MerchantCommands.AssignOperat
return ResultHelpers.CreateFailure(estateResult);

Result<MerchantAggregate> merchantResult = await DomainServiceHelper.GetAggregateOrFailure(ct => this.AggregateService.GetLatest<MerchantAggregate>(command.MerchantId, ct), command.MerchantId, cancellationToken);
if (estateResult.IsFailed)
if (merchantResult.IsFailed)
return ResultHelpers.CreateFailure(merchantResult);

EstateAggregate estateAggregate = estateResult.Data;
Expand All @@ -131,25 +131,26 @@ public async Task<Result> AssignOperatorToMerchant(MerchantCommands.AssignOperat
return Result.Invalid($"Operator Id {command.RequestDto.OperatorId} is not supported on Estate [{estate.Name}]");
}

// TODO: Reintroduce when we have an Operator Aggregate
// https://github.com/TransactionProcessing/EstateManagement/issues/558
Result<OperatorAggregate> operatorResult = await DomainServiceHelper.GetAggregateOrFailure(ct => this.AggregateService.GetLatest<OperatorAggregate>(command.RequestDto.OperatorId, ct), command.RequestDto.OperatorId, cancellationToken);
if (operatorResult.IsFailed)
return ResultHelpers.CreateFailure(operatorResult);
OperatorAggregate @operatorAggregate = operatorResult.Data;
// Operator has been validated, now check the rules of the operator against the passed in data
//if (@operator.RequireCustomMerchantNumber) {
// // requested addition must have a merchant number supplied
// if (String.IsNullOrEmpty(command.RequestDto.MerchantNumber)) {
// throw new InvalidOperationException($"Operator Id {command.RequestDto.OperatorId} requires that a merchant number is provided");
// }
//}

//if (@operator.RequireCustomTerminalNumber) {
// // requested addition must have a terminal number supplied
// if (String.IsNullOrEmpty(command.RequestDto.TerminalNumber)) {
// throw new InvalidOperationException($"Operator Id {command.RequestDto.OperatorId} requires that a terminal number is provided");
// }
//}
if (@operatorAggregate.RequireCustomMerchantNumber) {
// requested addition must have a merchant number supplied
if (String.IsNullOrEmpty(command.RequestDto.MerchantNumber)) {
return Result.Invalid($"Operator Id {command.RequestDto.OperatorId} requires that a merchant number is provided");
}
}

if (@operatorAggregate.RequireCustomTerminalNumber) {
// requested addition must have a terminal number supplied
if (String.IsNullOrEmpty(command.RequestDto.TerminalNumber)) {
return Result.Invalid($"Operator Id {command.RequestDto.OperatorId} requires that a terminal number is provided");
}
}

// Assign the operator
// TODO: Swap second parameter to name
Result stateResult = merchantAggregate.AssignOperator(command.RequestDto.OperatorId, @operator.Name, command.RequestDto.MerchantNumber, command.RequestDto.TerminalNumber);
if (stateResult.IsFailed)
return stateResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Background:

Given I have created the following operators
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Test Operator 1 | True | True |
| Test Estate 2 | Test Operator 1 | True | True |
| Test Estate 1 | Test Operator 1 | False | False |
| Test Estate 2 | Test Operator 1 | False | False |

And I have assigned the following operators to the estates
| EstateName | OperatorName |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Background:

Given I have created the following operators
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Test Operator 1 | True | True |
| Test Estate 1 | Test Operator 1 | False | False |

And I have assigned the following operators to the estates
| EstateName | OperatorName |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Background:

Given I have created the following operators
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Test Operator 1 | True | True |
| Test Estate 2 | Test Operator 1 | True | True |
| Test Estate 1 | Test Operator 1 | False | False |
| Test Estate 2 | Test Operator 1 | False | False |

And I have assigned the following operators to the estates
| EstateName | OperatorName |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Background:

Given I have created the following operators
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Safaricom | True | True |
| Test Estate 2 | Safaricom | True | True |
| Test Estate 1 | Safaricom | False | False |
| Test Estate 2 | Safaricom | False | False |

And I have assigned the following operators to the estates
| EstateName | OperatorName |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Background:

Given I have created the following operators
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Voucher | True | True |
| Test Estate 1 | Voucher | False | False |

And I have assigned the following operators to the estates
| EstateName | OperatorName |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ Background:

Given I have created the following operators
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Safaricom | True | True |
| Test Estate 1 | Voucher | True | True |
| Test Estate 1 | PataPawa PostPay | True | True |
| Test Estate 1 | PataPawa PrePay | True | True |
| Test Estate 1 | Safaricom | False | False |
| Test Estate 1 | Voucher | False | False |
| Test Estate 1 | PataPawa PostPay | False | False |
| Test Estate 1 | PataPawa PrePay | False | False |

And I have assigned the following operators to the estates
| EstateName | OperatorName |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Background:

Given I have created the following operators
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Safaricom | True | True |
| Test Estate 1 | Voucher | True | True |
| Test Estate 1 | Safaricom | False | False |
| Test Estate 1 | Voucher | False | False |

And I have assigned the following operators to the estates
| EstateName | OperatorName |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Background:

Given I have created the following operators
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Safaricom | True | True |
| Test Estate 2 | Safaricom | True | True |
| Test Estate 1 | Safaricom | False | False |
| Test Estate 2 | Safaricom | False | False |

And I have assigned the following operators to the estates
| EstateName | OperatorName |
Expand Down
Loading