Skip to content

Commit dfc7cbb

Browse files
Merge pull request #192 from TransactionProcessing/specflow/#188_settlementdatecomparison
Fix issues with Settlement Tests
2 parents 3d0d116 + 79a9e67 commit dfc7cbb

File tree

11 files changed

+67
-84
lines changed

11 files changed

+67
-84
lines changed

TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
108108
this.TransactionAggregateManager.Setup(t => t.GetAggregate(It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
109109
.ReturnsAsync(TestData.GetCompletedAuthorisedSaleTransactionAggregate);
110110

111-
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>())).Returns(new List<CalculatedFee>
111+
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>(), It.IsAny<DateTime>())).Returns(new List<CalculatedFee>
112112
{
113113
TestData.CalculatedFeeMerchantFee(),
114114
TestData.CalculatedFeeServiceProviderFee
@@ -154,7 +154,7 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
154154
this.SettlementAggregateRepository.Setup(p => p.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
155155
.ReturnsAsync(pendingSettlementAggregate);
156156

157-
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>())).Returns(new List<CalculatedFee>
157+
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>(), It.IsAny<DateTime>())).Returns(new List<CalculatedFee>
158158
{
159159
TestData.CalculatedFeeMerchantFee(),
160160
TestData.CalculatedFeeServiceProviderFee
@@ -204,7 +204,7 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
204204
this.SettlementAggregateRepository.Setup(p => p.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
205205
.ReturnsAsync(pendingSettlementAggregate);
206206

207-
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>())).Returns(new List<CalculatedFee>
207+
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>(), It.IsAny<DateTime>())).Returns(new List<CalculatedFee>
208208
{
209209
TestData.CalculatedFeeMerchantFee(),
210210
TestData.CalculatedFeeServiceProviderFee
@@ -251,7 +251,7 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
251251
this.TransactionAggregateManager.Setup(t => t.GetAggregate(It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
252252
.ReturnsAsync(TestData.GetCompletedAuthorisedSaleTransactionAggregate);
253253

254-
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>())).Returns(new List<CalculatedFee>
254+
this.FeeCalculationManager.Setup(f => f.CalculateFees(It.IsAny<List<TransactionFeeToCalculate>>(), It.IsAny<Decimal>(), It.IsAny<DateTime>())).Returns(new List<CalculatedFee>
255255
{
256256
TestData.CalculatedFeeMerchantFee(),
257257
TestData.CalculatedFeeServiceProviderFee

TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent do
202202
}
203203

204204
// Do the fee calculation
205-
List<CalculatedFee> resultFees = this.FeeCalculationManager.CalculateFees(feesForCalculation, transactionAggregate.TransactionAmount.Value);
205+
List<CalculatedFee> resultFees = this.FeeCalculationManager.CalculateFees(feesForCalculation, transactionAggregate.TransactionAmount.Value, domainEvent.CompletedDateTime);
206206

207207
// Process the non merchant fees
208208
IEnumerable<CalculatedFee> nonMerchantFees = resultFees.Where(f => f.FeeType == FeeType.ServiceProvider);

TransactionProcessor.BusinessLogic/Manager/FeeCalculationManager.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public class FeeCalculationManager : IFeeCalculationManager
2020
/// <param name="transactionAmount">The transaction amount.</param>
2121
/// <returns></returns>
2222
public List<CalculatedFee> CalculateFees(List<TransactionFeeToCalculate> feeList,
23-
Decimal transactionAmount)
23+
Decimal transactionAmount,
24+
DateTime calculationDateTime = new DateTime())
2425
{
2526
List<CalculatedFee> calculatedFees = new List<CalculatedFee>();
2627

@@ -37,7 +38,7 @@ public List<CalculatedFee> CalculateFees(List<TransactionFeeToCalculate> feeList
3738
FeeCalculationType = transactionFeeToCalculate.CalculationType,
3839
FeeId = transactionFeeToCalculate.FeeId,
3940
FeeValue = transactionFeeToCalculate.Value,
40-
FeeCalculatedDateTime = DateTime.Now
41+
FeeCalculatedDateTime = calculationDateTime == DateTime.MinValue ? DateTime.Now : calculationDateTime
4142
});
4243
}
4344

@@ -51,7 +52,7 @@ public List<CalculatedFee> CalculateFees(List<TransactionFeeToCalculate> feeList
5152
FeeCalculationType = transactionFeeToCalculate.CalculationType,
5253
FeeId = transactionFeeToCalculate.FeeId,
5354
FeeValue = transactionFeeToCalculate.Value,
54-
FeeCalculatedDateTime = DateTime.Now
55+
FeeCalculatedDateTime = calculationDateTime == DateTime.MinValue ? DateTime.Now : calculationDateTime
5556
});
5657
}
5758
}

TransactionProcessor.BusinessLogic/Manager/IFeeCalculationManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ public interface IFeeCalculationManager
1717
/// </summary>
1818
/// <param name="feeList">The fee list.</param>
1919
/// <param name="transactionAmount">The transaction amount.</param>
20+
/// <param name="calculationDateTime">The calculation date time.</param>
2021
/// <returns></returns>
2122
List<CalculatedFee> CalculateFees(List<TransactionFeeToCalculate> feeList,
22-
Decimal transactionAmount);
23+
Decimal transactionAmount,
24+
DateTime calculationDateTime = new DateTime());
2325

2426
#endregion
2527
}

TransactionProcessor.IntegrationTests/LogonTransaction/LogonTransaction.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ Scenario: Logon Transaction with Existing Device
7575
| EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage |
7676
| Test Estate 1 | Test Merchant 1 | 1 | 0000 | SUCCESS |
7777

78-
@PRTest
7978
Scenario: Logon Transaction with Invalid Device
8079

8180
Given I have assigned the following devices to the merchants

TransactionProcessor.IntegrationTests/LogonTransaction/LogonTransaction.feature.cs

Lines changed: 13 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TransactionProcessor.IntegrationTests/SaleTransaction/SaleTransactionFeature.feature

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ Scenario: Sale Transactions
104104
| Test Estate 1 | Test Merchant 2 | 6 | 0000 | SUCCESS |
105105
| Test Estate 2 | Test Merchant 3 | 7 | 0000 | SUCCESS |
106106

107-
@PRTest
108107
Scenario: Sale Transaction with Invalid Device
109108

110109
When I perform the following transactions
@@ -135,7 +134,6 @@ Scenario: Sale Transaction with Invalid Merchant
135134
| EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage |
136135
| Test Estate 1 | InvalidMerchant | 1 | 1002 | Merchant Id [d59320fa-4c3e-4900-a999-483f6a10c69a] is not a valid merchant for estate [Test Estate 1] |
137136

138-
@PRTest
139137
Scenario: Sale Transaction with Not Enough Credit Available
140138

141139
When I perform the following transactions

0 commit comments

Comments
 (0)