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 @@ -24,7 +24,8 @@ public async Task MerchantRequestHandler_GetContractProductsRequest_Handle_IsHan

GetContractProductsRequest request = GetContractProductsRequest.Create(TestData.AccessToken,
TestData.EstateId,
TestData.MerchantId);
TestData.MerchantId,
null);

List<ContractProductModel> contractProductModels = await handler.Handle(request, CancellationToken.None);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,28 @@ public async Task TransactionRequestHandler_PerformMobileTopupRequest_Handle_IsH

response.ShouldBeTrue();
}

[Fact]
public async Task TransactionRequestHandler_PerformVoucherIssueRequest_Handle_IsHandled()
{
Mock<ITransactionService> transactionService = new Mock<ITransactionService>();
transactionService.Setup(t => t.PerformVoucherIssue(It.IsAny<PerformVoucherIssueRequestModel>(), It.IsAny<CancellationToken>())).ReturnsAsync(true);
TransactionRequestHandler handler = new TransactionRequestHandler(transactionService.Object);

PerformVoucherIssueRequest request = PerformVoucherIssueRequest.Create(TestData.TransactionDateTime,
TestData.TransactionNumber,
TestData.DeviceIdentifier,
TestData.ApplicationVersion,
TestData.OperatorId3ContractId,
TestData.Operator3Product_200KES.ProductId,
TestData.OperatorIdentifier3,
TestData.RecipientMobileNumber,
TestData.RecipientEmailAddress,
TestData.Operator3Product_200KES.Value,
TestData.CustomerEmailAddress);

Boolean response = await handler.Handle(request, CancellationToken.None);

response.ShouldBeTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public void GetContractProductsRequest_Create_IsCreated()
{
GetContractProductsRequest request = GetContractProductsRequest.Create(TestData.AccessToken,
TestData.EstateId,
TestData.MerchantId);
TestData.MerchantId,
null);

request.ShouldNotBeNull();
request.AccessToken.ShouldBe(TestData.AccessToken);
Expand Down Expand Up @@ -90,4 +91,33 @@ public void PerformMobileTopupRequest_Create_IsCreated()
request.TopupAmount.ShouldBe(TestData.Operator1Product_100KES.Value);
request.CustomerEmailAddress.ShouldBe(TestData.CustomerEmailAddress);
}

[Fact]
public void PerformVoucherIssueRequest_Create_IsCreated()
{
PerformVoucherIssueRequest request = PerformVoucherIssueRequest.Create(TestData.TransactionDateTime,
TestData.TransactionNumber,
TestData.DeviceIdentifier,
TestData.ApplicationVersion,
TestData.OperatorId3ContractId,
TestData.Operator3Product_200KES.ProductId,
TestData.OperatorIdentifier3,
TestData.RecipientMobileNumber,
TestData.RecipientEmailAddress,
TestData.Operator3Product_200KES.Value,
TestData.CustomerEmailAddress);

request.ShouldNotBeNull();
request.TransactionDateTime.ShouldBe(TestData.TransactionDateTime);
request.TransactionNumber.ShouldBe(TestData.TransactionNumber);
request.DeviceIdentifier.ShouldBe(TestData.DeviceIdentifier);
request.ApplicationVersion.ShouldBe(TestData.ApplicationVersion);
request.ContractId.ShouldBe(TestData.OperatorId3ContractId);
request.ProductId.ShouldBe(TestData.Operator3Product_200KES.ProductId);
request.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier3);
request.RecipientMobileNumber.ShouldBe(TestData.RecipientMobileNumber);
request.RecipientEmailAddress.ShouldBe(TestData.RecipientEmailAddress);
request.VoucherAmount.ShouldBe(TestData.Operator3Product_200KES.Value);
request.CustomerEmailAddress.ShouldBe(TestData.CustomerEmailAddress);
}
}
25 changes: 24 additions & 1 deletion TransactionMobile.Maui.BusinessLogic.Tests/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ public static class TestData

public static String OperatorIdentifier1 = "Safaricom";
public static String OperatorIdentifier2 = "Safaricom1";
public static String OperatorIdentifier3 = "Voucher";

public static String OperatorName1 = "Safaricom";
public static String OperatorName2 = "Safaricom1";
public static String OperatorName3 = "Voucher";

public static Guid OperatorId1 = Guid.Parse("2CA5F4C7-34EC-425B-BB53-7EEDF48D9967");
public static Guid OperatorId2 = Guid.Parse("1CA5F4C7-34EC-425B-BB53-7EEDF48D9968");
public static Guid OperatorId3 = Guid.Parse("17FA0431-4DCB-43CF-97B7-2CEDC74E4796");

public static Guid OperatorId1ContractId = Guid.Parse("D57DAC9B-4039-4120-B5A8-F7FDF1D3A3C2");
public static Guid OperatorId2ContractId = Guid.Parse("2471F981-DDA8-4B87-91F4-DD5DCB984FC1");
public static Guid OperatorId3ContractId = Guid.Parse("(0BCACE74-CBF1-4F2C-AC1C-733BF1F53133)");

public static ContractProductModel Operator1Product_100KES = new ContractProductModel
{
Expand Down Expand Up @@ -75,12 +80,26 @@ public static class TestData
ProductType = ProductType.MobileTopup
};

public static ContractProductModel Operator3Product_200KES = new ContractProductModel
{
ContractId = OperatorId3ContractId,
IsFixedValue = false,
OperatorId = TestData.OperatorId3,
OperatorIdentfier = OperatorIdentifier3,
OperatorName = OperatorName3,
ProductDisplayText = "100 KES",
ProductId = Guid.Parse("3270DC5F-1BB3-4ECF-BA06-AFB42B651483"),
ProductType = ProductType.Voucher,
Value = 200
};

public static List<ContractProductModel> ContractProductList = new List<ContractProductModel>
{
Operator1Product_100KES,
Operator1Product_200KES,
Operator1Product_Custom,
Operator2Product_Custom
Operator2Product_Custom,
TestData.Operator3Product_200KES
};

public static ContractOperatorModel ContractOperatorModel = new ContractOperatorModel
Expand All @@ -104,6 +123,10 @@ public static class TestData
public static String CustomerAccountNumber = "0123456";
public static String CustomerEmailAddress = "1@2.com";

public static String RecipientMobileNumber = "0123456";

public static String RecipientEmailAddress = "1@2.com";

public static Decimal MerchantBalance = 199.99m;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests;
using ViewModels.Transactions;
using Xunit;

public class MobileTopupFailedViewModelTests
public class MobileTopupFailedPageViewModelTests
{
[Fact]
public void MobileTopupFailedPageViewModel_CompletedCommand_Execute_IsExecuted()
public void MobileTopupFailedPageViewModel_CancelledCommand_Execute_IsExecuted()
{
Mock<INavigationService> navigationService = new Mock<INavigationService>();
MobileTopupFailedPageViewModel viewModel = new MobileTopupFailedPageViewModel(navigationService.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public void MobileTopupPerformTopupPageViewModel_ApplyQueryAttributes_QueryAttri
{
{nameof(viewModel.ContractId), TestData.OperatorId1ContractId},
{nameof(viewModel.ProductId), TestData.Operator1Product_100KES.ProductId},
{nameof(viewModel.OperatorIdentifer), TestData.OperatorIdentifier1},
{nameof(viewModel.OperatorIdentifier), TestData.OperatorIdentifier1},
{nameof(viewModel.TopupAmount), TestData.Operator1Product_100KES.Value}
});

viewModel.ContractId.ShouldBe(TestData.OperatorId1ContractId.ToString());
viewModel.ProductId.ShouldBe(TestData.Operator1Product_100KES.ProductId.ToString());
viewModel.OperatorIdentifer.ShouldBe(TestData.OperatorIdentifier1);
viewModel.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier1);
viewModel.TopupAmount.ShouldBe(TestData.Operator1Product_100KES.Value);
}

Expand All @@ -50,7 +50,7 @@ public void MobileTopupPerformTopupPageViewModel_CustomerEmailAddressEntryComple
{
{nameof(viewModel.ContractId), TestData.OperatorId1ContractId},
{nameof(viewModel.ProductId), TestData.Operator1Product_100KES.ProductId},
{nameof(viewModel.OperatorIdentifer), TestData.OperatorIdentifier1},
{nameof(viewModel.OperatorIdentifier), TestData.OperatorIdentifier1},
{nameof(viewModel.TopupAmount), TestData.Operator1Product_100KES.Value}
});
viewModel.CustomerEmailAddressEntryCompletedCommand.Execute(null);
Expand All @@ -73,7 +73,7 @@ public void MobileTopupPerformTopupPageViewModel_CustomerMobileNumberEntryComple
{
{nameof(viewModel.ContractId), TestData.OperatorId1ContractId},
{nameof(viewModel.ProductId), TestData.Operator1Product_100KES.ProductId},
{nameof(viewModel.OperatorIdentifer), TestData.OperatorIdentifier1},
{nameof(viewModel.OperatorIdentifier), TestData.OperatorIdentifier1},
{nameof(viewModel.TopupAmount), TestData.Operator1Product_100KES.Value}
});
viewModel.CustomerMobileNumberEntryCompletedCommand.Execute(null);
Expand All @@ -96,7 +96,7 @@ public void MobileTopupPerformTopupPageViewModel_TopupAmountEntryCompletedComman
{
{nameof(viewModel.ContractId), TestData.OperatorId1ContractId},
{nameof(viewModel.ProductId), TestData.Operator1Product_100KES.ProductId},
{nameof(viewModel.OperatorIdentifer), TestData.OperatorIdentifier1},
{nameof(viewModel.OperatorIdentifier), TestData.OperatorIdentifier1},
{nameof(viewModel.TopupAmount), TestData.Operator1Product_100KES.Value}
});
viewModel.TopupAmountEntryCompletedCommand.Execute(null);
Expand All @@ -114,7 +114,7 @@ public void MobileTopupPerformTopupPageViewModel_PerformTopupCommand_Execute_Suc
{
{nameof(viewModel.ContractId), TestData.OperatorId1ContractId},
{nameof(viewModel.ProductId), TestData.Operator1Product_100KES.ProductId},
{nameof(viewModel.OperatorIdentifer), TestData.OperatorIdentifier1},
{nameof(viewModel.OperatorIdentifier), TestData.OperatorIdentifier1},
{nameof(viewModel.TopupAmount), TestData.Operator1Product_100KES.Value}
});
viewModel.PerformTopupCommand.Execute(null);
Expand All @@ -133,7 +133,7 @@ public void MobileTopupPerformTopupPageViewModel_PerformTopupCommand_Execute_Fai
{
{nameof(viewModel.ContractId), TestData.OperatorId1ContractId},
{nameof(viewModel.ProductId), TestData.Operator1Product_100KES.ProductId},
{nameof(viewModel.OperatorIdentifer), TestData.OperatorIdentifier1},
{nameof(viewModel.OperatorIdentifier), TestData.OperatorIdentifier1},
{nameof(viewModel.TopupAmount), TestData.Operator1Product_100KES.Value}
});
viewModel.PerformTopupCommand.Execute(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task MobileTopupSelectOperatorPageViewModel_Initialise_IsInitialise
await viewModel.Initialise(CancellationToken.None);
mediator.Verify(x => x.Send(It.IsAny<GetContractProductsRequest>(), It.IsAny<CancellationToken>()), Times.Once);

viewModel.Operators.Count.ShouldBe(2);
viewModel.Operators.Count.ShouldBe(3);
}

[Fact]
Expand All @@ -37,7 +37,7 @@ public async Task MobileTopupSelectOperatorPageViewModel_OperatorSelectedCommand

await viewModel.Initialise(CancellationToken.None);

viewModel.Operators.Count.ShouldBe(2);
viewModel.Operators.Count.ShouldBe(3);

ItemSelected<ContractOperatorModel> selectedContractOperator = new ItemSelected<ContractOperatorModel>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests;
using ViewModels.Transactions;
using Xunit;

public class MobileTopupSuccessViewModelTests
public class MobileTopupSuccessPageViewModelTests
{
[Fact]
public void MobileTopupSuccessPageViewModel_CompletedCommand_Execute_IsExecuted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public void TransactionsPageViewModel_VoucherCommand_Execute_IsExecuted()
TransactionsPageViewModel viewModel = new TransactionsPageViewModel(navigationService.Object);

viewModel.VoucherCommand.Execute(null);
navigationService.Verify(n => n.GoToHome(), Times.Once);
navigationService.Verify(n => n.GoToVoucherSelectOperatorPage(), Times.Once);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests;

using Moq;
using UIServices;
using ViewModels.Transactions;
using Xunit;

public class VoucherIssueFailedPageViewModelTests
{
[Fact]
public void VoucherIssueFailedPageViewModel_CancelledCommand_Execute_IsExecuted()
{
Mock<INavigationService> navigationService = new Mock<INavigationService>();
VoucherIssueFailedPageViewModel viewModel = new VoucherIssueFailedPageViewModel(navigationService.Object);

viewModel.CancelledCommand.Execute(null);
navigationService.Verify(n => n.PopToRoot(), Times.Once);
}
}
Loading