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
47 changes: 0 additions & 47 deletions .github/workflows/prlinked.yml

This file was deleted.

53 changes: 48 additions & 5 deletions TransactionProcessor.Aggregates.Tests/MerchantAggregateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void MerchantAggregate_AddAddress_AddressIsAdded(){
aggregate.Create(TestData.EstateId, TestData.MerchantName, TestData.DateMerchantCreated, TestData.AddressModel, TestData.ContactModel,
TestData.SettlementScheduleModel);

Address newAddress = new(Guid.Empty, TestData.MerchantAddressLine1,
Address newAddress = Address.Create(Guid.Empty, TestData.MerchantAddressLine1,
TestData.MerchantAddressLine2,
TestData.MerchantAddressLine3,
TestData.MerchantAddressLine4,
Expand Down Expand Up @@ -577,7 +577,7 @@ public void MerchantAggregate_UpdateAddress_AddressIsAdded(){
Merchant merchantModel = aggregate.GetMerchant();
Address? address = merchantModel.Addresses.ShouldHaveSingleItem();

Address newAddress = new(address.AddressId, TestData.MerchantAddressLine1Update, TestData.MerchantAddressLine2Update, TestData.MerchantAddressLine3Update, TestData.MerchantAddressLine4Update, TestData.MerchantTownUpdate, TestData.MerchantRegionUpdate, TestData.MerchantPostalCodeUpdate, TestData.MerchantCountryUpdate);
Address newAddress = Address.Create(address.AddressId, TestData.MerchantAddressLine1Update, TestData.MerchantAddressLine2Update, TestData.MerchantAddressLine3Update, TestData.MerchantAddressLine4Update, TestData.MerchantTownUpdate, TestData.MerchantRegionUpdate, TestData.MerchantPostalCodeUpdate, TestData.MerchantCountryUpdate);
Result result = aggregate.UpdateAddress(newAddress);
result.IsSuccess.ShouldBeTrue();

Expand All @@ -598,7 +598,7 @@ public void MerchantAggregate_UpdateAddress_MerchantNotCreated_ErrorThrown()
{
MerchantAggregate aggregate = MerchantAggregate.Create(TestData.MerchantId);

Address newAddress = new(Guid.NewGuid(), TestData.MerchantAddressLine1Update, TestData.MerchantAddressLine2Update, TestData.MerchantAddressLine3Update, TestData.MerchantAddressLine4Update, TestData.MerchantTownUpdate, TestData.MerchantRegionUpdate, TestData.MerchantPostalCodeUpdate, TestData.MerchantCountryUpdate);
Address newAddress = Address.Create(Guid.NewGuid(), TestData.MerchantAddressLine1Update, TestData.MerchantAddressLine2Update, TestData.MerchantAddressLine3Update, TestData.MerchantAddressLine4Update, TestData.MerchantTownUpdate, TestData.MerchantRegionUpdate, TestData.MerchantPostalCodeUpdate, TestData.MerchantCountryUpdate);
Result result = aggregate.UpdateAddress(newAddress);
result.IsFailed.ShouldBeTrue();
result.Status.ShouldBe(ResultStatus.Invalid);
Expand All @@ -610,7 +610,7 @@ public void MerchantAggregate_UpdateAddress_AddressNotFound_NoErrorThrown(){
aggregate.Create(TestData.EstateId, TestData.MerchantName, TestData.DateMerchantCreated, TestData.AddressModel, TestData.ContactModel,
TestData.SettlementScheduleModel);

Address newAddress = new(Guid.NewGuid(), TestData.MerchantAddressLine1Update, TestData.MerchantAddressLine2Update, TestData.MerchantAddressLine3Update, TestData.MerchantAddressLine4Update, TestData.MerchantTownUpdate, TestData.MerchantRegionUpdate, TestData.MerchantPostalCodeUpdate, TestData.MerchantCountryUpdate);
Address newAddress = Address.Create(Guid.NewGuid(), TestData.MerchantAddressLine1Update, TestData.MerchantAddressLine2Update, TestData.MerchantAddressLine3Update, TestData.MerchantAddressLine4Update, TestData.MerchantTownUpdate, TestData.MerchantRegionUpdate, TestData.MerchantPostalCodeUpdate, TestData.MerchantCountryUpdate);

Result result = aggregate.UpdateAddress(newAddress);
result.IsSuccess.ShouldBeTrue();
Expand All @@ -625,7 +625,7 @@ public void MerchantAggregate_UpdateAddress_UpdatedAddressHasNotChanges_NoErrorT
Merchant merchantModel = aggregate.GetMerchant();
Address? address = merchantModel.Addresses.ShouldHaveSingleItem();

Address newAddress = new (address.AddressId, address.AddressLine1, address.AddressLine2, address.AddressLine3, address.AddressLine4, address.Town, address.Region, address.PostalCode, address.Country);
Address newAddress = Address.Create(address.AddressId, address.AddressLine1, address.AddressLine2, address.AddressLine3, address.AddressLine4, address.Town, address.Region, address.PostalCode, address.Country);

Result result = aggregate.UpdateAddress(newAddress);

Expand Down Expand Up @@ -845,5 +845,48 @@ public void MerchantAggregate_RemoveContract_And_ReAdd_ContractIsReAdded()
contractModel.ContractId.ShouldBe(TestData.ContractId);
contractModel.IsDeleted.ShouldBeFalse();
}

[Theory]
[InlineData("")]
[InlineData(null)]
public void Address_AddressLine1IsRequired_ErrorThrown(String addressLine1){
Should.Throw<ArgumentException>(() => {
Address.Create(Guid.NewGuid(), addressLine1, TestData.MerchantAddressLine2, TestData.MerchantAddressLine3, TestData.MerchantAddressLine4, TestData.MerchantTown, TestData.MerchantRegion, TestData.MerchantPostalCode, TestData.MerchantCountry);
});
}

[Theory]
[InlineData("")]
[InlineData(null)]
public void Address_TownIsRequired_ErrorThrown(String town)
{
Should.Throw<ArgumentException>(() => {
Address.Create(Guid.NewGuid(), TestData.MerchantAddressLine1, TestData.MerchantAddressLine2, TestData.MerchantAddressLine3, TestData.MerchantAddressLine4, town, TestData.MerchantRegion, TestData.MerchantPostalCode, TestData.MerchantCountry);
});
}


[Theory]
[InlineData("")]
[InlineData(null)]
public void Address_PostalCodeIsRequired_ErrorThrown(String postalCode)
{
Should.Throw<ArgumentException>(() => {
Address.Create(Guid.NewGuid(), TestData.MerchantAddressLine1, TestData.MerchantAddressLine2, TestData.MerchantAddressLine3, TestData.MerchantAddressLine4, TestData.MerchantTown, TestData.MerchantRegion, postalCode, TestData.MerchantCountry);
});
}



[Theory]
[InlineData("")]
[InlineData(null)]
public void Address_CountryIsRequired_ErrorThrown(String country)
{
Should.Throw<ArgumentException>(() => {
Address.Create(Guid.NewGuid(), TestData.MerchantAddressLine1, TestData.MerchantAddressLine2, TestData.MerchantAddressLine3, TestData.MerchantAddressLine4, TestData.MerchantTown, TestData.MerchantRegion, TestData.MerchantPostalCode, country);
});
}

}
}
2 changes: 1 addition & 1 deletion TransactionProcessor.Aggregates/MerchantAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public static Merchant GetMerchant(this MerchantAggregate aggregate)
{
merchantModel.Addresses = new();
foreach (KeyValuePair<Guid, Address> aggregateAddress in aggregate.Addresses) {
AddressModel address = new AddressModel(aggregateAddress.Key, aggregateAddress.Value.AddressLine1, aggregateAddress.Value.AddressLine2, aggregateAddress.Value.AddressLine3, aggregateAddress.Value.AddressLine4, aggregateAddress.Value.Town, aggregateAddress.Value.Region, aggregateAddress.Value.PostalCode, aggregateAddress.Value.Country);
AddressModel address = AddressModel.Create(aggregateAddress.Key, aggregateAddress.Value.AddressLine1, aggregateAddress.Value.AddressLine2, aggregateAddress.Value.AddressLine3, aggregateAddress.Value.AddressLine4, aggregateAddress.Value.Town, aggregateAddress.Value.Region, aggregateAddress.Value.PostalCode, aggregateAddress.Value.Country);

merchantModel.Addresses.Add(address);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public async Task<Result> CreateMerchant(MerchantCommands.CreateMerchantCommand
MerchantAggregate merchantAggregate = merchantResult.Data;

// Build up the models for the Crete call
Address address = new Address(Guid.Empty, command.RequestDto.Address.AddressLine1, command.RequestDto.Address.AddressLine2, command.RequestDto.Address.AddressLine3, command.RequestDto.Address.AddressLine4, command.RequestDto.Address.Town, command.RequestDto.Address.Region, command.RequestDto.Address.PostalCode, command.RequestDto.Address.Country);
Address address = Address.Create(Guid.Empty, command.RequestDto.Address.AddressLine1, command.RequestDto.Address.AddressLine2, command.RequestDto.Address.AddressLine3, command.RequestDto.Address.AddressLine4, command.RequestDto.Address.Town, command.RequestDto.Address.Region, command.RequestDto.Address.PostalCode, command.RequestDto.Address.Country);
Contact contact = new Contact(Guid.Empty, command.RequestDto.Contact.EmailAddress, command.RequestDto.Contact.ContactName, command.RequestDto.Contact.PhoneNumber);
// Set the settlement schedule
SettlementSchedule settlementSchedule = ConvertSettlementSchedule(command.RequestDto.SettlementSchedule);
Expand Down Expand Up @@ -504,7 +504,7 @@ public async Task<Result> AddMerchantAddress(MerchantCommands.AddMerchantAddress
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);

Address address = new(Guid.Empty, command.RequestDto.AddressLine1, command.RequestDto.AddressLine2, command.RequestDto.AddressLine3, command.RequestDto.AddressLine4, command.RequestDto.Town, command.RequestDto.Region, command.RequestDto.PostalCode, command.RequestDto.Country);
Address address = Address.Create(Guid.Empty, command.RequestDto.AddressLine1, command.RequestDto.AddressLine2, command.RequestDto.AddressLine3, command.RequestDto.AddressLine4, command.RequestDto.Town, command.RequestDto.Region, command.RequestDto.PostalCode, command.RequestDto.Country);

Result stateResult = merchantAggregate.AddAddress(address);
if (stateResult.IsFailed)
Expand Down Expand Up @@ -542,7 +542,7 @@ public async Task<Result> UpdateMerchantAddress(MerchantCommands.UpdateMerchantA
if (result.IsFailed)
return ResultHelpers.CreateFailure(result);

Address address = new(command.AddressId, command.RequestDto.AddressLine1, command.RequestDto.AddressLine2, command.RequestDto.AddressLine3, command.RequestDto.AddressLine4, command.RequestDto.Town, command.RequestDto.Region, command.RequestDto.PostalCode, command.RequestDto.Country);
Address address = Address.Create(command.AddressId, command.RequestDto.AddressLine1, command.RequestDto.AddressLine2, command.RequestDto.AddressLine3, command.RequestDto.AddressLine4, command.RequestDto.Town, command.RequestDto.Region, command.RequestDto.PostalCode, command.RequestDto.Country);

Result stateResult = merchantAggregate.UpdateAddress(address);
if (stateResult.IsFailed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,10 @@ public static List<CreateEstateRequest> ToCreateEstateRequests(this DataTableRow
"Region"),
Country =
ReqnrollTableHelper.GetStringRowValue(tableRow,
"Country")
"Country"),
PostalCode =
ReqnrollTableHelper.GetStringRowValue(tableRow,
"PostalCode")
},
SettlementSchedule = schedule,
MerchantId = Guid.NewGuid()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ Background:
Scenario: Get Merchant Contracts

Given I create the following merchants
| MerchantName | AddressLine1 | Town | Region | Country | ContactName | EmailAddress | EstateName |
| Test Merchant 1 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | [email protected] | Test Estate 1 |
| Test Merchant 2 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | [email protected] | Test Estate 2 |
| MerchantName | AddressLine1 | Town | Region | PostalCode | Country | ContactName | EmailAddress | EstateName |
| Test Merchant 1 | Address Line 1 | TestTown | Test Region | TE57 1NG | United Kingdom | Test Contact 1 | [email protected] | Test Estate 1 |
| Test Merchant 2 | Address Line 1 | TestTown | Test Region | TE57 2NG | United Kingdom | Test Contact 1 | [email protected] | Test Estate 2 |

Given I create a contract with the following values
| EstateName | OperatorName | ContractDescription |
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ Background:
| Test Estate 1 | Test Operator 1 |

Given I create the following merchants
| MerchantName | AddressLine1 | Town | Region | Country | ContactName | EmailAddress | EstateName |
| Test Merchant 1 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | [email protected] | Test Estate 1 |
| Test Merchant 2 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 2 | [email protected] | Test Estate 1 |
| Test Merchant 3 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 3 | [email protected] | Test Estate 1 |
| Test Merchant 4 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 4 | [email protected] | Test Estate 1 |
| Test Merchant 5 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 5 | [email protected] | Test Estate 1 |
| Test Merchant 6 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 6 | [email protected] | Test Estate 1 |
| Test Merchant 7 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 7 | [email protected] | Test Estate 1 |
| MerchantName | AddressLine1 | Town | Region | PostalCode | Country | ContactName | EmailAddress | EstateName |
| Test Merchant 1 | Address Line 1 | TestTown | Test Region | TE57 1NG | United Kingdom | Test Contact 1 | [email protected] | Test Estate 1 |
| Test Merchant 2 | Address Line 1 | TestTown | Test Region | TE57 2NG | United Kingdom | Test Contact 2 | [email protected] | Test Estate 1 |
| Test Merchant 3 | Address Line 1 | TestTown | Test Region | TE57 3NG | United Kingdom | Test Contact 3 | [email protected] | Test Estate 1 |
| Test Merchant 4 | Address Line 1 | TestTown | Test Region | TE57 4NG | United Kingdom | Test Contact 4 | [email protected] | Test Estate 1 |
| Test Merchant 5 | Address Line 1 | TestTown | Test Region | TE57 5NG | United Kingdom | Test Contact 5 | [email protected] | Test Estate 1 |
| Test Merchant 6 | Address Line 1 | TestTown | Test Region | TE57 6NG | United Kingdom | Test Contact 6 | [email protected] | Test Estate 1 |
| Test Merchant 7 | Address Line 1 | TestTown | Test Region | TE57 7NG | United Kingdom | Test Contact 7 | [email protected] | Test Estate 1 |

Given I have assigned the following operator to the merchants
| OperatorName | MerchantName | MerchantNumber | TerminalNumber | EstateName |
Expand Down
Loading
Loading