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 @@ -50,7 +50,7 @@ public void PerformMobileTopupRequest_ToTransactionRecord_IsTranslated(Boolean i
transactionRecord.ContractId.ShouldBe(request.ContractId);
transactionRecord.CustomerAccountNumber.ShouldBe(request.CustomerAccountNumber);
transactionRecord.CustomerEmailAddress.ShouldBe(request.CustomerEmailAddress);
transactionRecord.OperatorIdentifier.ShouldBe(request.OperatorId.ToString());
transactionRecord.OperatorId.ShouldBe(request.OperatorId);
}

[Theory]
Expand All @@ -76,7 +76,7 @@ public void PerformVoucherIssueRequest_ToTransactionRecord_IsTranslated(Boolean
transactionRecord.RecipientEmailAddress.ShouldBe(request.RecipientEmailAddress);
transactionRecord.RecipientMobileNumber.ShouldBe(request.RecipientMobileNumber);
transactionRecord.CustomerEmailAddress.ShouldBe(request.CustomerEmailAddress);
transactionRecord.OperatorIdentifier.ShouldBe(request.OperatorId.ToString());
transactionRecord.OperatorId.ShouldBe(request.OperatorId);
}

[Theory]
Expand All @@ -96,7 +96,7 @@ public void PerformBillPaymentGetAccountRequest_ToTransactionRecord_IsTranslated
transactionRecord.ProductId.ShouldBe(request.ProductId);
transactionRecord.ContractId.ShouldBe(request.ContractId);
transactionRecord.CustomerAccountNumber.ShouldBe(request.CustomerAccountNumber);
transactionRecord.OperatorIdentifier.ShouldBe(request.OperatorId.ToString());
transactionRecord.OperatorId.ShouldBe(request.OperatorId);
}

[Theory]
Expand All @@ -119,7 +119,7 @@ public void PerformBillPaymentMakePostPaymentRequest_ToTransactionRecord_IsTrans
transactionRecord.ProductId.ShouldBe(request.ProductId);
transactionRecord.ContractId.ShouldBe(request.ContractId);
transactionRecord.CustomerAccountNumber.ShouldBe(request.CustomerAccountNumber);
transactionRecord.OperatorIdentifier.ShouldBe(request.OperatorId.ToString());
transactionRecord.OperatorId.ShouldBe(request.OperatorId);
}

[Theory]
Expand All @@ -142,7 +142,7 @@ public void PerformBillPaymentMakePrePaymentRequest_ToTransactionRecord_IsTransl
transactionRecord.ProductId.ShouldBe(request.ProductId);
transactionRecord.ContractId.ShouldBe(request.ContractId);
transactionRecord.CustomerAccountNumber.ShouldBe(request.CustomerAccountNumber);
transactionRecord.OperatorIdentifier.ShouldBe(request.OperatorId.ToString());
transactionRecord.OperatorId.ShouldBe(request.OperatorId);
}

[Theory]
Expand All @@ -162,7 +162,7 @@ public void PerformBillPaymentGetMeterRequest_ToTransactionRecord_IsTranslated(B
transactionRecord.ProductId.ShouldBe(request.ProductId);
transactionRecord.ContractId.ShouldBe(request.ContractId);
transactionRecord.CustomerAccountNumber.ShouldBe(request.MeterNumber);
transactionRecord.OperatorIdentifier.ShouldBe(request.OperatorId.ToString());
transactionRecord.OperatorId.ShouldBe(request.OperatorId);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ public async Task AuthenticationService_GetToken_TokenReturned(){
token.Data.ExpiryInMinutes.ShouldBe(TestData.TokenExpiryInMinutes);
}

[Fact]
public async Task AuthenticationService_GetToken_SecurityClientFailed_TokenNotReturned()
{
this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(Result.Failure());

Result<TokenResponseModel> token = await this.AuthenticationService.GetToken(TestData.UserName, TestData.Password, CancellationToken.None);
token.IsFailed.ShouldBeTrue();
}

[Fact]
public async Task AuthenticationService_GetToken_SecurityClientThrowsException_TokenNotReturned()
{
Expand All @@ -65,6 +74,16 @@ public async Task AuthenticationService_RefreshAccessToken_TokenReturned()
token.Data.ExpiryInMinutes.ShouldBe(TestData.TokenExpiryInMinutes);
}

[Fact]
public async Task AuthenticationService_RefreshAccessToken_SecurityClientFailed_TokenNotReturned()
{
this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(Result.Failure());

Result<TokenResponseModel> token = await this.AuthenticationService.RefreshAccessToken(TestData.RefreshToken, CancellationToken.None);

token.IsFailed.ShouldBeTrue();
}

[Fact]
public async Task AuthenticationService_RefreshAccessToken_SecurityClientThrowsException_TokenNotReturned()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ public async Task MerchantService_GetMerchantDetails_MerchantDetailsReturned(){
merchantDetails.Data.SettlementSchedule.ShouldBe(merchantResponse.SettlementSchedule.ToString());
}

[Fact]
public async Task MerchantService_GetMerchantDetails_ResultFailed_FailedResultIsReturned()
{
this.MockHttpMessageHandler.When($"http://localhost/api/merchants?application_version=1.0.0")
.Respond(HttpStatusCode.BadRequest);

Result<MerchantDetailsModel> merchantDetails = await this.MerchantService.GetMerchantDetails(CancellationToken.None);
merchantDetails.IsFailed.ShouldBeTrue();
}

[Fact]
public async Task MerchantService_GetMerchantDetails_ExceptionThrown_FailedResultReturned(){
Expand Down
16 changes: 8 additions & 8 deletions TransactionMobile.Maui.BusinessLogic.Tests/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,26 @@ public static class TestData
new TransactionRecord{
Amount = TestData.Operator1Product_100KES.Value,
ContractId = TestData.Operator1Product_100KES.ContractId,
OperatorIdentifier = TestData.Operator1Product_100KES.OperatorIdentfier,
IsSuccessful = true
IsSuccessful = true,
OperatorId = TestData.Operator1Product_100KES.OperatorId,
},
new TransactionRecord{
Amount = TestData.Operator1Product_100KES.Value,
ContractId = TestData.Operator1Product_100KES.ContractId,
OperatorIdentifier = TestData.Operator1Product_100KES.OperatorIdentfier,
IsSuccessful = true
IsSuccessful = true,
OperatorId = TestData.Operator1Product_100KES.OperatorId,
},
new TransactionRecord{
Amount = TestData.Operator1Product_100KES.Value,
ContractId = TestData.Operator1Product_100KES.ContractId,
OperatorIdentifier = TestData.Operator1Product_100KES.OperatorIdentfier,
IsSuccessful = true
IsSuccessful = true,
OperatorId = TestData.Operator1Product_100KES.OperatorId,
},
new TransactionRecord{
Amount = TestData.Operator3Product_200KES.Value,
ContractId = TestData.Operator3Product_200KES.ContractId,
OperatorIdentifier = TestData.Operator3Product_200KES.OperatorIdentfier,
IsSuccessful = true
IsSuccessful = true,
OperatorId = TestData.Operator3Product_200KES.OperatorId,
}
};

Expand Down
19 changes: 9 additions & 10 deletions TransactionMobile.Maui.BusinessLogic/Common/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ public static TransactionRecord ToTransactionRecord(this PerformMobileTopupReque
ContractId = request.ContractId,
CustomerAccountNumber = request.CustomerAccountNumber,
CustomerEmailAddress = request.CustomerEmailAddress,
// TODO: Change db to be guid later
OperatorIdentifier = request.OperatorId.ToString(),
IsTrainingMode = isTrainingMode
OperatorId = request.OperatorId,
IsTrainingMode = isTrainingMode
};

return transactionRecord;
Expand All @@ -50,8 +49,8 @@ public static TransactionRecord ToTransactionRecord(this PerformVoucherIssueRequ
RecipientEmailAddress = request.RecipientEmailAddress,
RecipientMobileNumber = request.RecipientMobileNumber,
CustomerEmailAddress = request.CustomerEmailAddress,
OperatorIdentifier = request.OperatorId.ToString(),
IsTrainingMode = isTrainingMode
OperatorId = request.OperatorId,
IsTrainingMode = isTrainingMode
};

return transactionRecord;
Expand All @@ -65,8 +64,8 @@ public static TransactionRecord ToTransactionRecord(this PerformBillPaymentGetAc
Amount = 0,
ProductId = request.ProductId,
ContractId = request.ContractId,
OperatorIdentifier = request.OperatorId.ToString(),
CustomerAccountNumber = request.CustomerAccountNumber,
OperatorId = request.OperatorId,
CustomerAccountNumber = request.CustomerAccountNumber,
IsTrainingMode = isTrainingMode
};
return transactionRecord;
Expand All @@ -80,7 +79,7 @@ public static TransactionRecord ToTransactionRecord(this PerformBillPaymentMakeP
Amount = 0,
ProductId = request.ProductId,
ContractId = request.ContractId,
OperatorIdentifier = request.OperatorId.ToString(),
OperatorId = request.OperatorId,
CustomerAccountNumber = request.CustomerAccountNumber,
IsTrainingMode = isTrainingMode
};
Expand All @@ -96,7 +95,7 @@ public static TransactionRecord ToTransactionRecord(this PerformBillPaymentMakeP
Amount = 0,
ProductId = request.ProductId,
ContractId = request.ContractId,
OperatorIdentifier = request.OperatorId.ToString(),
OperatorId = request.OperatorId,
CustomerAccountNumber = request.MeterNumber,
IsTrainingMode = isTrainingMode
};
Expand All @@ -112,7 +111,7 @@ public static TransactionRecord ToTransactionRecord(this PerformBillPaymentGetMe
Amount = 0,
ProductId = request.ProductId,
ContractId = request.ContractId,
OperatorIdentifier = request.OperatorId.ToString(),
OperatorId = request.OperatorId,
CustomerAccountNumber = request.MeterNumber,
IsTrainingMode = isTrainingMode
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public class TransactionRecord
public String CustomerEmailAddress { get; set; }

public String DeviceIdentifier { get; set; }

public String OperatorIdentifier { get; set; }


public Guid ProductId { get; set; }

public Decimal Amount { get; set; }
Expand All @@ -39,6 +37,7 @@ public class TransactionRecord
public String ResponseMessage { get; set; }

public Boolean IsTrainingMode { get; set; }
public Guid OperatorId { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,22 @@ public async Task<Result<PerformReconciliationResponseModel>> Handle(PerformReco
group t by new
{
t.ContractId,
t.OperatorIdentifier
t.OperatorId
}
into tempOperatorTotals
select new
{
ContractId = tempOperatorTotals.Key.ContractId,
OperatorId = tempOperatorTotals.Key.OperatorIdentifier,
OperatorId = tempOperatorTotals.Key.OperatorId,
TransactionValue = tempOperatorTotals.Sum(t => t.Amount),
TransactionCount = tempOperatorTotals.Count()
}).ToList();

List<OperatorTotalModel> operatorTotals = (from t in workingTotals
where Guid.TryParse(t.OperatorId, out _) == true
select new OperatorTotalModel
{
ContractId = t.ContractId,
OperatorId = Guid.Parse(t.OperatorId),
OperatorId = t.OperatorId,
TransactionValue = t.TransactionValue,
TransactionCount = t.TransactionCount
}).ToList();
Expand Down
Loading
Loading