diff --git a/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs b/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs index ca2dff3a..c467dd73 100644 --- a/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs +++ b/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs @@ -10,6 +10,7 @@ using Shouldly; using SimpleResults; using TransactionProcessor.Client; +using TransactionProcessor.DataTransferObjects.Requests.Contract; using TransactionProcessor.DataTransferObjects.Requests.Merchant; using TransactionProcessor.DataTransferObjects.Requests.Operator; using TransactionProcessor.DataTransferObjects.Responses.Contract; @@ -642,4 +643,132 @@ public async Task ApiClient_RemoveOperatorFromMerchant_ClientCallFailed_ResultIs TestData.Operator1Id, CancellationToken.None); result.IsFailed.ShouldBeTrue(); } + + [Fact] + public async Task ApiClient_AssignDeviceToMerchant_DeviceAssigned() + { + this.TransactionProcessorClient.Setup(e => e.AddDeviceToMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); + + Result result = await this.ApiClient.AssignDeviceToMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, + TestData.AssignDeviceToMerchantModel, CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_AssignDeviceToMerchant_ClientCallFailed_ResultIsFailed() + { + this.TransactionProcessorClient.Setup(e => e.AddDeviceToMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); + + Result result = await this.ApiClient.AssignDeviceToMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, + TestData.AssignDeviceToMerchantModel, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_CreateContract_DataIsReturned() + { + this.TransactionProcessorClient.Setup(e => e.CreateContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); + + Result result = await this.ApiClient.CreateContract(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.CreateContractModel, CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_CreateContract_ErrorAtServer_NoDataIsReturned() + { + this.TransactionProcessorClient.Setup(e => e.CreateContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + Result result = await this.ApiClient.CreateContract(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.CreateContractModel, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_CreateContract_ClientThrowsException_ResultIsFailed() + { + this.TransactionProcessorClient.Setup(e => e.CreateContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); + + Result result = await this.ApiClient.CreateContract(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.CreateContractModel, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_MakeDeposit_DataIsReturned() + { + this.TransactionProcessorClient.Setup(e => e.MakeMerchantDeposit(It.IsAny(), It.IsAny(),It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); + + Result result = await this.ApiClient.MakeDeposit(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, TestData.MakeDepositModel, CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_MakeDeposit_ErrorAtServer_NoDataIsReturned() + { + this.TransactionProcessorClient.Setup(e => e.MakeMerchantDeposit(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + Result result = await this.ApiClient.MakeDeposit(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, TestData.MakeDepositModel, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_MakeDeposit_ClientThrowsException_ResultIsFailed() + { + this.TransactionProcessorClient.Setup(e => e.MakeMerchantDeposit(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); + + Result result = await this.ApiClient.MakeDeposit(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, TestData.MakeDepositModel, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_CreateContractProduct_DataIsReturned() + { + this.TransactionProcessorClient.Setup(e => e.AddProductToContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); + + Result result = await this.ApiClient.CreateContractProduct(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Contract1Id, TestData.CreateContractProductModel, CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_CreateContractProduct_ErrorAtServer_NoDataIsReturned() + { + this.TransactionProcessorClient.Setup(e => e.AddProductToContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + Result result = await this.ApiClient.CreateContractProduct(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Contract1Id, TestData.CreateContractProductModel, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_CreateContractProduct_ClientThrowsException_ResultIsFailed() + { + this.TransactionProcessorClient.Setup(e => e.AddProductToContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); + + Result result = await this.ApiClient.CreateContractProduct(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Contract1Id, TestData.CreateContractProductModel, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_CreateContractProductTransactionFee_DataIsReturned() + { + this.TransactionProcessorClient.Setup(e => e.AddTransactionFeeForProductToContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); + + Result result = await this.ApiClient.CreateContractProductTransactionFee(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Contract1Id, TestData.Contract1Product1Id, TestData.CreateContractProductTransactionFeeModel, CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_CreateContractProductTransactionFee_ErrorAtServer_NoDataIsReturned() + { + this.TransactionProcessorClient.Setup(e => e.AddTransactionFeeForProductToContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + Result result = await this.ApiClient.CreateContractProductTransactionFee(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Contract1Id, TestData.Contract1Product1Id, TestData.CreateContractProductTransactionFeeModel, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task ApiClient_CreateContractProductTransactionFee_ClientThrowsException_ResultIsFailed() + { + this.TransactionProcessorClient.Setup(e => e.AddTransactionFeeForProductToContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); + + Result result = await this.ApiClient.CreateContractProductTransactionFee(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Contract1Id, TestData.Contract1Product1Id, TestData.CreateContractProductTransactionFeeModel, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } } \ No newline at end of file diff --git a/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs b/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs index f2fad8b4..655b97e1 100644 --- a/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs +++ b/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs @@ -57,6 +57,11 @@ public MediatorTests() { this.Requests.Add(TestData.RemoveOperatorFromMerchantCommand); this.Requests.Add(TestData.AssignContractToMerchantCommand); this.Requests.Add(TestData.RemoveContractFromMerchantCommand); + this.Requests.Add(TestData.AssignDeviceToMerchantCommand); + this.Requests.Add(TestData.CreateContractCommand); + this.Requests.Add(TestData.CreateContractProductCommand); + this.Requests.Add(TestData.CreateContractProductTransactionFeeCommand); + this.Requests.Add(TestData.MakeDepositCommand); diff --git a/EstateManagementUI.BusinessLogic.Tests/ModelFactoryTests.cs b/EstateManagementUI.BusinessLogic.Tests/ModelFactoryTests.cs index 2d97780e..24745ed8 100644 --- a/EstateManagementUI.BusinessLogic.Tests/ModelFactoryTests.cs +++ b/EstateManagementUI.BusinessLogic.Tests/ModelFactoryTests.cs @@ -795,6 +795,23 @@ public void ModelFactory_ConvertFrom_AssignContractToMerchantModel_ModelIsNull_M request.ShouldBeNull(); } + [Fact] + public void ModelFactory_ConvertFrom_AssignDeviceToMerchantModel_ModelIsConverted() + { + var model = TestData.AssignDeviceToMerchantModel; + var request = ModelFactory.ConvertFrom(model); + request.ShouldNotBeNull(); + request.DeviceIdentifier.ShouldBe(model.DeviceIdentifier); + } + + [Fact] + public void ModelFactory_ConvertFrom_AssignDeviceToMerchantModel_ModelIsNull_ModelIsConverted() + { + AssignDeviceToMerchantModel model = null; + var request = ModelFactory.ConvertFrom(model); + request.ShouldBeNull(); + } + [Fact] public void ModelFactory_ConvertFrom_FileDetails_SourceIsNull_ReturnsNull() { diff --git a/EstateManagementUI.BusinessLogic/Clients/ApiClient.cs b/EstateManagementUI.BusinessLogic/Clients/ApiClient.cs index 4829587d..b656dfae 100644 --- a/EstateManagementUI.BusinessLogic/Clients/ApiClient.cs +++ b/EstateManagementUI.BusinessLogic/Clients/ApiClient.cs @@ -61,7 +61,21 @@ async Task ClientMethod() { return await this.TransactionProcessorClient.AddContractToMerchant(accessToken, estateId, merchantId, apiRequest, cancellationToken); } - ; + return await this.CallClientMethod(ClientMethod, cancellationToken); + } + + public async Task AssignDeviceToMerchant(String accessToken, + Guid actionId, + Guid estateId, + Guid merchantId, + AssignDeviceToMerchantModel assignDeviceToMerchantModel, + CancellationToken cancellationToken) { + async Task ClientMethod() + { + AddMerchantDeviceRequest apiRequest = ModelFactory.ConvertFrom(assignDeviceToMerchantModel); + + return await this.TransactionProcessorClient.AddDeviceToMerchant(accessToken, estateId, merchantId, apiRequest, cancellationToken); + } return await this.CallClientMethod(ClientMethod, cancellationToken); } diff --git a/EstateManagementUI.BusinessLogic/Clients/IApiClient.cs b/EstateManagementUI.BusinessLogic/Clients/IApiClient.cs index 2fd7751e..e3fbab3a 100644 --- a/EstateManagementUI.BusinessLogic/Clients/IApiClient.cs +++ b/EstateManagementUI.BusinessLogic/Clients/IApiClient.cs @@ -27,6 +27,13 @@ Task AssignContractToMerchant(String accessToken, AssignContractToMerchantModel assignContractToMerchantModel, CancellationToken cancellationToken); + Task AssignDeviceToMerchant(String accessToken, + Guid actionId, + Guid estateId, + Guid merchantId, + AssignDeviceToMerchantModel assignDeviceToMerchantModel, + CancellationToken cancellationToken); + Task RemoveOperatorFromMerchant(String accessToken, Guid actionId, Guid estateId, diff --git a/EstateManagementUI.BusinessLogic/Common/ConfigurationService.cs b/EstateManagementUI.BusinessLogic/Common/ConfigurationService.cs index 31208b50..cf80de02 100644 --- a/EstateManagementUI.BusinessLogic/Common/ConfigurationService.cs +++ b/EstateManagementUI.BusinessLogic/Common/ConfigurationService.cs @@ -1,7 +1,9 @@ -using Shared.General; +using System.Diagnostics.CodeAnalysis; +using Shared.General; namespace EstateManagementUI.BusinessLogic.Common; +[ExcludeFromCodeCoverage] public class ConfigurationService : IConfigurationService { public Boolean GetPermissionsBypass() diff --git a/EstateManagementUI.BusinessLogic/Common/ModelFactory.cs b/EstateManagementUI.BusinessLogic/Common/ModelFactory.cs index a256c2da..dcb21648 100644 --- a/EstateManagementUI.BusinessLogic/Common/ModelFactory.cs +++ b/EstateManagementUI.BusinessLogic/Common/ModelFactory.cs @@ -728,4 +728,13 @@ public static AddTransactionFeeForProductToContractRequest ConvertFrom(CreateCon }; return addTransactionFeeForProductToContractRequest; } + + public static AddMerchantDeviceRequest ConvertFrom(AssignDeviceToMerchantModel source) { + if (source == null) + { + return null; + } + AddMerchantDeviceRequest addMerchantDeviceRequest = new() { DeviceIdentifier = source.DeviceIdentifier }; + return addMerchantDeviceRequest; + } } \ No newline at end of file diff --git a/EstateManagementUI.BusinessLogic/Models/AssignContractToMerchantModel.cs b/EstateManagementUI.BusinessLogic/Models/AssignContractToMerchantModel.cs index 38767cb0..6b5295c8 100644 --- a/EstateManagementUI.BusinessLogic/Models/AssignContractToMerchantModel.cs +++ b/EstateManagementUI.BusinessLogic/Models/AssignContractToMerchantModel.cs @@ -9,5 +9,15 @@ public class AssignContractToMerchantModel public Guid ContractId { get; set; } + #endregion +} + +[ExcludeFromCodeCoverage] +public class AssignDeviceToMerchantModel +{ + #region Properties + + public String DeviceIdentifier { get; set; } + #endregion } \ No newline at end of file diff --git a/EstateManagementUI.BusinessLogic/Models/UpdateOperatorModel.cs b/EstateManagementUI.BusinessLogic/Models/UpdateOperatorModel.cs index ee8cc5d4..8c71ce96 100644 --- a/EstateManagementUI.BusinessLogic/Models/UpdateOperatorModel.cs +++ b/EstateManagementUI.BusinessLogic/Models/UpdateOperatorModel.cs @@ -86,6 +86,7 @@ public class AddressModel #endregion } +[ExcludeFromCodeCoverage] public class CreateContractModel { public Guid OperatorId { get; set; } @@ -93,6 +94,7 @@ public class CreateContractModel public string Description { get; set; } } +[ExcludeFromCodeCoverage] public class CreateContractProductModel { public Decimal? Value { get; set; } @@ -102,6 +104,7 @@ public class CreateContractProductModel public Int32 Type { get; set; } } +[ExcludeFromCodeCoverage] public class CreateContractProductTransactionFeeModel { public CalculationType CalculationType { get; set; } @@ -121,6 +124,7 @@ public enum SettlementSchedule Monthly } +[ExcludeFromCodeCoverage] public class MakeDepositModel { public Decimal Amount { get; set; } public String Reference { get; set; } diff --git a/EstateManagementUI.BusinessLogic/PermissionService/Constants/MerchantFunctions.cs b/EstateManagementUI.BusinessLogic/PermissionService/Constants/MerchantFunctions.cs index 537ef563..ac5d36db 100644 --- a/EstateManagementUI.BusinessLogic/PermissionService/Constants/MerchantFunctions.cs +++ b/EstateManagementUI.BusinessLogic/PermissionService/Constants/MerchantFunctions.cs @@ -14,7 +14,7 @@ public class MerchantFunctions public const string RemoveOperator = "Remove Operator"; public const string AddContract = "Add Contract"; public const string RemoveContract = "Remove Contract"; - //public const string AddDevice = "Add Device"; + public const string AddDevice = "Add Device"; //public const string RemoveDevice = "Remove Device"; //public const string EditAddress = "Edit Merchant Address"; //public const string EditContact = "Edit Merchant Contact"; diff --git a/EstateManagementUI.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs b/EstateManagementUI.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs index 422f78b1..3916037f 100644 --- a/EstateManagementUI.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs +++ b/EstateManagementUI.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs @@ -18,8 +18,8 @@ public class MerchantRequestHandler : IRequestHandler, IRequestHandler, IRequestHandler, - IRequestHandler -{ + IRequestHandler, + IRequestHandler { private readonly IApiClient ApiClient; public MerchantRequestHandler(IApiClient apiClient) { @@ -102,4 +102,11 @@ public async Task Handle(Commands.MakeDepositCommand request, request.MerchantId, request.MakeDepositModel, cancellationToken); return result; } + + public async Task Handle(Commands.AssignDeviceToMerchantCommand request, + CancellationToken cancellationToken) { + Result result = await this.ApiClient.AssignDeviceToMerchant(request.AccessToken, Guid.Empty, request.EstateId, + request.MerchantId, request.AssignDeviceToMerchantModel, cancellationToken); + return result; + } } \ No newline at end of file diff --git a/EstateManagementUI.BusinessLogic/Requests/Commands.cs b/EstateManagementUI.BusinessLogic/Requests/Commands.cs index 6da89e2a..eea09eb3 100644 --- a/EstateManagementUI.BusinessLogic/Requests/Commands.cs +++ b/EstateManagementUI.BusinessLogic/Requests/Commands.cs @@ -50,4 +50,9 @@ public record MakeDepositCommand(String AccessToken, public record CreateContractProductCommand(String AccessToken, Guid EstateId, Guid ContractId, CreateContractProductModel CreateContractProductModel) : IRequest; public record CreateContractProductTransactionFeeCommand(String AccessToken, Guid EstateId, Guid ContractId, Guid ProductId, CreateContractProductTransactionFeeModel CreateContractProductTransactionFeeModel) : IRequest; + + public record AssignDeviceToMerchantCommand(String AccessToken, + Guid EstateId, + Guid MerchantId, + AssignDeviceToMerchantModel AssignDeviceToMerchantModel) : IRequest; } \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs b/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs index bcbab766..fa94fc4c 100644 --- a/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs +++ b/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs @@ -1,16 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using EstateManagementUI.IntegrationTests.Steps; +using EstateManagementUI.IntegrationTests.Steps; using EventStore.Client; +using Microsoft.EntityFrameworkCore.Metadata.Internal; using OpenQA.Selenium; using OpenQA.Selenium.Support.Extensions; using Reqnroll; using Shared.IntegrationTesting; using Shouldly; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace EstateManagementUI.IntegrationTests.Common; @@ -140,6 +141,11 @@ public async Task ClickOnTheMerchantContractsTab() await this.ClickTab("nav-contracts-tab"); } + public async Task ClickOnTheMerchantDevicesTab() + { + await this.ClickTab("nav-devices-tab"); + } + public async Task VerifyOnMerchantOperatorsTab() { IWebElement element = this.WebDriver.FindElement(By.Id("merchantOperatorList")); element.ShouldNotBeNull(); @@ -151,6 +157,12 @@ public async Task VerifyOnMerchantContractsTab() element.ShouldNotBeNull(); } + public async Task VerifyOnMerchantDevicesTab() + { + IWebElement element = this.WebDriver.FindElement(By.Id("merchantDeviceList")); + element.ShouldNotBeNull(); + } + public async Task VerifyOnTheDashboard() { await Retry.For(async () => { @@ -544,6 +556,11 @@ public async Task ClickTheNewOperatorButton() await this.WebDriver.ClickButtonById("newOperatorButton"); } + public async Task ClickTheAddDeviceButton() + { + await this.WebDriver.ClickButtonById("addDeviceButton"); + } + public async Task ClickTheSaveOperatorButton() { await this.WebDriver.ClickButtonById("saveOperatorButton"); @@ -559,6 +576,11 @@ public async Task ClickTheAssignContractButton() await this.WebDriver.ClickButtonById("saveMerchantContractButton"); } + public async Task ClickTheAssignDeviceButton() + { + await this.WebDriver.ClickButtonById("saveMerchantDeviceButton"); + } + public async Task ClickTheSaveMerchantButton() { await this.WebDriver.ClickButtonById("saveMerchantButton"); @@ -729,6 +751,11 @@ public async Task EnterContractDetails(String contractName) await this.WebDriver.SelectDropDownItemByText("contractName", contractName); } + public async Task EnterDeviceDetails(String deviceIdentifier) + { + await this.WebDriver.FillInById("deviceIdentifier", deviceIdentifier, true); + } + public async Task EnterProductDetails(String productName, String displayText, String productValue, String productType){ await this.WebDriver.FillIn("productName", productName); await this.WebDriver.FillIn("displayText", displayText); @@ -1048,8 +1075,57 @@ await Retry.For(async () => { }); } + public async Task VerifyAddDeviceDialogIsDisplayed() { + await Retry.For(async () => { + IWebElement element = this.WebDriver.FindElement(By.Id("AddDeviceDialog")); + element.ShouldNotBeNull(); + }); + } + public async Task ClickTheSaveTransactionFeeButton() { await this.WebDriver.ClickButtonById("saveContractProductFeeButton"); } + + public async Task VerifyDeviceDetailsAreInTheList(String tableId, + List devicesList) { + await Retry.For(async () => { + Int32 foundRowCount = 0; + IWebElement tableElement = this.WebDriver.FindElement(By.Id(tableId)); + IList rows = tableElement.FindElements(By.TagName("tr")); + + rows.Count.ShouldBe(devicesList.Count + 1); + StringBuilder sb = new StringBuilder(); + foreach (String deviceDetail in devicesList) + { + IList rowTD; + foreach (IWebElement row in rows) + { + ReadOnlyCollection rowTH = row.FindElements(By.TagName("th")); + + if (rowTH.Any()) + { + // header row so skip + continue; + } + + rowTD = row.FindElements(By.TagName("td")); + + if (rowTD[0].Text == deviceDetail) + { + // We have found the row + foundRowCount++; + sb.AppendLine($"Found {deviceDetail}"); + break; + } + else + { + sb.AppendLine($"Not Found {deviceDetail}"); + } + } + } + + foundRowCount.ShouldBe(devicesList.Count, sb.ToString()); + }, TimeSpan.FromSeconds(120)); + } } \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/Steps/Gimp.cs b/EstateManagementUI.IntegrationTests/Steps/Gimp.cs index 0a5811ac..ae418079 100644 --- a/EstateManagementUI.IntegrationTests/Steps/Gimp.cs +++ b/EstateManagementUI.IntegrationTests/Steps/Gimp.cs @@ -199,6 +199,19 @@ public async Task ThenTheFollowingContractsAreDisplayedInTheList(DataTable dataT await this.UiHelpers.VerifyContractDetailsAreInTheList("merchantContractList", contractsList); } + [Then("the following devices are displayed in the list")] + public async Task ThenTheFollowingDevicesAreDisplayedInTheList(DataTable dataTable) + { + List devicesList = new(); + foreach (DataTableRow tableRow in dataTable.Rows) + { + devicesList.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "DeviceIdentifier"))); + } + + await this.UiHelpers.VerifyDeviceDetailsAreInTheList("merchantDeviceList", devicesList); + } + + [When("I click on the Add Operator Button")] public async Task WhenIClickOnTheAddOperatorButton() { @@ -220,6 +233,12 @@ public async Task ThenTheAssignContractDialogWillBeDisplayed() { await this.UiHelpers.VerifyAssignContractDialogIsDisplayed(); } + [Then("the Add Device Dialog will be displayed")] + public async Task ThenTheAddDeviceDialogWillBeDisplayed() + { + await this.UiHelpers.VerifyAddDeviceDialogIsDisplayed(); + } + [When("I enter the following details for the Contract")] public async Task WhenIEnterTheFollowingDetailsForTheContract(DataTable dataTable) @@ -236,11 +255,33 @@ public async Task WhenIEnterTheFollowingDetailsForTheContract(DataTable dataTabl } } + [When("I enter the following details for the Device")] + public async Task WhenIEnterTheFollowingDetailsForTheDevice(DataTable dataTable) + { + List deviceList = new List(); + foreach (DataTableRow tableRow in dataTable.Rows) + { + deviceList.Add(ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantDevice")); + } + + foreach (String device in deviceList) + { + await this.UiHelpers.EnterDeviceDetails(device); + } + } + + [When("click the Assign Contract button")] public async Task WhenClickTheAssignContractButton() { await this.UiHelpers.ClickTheAssignContractButton(); } - + + [When("click the Add Device button")] + public async Task WhenClickTheAddDeviceButton() { + await this.UiHelpers.ClickTheAssignDeviceButton(); + } + + [When("I enter the following details for the Operator")] public async Task WhenIEnterTheFollowingDetailsForTheOperator(DataTable dataTable) { @@ -299,7 +340,16 @@ public async Task WhenIClickOnTheContractsTab() await this.UiHelpers.ClickOnTheMerchantContractsTab(); } + [When("I click on the Devices tab")] + public async Task WhenIClickOnTheDevicesTab() { + await this.UiHelpers.ClickOnTheMerchantDevicesTab(); + } + [When("I click on the Add Device Button")] + public async Task WhenIClickOnTheAddDeviceButton() { + await this.UiHelpers.ClickTheAddDeviceButton(); + } + [Then("I am presented with the Merchants Operator List Screen")] public async Task ThenIAmPresentedWithTheMerchantsOperatorListScreen() { await this.UiHelpers.VerifyOnMerchantOperatorsTab(); @@ -311,6 +361,11 @@ public async Task ThenIAmPresentedWithTheMerchantsContractListScreen() await this.UiHelpers.VerifyOnMerchantContractsTab(); } + [Then("I am presented with the Merchants Device List Screen")] + public async Task ThenIAmPresentedWithTheMerchantsDeviceListScreen() { + await this.UiHelpers.VerifyOnMerchantDevicesTab(); + } + [Then("the View Merchant Screen is displayed")] public async Task ThenTheViewMerchantScreenIsDisplayed() { diff --git a/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature b/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature index 67a07f9c..3fb2d4da 100644 --- a/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature +++ b/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature @@ -72,8 +72,7 @@ Background: When I add the following devices to the merchant | DeviceIdentifier | MerchantName | EstateName | | TestDevice1 | Test Merchant 1 | Test Estate | - | TestDevice2 | Test Merchant 2 | Test Estate | - | TestDevice3 | Test Merchant 3 | Test Estate | + | TestDevice2 | Test Merchant 2 | Test Estate | Given I am on the application home page @@ -223,3 +222,33 @@ Scenario: Merchant Contract Management And the following contracts are displayed in the list | ContractName | IsDeleted | | Operator 1 Contract | True | + + +Scenario: Merchant Device Management + + Given I click on the My Merchants sidebar option + Then I am presented with the Merchants List Screen + And the following merchants details are in the list + | MerchantName | SettlementSchedule |ContactName | AddressLine1 | Town | + | Test Merchant 1 | Immediate |Test Contact 1 | Address Line 1 | TestTown | + | Test Merchant 2 | Weekly |Test Contact 1 | Address Line 1 | TestTown | + | Test Merchant 3 | Monthly |Test Contact 1 | Address Line 1 | TestTown | + + When I click on the Edit Merchant Button for 'Test Merchant 3' + Then the Edit Merchant Screen is displayed + + When I click on the Devices tab + Then I am presented with the Merchants Device List Screen + And the following devices are displayed in the list + | DeviceIdentifier | + + When I click on the Add Device Button + Then the Add Device Dialog will be displayed + When I enter the following details for the Device + | MerchantDevice | + | 123456ABCDEF | + And click the Add Device button + Then I am presented with the Merchants Device List Screen + And the following devices are displayed in the list + | DeviceIdentifier | + | 123456ABCDEF | diff --git a/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature.cs b/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature.cs index 8f7859a6..6f49a6a7 100644 --- a/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature.cs +++ b/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature.cs @@ -370,26 +370,22 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() "TestDevice2", "Test Merchant 2", "Test Estate"}); - table44.AddRow(new string[] { - "TestDevice3", - "Test Merchant 3", - "Test Estate"}); #line 72 await testRunner.WhenAsync("I add the following devices to the merchant", ((string)(null)), table44, "When "); #line hidden -#line 78 +#line 77 await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); #line hidden -#line 80 +#line 79 await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); #line hidden -#line 82 +#line 81 await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden -#line 84 +#line 83 await testRunner.WhenAsync("I login with the username \'estateuser@testestate1.co.uk\' and password \'123456\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 86 +#line 85 await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden } @@ -403,7 +399,7 @@ public async System.Threading.Tasks.Task MerchantPRTest() "PRTest"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant PR Test", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 89 +#line 88 this.ScenarioInitialize(scenarioInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -416,10 +412,10 @@ public async System.Threading.Tasks.Task MerchantPRTest() #line 4 await this.FeatureBackgroundAsync(); #line hidden -#line 91 +#line 90 await testRunner.GivenAsync("I click on the My Merchants sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); #line hidden -#line 92 +#line 91 await testRunner.ThenAsync("I am presented with the Merchants List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table45 = new global::Reqnroll.Table(new string[] { @@ -446,13 +442,13 @@ public async System.Threading.Tasks.Task MerchantPRTest() "Test Contact 1", "Address Line 1", "TestTown"}); -#line 93 +#line 92 await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table45, "And "); #line hidden -#line 98 +#line 97 await testRunner.WhenAsync("I click on the New Merchant Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 99 +#line 98 await testRunner.ThenAsync("the Add New Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table46 = new global::Reqnroll.Table(new string[] { @@ -473,13 +469,13 @@ public async System.Threading.Tasks.Task MerchantPRTest() "Country", "Test Contact 4", "1@2.com"}); -#line 100 +#line 99 await testRunner.WhenAsync("I enter the following details for the new Merchant", ((string)(null)), table46, "When "); #line hidden -#line 103 +#line 102 await testRunner.AndAsync("click the Save Merchant button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); #line hidden -#line 104 +#line 103 await testRunner.ThenAsync("I am presented with the Merchants List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table47 = new global::Reqnroll.Table(new string[] { @@ -512,13 +508,13 @@ public async System.Threading.Tasks.Task MerchantPRTest() "Test Contact 4", "Address Line 1", "TestTown"}); -#line 105 +#line 104 await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table47, "And "); #line hidden -#line 111 +#line 110 await testRunner.WhenAsync("I click on the Edit Merchant Button for \'Test Merchant 1\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 112 +#line 111 await testRunner.ThenAsync("the Edit Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table48 = new global::Reqnroll.Table(new string[] { @@ -537,13 +533,13 @@ public async System.Threading.Tasks.Task MerchantPRTest() "Contact", "ContactName", "Test Contact 1 Update"}); -#line 113 +#line 112 await testRunner.WhenAsync("I enter the following details for the updated Merchant", ((string)(null)), table48, "When "); #line hidden -#line 118 +#line 117 await testRunner.AndAsync("click the Save Merchant button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); #line hidden -#line 119 +#line 118 await testRunner.ThenAsync("I am presented with the Merchants List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table49 = new global::Reqnroll.Table(new string[] { @@ -576,13 +572,13 @@ public async System.Threading.Tasks.Task MerchantPRTest() "Test Contact 4", "Address Line 1", "TestTown"}); -#line 120 +#line 119 await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table49, "And "); #line hidden -#line 126 +#line 125 await testRunner.WhenAsync("I click on the Make Deposit Button for \'Test Merchant 1 Update\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 127 +#line 126 await testRunner.ThenAsync("the Make Deposit Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table50 = new global::Reqnroll.Table(new string[] { @@ -593,19 +589,19 @@ public async System.Threading.Tasks.Task MerchantPRTest() "1000.00", "Today", "Test Deposit 1"}); -#line 128 +#line 127 await testRunner.WhenAsync("I enter the following details for the deposit", ((string)(null)), table50, "When "); #line hidden -#line 131 +#line 130 await testRunner.AndAsync("click the Make Deposit button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); #line hidden -#line 132 +#line 131 await testRunner.ThenAsync("I am presented with the Merchants List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden -#line 133 +#line 132 await testRunner.WhenAsync("I click on the View Merchant Button for \'Test Merchant 1 Update\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 134 +#line 133 await testRunner.ThenAsync("the View Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden } @@ -619,7 +615,7 @@ public async System.Threading.Tasks.Task MerchantOperatorManagement() string[] tagsOfScenario = ((string[])(null)); System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Operator Management", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 137 +#line 136 this.ScenarioInitialize(scenarioInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -642,7 +638,7 @@ public async System.Threading.Tasks.Task MerchantOperatorManagement() "Test Operator1", "True", "True"}); -#line 138 +#line 137 await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table51, "Given "); #line hidden global::Reqnroll.Table table52 = new global::Reqnroll.Table(new string[] { @@ -651,13 +647,13 @@ public async System.Threading.Tasks.Task MerchantOperatorManagement() table52.AddRow(new string[] { "Test Estate", "Test Operator1"}); -#line 142 +#line 141 await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table52, "And "); #line hidden -#line 146 +#line 145 await testRunner.GivenAsync("I click on the My Merchants sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); #line hidden -#line 147 +#line 146 await testRunner.ThenAsync("I am presented with the Merchants List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table53 = new global::Reqnroll.Table(new string[] { @@ -684,19 +680,19 @@ public async System.Threading.Tasks.Task MerchantOperatorManagement() "Test Contact 1", "Address Line 1", "TestTown"}); -#line 148 +#line 147 await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table53, "And "); #line hidden -#line 154 +#line 153 await testRunner.WhenAsync("I click on the Edit Merchant Button for \'Test Merchant 1\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 155 +#line 154 await testRunner.ThenAsync("the Edit Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden -#line 157 +#line 156 await testRunner.WhenAsync("I click on the Operators tab", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 158 +#line 157 await testRunner.ThenAsync("I am presented with the Merchants Operator List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table54 = new global::Reqnroll.Table(new string[] { @@ -707,13 +703,13 @@ public async System.Threading.Tasks.Task MerchantOperatorManagement() "Test Operator", "00000001", "10000001"}); -#line 159 +#line 158 await testRunner.AndAsync("the following operators are displayed in the list", ((string)(null)), table54, "And "); #line hidden -#line 162 +#line 161 await testRunner.WhenAsync("I click on the Add Operator Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 163 +#line 162 await testRunner.ThenAsync("the Assign Operator Dialog will be displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table55 = new global::Reqnroll.Table(new string[] { @@ -724,13 +720,13 @@ public async System.Threading.Tasks.Task MerchantOperatorManagement() "Test Operator1", "00000111", "10000111"}); -#line 164 +#line 163 await testRunner.WhenAsync("I enter the following details for the Operator", ((string)(null)), table55, "When "); #line hidden -#line 167 +#line 166 await testRunner.AndAsync("click the Assign Operator button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); #line hidden -#line 168 +#line 167 await testRunner.ThenAsync("I am presented with the Merchants Operator List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table56 = new global::Reqnroll.Table(new string[] { @@ -748,13 +744,13 @@ public async System.Threading.Tasks.Task MerchantOperatorManagement() "00000111", "10000111", "False"}); -#line 169 +#line 168 await testRunner.AndAsync("the following operators are displayed in the list", ((string)(null)), table56, "And "); #line hidden -#line 173 +#line 172 await testRunner.WhenAsync("I click on the Remove Operator for \'Test Operator1\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 174 +#line 173 await testRunner.ThenAsync("I am presented with the Merchants Operator List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table57 = new global::Reqnroll.Table(new string[] { @@ -772,7 +768,7 @@ public async System.Threading.Tasks.Task MerchantOperatorManagement() "00000111", "10000111", "True"}); -#line 175 +#line 174 await testRunner.AndAsync("the following operators are displayed in the list", ((string)(null)), table57, "And "); #line hidden } @@ -786,7 +782,7 @@ public async System.Threading.Tasks.Task MerchantContractManagement() string[] tagsOfScenario = ((string[])(null)); System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Contract Management", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 180 +#line 179 this.ScenarioInitialize(scenarioInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -809,7 +805,7 @@ public async System.Threading.Tasks.Task MerchantContractManagement() "Test Operator1", "True", "True"}); -#line 181 +#line 180 await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table58, "Given "); #line hidden global::Reqnroll.Table table59 = new global::Reqnroll.Table(new string[] { @@ -818,7 +814,7 @@ public async System.Threading.Tasks.Task MerchantContractManagement() table59.AddRow(new string[] { "Test Estate", "Test Operator1"}); -#line 185 +#line 184 await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table59, "And "); #line hidden global::Reqnroll.Table table60 = new global::Reqnroll.Table(new string[] { @@ -829,13 +825,13 @@ public async System.Threading.Tasks.Task MerchantContractManagement() "Test Estate", "Test Operator1", "Operator 1 Contract"}); -#line 190 +#line 189 await testRunner.GivenAsync("I have created the following contracts", ((string)(null)), table60, "Given "); #line hidden -#line 194 +#line 193 await testRunner.GivenAsync("I click on the My Merchants sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); #line hidden -#line 195 +#line 194 await testRunner.ThenAsync("I am presented with the Merchants List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table61 = new global::Reqnroll.Table(new string[] { @@ -862,44 +858,44 @@ public async System.Threading.Tasks.Task MerchantContractManagement() "Test Contact 1", "Address Line 1", "TestTown"}); -#line 196 +#line 195 await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table61, "And "); #line hidden -#line 202 +#line 201 await testRunner.WhenAsync("I click on the Edit Merchant Button for \'Test Merchant 1\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 203 +#line 202 await testRunner.ThenAsync("the Edit Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden -#line 205 +#line 204 await testRunner.WhenAsync("I click on the Contracts tab", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 206 +#line 205 await testRunner.ThenAsync("I am presented with the Merchants Contract List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table62 = new global::Reqnroll.Table(new string[] { "ContractName", "IsDeleted"}); -#line 207 +#line 206 await testRunner.AndAsync("the following contracts are displayed in the list", ((string)(null)), table62, "And "); #line hidden -#line 210 +#line 209 await testRunner.WhenAsync("I click on the Add Contract Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 211 +#line 210 await testRunner.ThenAsync("the Assign Contract Dialog will be displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table63 = new global::Reqnroll.Table(new string[] { "ContractName"}); table63.AddRow(new string[] { "Operator 1 Contract"}); -#line 212 +#line 211 await testRunner.WhenAsync("I enter the following details for the Contract", ((string)(null)), table63, "When "); #line hidden -#line 215 +#line 214 await testRunner.AndAsync("click the Assign Contract button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); #line hidden -#line 216 +#line 215 await testRunner.ThenAsync("I am presented with the Merchants Contract List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table64 = new global::Reqnroll.Table(new string[] { @@ -908,13 +904,13 @@ public async System.Threading.Tasks.Task MerchantContractManagement() table64.AddRow(new string[] { "Operator 1 Contract", "False"}); -#line 217 +#line 216 await testRunner.AndAsync("the following contracts are displayed in the list", ((string)(null)), table64, "And "); #line hidden -#line 221 +#line 220 await testRunner.WhenAsync("I click on the Remove Contract for \'Operator 1 Contract\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden -#line 222 +#line 221 await testRunner.ThenAsync("I am presented with the Merchants Contract List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden global::Reqnroll.Table table65 = new global::Reqnroll.Table(new string[] { @@ -923,8 +919,108 @@ public async System.Threading.Tasks.Task MerchantContractManagement() table65.AddRow(new string[] { "Operator 1 Contract", "True"}); -#line 223 +#line 222 await testRunner.AndAsync("the following contracts are displayed in the list", ((string)(null)), table65, "And "); +#line hidden + } + await this.ScenarioCleanupAsync(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Merchant Device Management")] + public async System.Threading.Tasks.Task MerchantDeviceManagement() + { + string[] tagsOfScenario = ((string[])(null)); + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Device Management", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 227 +this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + await this.ScenarioStartAsync(); +#line 4 +await this.FeatureBackgroundAsync(); +#line hidden +#line 229 + await testRunner.GivenAsync("I click on the My Merchants sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); +#line hidden +#line 230 + await testRunner.ThenAsync("I am presented with the Merchants List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); +#line hidden + global::Reqnroll.Table table66 = new global::Reqnroll.Table(new string[] { + "MerchantName", + "SettlementSchedule", + "ContactName", + "AddressLine1", + "Town"}); + table66.AddRow(new string[] { + "Test Merchant 1", + "Immediate", + "Test Contact 1", + "Address Line 1", + "TestTown"}); + table66.AddRow(new string[] { + "Test Merchant 2", + "Weekly", + "Test Contact 1", + "Address Line 1", + "TestTown"}); + table66.AddRow(new string[] { + "Test Merchant 3", + "Monthly", + "Test Contact 1", + "Address Line 1", + "TestTown"}); +#line 231 + await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table66, "And "); +#line hidden +#line 237 + await testRunner.WhenAsync("I click on the Edit Merchant Button for \'Test Merchant 3\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); +#line hidden +#line 238 + await testRunner.ThenAsync("the Edit Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); +#line hidden +#line 240 + await testRunner.WhenAsync("I click on the Devices tab", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); +#line hidden +#line 241 + await testRunner.ThenAsync("I am presented with the Merchants Device List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); +#line hidden + global::Reqnroll.Table table67 = new global::Reqnroll.Table(new string[] { + "DeviceIdentifier"}); +#line 242 + await testRunner.AndAsync("the following devices are displayed in the list", ((string)(null)), table67, "And "); +#line hidden +#line 245 + await testRunner.WhenAsync("I click on the Add Device Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); +#line hidden +#line 246 + await testRunner.ThenAsync("the Add Device Dialog will be displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); +#line hidden + global::Reqnroll.Table table68 = new global::Reqnroll.Table(new string[] { + "MerchantDevice"}); + table68.AddRow(new string[] { + "123456ABCDEF"}); +#line 247 + await testRunner.WhenAsync("I enter the following details for the Device", ((string)(null)), table68, "When "); +#line hidden +#line 250 + await testRunner.AndAsync("click the Add Device button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); +#line hidden +#line 251 + await testRunner.ThenAsync("I am presented with the Merchants Device List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); +#line hidden + global::Reqnroll.Table table69 = new global::Reqnroll.Table(new string[] { + "DeviceIdentifier"}); + table69.AddRow(new string[] { + "123456ABCDEF"}); +#line 252 + await testRunner.AndAsync("the following devices are displayed in the list", ((string)(null)), table69, "And "); #line hidden } await this.ScenarioCleanupAsync(); diff --git a/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs b/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs index 41c10f05..01bbdea4 100644 --- a/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs +++ b/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs @@ -92,83 +92,83 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() { #line 4 #line hidden - global::Reqnroll.Table table66 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table70 = new global::Reqnroll.Table(new string[] { "Role Name"}); - table66.AddRow(new string[] { + table70.AddRow(new string[] { "Estate"}); #line 6 - await testRunner.GivenAsync("I create the following roles", ((string)(null)), table66, "Given "); + await testRunner.GivenAsync("I create the following roles", ((string)(null)), table70, "Given "); #line hidden - global::Reqnroll.Table table67 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table71 = new global::Reqnroll.Table(new string[] { "Name", "DisplayName", "Description"}); - table67.AddRow(new string[] { + table71.AddRow(new string[] { "estateManagement", "Estate Managememt REST Scope", "A scope for Estate Managememt REST"}); - table67.AddRow(new string[] { + table71.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST Scope", "Scope for Transaction Processor REST"}); - table67.AddRow(new string[] { + table71.AddRow(new string[] { "fileProcessor", "File Processor REST Scope", "Scope for File Processor REST"}); #line 10 - await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table67, "Given "); + await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table71, "Given "); #line hidden - global::Reqnroll.Table table68 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table72 = new global::Reqnroll.Table(new string[] { "Name", "DisplayName", "Secret", "Scopes", "UserClaims"}); - table68.AddRow(new string[] { + table72.AddRow(new string[] { "estateManagement", "Estate Managememt REST", "Secret1", "estateManagement", "merchantId,estateId,role"}); - table68.AddRow(new string[] { + table72.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST", "Secret1", "transactionProcessor", "merchantId,estateId,role"}); - table68.AddRow(new string[] { + table72.AddRow(new string[] { "fileProcessor", "File Processor REST", "Secret1", "fileProcessor", "merchantId,estateId,role"}); #line 16 - await testRunner.GivenAsync("I create the following api resources", ((string)(null)), table68, "Given "); + await testRunner.GivenAsync("I create the following api resources", ((string)(null)), table72, "Given "); #line hidden - global::Reqnroll.Table table69 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table73 = new global::Reqnroll.Table(new string[] { "Name", "DisplayName", "Description", "UserClaims"}); - table69.AddRow(new string[] { + table73.AddRow(new string[] { "openid", "Your user identifier", "", "sub"}); - table69.AddRow(new string[] { + table73.AddRow(new string[] { "profile", "User profile", "Your user profile information (first name, last name, etc.)", "name,role,email,given_name,middle_name,family_name,estateId,merchantId"}); - table69.AddRow(new string[] { + table73.AddRow(new string[] { "email", "Email", "Email and Email Verified Flags", "email_verified,email"}); #line 22 - await testRunner.GivenAsync("I create the following identity resources", ((string)(null)), table69, "Given "); + await testRunner.GivenAsync("I create the following identity resources", ((string)(null)), table73, "Given "); #line hidden - global::Reqnroll.Table table70 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table74 = new global::Reqnroll.Table(new string[] { "ClientId", "Name", "Secret", @@ -179,7 +179,7 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() "RequireConsent", "AllowOfflineAccess", "ClientUri"}); - table70.AddRow(new string[] { + table74.AddRow(new string[] { "serviceClient", "Service Client", "Secret1", @@ -190,7 +190,7 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() "", "", ""}); - table70.AddRow(new string[] { + table74.AddRow(new string[] { "estateUIClient", "Merchant Client", "Secret1", @@ -202,74 +202,74 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() "true", "https://[url]:[port]"}); #line 28 - await testRunner.GivenAsync("I create the following clients", ((string)(null)), table70, "Given "); + await testRunner.GivenAsync("I create the following clients", ((string)(null)), table74, "Given "); #line hidden - global::Reqnroll.Table table71 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table75 = new global::Reqnroll.Table(new string[] { "ClientId"}); - table71.AddRow(new string[] { + table75.AddRow(new string[] { "serviceClient"}); #line 33 - await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table71, "Given "); + await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table75, "Given "); #line hidden - global::Reqnroll.Table table72 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table76 = new global::Reqnroll.Table(new string[] { "EstateName"}); - table72.AddRow(new string[] { + table76.AddRow(new string[] { "Test Estate"}); #line 37 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table72, "Given "); + await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table76, "Given "); #line hidden - global::Reqnroll.Table table73 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table77 = new global::Reqnroll.Table(new string[] { "EstateName", "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table73.AddRow(new string[] { + table77.AddRow(new string[] { "Test Estate", "Test Operator 1", "True", "True"}); - table73.AddRow(new string[] { + table77.AddRow(new string[] { "Test Estate", "Test Operator 2", "True", "False"}); - table73.AddRow(new string[] { + table77.AddRow(new string[] { "Test Estate", "Test Operator 3", "False", "True"}); #line 41 - await testRunner.AndAsync("I have created the following operators", ((string)(null)), table73, "And "); + await testRunner.AndAsync("I have created the following operators", ((string)(null)), table77, "And "); #line hidden - global::Reqnroll.Table table74 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table78 = new global::Reqnroll.Table(new string[] { "EstateName", "OperatorName"}); - table74.AddRow(new string[] { + table78.AddRow(new string[] { "Test Estate", "Test Operator 1"}); - table74.AddRow(new string[] { + table78.AddRow(new string[] { "Test Estate", "Test Operator 2"}); - table74.AddRow(new string[] { + table78.AddRow(new string[] { "Test Estate", "Test Operator 3"}); #line 47 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table74, "And "); + await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table78, "And "); #line hidden - global::Reqnroll.Table table75 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table79 = new global::Reqnroll.Table(new string[] { "EmailAddress", "Password", "GivenName", "FamilyName", "EstateName"}); - table75.AddRow(new string[] { + table79.AddRow(new string[] { "estateuser@testestate1.co.uk", "123456", "TestEstate", "User1", "Test Estate"}); #line 53 - await testRunner.AndAsync("I have created the following security users", ((string)(null)), table75, "And "); + await testRunner.AndAsync("I have created the following security users", ((string)(null)), table79, "And "); #line hidden #line 57 await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); @@ -316,24 +316,24 @@ public async System.Threading.Tasks.Task OperatorPRTest() #line 71 await testRunner.ThenAsync("I am presented with the Operators List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden - global::Reqnroll.Table table76 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table80 = new global::Reqnroll.Table(new string[] { "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table76.AddRow(new string[] { + table80.AddRow(new string[] { "Test Operator 1", "Yes", "Yes"}); - table76.AddRow(new string[] { + table80.AddRow(new string[] { "Test Operator 2", "Yes", "No"}); - table76.AddRow(new string[] { + table80.AddRow(new string[] { "Test Operator 3", "No", "Yes"}); #line 72 - await testRunner.AndAsync("the following operator details are in the list", ((string)(null)), table76, "And "); + await testRunner.AndAsync("the following operator details are in the list", ((string)(null)), table80, "And "); #line hidden #line 77 await testRunner.WhenAsync("I click on the New Operator Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); @@ -341,16 +341,16 @@ public async System.Threading.Tasks.Task OperatorPRTest() #line 78 await testRunner.ThenAsync("the Add New Operator Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden - global::Reqnroll.Table table77 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table81 = new global::Reqnroll.Table(new string[] { "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table77.AddRow(new string[] { + table81.AddRow(new string[] { "Test Operator 4", "Yes", "Yes"}); #line 79 - await testRunner.WhenAsync("I enter the following details for the new Operator", ((string)(null)), table77, "When "); + await testRunner.WhenAsync("I enter the following details for the new Operator", ((string)(null)), table81, "When "); #line hidden #line 82 await testRunner.AndAsync("click the Save Operator button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); @@ -358,28 +358,28 @@ public async System.Threading.Tasks.Task OperatorPRTest() #line 83 await testRunner.ThenAsync("I am presented with the Operators List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden - global::Reqnroll.Table table78 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table82 = new global::Reqnroll.Table(new string[] { "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table78.AddRow(new string[] { + table82.AddRow(new string[] { "Test Operator 1", "Yes", "Yes"}); - table78.AddRow(new string[] { + table82.AddRow(new string[] { "Test Operator 2", "Yes", "No"}); - table78.AddRow(new string[] { + table82.AddRow(new string[] { "Test Operator 3", "No", "Yes"}); - table78.AddRow(new string[] { + table82.AddRow(new string[] { "Test Operator 4", "Yes", "Yes"}); #line 84 - await testRunner.AndAsync("the following operator details are in the list", ((string)(null)), table78, "And "); + await testRunner.AndAsync("the following operator details are in the list", ((string)(null)), table82, "And "); #line hidden #line 90 await testRunner.WhenAsync("I click on the Edit Operator Button for \'Test Operator 1\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); @@ -387,16 +387,16 @@ public async System.Threading.Tasks.Task OperatorPRTest() #line 91 await testRunner.ThenAsync("the Edit Operator Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden - global::Reqnroll.Table table79 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table83 = new global::Reqnroll.Table(new string[] { "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table79.AddRow(new string[] { + table83.AddRow(new string[] { "Test Operator 1 update", "No", "No"}); #line 92 - await testRunner.WhenAsync("I enter the following new details for the Operator", ((string)(null)), table79, "When "); + await testRunner.WhenAsync("I enter the following new details for the Operator", ((string)(null)), table83, "When "); #line hidden #line 95 await testRunner.AndAsync("click the Save Operator button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); @@ -404,28 +404,28 @@ public async System.Threading.Tasks.Task OperatorPRTest() #line 96 await testRunner.ThenAsync("I am presented with the Operators List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); #line hidden - global::Reqnroll.Table table80 = new global::Reqnroll.Table(new string[] { + global::Reqnroll.Table table84 = new global::Reqnroll.Table(new string[] { "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table80.AddRow(new string[] { + table84.AddRow(new string[] { "Test Operator 1 update", "No", "No"}); - table80.AddRow(new string[] { + table84.AddRow(new string[] { "Test Operator 2", "Yes", "No"}); - table80.AddRow(new string[] { + table84.AddRow(new string[] { "Test Operator 3", "No", "Yes"}); - table80.AddRow(new string[] { + table84.AddRow(new string[] { "Test Operator 4", "Yes", "Yes"}); #line 97 - await testRunner.AndAsync("the following operator details are in the list", ((string)(null)), table80, "And "); + await testRunner.AndAsync("the following operator details are in the list", ((string)(null)), table84, "And "); #line hidden } await this.ScenarioCleanupAsync(); diff --git a/EstateManagementUI.Testing/TestData.cs b/EstateManagementUI.Testing/TestData.cs index d8f19b53..bf0f73ba 100644 --- a/EstateManagementUI.Testing/TestData.cs +++ b/EstateManagementUI.Testing/TestData.cs @@ -103,8 +103,12 @@ public static class TestData { public static Commands.RemoveContractFromMerchantCommand RemoveContractFromMerchantCommand => new(AccessToken, EstateId, Merchant1Id, Contract1Id); - public static AssignContractToMerchantModel AssignContractToMerchantModel => new AssignContractToMerchantModel { ContractId = TestData.Contract1Id }; + public static Commands.AssignDeviceToMerchantCommand AssignDeviceToMerchantCommand => new(AccessToken, EstateId, Merchant1Id, AssignDeviceToMerchantModel); + public static AssignOperatorToMerchantModel AssignOperatorToMerchantModel => new AssignOperatorToMerchantModel { OperatorId = Operator1Id }; + public static AssignContractToMerchantModel AssignContractToMerchantModel => new AssignContractToMerchantModel { ContractId = TestData.Contract1Id }; + public static String DeviceIdentifier = "123456ABCDEF"; + public static AssignDeviceToMerchantModel AssignDeviceToMerchantModel => new AssignDeviceToMerchantModel { DeviceIdentifier = DeviceIdentifier }; public static Commands.AssignOperatorToMerchantCommand AssignOperatorToMerchantCommand => new(AccessToken, EstateId, Merchant1Id, new AssignOperatorToMerchantModel { OperatorId = Operator1Id @@ -112,10 +116,25 @@ public static class TestData { public static Commands.RemoveOperatorFromMerchantCommand RemoveOperatorFromMerchantCommand => new(AccessToken, EstateId, Merchant1Id, Operator1Id); + public static Commands.CreateContractCommand CreateContractCommand => new(AccessToken, EstateId, CreateContractModel); + public static Commands.CreateContractProductCommand CreateContractProductCommand => new(AccessToken, EstateId, Contract1Id, CreateContractProductModel); + + public static Commands.CreateContractProductTransactionFeeCommand CreateContractProductTransactionFeeCommand => new(AccessToken, EstateId, Contract1Id, Contract1Product1Id, CreateContractProductTransactionFeeModel); + + public static Commands.MakeDepositCommand MakeDepositCommand => new(AccessToken, EstateId, Merchant1Id, MakeDepositModel); public static CreateMerchantResponse CreateMerchantResponse => new() { EstateId = EstateId, MerchantId = Merchant1Id }; + public static Decimal DepositAmount = 100.00m; + public static DateTime DepositDateTime = DateTime.Now; + public static String DepositReference = "Deposit Reference 1"; + public static MakeDepositModel MakeDepositModel => new() { Amount = TestData.DepositAmount, Date = TestData.DepositDateTime, Reference = TestData.DepositReference }; + public static CreateContractModel CreateContractModel => new() { Description = Contract1Description, OperatorId = Operator1Id }; + + public static CreateContractProductModel CreateContractProductModel => new() { DisplayText = Contract1Product1DisplayText, Name = Contract1Product1Name, Type = (Int32)Contract1Product1ProductType, Value = Contract1Product1Value }; + public static CreateContractProductTransactionFeeModel CreateContractProductTransactionFeeModel => new() { CalculationType = TransactionFee1CalculationType, Description = TransactionFee1Description, FeeType = TransactionFee1Type, Value = TransactionFee1Value }; + public static CreateMerchantModel CreateMerchantModel(BusinessLogic.Models.SettlementSchedule settlementSchedule) => new CreateMerchantModel { diff --git a/EstateManagementUI.UITests/AddContractDialogTests.cs b/EstateManagementUI.UITests/AddContractDialogTests.cs index dfe818d6..a06748a0 100644 --- a/EstateManagementUI.UITests/AddContractDialogTests.cs +++ b/EstateManagementUI.UITests/AddContractDialogTests.cs @@ -1,4 +1,5 @@ using EstateManagementUI.BusinessLogic.PermissionService; +using EstateManagementUI.Pages.Merchant; using EstateManagementUI.Pages.Merchant.MerchantDetails; using EstateManagementUI.Pages.Shared.Components; using EstateManagementUI.Testing; diff --git a/EstateManagementUI.UITests/AddDeviceDialogTests.cs b/EstateManagementUI.UITests/AddDeviceDialogTests.cs new file mode 100644 index 00000000..fd6ba046 --- /dev/null +++ b/EstateManagementUI.UITests/AddDeviceDialogTests.cs @@ -0,0 +1,92 @@ +using System.Text; +using EstateManagementUI.BusinessLogic.PermissionService; +using EstateManagementUI.Pages.Merchant; +using EstateManagementUI.Pages.Merchant.MerchantDetails; +using EstateManagementUI.Pages.Shared.Components; +using EstateManagmentUI.BusinessLogic.Requests; +using MediatR; +using Moq; +using Newtonsoft.Json; +using Shouldly; +using SimpleResults; + +namespace EstateManagementUI.UITests; + +public class AddDeviceDialogTests { + private readonly Mock _mediatorMock; + private readonly Mock _permissionsServiceMock; + private readonly AddDeviceDialog _addDeviceDialog; + + public AddDeviceDialogTests() { + this._mediatorMock = new Mock(); + this._permissionsServiceMock = new Mock(); + + this._addDeviceDialog = new AddDeviceDialog(this._mediatorMock.Object, this._permissionsServiceMock.Object); + this._addDeviceDialog.ViewContext = TestHelper.GetTestViewContext(); + } + + [Fact] + public async Task Mount_NoErrors() + { + // Arrange + this._addDeviceDialog.MerchantId = Guid.NewGuid(); + this._addDeviceDialog.MerchantDevice = "ABCD1234"; + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success()); + + // Act + await this._addDeviceDialog.MountAsync(); + + // Assert + } + + [Fact] + public async Task Save_AssignsDeviceToMerchant() + { + // Arrange + this._addDeviceDialog.MerchantId = Guid.NewGuid(); + this._addDeviceDialog.MerchantDevice = "ABCD1234"; + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success()); + + // Act + await this._addDeviceDialog.Save(); + + // Assert + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._addDeviceDialog.Events.Count.ShouldBe(2); + this._addDeviceDialog.Events[0].ShouldBeOfType(); + this._addDeviceDialog.Events[1].ShouldBeOfType(); + } + + [Fact] + public async Task Save_AssignsDeviceToMerchant_Fails() + { + // Arrange + this._addDeviceDialog.MerchantId = Guid.NewGuid(); + this._addDeviceDialog.MerchantDevice = "ABCD1234"; + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure); + + // Act + await this._addDeviceDialog.Save(); + + // Assert + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + + this._addDeviceDialog.Events.Count.ShouldBe(2); + this._addDeviceDialog.Events[0].ShouldBeOfType(); + this._addDeviceDialog.Events[1].ShouldBeOfType(); + } + + [Fact] + public async Task Close_DispatchesHideAddContractDialogEvent() + { + // Act + await this._addDeviceDialog.Close(); + + // Assert + this._addDeviceDialog.Events.Count.ShouldBe(1); + this._addDeviceDialog.Events[0].ShouldBeOfType(); + } +} \ No newline at end of file diff --git a/EstateManagementUI.UITests/AddOperatorDialogTests.cs b/EstateManagementUI.UITests/AddOperatorDialogTests.cs new file mode 100644 index 00000000..59adf765 --- /dev/null +++ b/EstateManagementUI.UITests/AddOperatorDialogTests.cs @@ -0,0 +1,96 @@ +using EstateManagementUI.BusinessLogic.PermissionService; +using EstateManagementUI.Pages.Merchant; +using EstateManagementUI.Pages.Merchant.MerchantDetails; +using EstateManagementUI.Pages.Shared.Components; +using EstateManagementUI.Testing; +using EstateManagmentUI.BusinessLogic.Requests; +using MediatR; +using Moq; +using Shouldly; +using SimpleResults; + +namespace EstateManagementUI.UITests; + +public class AddOperatorDialogTests +{ + private readonly Mock _mediatorMock; + private readonly Mock _permissionsServiceMock; + private readonly AddOperatorDialog _addOperatorDialog; + + public AddOperatorDialogTests() + { + this._mediatorMock = new Mock(); + this._permissionsServiceMock = new Mock(); + + this._addOperatorDialog = new AddOperatorDialog(this._mediatorMock.Object, this._permissionsServiceMock.Object); + this._addOperatorDialog.ViewContext = TestHelper.GetTestViewContext(); + } + + [Fact] + public async Task MountAsync_ShouldPopulateOperators() + { + // Arrange + var operatorListModel = TestData.GetOperatorModels(); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(operatorListModel); + + // Act + await this._addOperatorDialog.MountAsync(); + + // Assert + this._addOperatorDialog.Operator.ShouldNotBeNull(); + this._addOperatorDialog.Operator.Operators.Count.ShouldBe(3); + } + + [Fact] + public async Task Save_ShouldAssignOperatorToMerchant() + { + // Arrange + this._addOperatorDialog.Operator = TestData.GetOperatorListModels().First(); + this._addOperatorDialog.MerchantNumber = "123456"; + this._addOperatorDialog.TerminalNumber = "7890"; + this._addOperatorDialog.MerchantId = Guid.NewGuid(); + + var assignOperatorToMerchantModel = TestData.GetAssignOperatorToMerchantModel(); + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success()); + + // Act + await this._addOperatorDialog.Save(); + + // Assert + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._addOperatorDialog.Events.ShouldContain(e => e is MerchantPageEvents.OperatorAssignedToMerchantEvent); + } + + [Fact] + public async Task Save_ShouldShowErrorMessageOnFailure() + { + // Arrange + this._addOperatorDialog.Operator = TestData.GetOperatorListModels().First(); + this._addOperatorDialog.MerchantNumber = "123456"; + this._addOperatorDialog.TerminalNumber = "7890"; + this._addOperatorDialog.MerchantId = Guid.NewGuid(); + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure("Error")); + + // Act + await this._addOperatorDialog.Save(); + + // Assert + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._addOperatorDialog.Events.ShouldContain(e => e is ShowMessage && ((ShowMessage)e).Message == "Error assigning operator to Merchant"); + } + + [Fact] + public async Task Close_ShouldDispatchHideAddOperatorDialogEvent() + { + // Act + await this._addOperatorDialog.Close(); + + // Assert + this._addOperatorDialog.Events.ShouldContain(e => e is MerchantPageEvents.HideAddOperatorDialog); + } +} \ No newline at end of file diff --git a/EstateManagementUI.UITests/ContractProductTransactionFeeListTests.cs b/EstateManagementUI.UITests/ContractProductTransactionFeeListTests.cs new file mode 100644 index 00000000..01a5cde5 --- /dev/null +++ b/EstateManagementUI.UITests/ContractProductTransactionFeeListTests.cs @@ -0,0 +1,164 @@ +using EstateManagementUI.BusinessLogic.PermissionService; +using EstateManagementUI.Pages.Contract.ContractProductTransactionFee; +using EstateManagementUI.Testing; +using EstateManagmentUI.BusinessLogic.Requests; +using MediatR; +using Moq; +using Shouldly; + +namespace EstateManagementUI.UITests; + +public class ContractProductTransactionFeeListTests +{ + private readonly Mock _mediatorMock; + private readonly Mock _permissionsServiceMock; + private readonly ContractProductTransactionFeeList _component; + + public ContractProductTransactionFeeListTests() + { + this._mediatorMock = new Mock(); + this._permissionsServiceMock = new Mock(); + this._component = new ContractProductTransactionFeeList(this._mediatorMock.Object, this._permissionsServiceMock.Object); + this._component.ViewContext = TestHelper.GetTestViewContext(); + } + + [Fact] + public async Task MountAsync_ShouldCallGetContract() + { + // Arrange + this._component.ContractId = TestData.ContractId; + this._component.ContractProductId = TestData.ContractProductId; + + var contractModel = TestData.GetContractModel(); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(contractModel); + + // Act + await this._component.MountAsync(); + + // Assert + this._component.ContractProductTransactionFees.Count.ShouldBe(2); + this._component.ContractProductTransactionFees[0].CalculationType.ShouldBe("Type1"); + this._component.ContractProductTransactionFees[1].CalculationType.ShouldBe("Type2"); + } + + [Fact] + public async Task Sort_ShouldSortContractProductTransactionFeesByValue() + { + // Arrange + this._component.ContractId = TestData.ContractId; + this._component.ContractProductId = TestData.ContractProductId; + + var contractModel = TestData.GetContractModel(); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(contractModel); + + // Act + await this._component.Sort(ContractProductTransactionFeeSorting.Value); + + // Assert + this._component.ContractProductTransactionFees[0].Value.ShouldBe(10.0m); + this._component.ContractProductTransactionFees[1].Value.ShouldBe(20.0m); + + // Act + await this._component.Sort(ContractProductTransactionFeeSorting.Value); + + // Assert + this._component.ContractProductTransactionFees[0].Value.ShouldBe(20.0m); + this._component.ContractProductTransactionFees[1].Value.ShouldBe(10.0m); + } + + [Fact] + public async Task Sort_ShouldSortContractProductTransactionFeesByCalculationType() + { + // Arrange + this._component.ContractId = TestData.ContractId; + this._component.ContractProductId = TestData.ContractProductId; + + var contractModel = TestData.GetContractModel(); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(contractModel); + + // Act + await this._component.Sort(ContractProductTransactionFeeSorting.CalculationType); + + // Assert + this._component.ContractProductTransactionFees[0].CalculationType.ShouldBe("Type2"); + this._component.ContractProductTransactionFees[1].CalculationType.ShouldBe("Type1"); + + // Act + await this._component.Sort(ContractProductTransactionFeeSorting.CalculationType); + + // Assert + this._component.ContractProductTransactionFees[0].CalculationType.ShouldBe("Type1"); + this._component.ContractProductTransactionFees[1].CalculationType.ShouldBe("Type2"); + } + + [Fact] + public async Task Sort_ShouldSortContractProductTransactionFeesByDescription() + { + // Arrange + this._component.ContractId = TestData.ContractId; + this._component.ContractProductId = TestData.ContractProductId; + + var contractModel = TestData.GetContractModel(); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(contractModel); + + // Act + await this._component.Sort(ContractProductTransactionFeeSorting.Description); + + // Assert + this._component.ContractProductTransactionFees[0].Description.ShouldBe("Description1"); + this._component.ContractProductTransactionFees[1].Description.ShouldBe("Description2"); + + // Act + await this._component.Sort(ContractProductTransactionFeeSorting.Description); + + // Assert + this._component.ContractProductTransactionFees[0].Description.ShouldBe("Description2"); + this._component.ContractProductTransactionFees[1].Description.ShouldBe("Description1"); + } + + [Fact] + public async Task Sort_ShouldSortContractProductTransactionFeesByFeeType() + { + // Arrange + this._component.ContractId = TestData.ContractId; + this._component.ContractProductId = TestData.ContractProductId; + + var contractModel = TestData.GetContractModel(); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(contractModel); + + // Act + await this._component.Sort(ContractProductTransactionFeeSorting.FeeType); + + // Assert + this._component.ContractProductTransactionFees[0].FeeType.ShouldBe("FeeType1"); + this._component.ContractProductTransactionFees[1].FeeType.ShouldBe("FeeType2"); + + // Act + await this._component.Sort(ContractProductTransactionFeeSorting.FeeType); + + // Assert + this._component.ContractProductTransactionFees[0].FeeType.ShouldBe("FeeType2"); + this._component.ContractProductTransactionFees[1].FeeType.ShouldBe("FeeType1"); + } + + [Fact] + public async Task NewContractProductFees_NavigatesToNewContractProductFeesPage() + { + // Arrange + this._component.Url = TestHelper.GetTestUrlHelper(); + + // Act + await this._component.NewContractProductTransactionFee(); + + // Assert + this._component.LocationUrl.ShouldNotBeNull(); + this._component.LocationUrl.ShouldBe("/Contract/NewContractProductTransactionFee"); + } + + +} \ No newline at end of file diff --git a/EstateManagementUI.UITests/ContractProductsListTests.cs b/EstateManagementUI.UITests/ContractProductsListTests.cs index ee6a6aaf..57e9c61c 100644 --- a/EstateManagementUI.UITests/ContractProductsListTests.cs +++ b/EstateManagementUI.UITests/ContractProductsListTests.cs @@ -1,6 +1,5 @@ using EstateManagementUI.BusinessLogic.PermissionService; using EstateManagementUI.Pages.Contract.ContractProduct; -using EstateManagementUI.Pages.Contract.ContractProductTransactionFee; using EstateManagementUI.Testing; using EstateManagementUI.ViewModels; using EstateManagmentUI.BusinessLogic.Requests; @@ -183,145 +182,18 @@ public async Task ViewProductFees_NavigatesToProductFeesPage() Guid payloadContractProductId = TestHelpers.GetPropertyValue(this._contractProductsList.Payload, "ContractProductId"); payloadContractProductId.ShouldBe(contractProductId); } -} - -public class ContractProductTransactionFeeListTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly ContractProductTransactionFeeList _component; - - public ContractProductTransactionFeeListTests() - { - _mediatorMock = new Mock(); - _permissionsServiceMock = new Mock(); - _component = new ContractProductTransactionFeeList(_mediatorMock.Object, _permissionsServiceMock.Object); - this._component.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_ShouldCallGetContract() - { - // Arrange - _component.ContractId = TestData.ContractId; - _component.ContractProductId = TestData.ContractProductId; - - var contractModel = TestData.GetContractModel(); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(contractModel); - - // Act - await _component.MountAsync(); - - // Assert - _component.ContractProductTransactionFees.Count.ShouldBe(2); - _component.ContractProductTransactionFees[0].CalculationType.ShouldBe("Type1"); - _component.ContractProductTransactionFees[1].CalculationType.ShouldBe("Type2"); - } - - [Fact] - public async Task Sort_ShouldSortContractProductTransactionFeesByValue() - { - // Arrange - _component.ContractId = TestData.ContractId; - _component.ContractProductId = TestData.ContractProductId; - - var contractModel = TestData.GetContractModel(); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(contractModel); - - // Act - await _component.Sort(ContractProductTransactionFeeSorting.Value); - - // Assert - _component.ContractProductTransactionFees[0].Value.ShouldBe(10.0m); - _component.ContractProductTransactionFees[1].Value.ShouldBe(20.0m); - - // Act - await _component.Sort(ContractProductTransactionFeeSorting.Value); - - // Assert - _component.ContractProductTransactionFees[0].Value.ShouldBe(20.0m); - _component.ContractProductTransactionFees[1].Value.ShouldBe(10.0m); - } - - [Fact] - public async Task Sort_ShouldSortContractProductTransactionFeesByCalculationType() - { - // Arrange - _component.ContractId = TestData.ContractId; - _component.ContractProductId = TestData.ContractProductId; - - var contractModel = TestData.GetContractModel(); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(contractModel); - - // Act - await _component.Sort(ContractProductTransactionFeeSorting.CalculationType); - - // Assert - _component.ContractProductTransactionFees[0].CalculationType.ShouldBe("Type2"); - _component.ContractProductTransactionFees[1].CalculationType.ShouldBe("Type1"); - - // Act - await _component.Sort(ContractProductTransactionFeeSorting.CalculationType); - - // Assert - _component.ContractProductTransactionFees[0].CalculationType.ShouldBe("Type1"); - _component.ContractProductTransactionFees[1].CalculationType.ShouldBe("Type2"); - } - - [Fact] - public async Task Sort_ShouldSortContractProductTransactionFeesByDescription() - { - // Arrange - _component.ContractId = TestData.ContractId; - _component.ContractProductId = TestData.ContractProductId; - - var contractModel = TestData.GetContractModel(); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(contractModel); - - // Act - await _component.Sort(ContractProductTransactionFeeSorting.Description); - - // Assert - _component.ContractProductTransactionFees[0].Description.ShouldBe("Description1"); - _component.ContractProductTransactionFees[1].Description.ShouldBe("Description2"); - - // Act - await _component.Sort(ContractProductTransactionFeeSorting.Description); - - // Assert - _component.ContractProductTransactionFees[0].Description.ShouldBe("Description2"); - _component.ContractProductTransactionFees[1].Description.ShouldBe("Description1"); - } [Fact] - public async Task Sort_ShouldSortContractProductTransactionFeesByFeeType() + public async Task NewContractProduct_NavigatesToNewContractProductPage() { // Arrange - _component.ContractId = TestData.ContractId; - _component.ContractProductId = TestData.ContractProductId; - - var contractModel = TestData.GetContractModel(); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(contractModel); - - // Act - await _component.Sort(ContractProductTransactionFeeSorting.FeeType); - - // Assert - _component.ContractProductTransactionFees[0].FeeType.ShouldBe("FeeType1"); - _component.ContractProductTransactionFees[1].FeeType.ShouldBe("FeeType2"); + this._contractProductsList.Url = TestHelper.GetTestUrlHelper(); // Act - await _component.Sort(ContractProductTransactionFeeSorting.FeeType); + await this._contractProductsList.NewContractProduct(); // Assert - _component.ContractProductTransactionFees[0].FeeType.ShouldBe("FeeType2"); - _component.ContractProductTransactionFees[1].FeeType.ShouldBe("FeeType1"); + this._contractProductsList.LocationUrl.ShouldNotBeNull(); + this._contractProductsList.LocationUrl.ShouldBe("/Contract/NewContractProduct"); } - - } \ No newline at end of file diff --git a/EstateManagementUI.UITests/ContractsListTests.cs b/EstateManagementUI.UITests/ContractsListTests.cs index bc32cc41..3f9997c0 100644 --- a/EstateManagementUI.UITests/ContractsListTests.cs +++ b/EstateManagementUI.UITests/ContractsListTests.cs @@ -1,18 +1,12 @@ using EstateManagementUI.BusinessLogic.PermissionService; using EstateManagementUI.Pages.Contract.Contracts; -using EstateManagementUI.Pages.Dashboard.Dashboard; -using EstateManagementUI.Pages.Merchant.MerchantDetails; -using EstateManagementUI.Pages.Shared.Components; using EstateManagementUI.Testing; -using EstateManagementUI.ViewModels; using EstateManagmentUI.BusinessLogic.Requests; using MediatR; using Microsoft.AspNetCore.Http; using Moq; using Shouldly; -using SimpleResults; using System.Security.Claims; -using static EstateManagementUI.Pages.Merchant.MerchantDetails.MerchantPageEvents; namespace EstateManagementUI.UITests; @@ -133,218 +127,35 @@ public async Task ViewProducts_ShouldNavigateToProductPage() var payloadContractId = TestHelpers.GetPropertyValue(_contractsList.Payload, "ContractId"); payloadContractId.ShouldBe(contractId); } -} - -public class AddOperatorDialogTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly AddOperatorDialog _addOperatorDialog; - - public AddOperatorDialogTests() - { - _mediatorMock = new Mock(); - _permissionsServiceMock = new Mock(); - - this._addOperatorDialog = new AddOperatorDialog(_mediatorMock.Object, _permissionsServiceMock.Object); - this._addOperatorDialog.ViewContext = TestHelper.GetTestViewContext(); - } [Fact] - public async Task MountAsync_ShouldPopulateOperators() + public async Task View_ShouldNavigateToContractPage() { // Arrange - var operatorListModel = TestData.GetOperatorModels(); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(operatorListModel); - - // Act - await this._addOperatorDialog.MountAsync(); - - // Assert - this._addOperatorDialog.Operator.ShouldNotBeNull(); - this._addOperatorDialog.Operator.Operators.Count.ShouldBe(3); - } - - [Fact] - public async Task Save_ShouldAssignOperatorToMerchant() - { - // Arrange - this._addOperatorDialog.Operator = TestData.GetOperatorListModels().First(); - this._addOperatorDialog.MerchantNumber = "123456"; - this._addOperatorDialog.TerminalNumber = "7890"; - this._addOperatorDialog.MerchantId = Guid.NewGuid(); - - var assignOperatorToMerchantModel = TestData.GetAssignOperatorToMerchantModel(); - - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success()); - - // Act - await this._addOperatorDialog.Save(); - - // Assert - _mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - this._addOperatorDialog.Events.ShouldContain(e => e is OperatorAssignedToMerchantEvent); - } - - [Fact] - public async Task Save_ShouldShowErrorMessageOnFailure() - { - // Arrange - this._addOperatorDialog.Operator = TestData.GetOperatorListModels().First(); - this._addOperatorDialog.MerchantNumber = "123456"; - this._addOperatorDialog.TerminalNumber = "7890"; - this._addOperatorDialog.MerchantId = Guid.NewGuid(); - - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Failure("Error")); - - // Act - await this._addOperatorDialog.Save(); - - // Assert - _mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - this._addOperatorDialog.Events.ShouldContain(e => e is ShowMessage && ((ShowMessage)e).Message == "Error assigning operator to Merchant"); - } - - [Fact] - public async Task Close_ShouldDispatchHideAddOperatorDialogEvent() - { - // Act - await this._addOperatorDialog.Close(); - - // Assert - this._addOperatorDialog.Events.ShouldContain(e => e is MerchantPageEvents.HideAddOperatorDialog); - } -} - -public class EditMerchantTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly EditMerchant _editMerchant; - - public EditMerchantTests() - { - _mediatorMock = new Mock(); - _permissionsServiceMock = new Mock(); - _editMerchant = new EditMerchant(_mediatorMock.Object, _permissionsServiceMock.Object); - this._editMerchant.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public void SetActiveTab_ShouldSetActiveTab() - { - // Act - _editMerchant.SetActiveTab("contracts"); - - // Assert - _editMerchant.ActiveTab.ShouldBe("contracts"); - } - - [Fact] - public void AddOperator_ShouldDispatchShowAddOperatorDialogEvent() - { - // Act - _editMerchant.AddOperator(); - - // Assert - _editMerchant.Events.ShouldContain(e => e is ShowAddOperatorDialog); - } - - [Fact] - public void AddContract_ShouldDispatchShowAddContractDialogEvent() - { - // Act - _editMerchant.AddContract(); - - // Assert - _editMerchant.Events.ShouldContain(e => e is ShowAddContractDialog); - } -} - -public class DashboardTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly Dashboard _dashboard; - - public DashboardTests() - { - _mediatorMock = new Mock(); - _permissionsServiceMock = new Mock(); - - _dashboard = new Dashboard(_mediatorMock.Object, _permissionsServiceMock.Object); - this._dashboard.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_ShouldPopulateDropdownsAndQueryData() - { - // Arrange - var merchants = TestData.GetMerchants(); - var operators = TestData.GetOperators(); - var comparisonDates = TestData.GetComparisonDates(); - - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(merchants); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(operators); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(comparisonDates); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetTodaysSalesModel())); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetTodaysSettlementModel())); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetTodaysSalesCountByHourModels())); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetTodaysSalesValueByHourModels())); + var contractId = Guid.NewGuid(); + this._contractsList.Url = TestHelper.GetTestUrlHelper(); // Act - await _dashboard.MountAsync(); + await _contractsList.View(contractId); // Assert - _dashboard.Merchant.ShouldNotBeNull(); - _dashboard.Operator.ShouldNotBeNull(); - _dashboard.ComparisonDate.ShouldNotBeNull(); - _dashboard.TodaysSales.ShouldNotBeNull(); - _dashboard.TodaysSettlement.ShouldNotBeNull(); - _dashboard.TodaysSalesCountByHour.ShouldNotBeNull(); - _dashboard.TodaysSalesValueByHour.ShouldNotBeNull(); - _mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - _mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - _mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + _contractsList.LocationUrl.ShouldNotBeNull(); + _contractsList.LocationUrl.ShouldBe("/Contract/ViewContract"); + var payloadContractId = TestHelpers.GetPropertyValue(_contractsList.Payload, "ContractId"); + payloadContractId.ShouldBe(contractId); } [Fact] - public async Task Query_ShouldGetTodaysData() + public async Task NewContract_ShouldNavigateToNewContractPage() { // Arrange - var selectedDate = DateTime.Now; - _dashboard.ComparisonDate = new ComparisonDateListModel { SelectedDate = selectedDate }; - - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetTodaysSalesModel())); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetTodaysSettlementModel())); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetTodaysSalesCountByHourModels())); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetTodaysSalesValueByHourModels())); + this._contractsList.Url = TestHelper.GetTestUrlHelper(); // Act - await _dashboard.Query(); + await _contractsList.NewContract(); // Assert - _dashboard.TodaysSales.ShouldNotBeNull(); - _dashboard.TodaysSettlement.ShouldNotBeNull(); - _dashboard.TodaysSalesCountByHour.ShouldNotBeNull(); - _dashboard.TodaysSalesValueByHour.ShouldNotBeNull(); - _mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - _mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - _mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - _mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + _contractsList.LocationUrl.ShouldNotBeNull(); + _contractsList.LocationUrl.ShouldBe("/Contract/NewContract"); } } \ No newline at end of file diff --git a/EstateManagementUI.UITests/DashboardTests.cs b/EstateManagementUI.UITests/DashboardTests.cs new file mode 100644 index 00000000..47d9702c --- /dev/null +++ b/EstateManagementUI.UITests/DashboardTests.cs @@ -0,0 +1,217 @@ +using EstateManagementUI.BusinessLogic.PermissionService; +using EstateManagementUI.Pages.Dashboard.Dashboard; +using EstateManagementUI.Testing; +using EstateManagementUI.ViewModels; +using EstateManagmentUI.BusinessLogic.Requests; +using MediatR; +using Moq; +using Shouldly; +using SimpleResults; + +namespace EstateManagementUI.UITests; + +public class DashboardTests +{ + private readonly Mock _mediatorMock; + private readonly Mock _permissionsServiceMock; + private readonly Dashboard _dashboard; + + public DashboardTests() + { + this._mediatorMock = new Mock(); + this._permissionsServiceMock = new Mock(); + + this._dashboard = new Dashboard(this._mediatorMock.Object, this._permissionsServiceMock.Object); + this._dashboard.ViewContext = TestHelper.GetTestViewContext(); + } + + [Fact] + public async Task MountAsync_ShouldPopulateDropdownsAndQueryData() + { + // Arrange + var merchants = TestData.GetMerchants(); + var operators = TestData.GetOperators(); + var comparisonDates = TestData.GetComparisonDates(); + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(merchants); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(operators); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(comparisonDates); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesModel())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSettlementModel())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesCountByHourModels())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesValueByHourModels())); + + // Act + await this._dashboard.MountAsync(); + + // Assert + this._dashboard.Merchant.ShouldNotBeNull(); + this._dashboard.Operator.ShouldNotBeNull(); + this._dashboard.ComparisonDate.ShouldNotBeNull(); + this._dashboard.TodaysSales.ShouldNotBeNull(); + this._dashboard.TodaysSettlement.ShouldNotBeNull(); + this._dashboard.TodaysSalesCountByHour.ShouldNotBeNull(); + this._dashboard.TodaysSalesValueByHour.ShouldNotBeNull(); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + } + + [Fact] + public async Task Query_ShouldGetTodaysData() + { + // Arrange + var selectedDate = DateTime.Now; + this._dashboard.ComparisonDate = new ComparisonDateListModel { SelectedDate = selectedDate }; + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesModel())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSettlementModel())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesCountByHourModels())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesValueByHourModels())); + + // Act + await this._dashboard.Query(); + + // Assert + this._dashboard.TodaysSales.ShouldNotBeNull(); + this._dashboard.TodaysSettlement.ShouldNotBeNull(); + this._dashboard.TodaysSalesCountByHour.ShouldNotBeNull(); + this._dashboard.TodaysSalesValueByHour.ShouldNotBeNull(); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + } + + [Fact] + public async Task Query_ShouldGetTodaysData_GetTodaysSalesFailed() + { + // Arrange + var selectedDate = DateTime.Now; + this._dashboard.ComparisonDate = new ComparisonDateListModel { SelectedDate = selectedDate }; + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure()); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSettlementModel())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesCountByHourModels())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesValueByHourModels())); + + // Act + await this._dashboard.Query(); + + // Assert + this._dashboard.TodaysSales.ShouldNotBeNull(); + this._dashboard.TodaysSettlement.ShouldNotBeNull(); + this._dashboard.TodaysSalesCountByHour.ShouldNotBeNull(); + this._dashboard.TodaysSalesValueByHour.ShouldNotBeNull(); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + } + + [Fact] + public async Task Query_ShouldGetTodaysData_GetTodaysSettlementFailed() + { + // Arrange + var selectedDate = DateTime.Now; + this._dashboard.ComparisonDate = new ComparisonDateListModel { SelectedDate = selectedDate }; + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesModel())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure()); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesCountByHourModels())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesValueByHourModels())); + + // Act + await this._dashboard.Query(); + + // Assert + this._dashboard.TodaysSales.ShouldNotBeNull(); + this._dashboard.TodaysSettlement.ShouldNotBeNull(); + this._dashboard.TodaysSalesCountByHour.ShouldNotBeNull(); + this._dashboard.TodaysSalesValueByHour.ShouldNotBeNull(); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + } + + [Fact] + public async Task Query_ShouldGetTodaysData_GetTodaysSalesCountByHourFailed() + { + // Arrange + var selectedDate = DateTime.Now; + this._dashboard.ComparisonDate = new ComparisonDateListModel { SelectedDate = selectedDate }; + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesModel())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSettlementModel())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure()); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesValueByHourModels())); + + // Act + await this._dashboard.Query(); + + // Assert + this._dashboard.TodaysSales.ShouldNotBeNull(); + this._dashboard.TodaysSettlement.ShouldNotBeNull(); + this._dashboard.TodaysSalesCountByHour.ShouldNotBeNull(); + this._dashboard.TodaysSalesValueByHour.ShouldNotBeNull(); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + } + + [Fact] + public async Task Query_ShouldGetTodaysData_GetTodaysSalesValueByHourFailed() + { + // Arrange + var selectedDate = DateTime.Now; + this._dashboard.ComparisonDate = new ComparisonDateListModel { SelectedDate = selectedDate }; + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesModel())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSettlementModel())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetTodaysSalesCountByHourModels())); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure()); + + // Act + await this._dashboard.Query(); + + // Assert + this._dashboard.TodaysSales.ShouldNotBeNull(); + this._dashboard.TodaysSettlement.ShouldNotBeNull(); + this._dashboard.TodaysSalesCountByHour.ShouldNotBeNull(); + this._dashboard.TodaysSalesValueByHour.ShouldNotBeNull(); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + } + +} \ No newline at end of file diff --git a/EstateManagementUI.UITests/DataHelperFunctionsTests.cs b/EstateManagementUI.UITests/DataHelperFunctionsTests.cs index d099a43f..9e5795ed 100644 --- a/EstateManagementUI.UITests/DataHelperFunctionsTests.cs +++ b/EstateManagementUI.UITests/DataHelperFunctionsTests.cs @@ -36,7 +36,7 @@ public async Task GetComparisonDates_ValidInputs_ReturnsComparisonDateListModel( } [Fact] - public async Task GetOperators_ValidInputs_ReturnsOperatorListModel() + public async Task GetOperatorsOld_ValidInputs_ReturnsOperatorListModel() { // Arrange string accessToken = "testAccessToken"; @@ -105,4 +105,81 @@ public async Task GetContracts_ValidInputs_ReturnsContractListModel() response.Contracts.ShouldNotBeEmpty(); response.Contracts.First().Text.ShouldBe("- Select a Contract -"); } + + [Fact] + public async Task GetOperators_ValidInputs_ReturnsOperatorListModel() + { + // Arrange + string accessToken = "testAccessToken"; + Guid estateId = Guid.NewGuid(); + var operators = new List + { + new OperatorModel() { OperatorId = Guid.NewGuid(), Name = "Operator 1" }, + new OperatorModel() { OperatorId = Guid.NewGuid(), Name = "Operator 2" }, + }; + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(operators); + + // Act + var response = await DataHelperFunctions.GetOperators(accessToken, estateId, this._mediatorMock.Object); + + // Assert + response.ShouldNotBeNull(); + response.ShouldNotBeEmpty(); + response.First().Text.ShouldBe("- Select an Operator -"); + } + + [Fact] + public async Task GetProductTypes_ValidInputs_ReturnsProductTypes() + { + // Arrange + string accessToken = "testAccessToken"; + Guid estateId = Guid.NewGuid(); + + // Act + var response = await DataHelperFunctions.GetProductTypes(accessToken, estateId); + + // Assert + response.ShouldNotBeNull(); + response.Count.ShouldBe(4); + } + + [Fact] + public async Task GetCalculationTypes_ReturnsCalculationTypes() + { + // Arrange + + // Act + var response = DataHelperFunctions.GetCalculationTypes(); + + // Assert + response.ShouldNotBeNull(); + response.Count.ShouldBe(3); + } + + [Fact] + public async Task GetFeeTypes_ReturnsFeeTypes() + { + // Arrange + + // Act + var response = DataHelperFunctions.GetFeeTypes(); + + // Assert + response.ShouldNotBeNull(); + response.Count.ShouldBe(3); + } + + [Fact] + public async Task GetSettlementSchedules_ReturnsSettlementSchedules() + { + // Arrange + + // Act + var response = DataHelperFunctions.GetSettlementSchedules(); + + // Assert + response.ShouldNotBeNull(); + response.Count.ShouldBe(4); + } } \ No newline at end of file diff --git a/EstateManagementUI.UITests/EditMerchantTests.cs b/EstateManagementUI.UITests/EditMerchantTests.cs new file mode 100644 index 00000000..3abce523 --- /dev/null +++ b/EstateManagementUI.UITests/EditMerchantTests.cs @@ -0,0 +1,148 @@ +using EstateManagementUI.BusinessLogic.PermissionService; +using EstateManagementUI.Pages.Merchant; +using EstateManagementUI.Pages.Merchant.MerchantDetails; +using EstateManagementUI.Pages.Shared.Components; +using EstateManagementUI.Testing; +using EstateManagmentUI.BusinessLogic.Requests; +using MediatR; +using Moq; +using Shouldly; +using SimpleResults; + +namespace EstateManagementUI.UITests; + +public class EditMerchantTests +{ + private readonly Mock _mediatorMock; + private readonly Mock _permissionsServiceMock; + private readonly EditMerchant _editMerchant; + + public EditMerchantTests() + { + this._mediatorMock = new Mock(); + this._permissionsServiceMock = new Mock(); + this._editMerchant = new EditMerchant(this._mediatorMock.Object, this._permissionsServiceMock.Object); + this._editMerchant.ViewContext = TestHelper.GetTestViewContext(); + } + + [Fact] + public void SetActiveTab_ShouldSetActiveTab() + { + // Act + this._editMerchant.SetActiveTab("contracts"); + + // Assert + this._editMerchant.ActiveTab.ShouldBe("contracts"); + } + + [Fact] + public void AddOperator_ShouldDispatchShowAddOperatorDialogEvent() + { + // Act + this._editMerchant.AddOperator(); + + // Assert + this._editMerchant.Events.ShouldContain(e => e is MerchantPageEvents.ShowAddOperatorDialog); + } + + [Fact] + public void AddContract_ShouldDispatchShowAddContractDialogEvent() { + // Act + this._editMerchant.AddContract(); + + // Assert + this._editMerchant.Events.ShouldContain(e => e is MerchantPageEvents.ShowAddContractDialog); + } + + [Fact] + public void AddDevice_ShouldDispatchShowAddDeviceDialogEvent() + { + // Act + this._editMerchant.AddDevice(); + + // Assert + this._editMerchant.Events.ShouldContain(e => e is MerchantPageEvents.ShowAddDeviceDialog); + } + + + [Fact] + public async Task GetSettlementSchedules_ReturnsSettlementSchedules() + { + // Arrange + + + // Act + var result = this._editMerchant.GetSettlementSchedules(); + + // Assert + result.Count().ShouldBe(4); + } +} + +public class MakeDepositTests { + private readonly Mock _mediatorMock; + private readonly Mock _permissionsServiceMock; + private readonly MakeDeposit _makeDeposit; + + public MakeDepositTests() + { + this._mediatorMock = new Mock(); + this._permissionsServiceMock = new Mock(); + this._makeDeposit = new MakeDeposit(this._mediatorMock.Object, this._permissionsServiceMock.Object); + this._makeDeposit.ViewContext = TestHelper.GetTestViewContext(); + } + + [Fact] + public async Task MountAsync_MerchantIsLoaded() { + this._makeDeposit.MerchantId = Guid.NewGuid(); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(TestData.MerchantResult); + + await this._makeDeposit.MountAsync(); + + this._makeDeposit.Name.ShouldBe(TestData.MerchantResult.Data.MerchantName); + } + + [Fact] + public async Task Close() + { + this._makeDeposit.Url = TestHelper.GetTestUrlHelper(); + + this._makeDeposit.Close(); + + this._makeDeposit.LocationUrl.ShouldNotBeNull(); + this._makeDeposit.LocationUrl.ShouldBe("/Merchant/Index"); + } + + [Fact] + public async Task Save_MerchantDepositIsMade() + { + this._makeDeposit.MerchantId = Guid.NewGuid(); + this._makeDeposit.Amount = 100; + this._makeDeposit.Date = DateTime.Now; + this._makeDeposit.Reference = "Reference"; + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success); + + await this._makeDeposit.Save(); + + this._makeDeposit.Events.ShouldContain(e => e is MerchantPageEvents.DepositMadeEvent); + } + + [Fact] + public async Task Save_SaveFailed_MerchantDepositIsNotMade() + { + this._makeDeposit.MerchantId = Guid.NewGuid(); + this._makeDeposit.Amount = 100; + this._makeDeposit.Date = DateTime.Now; + this._makeDeposit.Reference = "Reference"; + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure(new List(){"Error Message"})); + + await this._makeDeposit.Save(); + + this._makeDeposit.Events.ShouldContain(e => e is ShowMessage); + } +} \ No newline at end of file diff --git a/EstateManagementUI.UITests/MerchantDetailsTests.cs b/EstateManagementUI.UITests/MerchantDetailsTests.cs index 0a6efc52..0a30eaf0 100644 --- a/EstateManagementUI.UITests/MerchantDetailsTests.cs +++ b/EstateManagementUI.UITests/MerchantDetailsTests.cs @@ -31,6 +31,21 @@ public MerchantDetailsTests() this._merchant.ViewContext = TestHelper.GetTestViewContext(); } + [Fact] + public async Task Clone_NavigatesToMerchantIndexPage() + { + // Arrange + //var merchantId = Guid.NewGuid(); + this._merchant.Url = TestHelper.GetTestUrlHelper(); + + // Act + this._merchant.Close(); + + // Assert + this._merchant.LocationUrl.ShouldNotBeNull(); + this._merchant.LocationUrl.ShouldBe("/Merchant/Index"); + } + [Fact] public async Task MountAsync_LoadsMerchant_WhenMerchantIdIsNotEmpty() { @@ -165,6 +180,132 @@ public async Task Save_UpdatesMerchant_WhenMerchantIdIsNotEmpty() this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); } + [Fact] + public async Task Save_UpdateMerchantFails() + { + // Arrange + this._merchant.MerchantId = Guid.NewGuid(); + this._merchant.Name = "Updated Merchant"; + this._merchant.Reference = "Ref123"; + this._merchant.Address = new AddressViewModel + { + AddressLine1 = "123 Main St", + AddressLine2 = "Suite 100", + Town = "Anytown", + Region = "Anystate", + Country = "USA", + PostCode = "12345" + }; + this._merchant.Contact = new ContactViewModel + { + ContactName = "John Doe", + EmailAddress = "john.doe@example.com", + PhoneNumber = "555-1234" + }; + this._merchant.SettlementScheduleId = 0; + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure(new List() {"Error"})); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success()); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success()); + + // Act + await this._merchant.Save(); + + // Assert + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Never); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Never); + this._merchant.Events.Count.ShouldBe(1); + this._merchant.Events[0].ShouldBeOfType(); + } + + [Fact] + public async Task Save_UpdateMerchantAddressFails() + { + // Arrange + this._merchant.MerchantId = Guid.NewGuid(); + this._merchant.Name = "Updated Merchant"; + this._merchant.Reference = "Ref123"; + this._merchant.Address = new AddressViewModel + { + AddressLine1 = "123 Main St", + AddressLine2 = "Suite 100", + Town = "Anytown", + Region = "Anystate", + Country = "USA", + PostCode = "12345" + }; + this._merchant.Contact = new ContactViewModel + { + ContactName = "John Doe", + EmailAddress = "john.doe@example.com", + PhoneNumber = "555-1234" + }; + this._merchant.SettlementScheduleId = 0; + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success()); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure(new List() { "Error" })); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success()); + + // Act + await this._merchant.Save(); + + // Assert + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Never); + this._merchant.Events.Count.ShouldBe(1); + this._merchant.Events[0].ShouldBeOfType(); + } + + [Fact] + public async Task Save_UpdateMerchantContactFails() + { + // Arrange + this._merchant.MerchantId = Guid.NewGuid(); + this._merchant.Name = "Updated Merchant"; + this._merchant.Reference = "Ref123"; + this._merchant.Address = new AddressViewModel + { + AddressLine1 = "123 Main St", + AddressLine2 = "Suite 100", + Town = "Anytown", + Region = "Anystate", + Country = "USA", + PostCode = "12345" + }; + this._merchant.Contact = new ContactViewModel + { + ContactName = "John Doe", + EmailAddress = "john.doe@example.com", + PhoneNumber = "555-1234" + }; + this._merchant.SettlementScheduleId = 0; + + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success()); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success()); + this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure(new List() { "Error" })); + + // Act + await this._merchant.Save(); + + // Assert + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); + this._merchant.Events.Count.ShouldBe(1); + this._merchant.Events[0].ShouldBeOfType(); + } + [Fact] public async Task RemoveOperator_RemovesOperatorFromMerchant() { diff --git a/EstateManagementUI.UITests/MerchantsListTests.cs b/EstateManagementUI.UITests/MerchantsListTests.cs index d6c40253..658283ac 100644 --- a/EstateManagementUI.UITests/MerchantsListTests.cs +++ b/EstateManagementUI.UITests/MerchantsListTests.cs @@ -88,6 +88,23 @@ public async Task Edit_NavigatesToEditMerchantPage() Guid payloadMerchantId = TestHelpers.GetPropertyValue(this._merchantsList.Payload, "MerchantId"); payloadMerchantId.ShouldBe(merchantId); } + + [Fact] + public async Task MakeDeposit_NavigatesToMakeMerchantDepositPage() + { + // Arrange + var merchantId = Guid.NewGuid(); + this._merchantsList.Url = TestHelper.GetTestUrlHelper(); + + // Act + await this._merchantsList.MakeDeposit(merchantId); + + // Assert + this._merchantsList.LocationUrl.ShouldNotBeNull(); + this._merchantsList.LocationUrl.ShouldBe("/Merchant/MakeDeposit"); + Guid payloadMerchantId = TestHelpers.GetPropertyValue(this._merchantsList.Payload, "MerchantId"); + payloadMerchantId.ShouldBe(merchantId); + } [Fact] public async Task Sort_SortsMerchantsByName() diff --git a/EstateManagementUI.UITests/OperatorTests.cs b/EstateManagementUI.UITests/OperatorTests.cs index 080e8c7b..aff28b60 100644 --- a/EstateManagementUI.UITests/OperatorTests.cs +++ b/EstateManagementUI.UITests/OperatorTests.cs @@ -1,5 +1,5 @@ using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Operator.OperatorDialogs; +using EstateManagementUI.Pages.Operator; using EstateManagementUI.Testing; using EstateManagmentUI.BusinessLogic.Requests; using MediatR; diff --git a/EstateManagementUI.ViewModels/ListModels.cs b/EstateManagementUI.ViewModels/ListModels.cs index f20d0444..b508f8b3 100644 --- a/EstateManagementUI.ViewModels/ListModels.cs +++ b/EstateManagementUI.ViewModels/ListModels.cs @@ -35,7 +35,7 @@ public class ContractListModel public String ContractId { get; set; } } - + public class ProductTypeListModel { public List ProductTypes { get; set; } diff --git a/EstateManagementUI/Bootstrapper/AuthenticationRegistry.cs b/EstateManagementUI/Bootstrapper/AuthenticationRegistry.cs index a7d04a2b..c28eb447 100644 --- a/EstateManagementUI/Bootstrapper/AuthenticationRegistry.cs +++ b/EstateManagementUI/Bootstrapper/AuthenticationRegistry.cs @@ -68,7 +68,7 @@ public AuthenticationRegistry() { options.Scope.Add("email"); options.Scope.Add("offline_access"); - options.Scope.Add("estateManagement"); + //options.Scope.Add("estateReporting"); options.Scope.Add("fileProcessor"); options.Scope.Add("transactionProcessor"); diff --git a/EstateManagementUI/Bootstrapper/MediatorRegistry.cs b/EstateManagementUI/Bootstrapper/MediatorRegistry.cs index 75e015b3..99ac35a5 100644 --- a/EstateManagementUI/Bootstrapper/MediatorRegistry.cs +++ b/EstateManagementUI/Bootstrapper/MediatorRegistry.cs @@ -39,6 +39,7 @@ private void RegisterMerchantRequestHandler() { this.AddSingleton, MerchantRequestHandler>(); this.AddSingleton, MerchantRequestHandler>(); this.AddSingleton, MerchantRequestHandler>(); + this.AddSingleton, MerchantRequestHandler>(); } private void RegisterOperatorRequestHandler() { diff --git a/EstateManagementUI/Pages/Components/FieldSelect.cshtml.cs b/EstateManagementUI/Pages/Components/FieldSelect.cshtml.cs index 1f0af6bd..5f00eb6f 100644 --- a/EstateManagementUI/Pages/Components/FieldSelect.cshtml.cs +++ b/EstateManagementUI/Pages/Components/FieldSelect.cshtml.cs @@ -1,8 +1,10 @@ +using System.Diagnostics.CodeAnalysis; using Hydro; using Microsoft.AspNetCore.Mvc.ViewFeatures; namespace EstateManagementUI.Pages.Components; +[ExcludeFromCodeCoverage] public class FieldSelect : HydroView { public string Id { get; set; } @@ -12,4 +14,5 @@ public class FieldSelect : HydroView public bool UseBlank { get; set; } } +[ExcludeFromCodeCoverage] public record OptionItem(object Value, string Text); \ No newline at end of file diff --git a/EstateManagementUI/Pages/Contract/Contract/NewContract.cshtml.cs b/EstateManagementUI/Pages/Contract/Contract/NewContract.cshtml.cs index f7356e90..9754526f 100644 --- a/EstateManagementUI/Pages/Contract/Contract/NewContract.cshtml.cs +++ b/EstateManagementUI/Pages/Contract/Contract/NewContract.cshtml.cs @@ -114,14 +114,4 @@ private async Task CreateNeContract() public Guid ContractId { get; set; } } -} - - -public class ContractPageEvents { - public record ContractCreatedEvent; - public record ContractUpdatedEvent; - public record ContractProductCreatedEvent; - public record ContractProductUpdatedEvent; - public record ContractProductTransactionFeeCreatedEvent; - } \ No newline at end of file diff --git a/EstateManagementUI/Pages/Contract/ContractPageEvents.cs b/EstateManagementUI/Pages/Contract/ContractPageEvents.cs new file mode 100644 index 00000000..89c1d357 --- /dev/null +++ b/EstateManagementUI/Pages/Contract/ContractPageEvents.cs @@ -0,0 +1,14 @@ +using System.Diagnostics.CodeAnalysis; + +namespace EstateManagementUI.Pages.Contract +{ + [ExcludeFromCodeCoverage] + public class ContractPageEvents + { + public record ContractCreatedEvent; + public record ContractUpdatedEvent; + public record ContractProductCreatedEvent; + public record ContractProductUpdatedEvent; + public record ContractProductTransactionFeeCreatedEvent; + } +} diff --git a/EstateManagementUI/Pages/Merchant/MerchantDetails/AddContractDialog.cshtml.cs b/EstateManagementUI/Pages/Merchant/MerchantDetails/AddContractDialog.cshtml.cs index b0fa7fe3..8850af79 100644 --- a/EstateManagementUI/Pages/Merchant/MerchantDetails/AddContractDialog.cshtml.cs +++ b/EstateManagementUI/Pages/Merchant/MerchantDetails/AddContractDialog.cshtml.cs @@ -12,7 +12,7 @@ using EstateManagmentUI.BusinessLogic.Requests; using Hydro; using SimpleResults; -using static EstateManagementUI.Pages.Merchant.MerchantDetails.MerchantPageEvents; +using static EstateManagementUI.Pages.Merchant.MerchantPageEvents; namespace EstateManagementUI.Pages.Merchant.MerchantDetails { diff --git a/EstateManagementUI/Pages/Merchant/MerchantDetails/AddDeviceDialog.cshtml b/EstateManagementUI/Pages/Merchant/MerchantDetails/AddDeviceDialog.cshtml new file mode 100644 index 00000000..53b78cf0 --- /dev/null +++ b/EstateManagementUI/Pages/Merchant/MerchantDetails/AddDeviceDialog.cshtml @@ -0,0 +1,28 @@ +@model EstateManagementUI.Pages.Merchant.MerchantDetails.AddDeviceDialog + \ No newline at end of file diff --git a/EstateManagementUI/Pages/Merchant/MerchantDetails/AddDeviceDialog.cshtml.cs b/EstateManagementUI/Pages/Merchant/MerchantDetails/AddDeviceDialog.cshtml.cs new file mode 100644 index 00000000..824f23a3 --- /dev/null +++ b/EstateManagementUI/Pages/Merchant/MerchantDetails/AddDeviceDialog.cshtml.cs @@ -0,0 +1,67 @@ +using EstateManagementUI.BusinessLogic.Models; +using EstateManagementUI.BusinessLogic.PermissionService; +using EstateManagementUI.BusinessLogic.PermissionService.Constants; +using EstateManagementUI.Common; +using EstateManagementUI.ViewModels; +using MediatR; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; +using EstateManagementUI.Pages.Shared.Components; +using EstateManagmentUI.BusinessLogic.Requests; +using Hydro; +using SimpleResults; +using static EstateManagementUI.Pages.Merchant.MerchantPageEvents; + +namespace EstateManagementUI.Pages.Merchant.MerchantDetails +{ + public class AddDeviceDialog : DeviceDialog + { + [Display(Name = "MerchantDevice")] + public String MerchantDevice { get; set; } + + public AddDeviceDialog(IMediator mediator, IPermissionsService permissionsService) : base(mediator, permissionsService, MerchantFunctions.AddContract) { + } + + public override async Task MountAsync() + { + + } + + public async Task Save() { + await this.PopulateTokenAndEstateId(); + + AssignDeviceToMerchantModel assignDeviceToMerchant = new(){ + DeviceIdentifier= this.MerchantDevice + }; + Commands.AssignDeviceToMerchantCommand assignContractToMerchantCommand = + new(this.AccessToken, this.EstateId, this.MerchantId, assignDeviceToMerchant); + Result result = await this.Mediator.Send(assignContractToMerchantCommand, CancellationToken.None); + + if (result.IsSuccess) { + this.Dispatch(new DeviceAssignedToMerchantEvent(), Scope.Global); + } + else { + this.Dispatch(new ShowMessage("Error assigning device to Merchant", ToastType.Error), Scope.Global); + } + + await this.Close(); + } + + public async Task Close() => this.Dispatch(new MerchantPageEvents.HideAddDeviceDialog(), Scope.Global); + } + + [ExcludeFromCodeCoverage] + public class DeviceDialog : SecureHydroComponent { + protected readonly IMediator Mediator; + + public Guid MerchantId { get; set; } + + public DeviceDialog(IMediator mediator, + IPermissionsService permissionsService, + String merchantFunction) : base(ApplicationSections.Merchant, merchantFunction, permissionsService) { + this.Mediator = mediator; + } + } +} diff --git a/EstateManagementUI/Pages/Merchant/MerchantDetails/AddOperatorDialog.cshtml.cs b/EstateManagementUI/Pages/Merchant/MerchantDetails/AddOperatorDialog.cshtml.cs index 88c325b9..b2a062ad 100644 --- a/EstateManagementUI/Pages/Merchant/MerchantDetails/AddOperatorDialog.cshtml.cs +++ b/EstateManagementUI/Pages/Merchant/MerchantDetails/AddOperatorDialog.cshtml.cs @@ -10,7 +10,7 @@ using EstateManagmentUI.BusinessLogic.Requests; using Hydro; using SimpleResults; -using static EstateManagementUI.Pages.Merchant.MerchantDetails.MerchantPageEvents; +using static EstateManagementUI.Pages.Merchant.MerchantPageEvents; namespace EstateManagementUI.Pages.Merchant.MerchantDetails { diff --git a/EstateManagementUI/Pages/Merchant/MerchantDetails/EditMerchant.cshtml b/EstateManagementUI/Pages/Merchant/MerchantDetails/EditMerchant.cshtml index fdf67533..42d81c04 100644 --- a/EstateManagementUI/Pages/Merchant/MerchantDetails/EditMerchant.cshtml +++ b/EstateManagementUI/Pages/Merchant/MerchantDetails/EditMerchant.cshtml @@ -229,6 +229,7 @@
+ @@ -261,6 +262,10 @@ @if (Model.ShowContractDialog) { } + @if (Model.ShowDeviceDialog) + { + + }
diff --git a/EstateManagementUI/Pages/Merchant/MerchantDetails/EditMerchant.cshtml.cs b/EstateManagementUI/Pages/Merchant/MerchantDetails/EditMerchant.cshtml.cs index 2b486295..714ba354 100644 --- a/EstateManagementUI/Pages/Merchant/MerchantDetails/EditMerchant.cshtml.cs +++ b/EstateManagementUI/Pages/Merchant/MerchantDetails/EditMerchant.cshtml.cs @@ -31,19 +31,28 @@ public EditMerchant(IMediator mediator, IPermissionsService permissionsService) Subscribe(Handle); Subscribe(Handle); + Subscribe(Handle); + Subscribe(Handle); + Subscribe(Handle); Subscribe(Handle); this.Subscribe(Handle); this.Subscribe(Handle); + + this.Subscribe(Handle); } public void SetActiveTab(String activeTab) { this.ActiveTab = activeTab; } + [ExcludeFromCodeCoverage] public Boolean ShowOperatorDialog { get; set; } + [ExcludeFromCodeCoverage] public Boolean ShowContractDialog { get; set; } + [ExcludeFromCodeCoverage] + public Boolean ShowDeviceDialog { get; set; } [ExcludeFromCodeCoverage] private async Task Handle(MerchantPageEvents.OperatorAssignedToMerchantEvent obj) { @@ -60,6 +69,14 @@ private async Task Handle(MerchantPageEvents.ContractAssignedToMerchantEvent obj await this.LoadMerchant(CancellationToken.None); } + [ExcludeFromCodeCoverage] + private async Task Handle(MerchantPageEvents.DeviceAssignedToMerchantEvent obj) + { + await Task.Delay(1000); + this.Dispatch(new ShowMessage("Device Added to Merchant Successfully", ToastType.Success), Scope.Global); + await this.LoadMerchant(CancellationToken.None); + } + [ExcludeFromCodeCoverage] private async Task Handle(MerchantPageEvents.OperatorRemovedFromMerchantEvent obj) { @@ -87,6 +104,12 @@ private async Task Handle(MerchantPageEvents.ShowAddContractDialog obj) this.ShowContractDialog = true; } + [ExcludeFromCodeCoverage] + private async Task Handle(MerchantPageEvents.ShowAddDeviceDialog obj) + { + this.ShowDeviceDialog= true; + } + [ExcludeFromCodeCoverage] private async Task Handle(MerchantPageEvents.HideAddOperatorDialog obj) { this.ShowOperatorDialog = false; @@ -98,10 +121,18 @@ private async Task Handle(MerchantPageEvents.HideAddContractDialog obj) this.ShowContractDialog= false; } + [ExcludeFromCodeCoverage] + private async Task Handle(MerchantPageEvents.HideAddDeviceDialog obj) + { + this.ShowDeviceDialog = false; + } + public void AddOperator() => this.Dispatch(new MerchantPageEvents.ShowAddOperatorDialog(), Scope.Global); public void AddContract() => this.Dispatch(new MerchantPageEvents.ShowAddContractDialog(), Scope.Global); + public void AddDevice() => this.Dispatch(new MerchantPageEvents.ShowAddDeviceDialog(), Scope.Global); + public List GetSettlementSchedules() => DataHelperFunctions.GetSettlementSchedules(); } } diff --git a/EstateManagementUI/Pages/Merchant/MerchantDetails/MakeDeposit.cshtml.cs b/EstateManagementUI/Pages/Merchant/MerchantDetails/MakeDeposit.cshtml.cs index d0622b36..f5710f3d 100644 --- a/EstateManagementUI/Pages/Merchant/MerchantDetails/MakeDeposit.cshtml.cs +++ b/EstateManagementUI/Pages/Merchant/MerchantDetails/MakeDeposit.cshtml.cs @@ -138,9 +138,9 @@ protected async Task LoadMerchant(CancellationToken cancellationToken) { Queries.GetMerchantQuery query = new(this.AccessToken, this.EstateId, this.MerchantId); Result result = await this.Mediator.Send(query, cancellationToken); - if (result.IsFailed) { - // handle this - } + //if (result.IsFailed) { + // // handle this + //} this.Name = result.Data.MerchantName; } @@ -148,10 +148,6 @@ protected async Task LoadMerchant(CancellationToken cancellationToken) { public DateTime Date { get; set; } public String Reference { get; set; } public async Task Save() { - if (!this.ModelState.IsValid) { - return; - } - await this.PopulateTokenAndEstateId(); Commands.MakeDepositCommand command = new(this.AccessToken, this.EstateId, this.MerchantId, new BusinessLogic.Models.MakeDepositModel diff --git a/EstateManagementUI/Pages/Merchant/MerchantDetails/Merchant.cs b/EstateManagementUI/Pages/Merchant/MerchantDetails/Merchant.cs index 852d832a..f3b3d880 100644 --- a/EstateManagementUI/Pages/Merchant/MerchantDetails/Merchant.cs +++ b/EstateManagementUI/Pages/Merchant/MerchantDetails/Merchant.cs @@ -80,10 +80,10 @@ protected async Task LoadMerchant(CancellationToken cancellationToken) { Queries.GetMerchantQuery query = new(this.AccessToken, this.EstateId, this.MerchantId); Result result = await this.Mediator.Send(query, cancellationToken); - if (result.IsFailed) - { - // handle this - } + //if (result.IsFailed) + //{ + // // handle this + //} // We need to now get all the contracts here to populate the names on the Merchant Model Queries.GetContractsQuery contractsQuery = new Queries.GetContractsQuery(this.AccessToken, this.EstateId); @@ -238,9 +238,6 @@ private async Task UpdateExitingMerchant() { } public async Task Save() { - if (!this.ModelState.IsValid) { - return; - } await this.PopulateTokenAndEstateId(); Task t = this.MerchantId switch { diff --git a/EstateManagementUI/Pages/Merchant/MerchantDetails/MerchantPageEvents.cs b/EstateManagementUI/Pages/Merchant/MerchantPageEvents.cs similarity index 77% rename from EstateManagementUI/Pages/Merchant/MerchantDetails/MerchantPageEvents.cs rename to EstateManagementUI/Pages/Merchant/MerchantPageEvents.cs index 2fd12723..2acb31ee 100644 --- a/EstateManagementUI/Pages/Merchant/MerchantDetails/MerchantPageEvents.cs +++ b/EstateManagementUI/Pages/Merchant/MerchantPageEvents.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -namespace EstateManagementUI.Pages.Merchant.MerchantDetails; +namespace EstateManagementUI.Pages.Merchant; [ExcludeFromCodeCoverage] public class MerchantPageEvents @@ -16,4 +16,7 @@ public record HideAddContractDialog; public record ContractAssignedToMerchantEvent; public record ContractRemovedFromMerchantEvent; public record DepositMadeEvent; + public record DeviceAssignedToMerchantEvent; + public record ShowAddDeviceDialog; + public record HideAddDeviceDialog; } \ No newline at end of file diff --git a/EstateManagementUI/Pages/Merchant/MerchantsList/MerchantsList.cshtml.cs b/EstateManagementUI/Pages/Merchant/MerchantsList/MerchantsList.cshtml.cs index a466611a..7d72d7cf 100644 --- a/EstateManagementUI/Pages/Merchant/MerchantsList/MerchantsList.cshtml.cs +++ b/EstateManagementUI/Pages/Merchant/MerchantsList/MerchantsList.cshtml.cs @@ -21,8 +21,8 @@ public class MerchantsList : SecureHydroComponent { private readonly IMediator Mediator; - public Guid MerchantId { get; set; } - public bool ShowDialog { get; set; } + //public Guid MerchantId { get; set; } + //public bool ShowDialog { get; set; } public MerchantsList(IMediator mediator, IPermissionsService permissionsService) : base(ApplicationSections.Merchant, MerchantFunctions.ViewList, permissionsService) { diff --git a/EstateManagementUI/Pages/Operator/OperatorDialogs/OperatorPageEvents.cs b/EstateManagementUI/Pages/Operator/OperatorPageEvents.cs similarity index 85% rename from EstateManagementUI/Pages/Operator/OperatorDialogs/OperatorPageEvents.cs rename to EstateManagementUI/Pages/Operator/OperatorPageEvents.cs index c64f4976..3c91c3ae 100644 --- a/EstateManagementUI/Pages/Operator/OperatorDialogs/OperatorPageEvents.cs +++ b/EstateManagementUI/Pages/Operator/OperatorPageEvents.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -namespace EstateManagementUI.Pages.Operator.OperatorDialogs; +namespace EstateManagementUI.Pages.Operator; [ExcludeFromCodeCoverage] public class OperatorPageEvents diff --git a/EstateManagementUI/Pages/Operator/OperatorsList/OperatorsList.cshtml.cs b/EstateManagementUI/Pages/Operator/OperatorsList/OperatorsList.cshtml.cs index 4e61f94b..10f47785 100644 --- a/EstateManagementUI/Pages/Operator/OperatorsList/OperatorsList.cshtml.cs +++ b/EstateManagementUI/Pages/Operator/OperatorsList/OperatorsList.cshtml.cs @@ -11,10 +11,9 @@ using System.Collections.Generic; using System.Reflection.Metadata; using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Operator.OperatorDialogs; using EstateManagementUI.Pages.Shared.Components; using SimpleResults; -using static EstateManagementUI.Pages.Operator.OperatorDialogs.OperatorPageEvents; +using static EstateManagementUI.Pages.Operator.OperatorPageEvents; using Microsoft.AspNetCore.Mvc; namespace EstateManagementUI.Pages.Operator.OperatorsList