From e3c34aaa8db5f4ddbb18e2e41f632f0ee6027c42 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 09:54:50 +0000 Subject: [PATCH 1/7] Initial plan From ab9b37b6cc741e0a930ada8fa831ca65ef6edb5b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:01:55 +0000 Subject: [PATCH 2/7] Add Dashboard integration tests project with Reqnroll, Playwright, and Shouldly Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- EstateManagementUI.DashboardTests/.gitignore | 42 +++ .../Common/DashboardPageHelper.cs | 242 ++++++++++++++++++ .../EstateManagementUI.DashboardTests.csproj | 39 +++ .../Features/Dashboard.feature | 88 +++++++ .../Hooks/BrowserHooks.cs | 144 +++++++++++ EstateManagementUI.DashboardTests/README.md | 138 ++++++++++ .../Steps/DashboardSteps.cs | 187 ++++++++++++++ .../appsettings.json | 23 ++ 8 files changed, 903 insertions(+) create mode 100644 EstateManagementUI.DashboardTests/.gitignore create mode 100644 EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs create mode 100644 EstateManagementUI.DashboardTests/EstateManagementUI.DashboardTests.csproj create mode 100644 EstateManagementUI.DashboardTests/Features/Dashboard.feature create mode 100644 EstateManagementUI.DashboardTests/Hooks/BrowserHooks.cs create mode 100644 EstateManagementUI.DashboardTests/README.md create mode 100644 EstateManagementUI.DashboardTests/Steps/DashboardSteps.cs create mode 100644 EstateManagementUI.DashboardTests/appsettings.json diff --git a/EstateManagementUI.DashboardTests/.gitignore b/EstateManagementUI.DashboardTests/.gitignore new file mode 100644 index 00000000..3eb6e160 --- /dev/null +++ b/EstateManagementUI.DashboardTests/.gitignore @@ -0,0 +1,42 @@ +## Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +## Test Results +[Tt]est[Rr]esult*/ +TestResults/ +*.trx +*.coverage + +## Playwright +.playwright/ +playwright-report/ +playwright/.cache/ + +## Screenshots +screenshot-*.png + +## Visual Studio cache/options +.vs/ +.vscode/ + +## Reqnroll/SpecFlow generated files +*.feature.cs + +## NuGet +*.nupkg +*.snupkg +packages/ +.nuget/ diff --git a/EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs b/EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs new file mode 100644 index 00000000..dd61ae61 --- /dev/null +++ b/EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs @@ -0,0 +1,242 @@ +using Microsoft.Playwright; +using Shouldly; + +namespace EstateManagementUI.DashboardTests.Common; + +/// +/// Helper class for interacting with the Dashboard page using Playwright +/// +public class DashboardPageHelper +{ + private readonly IPage _page; + private readonly string _baseUrl; + + public DashboardPageHelper(IPage page, string baseUrl) + { + _page = page; + _baseUrl = baseUrl; + } + + #region Navigation + + /// + /// Navigate to the home/dashboard page + /// + public async Task NavigateToDashboard() + { + await _page.GotoAsync(_baseUrl); + await _page.WaitForLoadStateAsync(LoadState.NetworkIdle); + } + + #endregion + + #region Verification Methods + + /// + /// Verify the page title is "Dashboard" + /// + public async Task VerifyDashboardPageTitle() + { + var title = await _page.TitleAsync(); + title.ShouldBe("Dashboard"); + } + + /// + /// Verify the Administrator welcome message is displayed + /// + public async Task VerifyAdministratorWelcomeMessage() + { + var heading = await _page.Locator("h2:has-text('Welcome, Administrator')").TextContentAsync(); + heading.ShouldNotBeNull(); + heading.ShouldContain("Welcome, Administrator"); + + var description = await _page.Locator("p:has-text('administrative access')").TextContentAsync(); + description.ShouldNotBeNull(); + description.ShouldContain("administrative access to manage system permissions"); + } + + /// + /// Verify that KPI cards are visible on the dashboard + /// + public async Task VerifyKpiCardsAreVisible() + { + await _page.Locator("text=Merchants with Sales (Last Hour)").WaitForAsync(); + await _page.Locator("text=Merchants with No Sales Today").WaitForAsync(); + await _page.Locator("text=Merchants with No Sales (7 Days)").WaitForAsync(); + } + + /// + /// Verify that KPI cards are NOT visible (Administrator role) + /// + public async Task VerifyKpiCardsAreNotVisible() + { + var salesLastHourCount = await _page.Locator("text=Merchants with Sales (Last Hour)").CountAsync(); + salesLastHourCount.ShouldBe(0, "KPI cards should not be visible for Administrator role"); + } + + /// + /// Verify Merchant KPI values match expected hardcoded test data + /// + public async Task VerifyMerchantKpiValues(int salesLastHour, int noSalesToday, int noSales7Days) + { + // Wait for KPI cards to load + await _page.Locator("text=Merchants with Sales (Last Hour)").WaitForAsync(); + + // Verify Merchants with Sales in Last Hour + var salesLastHourCard = _page.Locator(".info-box").Filter(new LocatorFilterOptions + { + HasText = "Merchants with Sales (Last Hour)" + }); + var salesLastHourValue = await salesLastHourCard.Locator(".info-box-number").TextContentAsync(); + salesLastHourValue.ShouldNotBeNull(); + int.Parse(salesLastHourValue.Trim()).ShouldBe(salesLastHour); + + // Verify Merchants with No Sales Today + var noSalesTodayCard = _page.Locator(".info-box").Filter(new LocatorFilterOptions + { + HasText = "Merchants with No Sales Today" + }); + var noSalesTodayValue = await noSalesTodayCard.Locator(".info-box-number").TextContentAsync(); + noSalesTodayValue.ShouldNotBeNull(); + int.Parse(noSalesTodayValue.Trim()).ShouldBe(noSalesToday); + + // Verify Merchants with No Sales in Last 7 Days + var noSales7DaysCard = _page.Locator(".info-box").Filter(new LocatorFilterOptions + { + HasText = "Merchants with No Sales (7 Days)" + }); + var noSales7DaysValue = await noSales7DaysCard.Locator(".info-box-number").TextContentAsync(); + noSales7DaysValue.ShouldNotBeNull(); + int.Parse(noSales7DaysValue.Trim()).ShouldBe(noSales7Days); + } + + /// + /// Verify Today's Sales card is displayed + /// + public async Task VerifyTodaysSalesCardIsDisplayed() + { + await _page.Locator("h3:has-text('Today\\'s Sales')").WaitForAsync(); + } + + /// + /// Verify Today's Sales values + /// + public async Task VerifyTodaysSalesValues(int todayCount, decimal todayValue) + { + var salesCard = _page.Locator(".card").Filter(new LocatorFilterOptions + { + HasText = "Today's Sales" + }); + + // Wait for the card to be visible + await salesCard.WaitForAsync(); + + // Verify today's sales count + var todayTransactions = await salesCard.Locator("p:has-text('transactions')").First.TextContentAsync(); + todayTransactions.ShouldNotBeNull(); + todayTransactions.ShouldContain($"{todayCount} transactions"); + + // Verify today's sales value is displayed (currency format) + var todayValueText = await salesCard.Locator(".text-2xl.font-bold").First.TextContentAsync(); + todayValueText.ShouldNotBeNull(); + // Just verify value is present and formatted as currency + todayValueText.ShouldContain("$"); + } + + /// + /// Verify Failed Sales card is displayed + /// + public async Task VerifyFailedSalesCardIsDisplayed() + { + await _page.Locator("h3:has-text('Failed Sales (Low Credit)')").WaitForAsync(); + } + + /// + /// Verify Failed Sales values + /// + public async Task VerifyFailedSalesValues(int todayCount) + { + var failedSalesCard = _page.Locator(".card").Filter(new LocatorFilterOptions + { + HasText = "Failed Sales (Low Credit)" + }); + + // Wait for the card to be visible + await failedSalesCard.WaitForAsync(); + + // Verify today's failed sales count + var todayTransactions = await failedSalesCard.Locator("p:has-text('transactions')").First.TextContentAsync(); + todayTransactions.ShouldNotBeNull(); + todayTransactions.ShouldContain($"{todayCount} transactions"); + } + + /// + /// Verify comparison date selector is visible + /// + public async Task VerifyComparisonDateSelectorIsVisible() + { + await _page.Locator("label:has-text('Compare to:')").WaitForAsync(); + await _page.Locator("#comparisonDateSelector").WaitForAsync(); + } + + /// + /// Verify comparison date selector is NOT visible (Administrator role) + /// + public async Task VerifyComparisonDateSelectorIsNotVisible() + { + var selectorCount = await _page.Locator("#comparisonDateSelector").CountAsync(); + selectorCount.ShouldBe(0, "Comparison date selector should not be visible for Administrator role"); + } + + /// + /// Verify Recently Created Merchants section is visible + /// + public async Task VerifyRecentlyCreatedMerchantsIsVisible() + { + await _page.Locator("h3:has-text('Recently Created Merchants')").WaitForAsync(); + } + + /// + /// Verify Recently Created Merchants section is NOT visible (Administrator role) + /// + public async Task VerifyRecentlyCreatedMerchantsIsNotVisible() + { + var merchantsCount = await _page.Locator("h3:has-text('Recently Created Merchants')").CountAsync(); + merchantsCount.ShouldBe(0, "Recently Created Merchants should not be visible for Administrator role"); + } + + /// + /// Verify that at least one merchant is displayed in the Recently Created Merchants section + /// + public async Task VerifyRecentlyCreatedMerchantsHasData() + { + var merchantsCard = _page.Locator(".card").Filter(new LocatorFilterOptions + { + HasText = "Recently Created Merchants" + }); + + await merchantsCard.WaitForAsync(); + + // Check that at least one merchant is displayed + var merchantItems = merchantsCard.Locator(".flex.items-center.justify-between"); + var count = await merchantItems.CountAsync(); + count.ShouldBeGreaterThan(0, "At least one merchant should be displayed"); + } + + #endregion + + #region Interaction Methods + + /// + /// Select a comparison date from the dropdown + /// + public async Task SelectComparisonDate(string dateDescription) + { + await _page.Locator("#comparisonDateSelector").SelectOptionAsync(new[] { new SelectOptionValue { Label = dateDescription } }); + // Wait for dashboard to reload + await Task.Delay(500); // Small delay for state update + await _page.WaitForLoadStateAsync(LoadState.NetworkIdle); + } + + #endregion +} diff --git a/EstateManagementUI.DashboardTests/EstateManagementUI.DashboardTests.csproj b/EstateManagementUI.DashboardTests/EstateManagementUI.DashboardTests.csproj new file mode 100644 index 00000000..96310436 --- /dev/null +++ b/EstateManagementUI.DashboardTests/EstateManagementUI.DashboardTests.csproj @@ -0,0 +1,39 @@ + + + + net10.0 + enable + enable + + false + true + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + Always + true + PreserveNewest + + + + diff --git a/EstateManagementUI.DashboardTests/Features/Dashboard.feature b/EstateManagementUI.DashboardTests/Features/Dashboard.feature new file mode 100644 index 00000000..d7e0c8a2 --- /dev/null +++ b/EstateManagementUI.DashboardTests/Features/Dashboard.feature @@ -0,0 +1,88 @@ +Feature: Dashboard Integration Tests + As a user of the Estate Management UI + I want to see appropriate dashboard content based on my role + So that I can access the information relevant to my permissions + +Background: + Given the user navigates to the Dashboard + +@DashboardTests @AdminRole +Scenario: Administrator user sees limited dashboard view + Given the user is authenticated as an "Administrator" user + When the user navigates to the Dashboard + Then the Dashboard page is displayed + And the Administrator welcome message is displayed + And no merchant KPI cards are displayed + And no sales data cards are displayed + +@DashboardTests @EstateRole +Scenario: Estate user sees full dashboard with merchant KPIs + Given the user is authenticated as an "Estate" user + When the user navigates to the Dashboard + Then the Dashboard page is displayed + And the merchant KPI cards are displayed + And the Merchants with Sales in Last Hour shows "45" + And the Merchants with No Sales Today shows "12" + And the Merchants with No Sales in Last 7 Days shows "5" + +@DashboardTests @EstateRole +Scenario: Estate user sees sales data on dashboard + Given the user is authenticated as an "Estate" user + When the user navigates to the Dashboard + Then the Dashboard page is displayed + And the Today's Sales card is displayed + And the Today's Sales card shows "523" transactions + And the Today's Sales card shows a value greater than $0 + And the Failed Sales card is displayed + And the Failed Sales card shows "18" transactions + +@DashboardTests @EstateRole +Scenario: Estate user sees comparison date selector + Given the user is authenticated as an "Estate" user + When the user navigates to the Dashboard + Then the Dashboard page is displayed + And the comparison date selector is displayed + +@DashboardTests @EstateRole +Scenario: Estate user sees recently created merchants + Given the user is authenticated as an "Estate" user + When the user navigates to the Dashboard + Then the Dashboard page is displayed + And the Recently Created Merchants section is displayed + And at least "1" merchant is shown in Recently Created Merchants + +@DashboardTests @ViewerRole +Scenario: Viewer user sees full dashboard with merchant KPIs + Given the user is authenticated as an "Viewer" user + When the user navigates to the Dashboard + Then the Dashboard page is displayed + And the merchant KPI cards are displayed + And the Merchants with Sales in Last Hour shows "45" + And the Merchants with No Sales Today shows "12" + And the Merchants with No Sales in Last 7 Days shows "5" + +@DashboardTests @ViewerRole +Scenario: Viewer user sees sales data on dashboard + Given the user is authenticated as an "Viewer" user + When the user navigates to the Dashboard + Then the Dashboard page is displayed + And the Today's Sales card is displayed + And the Today's Sales card shows "523" transactions + And the Today's Sales card shows a value greater than $0 + And the Failed Sales card is displayed + And the Failed Sales card shows "18" transactions + +@DashboardTests @ViewerRole +Scenario: Viewer user sees comparison date selector + Given the user is authenticated as an "Viewer" user + When the user navigates to the Dashboard + Then the Dashboard page is displayed + And the comparison date selector is displayed + +@DashboardTests @ViewerRole +Scenario: Viewer user sees recently created merchants + Given the user is authenticated as an "Viewer" user + When the user navigates to the Dashboard + Then the Dashboard page is displayed + And the Recently Created Merchants section is displayed + And at least "1" merchant is shown in Recently Created Merchants diff --git a/EstateManagementUI.DashboardTests/Hooks/BrowserHooks.cs b/EstateManagementUI.DashboardTests/Hooks/BrowserHooks.cs new file mode 100644 index 00000000..df8ea919 --- /dev/null +++ b/EstateManagementUI.DashboardTests/Hooks/BrowserHooks.cs @@ -0,0 +1,144 @@ +using Microsoft.Playwright; +using Reqnroll; + +namespace EstateManagementUI.DashboardTests.Hooks; + +/// +/// Hooks for managing browser lifecycle using Playwright +/// +[Binding] +public class BrowserHooks +{ + private static IPlaywright? _playwright; + private static IBrowser? _browser; + private readonly ScenarioContext _scenarioContext; + + public BrowserHooks(ScenarioContext scenarioContext) + { + _scenarioContext = scenarioContext; + } + + /// + /// Install Playwright browsers and initialize Playwright before running any tests + /// + [BeforeTestRun] + public static async Task BeforeTestRun() + { + // Install Playwright browsers if needed + var exitCode = Microsoft.Playwright.Program.Main(new[] { "install" }); + if (exitCode != 0) + { + throw new Exception($"Playwright installation failed with exit code {exitCode}"); + } + + // Initialize Playwright + _playwright = await Playwright.CreateAsync(); + } + + /// + /// Create a new browser page for each scenario + /// + [BeforeScenario(Order = 0)] + public async Task BeforeScenario() + { + var page = await CreateBrowserPage(); + + // Register the page for this scenario + _scenarioContext.ScenarioContainer.RegisterInstanceAs(page); + } + + /// + /// Cleanup browser page after each scenario and take screenshot on failure + /// + [AfterScenario(Order = 0)] + public async Task AfterScenario() + { + var page = _scenarioContext.ScenarioContainer.Resolve(); + + if (page != null) + { + // Take screenshot on failure + if (_scenarioContext.TestError != null) + { + var scenarioName = _scenarioContext.ScenarioInfo.Title.Replace(" ", "_"); + var screenshotPath = $"screenshot-{scenarioName}-{DateTime.Now:yyyyMMddHHmmss}.png"; + await page.ScreenshotAsync(new PageScreenshotOptions + { + Path = screenshotPath, + FullPage = true + }); + Console.WriteLine($"Screenshot saved to: {screenshotPath}"); + } + + await page.CloseAsync(); + } + } + + /// + /// Cleanup Playwright resources after all tests complete + /// + [AfterTestRun] + public static async Task AfterTestRun() + { + if (_browser != null) + { + await _browser.CloseAsync(); + _browser = null; + } + + if (_playwright != null) + { + _playwright.Dispose(); + _playwright = null; + } + } + + /// + /// Create a new browser page with appropriate configuration + /// + private async Task CreateBrowserPage() + { + var browserType = Environment.GetEnvironmentVariable("Browser") ?? "Chrome"; + var isCI = string.Equals( + Environment.GetEnvironmentVariable("IsCI"), + "true", + StringComparison.InvariantCultureIgnoreCase); + + if (_browser == null) + { + _browser = browserType switch + { + "Firefox" => await _playwright!.Firefox.LaunchAsync(new BrowserTypeLaunchOptions + { + Headless = isCI, + Args = new[] { "--ignore-certificate-errors" } + }), + "WebKit" => await _playwright!.Webkit.LaunchAsync(new BrowserTypeLaunchOptions + { + Headless = isCI, + Args = new[] { "--ignore-certificate-errors" } + }), + _ => await _playwright!.Chromium.LaunchAsync(new BrowserTypeLaunchOptions + { + Headless = isCI, + Args = new[] + { + "--ignore-certificate-errors", + "--no-sandbox", + "--disable-dev-shm-usage", + "--disable-gpu", + "--disable-extensions" + } + }) + }; + } + + var context = await _browser.NewContextAsync(new BrowserNewContextOptions + { + IgnoreHTTPSErrors = true, + ViewportSize = new ViewportSize { Width = 1920, Height = 1080 } + }); + + return await context.NewPageAsync(); + } +} diff --git a/EstateManagementUI.DashboardTests/README.md b/EstateManagementUI.DashboardTests/README.md new file mode 100644 index 00000000..b2822e19 --- /dev/null +++ b/EstateManagementUI.DashboardTests/README.md @@ -0,0 +1,138 @@ +# Estate Management UI - Dashboard Integration Tests + +This project contains integration tests for the Dashboard functionality of the Estate Management Blazor Server application, using Reqnroll (SpecFlow successor), Playwright, and Shouldly. + +## Project Structure + +``` +EstateManagementUI.DashboardTests/ +├── Features/ # Reqnroll feature files (Gherkin scenarios) +│ └── Dashboard.feature # Dashboard test scenarios for all roles +├── Steps/ # Step definitions (links features to code) +│ └── DashboardSteps.cs # Dashboard step implementations +├── Hooks/ # Test lifecycle hooks +│ └── BrowserHooks.cs # Playwright browser management +├── Common/ # Helper classes and utilities +│ └── DashboardPageHelper.cs # Page object for Dashboard interactions +└── appsettings.json # Test configuration and hardcoded test data +``` + +## Key Components + +### 1. Feature File (`Features/Dashboard.feature`) +- Defines test scenarios in Gherkin syntax (Given/When/Then) +- Covers three user roles: Administrator, Estate, and Viewer +- Tests dashboard visibility and data display based on role permissions +- Uses hardcoded test data values from the application + +### 2. Hooks File (`Hooks/BrowserHooks.cs`) +- Manages Playwright browser lifecycle +- `BeforeTestRun`: Installs Playwright browsers and initializes Playwright +- `BeforeScenario`: Creates a new browser page for each test scenario +- `AfterScenario`: Cleans up and takes screenshots on test failures +- `AfterTestRun`: Disposes Playwright resources + +### 3. Step Definitions (`Steps/DashboardSteps.cs`) +- Links Gherkin steps from feature files to C# code +- Uses DashboardPageHelper to interact with the browser +- Implements Given/When/Then steps for all Dashboard scenarios + +### 4. Page Helper (`Common/DashboardPageHelper.cs`) +- Encapsulates all Dashboard page interactions using Playwright +- Provides methods for navigation, verification, and interaction +- Uses Shouldly for assertions + +## Test Data + +The tests are designed to assert against hardcoded test data in the application's `TestMediatorService.cs`: + +### Merchant KPIs +- Merchants with Sales in Last Hour: **45** +- Merchants with No Sales Today: **12** +- Merchants with No Sales in Last 7 Days: **5** + +### Today's Sales +- Transaction Count: **523** +- Sales Value: **$145,000.00** + +### Failed Sales (Low Credit) +- Transaction Count: **18** +- Sales Value: **$850.00** + +These values are defined in the application's `TestMediatorService` and can be updated when the test data is changed. + +## User Roles Tested + +### Administrator Role +- Can only view the Dashboard with a welcome message +- No access to merchant KPIs, sales data, or reports +- Limited to permission management functions + +### Estate Role +- Full access to all dashboard features +- Can view all merchant KPIs +- Can view sales data and comparisons +- Can view recently created merchants +- Has full CRUD permissions across the application + +### Viewer Role +- View-only access to all dashboard features +- Can view all merchant KPIs +- Can view sales data and comparisons +- Can view recently created merchants +- Cannot create, edit, or delete any data + +## Running the Tests + +The tests are designed to run against a running instance of the Estate Management UI application. The application startup and configuration will be handled separately. + +### Prerequisites +1. .NET 10 SDK +2. Playwright browsers (automatically installed by the test hooks) + +### Configuration +Set the following environment variables before running tests: +- `APP_URL`: Base URL of the application (default: `https://localhost:5001`) +- `Browser`: Browser to use - Chrome, Firefox, or WebKit (default: Chrome) +- `IsCI`: Set to "true" to run in headless mode (default: false) + +### Execute Tests +```bash +dotnet test EstateManagementUI.DashboardTests.csproj +``` + +### Filter by Role +```bash +# Run only Administrator role tests +dotnet test --filter "Category=AdminRole" + +# Run only Estate role tests +dotnet test --filter "Category=EstateRole" + +# Run only Viewer role tests +dotnet test --filter "Category=ViewerRole" +``` + +## Notes + +- **Application Startup**: The tests assume the application is already running. Application startup logic will be implemented separately. +- **Authentication**: The authentication/role setup is a placeholder. The actual implementation will depend on how the application is configured for testing. +- **Test Data**: All assertions are based on hardcoded values in the application's `TestMediatorService`. Update the feature file and `appsettings.json` if test data changes. +- **Screenshots**: On test failure, screenshots are automatically saved to the test output directory with timestamps. + +## Dependencies + +- **Reqnroll 3.2.1**: BDD framework (SpecFlow successor) +- **Playwright 1.49.0**: Browser automation +- **Shouldly 4.3.0**: Assertion library with readable error messages +- **NUnit 4.4.0**: Test framework +- **.NET 10**: Target framework + +## Future Enhancements + +When application startup is implemented: +1. Add Docker container management for the application +2. Add test data setup/teardown +3. Add user authentication simulation +4. Add role switching capabilities +5. Add test reporting and metrics diff --git a/EstateManagementUI.DashboardTests/Steps/DashboardSteps.cs b/EstateManagementUI.DashboardTests/Steps/DashboardSteps.cs new file mode 100644 index 00000000..fa7b4878 --- /dev/null +++ b/EstateManagementUI.DashboardTests/Steps/DashboardSteps.cs @@ -0,0 +1,187 @@ +using Microsoft.Playwright; +using Reqnroll; +using EstateManagementUI.DashboardTests.Common; + +namespace EstateManagementUI.DashboardTests.Steps; + +/// +/// Step definitions for Dashboard integration tests +/// Links feature file scenarios to browser automation code +/// +[Binding] +public class DashboardSteps +{ + private readonly IPage _page; + private readonly DashboardPageHelper _dashboardHelper; + private readonly ScenarioContext _scenarioContext; + + public DashboardSteps(ScenarioContext scenarioContext) + { + _scenarioContext = scenarioContext; + _page = scenarioContext.ScenarioContainer.Resolve(); + + // Get base URL from environment variable or use default + var baseUrl = Environment.GetEnvironmentVariable("APP_URL") ?? "https://localhost:5001"; + _dashboardHelper = new DashboardPageHelper(_page, baseUrl); + } + + #region Navigation Steps + + [Given(@"the user navigates to the Dashboard")] + [When(@"the user navigates to the Dashboard")] + public async Task GivenTheUserNavigatesToTheDashboard() + { + await _dashboardHelper.NavigateToDashboard(); + } + + #endregion + + #region Authentication/Role Steps + + [Given(@"the user is authenticated as an ""(.*)"" user")] + public async Task GivenTheUserIsAuthenticatedAsAUser(string role) + { + // Store the role in scenario context for reference + _scenarioContext["UserRole"] = role; + + // Note: This step assumes the application will be started in test mode + // with the appropriate role already configured. The actual authentication + // setup will be handled when the application startup is implemented. + await Task.CompletedTask; + } + + #endregion + + #region Verification Steps - Common + + [Then(@"the Dashboard page is displayed")] + public async Task ThenTheDashboardPageIsDisplayed() + { + await _dashboardHelper.VerifyDashboardPageTitle(); + } + + #endregion + + #region Verification Steps - Administrator Role + + [Then(@"the Administrator welcome message is displayed")] + public async Task ThenTheAdministratorWelcomeMessageIsDisplayed() + { + await _dashboardHelper.VerifyAdministratorWelcomeMessage(); + } + + [Then(@"no merchant KPI cards are displayed")] + public async Task ThenNoMerchantKpiCardsAreDisplayed() + { + await _dashboardHelper.VerifyKpiCardsAreNotVisible(); + } + + [Then(@"no sales data cards are displayed")] + public async Task ThenNoSalesDataCardsAreDisplayed() + { + await _dashboardHelper.VerifyComparisonDateSelectorIsNotVisible(); + await _dashboardHelper.VerifyRecentlyCreatedMerchantsIsNotVisible(); + } + + #endregion + + #region Verification Steps - Estate/Viewer Roles + + [Then(@"the merchant KPI cards are displayed")] + public async Task ThenTheMerchantKpiCardsAreDisplayed() + { + await _dashboardHelper.VerifyKpiCardsAreVisible(); + } + + [Then(@"the Merchants with Sales in Last Hour shows ""(.*)""")] + public async Task ThenTheMerchantsWithSalesInLastHourShows(int expectedValue) + { + // This will be verified as part of the full KPI verification + _scenarioContext["ExpectedSalesLastHour"] = expectedValue; + } + + [Then(@"the Merchants with No Sales Today shows ""(.*)""")] + public async Task ThenTheMerchantsWithNoSalesTodayShows(int expectedValue) + { + _scenarioContext["ExpectedNoSalesToday"] = expectedValue; + } + + [Then(@"the Merchants with No Sales in Last 7 Days shows ""(.*)""")] + public async Task ThenTheMerchantsWithNoSalesInLast7DaysShows(int expectedValue) + { + _scenarioContext["ExpectedNoSales7Days"] = expectedValue; + + // Now verify all KPI values + var salesLastHour = (int)_scenarioContext["ExpectedSalesLastHour"]; + var noSalesToday = (int)_scenarioContext["ExpectedNoSalesToday"]; + var noSales7Days = expectedValue; + + await _dashboardHelper.VerifyMerchantKpiValues(salesLastHour, noSalesToday, noSales7Days); + } + + [Then(@"the Today's Sales card is displayed")] + public async Task ThenTheTodaysSalesCardIsDisplayed() + { + await _dashboardHelper.VerifyTodaysSalesCardIsDisplayed(); + } + + [Then(@"the Today's Sales card shows ""(.*)"" transactions")] + public async Task ThenTheTodaysSalesCardShowsTransactions(int transactionCount) + { + // Store for later verification + _scenarioContext["TodaysSalesCount"] = transactionCount; + } + + [Then(@"the Today's Sales card shows a value greater than \$(.*)")] + public async Task ThenTheTodaysSalesCardShowsAValueGreaterThan(decimal minimumValue) + { + // Verify sales values + var salesCount = (int)_scenarioContext["TodaysSalesCount"]; + await _dashboardHelper.VerifyTodaysSalesValues(salesCount, minimumValue); + } + + [Then(@"the Failed Sales card is displayed")] + public async Task ThenTheFailedSalesCardIsDisplayed() + { + await _dashboardHelper.VerifyFailedSalesCardIsDisplayed(); + } + + [Then(@"the Failed Sales card shows ""(.*)"" transactions")] + public async Task ThenTheFailedSalesCardShowsTransactions(int transactionCount) + { + await _dashboardHelper.VerifyFailedSalesValues(transactionCount); + } + + [Then(@"the comparison date selector is displayed")] + public async Task ThenTheComparisonDateSelectorIsDisplayed() + { + await _dashboardHelper.VerifyComparisonDateSelectorIsVisible(); + } + + [Then(@"the Recently Created Merchants section is displayed")] + public async Task ThenTheRecentlyCreatedMerchantsSectionIsDisplayed() + { + await _dashboardHelper.VerifyRecentlyCreatedMerchantsIsVisible(); + } + + [Then(@"at least ""(.*)"" merchant is shown in Recently Created Merchants")] + public async Task ThenAtLeastMerchantIsShownInRecentlyCreatedMerchants(int minCount) + { + if (minCount > 0) + { + await _dashboardHelper.VerifyRecentlyCreatedMerchantsHasData(); + } + } + + #endregion + + #region Interaction Steps + + [When(@"the user selects ""(.*)"" from the comparison date selector")] + public async Task WhenTheUserSelectsFromTheComparisonDateSelector(string dateOption) + { + await _dashboardHelper.SelectComparisonDate(dateOption); + } + + #endregion +} diff --git a/EstateManagementUI.DashboardTests/appsettings.json b/EstateManagementUI.DashboardTests/appsettings.json new file mode 100644 index 00000000..b8feceb8 --- /dev/null +++ b/EstateManagementUI.DashboardTests/appsettings.json @@ -0,0 +1,23 @@ +{ + "TestSettings": { + "BaseUrl": "https://localhost:5001", + "Browser": "Chrome", + "Headless": false, + "DefaultTimeout": 30000 + }, + "HardcodedTestData": { + "MerchantKpi": { + "MerchantsWithSaleInLastHour": 45, + "MerchantsWithNoSaleToday": 12, + "MerchantsWithNoSaleInLast7Days": 5 + }, + "TodaysSales": { + "TodaysSalesCount": 523, + "TodaysSalesValue": 145000.00 + }, + "TodaysFailedSales": { + "TodaysSalesCount": 18, + "TodaysSalesValue": 850.00 + } + } +} From 0a1b76657115f554a506908c4720462c312ac159 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:05:27 +0000 Subject: [PATCH 3/7] Fix test data assertions to match actual hardcoded values (failed sales count: 15) Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- .../Common/DashboardPageHelper.cs | 4 ++-- EstateManagementUI.DashboardTests/Features/Dashboard.feature | 4 ++-- EstateManagementUI.DashboardTests/README.md | 2 +- EstateManagementUI.DashboardTests/appsettings.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs b/EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs index dd61ae61..e7c830a9 100644 --- a/EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs +++ b/EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs @@ -115,7 +115,7 @@ public async Task VerifyMerchantKpiValues(int salesLastHour, int noSalesToday, i /// public async Task VerifyTodaysSalesCardIsDisplayed() { - await _page.Locator("h3:has-text('Today\\'s Sales')").WaitForAsync(); + await _page.Locator("h3:has-text(\"Today's Sales\")").WaitForAsync(); } /// @@ -232,7 +232,7 @@ public async Task VerifyRecentlyCreatedMerchantsHasData() /// public async Task SelectComparisonDate(string dateDescription) { - await _page.Locator("#comparisonDateSelector").SelectOptionAsync(new[] { new SelectOptionValue { Label = dateDescription } }); + await _page.Locator("#comparisonDateSelector").SelectOptionAsync(new[] { dateDescription }); // Wait for dashboard to reload await Task.Delay(500); // Small delay for state update await _page.WaitForLoadStateAsync(LoadState.NetworkIdle); diff --git a/EstateManagementUI.DashboardTests/Features/Dashboard.feature b/EstateManagementUI.DashboardTests/Features/Dashboard.feature index d7e0c8a2..c4ebbbe5 100644 --- a/EstateManagementUI.DashboardTests/Features/Dashboard.feature +++ b/EstateManagementUI.DashboardTests/Features/Dashboard.feature @@ -34,7 +34,7 @@ Scenario: Estate user sees sales data on dashboard And the Today's Sales card shows "523" transactions And the Today's Sales card shows a value greater than $0 And the Failed Sales card is displayed - And the Failed Sales card shows "18" transactions + And the Failed Sales card shows "15" transactions @DashboardTests @EstateRole Scenario: Estate user sees comparison date selector @@ -70,7 +70,7 @@ Scenario: Viewer user sees sales data on dashboard And the Today's Sales card shows "523" transactions And the Today's Sales card shows a value greater than $0 And the Failed Sales card is displayed - And the Failed Sales card shows "18" transactions + And the Failed Sales card shows "15" transactions @DashboardTests @ViewerRole Scenario: Viewer user sees comparison date selector diff --git a/EstateManagementUI.DashboardTests/README.md b/EstateManagementUI.DashboardTests/README.md index b2822e19..791334de 100644 --- a/EstateManagementUI.DashboardTests/README.md +++ b/EstateManagementUI.DashboardTests/README.md @@ -56,7 +56,7 @@ The tests are designed to assert against hardcoded test data in the application' - Sales Value: **$145,000.00** ### Failed Sales (Low Credit) -- Transaction Count: **18** +- Transaction Count: **15** - Sales Value: **$850.00** These values are defined in the application's `TestMediatorService` and can be updated when the test data is changed. diff --git a/EstateManagementUI.DashboardTests/appsettings.json b/EstateManagementUI.DashboardTests/appsettings.json index b8feceb8..0f5bae89 100644 --- a/EstateManagementUI.DashboardTests/appsettings.json +++ b/EstateManagementUI.DashboardTests/appsettings.json @@ -16,7 +16,7 @@ "TodaysSalesValue": 145000.00 }, "TodaysFailedSales": { - "TodaysSalesCount": 18, + "TodaysSalesCount": 15, "TodaysSalesValue": 850.00 } } From 832638ac66f665f49bfd7aabbf36fad526f39660 Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Mon, 12 Jan 2026 10:32:21 +0000 Subject: [PATCH 4/7] remove old tests --- .../Common/BlazorUiHelpers.cs | 651 -------- .../Common/ClientDetails.cs | 28 - .../Common/DockerHelper.cs | 479 ------ .../Common/GenericSteps.cs | 64 - .../Common/Hooks.cs | 136 -- .../Common/PlaywrightExtensions.cs | 225 --- .../Common/Setup.cs | 20 - .../Common/SharedSteps.cs | 432 ----- .../Common/TestConfiguration.cs | 102 -- .../Common/TestDataHelper.cs | 96 -- .../Common/TestingContext.cs | 97 -- ...ManagementUI.BlazorIntegrationTests.csproj | 67 - .../MIGRATION_GUIDE.md | 397 ----- .../NuGet.Config | 24 - .../README.md | 160 -- .../SKIP_REMOTE_CALLS.md | 261 --- .../Steps/BlazorUiSteps.cs | 403 ----- .../Steps/TestDataManagementSteps.cs | 170 -- .../TEST_INFRASTRUCTURE.md | 247 --- .../Tests/ContractTests.feature | 128 -- .../Tests/ContractTests.feature.cs | 578 ------- .../Tests/EstateTests.feature | 85 - .../Tests/EstateTests.feature.cs | 387 ----- .../Tests/MerchantTests.feature | 254 --- .../Tests/MerchantTests.feature.cs | 1046 ------------ .../Tests/OperatorTests.feature | 102 -- .../Tests/OperatorTests.feature.cs | 465 ------ .../appsettings.json | 6 - .../nlog.config | 31 - .../ApiClientTests.cs | 817 ---------- ...ateManagementUI.BusinessLogic.Tests.csproj | 47 - .../ExtensionsTests.cs | 33 - .../MediatorTests.cs | 151 -- .../ModelFactoryTests.cs | 871 ---------- .../PermissionsServiceTests.cs | 253 --- .../Common/ClientDetails.cs | 28 - .../Common/DockerHelper.cs | 467 ------ .../Common/EstateManagementUiSteps.cs | 1133 ------------- .../Common/Extensions.cs | 214 --- .../Common/GenericSteps.cs | 63 - .../Common/Hooks.cs | 209 --- .../Common/Setup.cs | 20 - .../Common/SharedSteps.cs | 331 ---- .../Common/TestingContext.cs | 97 -- ...EstateManagementUI.IntegrationTests.csproj | 60 - .../Steps/Gimp.cs | 632 -------- .../Tests/ContractTests.feature | 128 -- .../Tests/ContractTests.feature.cs | 578 ------- .../Tests/EstateTests.feature | 85 - .../Tests/EstateTests.feature.cs | 389 ----- .../Tests/MerchantTests.feature | 254 --- .../Tests/MerchantTests.feature.cs | 1069 ------------- .../Tests/OperatorTests.feature | 102 -- .../Tests/OperatorTests.feature.cs | 465 ------ .../nlog.config | 31 - .../EstateManagementUI.Testing.csproj | 35 - EstateManagementUI.Testing/TestData.cs | 1419 ----------------- .../AddContractDialogTests.cs | 97 -- .../AddDeviceDialogTests.cs | 95 -- .../AddOperatorDialogTests.cs | 99 -- .../ChartHelpersTests.cs | 86 - .../ContractProductTransactionFeeListTests.cs | 164 -- .../ContractProductsListTests.cs | 199 --- .../ContractsListTests.cs | 161 -- EstateManagementUI.UITests/DashboardTests.cs | 217 --- .../DataHelperFunctionsTests.cs | 190 --- .../EditMerchantTests.cs | 153 -- .../EstateManagementUI.UITests.csproj | 40 - .../FileDetailsTests.cs | 96 -- .../FileImportLogListTests.cs | 139 -- .../FileImportLogTests.cs | 168 -- EstateManagementUI.UITests/HelpersTests.cs | 98 -- .../MerchantDetailsTests.cs | 344 ---- EstateManagementUI.UITests/MerchantTests.cs | 227 --- .../MerchantsListTests.cs | 246 --- .../NavigationServiceTests.cs | 133 -- .../OperatorListTests.cs | 44 - EstateManagementUI.UITests/OperatorTests.cs | 144 -- .../OperatorsListTests.cs | 159 -- .../ProfileDropdownTests.cs | 91 -- .../SettlementAnalysisTests.cs | 132 -- EstateManagementUI.UITests/TestHelpers.cs | 25 - .../TransactionAnalysisTests.cs | 433 ----- EstateManagementUI.UITests/UsersListTests.cs | 44 - EstateManagementUI.UITests/ViewEstateTests.cs | 45 - EstateManagementUI.sln | 28 +- 86 files changed, 14 insertions(+), 21205 deletions(-) delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/BlazorUiHelpers.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/ClientDetails.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/DockerHelper.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/GenericSteps.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/Hooks.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/PlaywrightExtensions.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/Setup.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/SharedSteps.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/TestConfiguration.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/TestDataHelper.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Common/TestingContext.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/EstateManagementUI.BlazorIntegrationTests.csproj delete mode 100644 EstateManagementUI.BlazorIntegrationTests/MIGRATION_GUIDE.md delete mode 100644 EstateManagementUI.BlazorIntegrationTests/NuGet.Config delete mode 100644 EstateManagementUI.BlazorIntegrationTests/README.md delete mode 100644 EstateManagementUI.BlazorIntegrationTests/SKIP_REMOTE_CALLS.md delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Steps/BlazorUiSteps.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Steps/TestDataManagementSteps.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/TEST_INFRASTRUCTURE.md delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Tests/ContractTests.feature delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Tests/ContractTests.feature.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Tests/EstateTests.feature delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Tests/EstateTests.feature.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Tests/MerchantTests.feature delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Tests/MerchantTests.feature.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Tests/OperatorTests.feature delete mode 100644 EstateManagementUI.BlazorIntegrationTests/Tests/OperatorTests.feature.cs delete mode 100644 EstateManagementUI.BlazorIntegrationTests/appsettings.json delete mode 100644 EstateManagementUI.BlazorIntegrationTests/nlog.config delete mode 100644 EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs delete mode 100644 EstateManagementUI.BusinessLogic.Tests/EstateManagementUI.BusinessLogic.Tests.csproj delete mode 100644 EstateManagementUI.BusinessLogic.Tests/ExtensionsTests.cs delete mode 100644 EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs delete mode 100644 EstateManagementUI.BusinessLogic.Tests/ModelFactoryTests.cs delete mode 100644 EstateManagementUI.BusinessLogic.Tests/PermissionsServiceTests.cs delete mode 100644 EstateManagementUI.IntegrationTests/Common/ClientDetails.cs delete mode 100644 EstateManagementUI.IntegrationTests/Common/DockerHelper.cs delete mode 100644 EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs delete mode 100644 EstateManagementUI.IntegrationTests/Common/Extensions.cs delete mode 100644 EstateManagementUI.IntegrationTests/Common/GenericSteps.cs delete mode 100644 EstateManagementUI.IntegrationTests/Common/Hooks.cs delete mode 100644 EstateManagementUI.IntegrationTests/Common/Setup.cs delete mode 100644 EstateManagementUI.IntegrationTests/Common/SharedSteps.cs delete mode 100644 EstateManagementUI.IntegrationTests/Common/TestingContext.cs delete mode 100644 EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj delete mode 100644 EstateManagementUI.IntegrationTests/Steps/Gimp.cs delete mode 100644 EstateManagementUI.IntegrationTests/Tests/ContractTests.feature delete mode 100644 EstateManagementUI.IntegrationTests/Tests/ContractTests.feature.cs delete mode 100644 EstateManagementUI.IntegrationTests/Tests/EstateTests.feature delete mode 100644 EstateManagementUI.IntegrationTests/Tests/EstateTests.feature.cs delete mode 100644 EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature delete mode 100644 EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature.cs delete mode 100644 EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature delete mode 100644 EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs delete mode 100644 EstateManagementUI.IntegrationTests/nlog.config delete mode 100644 EstateManagementUI.Testing/EstateManagementUI.Testing.csproj delete mode 100644 EstateManagementUI.Testing/TestData.cs delete mode 100644 EstateManagementUI.UITests/AddContractDialogTests.cs delete mode 100644 EstateManagementUI.UITests/AddDeviceDialogTests.cs delete mode 100644 EstateManagementUI.UITests/AddOperatorDialogTests.cs delete mode 100644 EstateManagementUI.UITests/ChartHelpersTests.cs delete mode 100644 EstateManagementUI.UITests/ContractProductTransactionFeeListTests.cs delete mode 100644 EstateManagementUI.UITests/ContractProductsListTests.cs delete mode 100644 EstateManagementUI.UITests/ContractsListTests.cs delete mode 100644 EstateManagementUI.UITests/DashboardTests.cs delete mode 100644 EstateManagementUI.UITests/DataHelperFunctionsTests.cs delete mode 100644 EstateManagementUI.UITests/EditMerchantTests.cs delete mode 100644 EstateManagementUI.UITests/EstateManagementUI.UITests.csproj delete mode 100644 EstateManagementUI.UITests/FileDetailsTests.cs delete mode 100644 EstateManagementUI.UITests/FileImportLogListTests.cs delete mode 100644 EstateManagementUI.UITests/FileImportLogTests.cs delete mode 100644 EstateManagementUI.UITests/HelpersTests.cs delete mode 100644 EstateManagementUI.UITests/MerchantDetailsTests.cs delete mode 100644 EstateManagementUI.UITests/MerchantTests.cs delete mode 100644 EstateManagementUI.UITests/MerchantsListTests.cs delete mode 100644 EstateManagementUI.UITests/NavigationServiceTests.cs delete mode 100644 EstateManagementUI.UITests/OperatorListTests.cs delete mode 100644 EstateManagementUI.UITests/OperatorTests.cs delete mode 100644 EstateManagementUI.UITests/OperatorsListTests.cs delete mode 100644 EstateManagementUI.UITests/ProfileDropdownTests.cs delete mode 100644 EstateManagementUI.UITests/SettlementAnalysisTests.cs delete mode 100644 EstateManagementUI.UITests/TestHelpers.cs delete mode 100644 EstateManagementUI.UITests/TransactionAnalysisTests.cs delete mode 100644 EstateManagementUI.UITests/UsersListTests.cs delete mode 100644 EstateManagementUI.UITests/ViewEstateTests.cs diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/BlazorUiHelpers.cs b/EstateManagementUI.BlazorIntegrationTests/Common/BlazorUiHelpers.cs deleted file mode 100644 index f17f2c98..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/BlazorUiHelpers.cs +++ /dev/null @@ -1,651 +0,0 @@ -using Microsoft.Playwright; -using Reqnroll; -using Shared.IntegrationTesting; -using Shouldly; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace EstateManagementUI.BlazorIntegrationTests.Common; - -public class BlazorUiHelpers -{ - private readonly IPage Page; - private readonly Int32 EstateManagementUiPort; - - public BlazorUiHelpers(IPage page, Int32 estateManagementUiPort) - { - this.Page = page; - this.EstateManagementUiPort = estateManagementUiPort; - } - - private async Task VerifyPageTitle(String expectedTitle) - { - await Retry.For(async () => - { - var title = await this.Page.TitleAsync(); - title.ShouldBe($"{expectedTitle}"); - }); - } - - public async Task NavigateToHomePage() - { - await this.Page.GotoAsync($"https://localhost:{this.EstateManagementUiPort}"); - if (TestConfiguration.IsTestMode == false) { - await this.VerifyPageTitle("Welcome - Estate Management"); - } - } - - public async Task ClickContractsSidebarOption() - { - await this.Page.ClickButtonById("contractsLink"); - } - - public async Task ClickMyEstateSidebarOption() - { - await this.Page.ClickButtonById("estateDetailsLink"); - } - - public async Task ClickMyMerchantsSidebarOption() - { - await this.Page.ClickButtonById("merchantsLink"); - } - - public async Task ClickMyOperatorsSidebarOption() - { - await this.Page.ClickButtonById("operatorsLink"); - } - - public async Task ClickOnTheSignInButton() - { - await this.Page.ClickButtonById("loginButton"); - } - - public async Task VerifyOnTheMakeMerchantDepositScreen() - { - await Retry.For(async () => - { - var title = await this.Page.TitleAsync(); - title.ShouldBe("Make Merchant Deposit"); - }); - } - - public async Task VerifyOnTheTheMerchantDetailsScreen(String merchantName) - { - await Retry.For(async () => - { - var value = await this.Page.GetValueById("MerchantName"); - value.ShouldBe(merchantName); - }); - } - - public async Task VerifyOnTheNewContractScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("New Contract"); }); - } - - public async Task VerifyOnTheNewContractProductScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("New Contract Product"); }); - } - - public async Task VerifyOnTheNewMerchantScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("Create New Merchant"); }); - } - - public async Task VerifyOnTheEditMerchantScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("Edit Merchant"); }); - } - - public async Task VerifyOnTheMakeDepositScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("Make Deposit"); }); - } - - public async Task VerifyOnTheViewMerchantScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("View Merchant"); }); - } - - public async Task VerifyOnTheNewOperatorScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("New Operator"); }); - } - - public async Task VerifyOnTheEditOperatorScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("Edit Operator"); }); - } - - public async Task VerifyOnTheContractsListScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("Contract Management"); }); - } - - public async Task VerifyOnTheContractProductsListScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("View Contract Products"); }); - } - - public async Task VerifyOnTheContractProductsFeesListScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("View Contract Product Fees"); }); - } - - public async Task VerifyOnTheNewTransactionFeeScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("New Transaction Fee"); }); - } - - public async Task VerifyOnTheLoginScreen() - { - await Retry.For(async () => - { - var loginButton = await this.Page.FindButtonByText("Login", TimeSpan.FromMinutes(2)); - loginButton.ShouldNotBeNull(); - }); - } - - public async Task ClickOnTheMerchantOperatorsTab() - { - await this.ClickTab("nav-operators-tab"); - } - - public async Task ClickOnTheMerchantContractsTab() - { - await this.ClickTab("nav-contracts-tab"); - } - - public async Task ClickOnTheMerchantDevicesTab() - { - await this.ClickTab("nav-devices-tab"); - } - - private async Task ClickTab(String tabId) - { - await Retry.For(async () => - { - var locator = this.Page.Locator($"#{tabId}"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - await locator.ClickAsync(); - }); - } - - public async Task VerifyOnMerchantOperatorsTab() - { - await Retry.For(async () => - { - var locator = this.Page.Locator("#merchantOperatorList"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - }); - } - - public async Task VerifyOnMerchantContractsTab() - { - await Retry.For(async () => - { - var locator = this.Page.Locator("#merchantContractList"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - }); - } - - public async Task VerifyOnMerchantDevicesTab() - { - await Retry.For(async () => - { - var locator = this.Page.Locator("#merchantDeviceList"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - }); - } - - public async Task VerifyOnTheDashboard() - { - await Retry.For(async () => { await this.VerifyPageTitle("Dashboard"); }); - } - - public async Task VerifyOnTheEstateDetailsScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("Estate Management"); }); - } - - public async Task VerifyOnTheMerchantsListScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("Merchant Management"); }); - } - - public async Task VerifyOnTheOperatorsListScreen() - { - await Retry.For(async () => { await this.VerifyPageTitle("Operator Management"); }); - } - - public async Task VerifyTheCorrectEstateDetailsAreDisplayed(String estateName) - { - await Retry.For(async () => - { - var estateNameValue = await this.Page.GetValueById("Estate_Name"); - estateNameValue.ShouldBe(estateName); - - var estateRefValue = await this.Page.GetValueById("Estate_Reference"); - estateRefValue.ShouldNotBeNull(); - estateRefValue.ShouldNotBeEmpty(); - }); - } - - public async Task VerifyTheContractDetailsAreInTheList(List<(String, String, Int32)> contractDescriptions) - { - await Retry.For(async () => - { - Int32 foundRowCount = 0; - var rows = await this.Page.Locator("#contractList tr").AllAsync(); - - rows.Count.ShouldBe(contractDescriptions.Count + 1); - - foreach ((String description, String operatorName, Int32 products) in contractDescriptions) - { - foreach (var row in rows) - { - var headers = await row.Locator("th").AllAsync(); - if (headers.Any()) - { - // header row so skip - continue; - } - - var cells = await row.Locator("td").AllAsync(); - if (cells.Count > 0) - { - var cellText = await cells[0].TextContentAsync(); - if (cellText == description) - { - // Compare other fields - var operatorText = await cells[1].TextContentAsync(); - var productsText = await cells[2].TextContentAsync(); - - cellText.ShouldBe(description); - operatorText.ShouldBe(operatorName); - productsText.ShouldBe(products.ToString()); - - foundRowCount++; - break; - } - } - } - } - - foundRowCount.ShouldBe(contractDescriptions.Count); - }, TimeSpan.FromSeconds(120)); - } - - public async Task ClickTheSaveProductButton() - { - await this.Page.ClickButtonById("saveProductButton"); - } - - public async Task Login(String username, String password) - { - await this.Page.FillIn("Input.Username", username); - await this.Page.FillIn("Input.Password", password); - await this.Page.ClickButtonByText("Login"); - } - - public async Task ClickTheNewOperatorButton() - { - await this.Page.ClickButtonById("newOperatorButton"); - } - - public async Task ClickTheNewMerchantButton() - { - await this.Page.ClickButtonById("newMerchantButton"); - } - - public async Task ClickTheEditOperatorButton(String operatorName) - { - await this.ClickElementInTable("operatorList", operatorName, "editOperatorLink"); - } - - public async Task ClickTheEditMerchantButton(String merchantName) - { - await this.ClickElementInTable("merchantList", merchantName, "editMerchantLink"); - } - - public async Task ClickTheMakeDepositButtonFor(String merchantName) - { - await this.ClickElementInTable("merchantList", merchantName, "makeDepositLink"); - } - - public async Task ClickTheAssignOperatorButton() - { - await this.Page.ClickButtonById("assignOperatorButton"); - } - - public async Task ClickTheAddDeviceButton() - { - await this.Page.ClickButtonById("addDeviceButton"); - } - - public async Task ClickAddNewContractButton() - { - await Retry.For(async () => { await this.Page.ClickButtonById("newContractButton"); }); - } - - public async Task ClickAddNewMerchantButton() - { - await Retry.For(async () => { await this.Page.ClickButtonById("newMerchantButton"); }); - } - - public async Task ClickAddNewProductButton() - { - await Retry.For(async () => { await this.Page.ClickButtonById("newContractProductButton"); }); - } - - public async Task ClickAddNewTransactionFeeButton() - { - await Retry.For(async () => { await this.Page.ClickButtonById("newContractProductTransactionFeeButton"); }); - } - - public async Task ClickTheCreateContractButton() - { - await this.Page.ClickButtonById("createContractButton"); - } - - public async Task VerifyMerchantDetailsAreInTheList(List merchantDetailsList) - { - await Retry.For(async () => - { - Int32 foundRowCount = 0; - var rows = await this.Page.Locator("#merchantList tr").AllAsync(); - - rows.Count.ShouldBe(merchantDetailsList.Count + 1); - - foreach (var merchantDetails in merchantDetailsList) - { - foreach (var row in rows) - { - var headers = await row.Locator("th").AllAsync(); - if (headers.Any()) - { - continue; - } - - var cells = await row.Locator("td").AllAsync(); - if (cells.Count > 0) - { - var cellText = await cells[0].TextContentAsync(); - // The merchant name cell contains an avatar with the first letter and the full name - // So we check if the cell text contains the merchant name - if (cellText != null && cellText.Contains(merchantDetails.MerchantName)) - { - cellText.ShouldContain(merchantDetails.MerchantName); - var settlementScheduleText = await cells[4].TextContentAsync(); - settlementScheduleText.ShouldBe(merchantDetails.SettlementSchedule); - - foundRowCount++; - break; - } - } - } - } - - foundRowCount.ShouldBe(merchantDetailsList.Count); - }, TimeSpan.FromSeconds(120)); - } - - public async Task VerifyOperatorDetailsAreInTheList(String tableId, List<(String, String, String, String)> operatorDetails) - { - await Retry.For(async () => - { - Int32 foundRowCount = 0; - var rows = await this.Page.Locator($"#{tableId} tr").AllAsync(); - - rows.Count.ShouldBe(operatorDetails.Count + 1); - - foreach ((String name, String merchantNumber, String terminalNumber, String isDeleted) in operatorDetails) - { - foreach (var row in rows) - { - var headers = await row.Locator("th").AllAsync(); - if (headers.Any()) - { - continue; - } - - var cells = await row.Locator("td").AllAsync(); - if (cells.Count > 0) - { - var cellText = await cells[0].TextContentAsync(); - if (cellText == name) - { - cellText.ShouldBe(name); - var col1Text = await cells[1].TextContentAsync(); - col1Text.ShouldBe(merchantNumber); - var col2Text = await cells[2].TextContentAsync(); - col2Text.ShouldBe(terminalNumber); - - if (!String.IsNullOrEmpty(isDeleted)) - { - var col3Text = await cells[3].TextContentAsync(); - col3Text.ShouldBe(isDeleted); - } - - foundRowCount++; - break; - } - } - } - } - - foundRowCount.ShouldBe(operatorDetails.Count); - }, TimeSpan.FromSeconds(120)); - } - - public async Task VerifyContractDetailsAreInTheList(String tableId, List<(String, String)> contractDetails) - { - await Retry.For(async () => - { - Int32 foundRowCount = 0; - var rows = await this.Page.Locator($"#{tableId} tr").AllAsync(); - - rows.Count.ShouldBe(contractDetails.Count + 1); - - foreach ((String contractName, String isDeleted) in contractDetails) - { - foreach (var row in rows) - { - var headers = await row.Locator("th").AllAsync(); - if (headers.Any()) - { - continue; - } - - var cells = await row.Locator("td").AllAsync(); - if (cells.Count > 0) - { - var cellText = await cells[0].TextContentAsync(); - if (cellText == contractName) - { - cellText.ShouldBe(contractName); - var col1Text = await cells[1].TextContentAsync(); - col1Text.ShouldBe(isDeleted); - - foundRowCount++; - break; - } - } - } - } - - foundRowCount.ShouldBe(contractDetails.Count); - }, TimeSpan.FromSeconds(120)); - } - - private async Task ClickElementInTable(String tableId, String textToSearchFor, String elementToClickId) - { - await Retry.For(async () => - { - var rows = await this.Page.Locator($"#{tableId} tr").AllAsync(); - rows.ShouldNotBeNull(); - rows.Any().ShouldBeTrue(); - - foreach (var row in rows) - { - var headers = await row.Locator("th").AllAsync(); - if (headers.Any()) - { - continue; - } - - var cells = await row.Locator("td").AllAsync(); - if (cells.Count > 0) - { - var cellText = await cells[0].TextContentAsync(); - // The merchant name cell contains an avatar with the first letter and the full name - // So we check if the cell text contains the merchant name - if (cellText != null && cellText.Contains(textToSearchFor)) - { - - var link = row.Locator($"#{elementToClickId}"); - await link.ClickAsync(); - return; - } - } - } - - throw new Exception($"Could not find row with text '{textToSearchFor}' in table '{tableId}'"); - }); - } - - public async Task FillInNewMerchantForm(String merchantName, String settlementSchedule, String addressLine1, - String town, String region, String country, String contactName, String emailAddress) - { - await this.Page.FillIn("MerchantName", merchantName); - await this.Page.SelectDropDownItemByText("SettlementSchedule", settlementSchedule); - await this.Page.FillIn("AddressLine1", addressLine1); - await this.Page.FillIn("Town", town); - await this.Page.FillIn("Region", region); - await this.Page.FillIn("PostCode", "12345"); // Default postcode - await this.Page.FillIn("Country", country); - await this.Page.FillIn("ContactName", contactName); - await this.Page.FillIn("EmailAddress", emailAddress); - await this.Page.FillIn("PhoneNumber", "1234567890"); // Default phone number - } - - public async Task ClickTheCreateMerchantButton() - { - await this.Page.ClickButtonById("createMerchantButton"); - } - - public async Task ClickTheUpdateMerchantButton() - { - //await this.Page.ClickButtonById("createMerchantButton"); - // Click the save button on the respective tab - await Retry.For(async () => - { - var saveButton = this.Page.Locator("button:has-text('Save')").First; - await saveButton.ClickAsync(); - }, TimeSpan.FromSeconds(30)); - } - - public async Task UpdateMerchantField(String tab, String field, String value) - { - // Click the tab first - await Retry.For(async () => - { - var tabButton = this.Page.Locator($"button:has-text('{tab}')"); - await tabButton.ClickAsync(); - }, TimeSpan.FromSeconds(30)); - - // Wait a bit for the tab content to load - await Task.Delay(500); - - // Fill in the field based on the tab - if (tab.Equals("Merchant Details", StringComparison.OrdinalIgnoreCase)) - { - await this.Page.FillIn(field, value); - } - else if (tab.Equals("Address Details", StringComparison.OrdinalIgnoreCase)) - { - await this.Page.FillIn(field, value); - } - else if (tab.Equals("Contact Details", StringComparison.OrdinalIgnoreCase)) - { - await this.Page.FillIn(field, value); - } - } - - public async Task FillInDepositForm(String amount, String date, String reference) - { - // Note: Make Deposit functionality might not exist in Blazor Server app yet - // This is a placeholder implementation - await this.Page.FillInNumeric("Amount", amount); - - if (date.Equals("Today", StringComparison.OrdinalIgnoreCase)) - { - // Use today's date - await this.Page.FillIn("Date", DateTime.Now.ToString("yyyy-MM-dd")); - } - else - { - await this.Page.FillIn("Date", date); - } - - await this.Page.FillIn("Reference", reference); - } - - public async Task ClickTheMakeDepositButton() - { - await this.Page.ClickButtonById("makeDepositButton"); - } - - public async Task ClickTheViewMerchantButton(String merchantName) - { - await Retry.For(async () => - { - var rows = await this.Page.Locator("#merchantList tr").AllAsync(); - - foreach (var row in rows) - { - var headers = await row.Locator("th").AllAsync(); - if (headers.Any()) - { - continue; - } - - var cells = await row.Locator("td").AllAsync(); - if (cells.Count > 0) - { - var cellText = await cells[0].TextContentAsync(); - if (cellText != null && cellText.Contains(merchantName)) - { - // Find and click the View button in this row - var viewButton = row.Locator("button[title='View']"); - await viewButton.ClickAsync(); - return; - } - } - } - - throw new Exception($"Could not find merchant '{merchantName}' in the list"); - }, TimeSpan.FromSeconds(60)); - } -} - -public record MerchantDetails -{ - public String MerchantName { get; init; } - public String SettlementSchedule { get; init; } - public String ContactName { get; init; } - public String AddressLine1 { get; init; } - public String Town { get; init; } - - public MerchantDetails(String merchantName, String settlementSchedule, String contactName, String addressLine1, String town) - { - this.MerchantName = merchantName; - this.SettlementSchedule = settlementSchedule; - this.ContactName = contactName; - this.AddressLine1 = addressLine1; - this.Town = town; - } -} diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/ClientDetails.cs b/EstateManagementUI.BlazorIntegrationTests/Common/ClientDetails.cs deleted file mode 100644 index 793b03e5..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/ClientDetails.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace EstateManagementUI.IntegrationTests.Common -{ - public class ClientDetails - { - public String ClientId { get; private set; } - public String ClientSecret { get; private set; } - public List GrantTypes { get; private set; } - - private ClientDetails(String clientId, - String clientSecret, - List grantTypes) - { - this.ClientId = clientId; - this.ClientSecret = clientSecret; - this.GrantTypes = grantTypes; - } - - public static ClientDetails Create(String clientId, - String clientSecret, - List grantTypes) - { - return new ClientDetails(clientId, clientSecret, grantTypes); - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/DockerHelper.cs b/EstateManagementUI.BlazorIntegrationTests/Common/DockerHelper.cs deleted file mode 100644 index ed7ec7df..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/DockerHelper.cs +++ /dev/null @@ -1,479 +0,0 @@ -using DotNet.Testcontainers.Builders; -using DotNet.Testcontainers.Containers; -using DotNet.Testcontainers.Networks; -using EstateManagementUI.BlazorIntegrationTests.Common; -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.BusinessLogic.PermissionService.Database; -using EstateManagementUI.BusinessLogic.PermissionService.Database.Entities; -//using EstateManagementUI.Controllers; -using EventStore.Client; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using SecurityService.Client; -using Shared.Exceptions; -using Shared.IntegrationTesting; -using Shared.IntegrationTesting.TestContainers; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using TransactionProcessor.Client; - -namespace EstateManagementUI.IntegrationTests.Common -{ - public class DockerHelper : global::Shared.IntegrationTesting.TestContainers.DockerHelper - { - #region Fields - - public ITransactionProcessorClient TransactionProcessorClient; - - public HttpClient HttpClient; - - public ISecurityServiceClient SecurityServiceClient; - - public EventStoreProjectionManagementClient ProjectionManagementClient; - - public HttpClient TestHostHttpClient; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The logger. - public DockerHelper() - { - this.TestingContext = new TestingContext(); - } - - #endregion - - #region Methods - - public Int32 EstateManagementUiPort; - - protected String EstateManagementUiContainerName; - - private readonly TestingContext TestingContext; - - public override void SetupContainerNames() { - base.SetupContainerNames(); - this.SecurityServiceContainerName = $"identity-server{this.TestId:N}"; - this.EstateManagementUiContainerName = $"estateadministrationui{this.TestId:N}"; - } - - private static void AddEntryToHostsFile(String ipaddress, - String hostname) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - var hostsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), @"drivers\etc\hosts"); - using (StreamWriter w = File.AppendText(hostsPath)) - { - w.WriteLine($"{ipaddress} {hostname}"); - } - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - DockerHelper.ExecuteBashCommand($"echo {ipaddress} {hostname} | sudo tee -a /etc/hosts"); - } - } - - /// - /// Executes the bash command. - /// - /// The command. - /// - private static void ExecuteBashCommand(String command) - { - // according to: https://stackoverflow.com/a/15262019/637142 - // thans to this we will pass everything as one command - command = command.Replace("\"", "\"\""); - - var proc = new Process - { - StartInfo = new ProcessStartInfo - { - FileName = "/bin/bash", - Arguments = "-c \"" + command + "\"", - UseShellExecute = false, - RedirectStandardOutput = true, - CreateNoWindow = true - } - }; - Console.WriteLine(proc.StartInfo.Arguments); - - proc.Start(); - proc.WaitForExit(); - } - - public override async Task CreateSubscriptions() { - if (TestConfiguration.IsUIOnlyTestMode) - return; - - List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new(); - subscriptions.AddRange(MessagingService.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); - subscriptions.AddRange(TransactionProcessor.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); - - // TODO: Add File Processor Subscriptions - - foreach ((String streamName, String groupName, Int32 maxRetries) subscription in subscriptions) - { - var x = subscription; - x.maxRetries = 2; - await this.CreatePersistentSubscription(x); - } - } - - protected override List GetRequiredProjections() - { - if (TestConfiguration.IsUIOnlyTestMode) - return new List(); - - List requiredProjections = new List(); - - requiredProjections.Add("EstateAggregator.js"); - requiredProjections.Add("MerchantAggregator.js"); - requiredProjections.Add("MerchantBalanceCalculator.js"); - requiredProjections.Add("MerchantBalanceProjection.js"); - - return requiredProjections; - } - - public override ContainerBuilder SetupTransactionProcessorContainer() - { - - Dictionary variables = new Dictionary(); - variables.Add($"OperatorConfiguration:PataPawaPrePay:Url",$"http://{this.TestHostContainerName}:{DockerPorts.TestHostPort}/api/patapawaprepay"); - - this.AdditionalVariables.Add(ContainerType.FileProcessor, variables); - - return base.SetupTransactionProcessorContainer(); - } - - /// - /// Starts the containers for scenario run. - /// - /// Name of the scenario. - public override async Task StartContainersForScenarioRun(String scenarioName, DockerServices dockerServices) - { - await base.StartContainersForScenarioRun(scenarioName, dockerServices); - - await this.StartEstateManagementUiContainer(this.TestNetworks, this.SecurityServicePort, DockerPorts.SecurityServiceDockerPort); - - // Setup the base address resolvers - String TransactionProcessorBaseAddressResolver(String api) => $"http://127.0.0.1:{this.TransactionProcessorPort}"; - - HttpClientHandler clientHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (message, - certificate2, - arg3, - arg4) => - { - return true; - } - - }; - HttpClient httpClient = new HttpClient(clientHandler); - this.TransactionProcessorClient = new TransactionProcessorClient(TransactionProcessorBaseAddressResolver, httpClient); - Func securityServiceBaseAddressResolver = api => $"https://127.0.0.1:{this.SecurityServicePort}"; - this.SecurityServiceClient = new SecurityServiceClient(securityServiceBaseAddressResolver, httpClient); - this.TestHostHttpClient = new HttpClient(clientHandler); - this.TestHostHttpClient.BaseAddress = new Uri($"http://127.0.0.1:{this.TestHostServicePort}"); - this.ProjectionManagementClient = new EventStoreProjectionManagementClient(ConfigureEventStoreSettings()); - } - - private async Task StartEstateManagementUiContainer(List networkServices, - Int32 securityServiceContainerPort, - Int32 securityServiceLocalPort) - { - TraceX("About to Start Estate Management UI Container"); - - var environmentVariables = this.GetCommonEnvironmentVariables(); - - environmentVariables.Remove("AppSettings:ClientId"); - environmentVariables.Remove("AppSettings:ClientSecret"); - - // Blazor Server uses Authentication: prefix for OIDC settings - environmentVariables.Add("Authentication:Authority",$"https://{this.SecurityServiceContainerName}:0"); // The port is set to 0 to stop defaulting to 443 - environmentVariables.Add("Authentication:ClientId","estateUIClient"); - environmentVariables.Add("Authentication:ClientSecret","Secret1"); - - // Backend API client credentials - environmentVariables.Add("ApiClient:ClientId", "serviceClient"); - environmentVariables.Add("ApiClient:ClientSecret", "Secret1"); - environmentVariables.Add("ApiClient:Scope", "estateManagement transactionProcessor"); - - // Other settings - environmentVariables.Add("AppSettings:SecurityServiceLocalPort",$"{securityServiceLocalPort}"); - environmentVariables.Add("AppSettings:SecurityServicePort",$"{securityServiceContainerPort}"); - environmentVariables.Add("AppSettings:HttpClientIgnoreCertificateErrors",$"true"); - environmentVariables.Add("AppSettings:IsIntegrationTest","true"); - environmentVariables.Add("ASPNETCORE_ENVIRONMENT","Development"); - environmentVariables.Add("urls","https://*:5004"); - environmentVariables.Add($"DataReloadConfig:DefaultInSeconds","1"); - environmentVariables.Add("ConnectionStrings:TransactionProcessorReadModel", this.SetConnectionString( "TransactionProcessorReadModel", this.UseSecureSqlServerDatabase)); - - TraceX("About to Built Estate Management UI Blazor Container"); - ContainerBuilder containerBuilder = new ContainerBuilder() - .WithName(this.EstateManagementUiContainerName) - .WithImage("estatemanagementuiblazorserver") - .WithEnvironment(environmentVariables) - .MountHostFolder(this.DockerPlatform, this.HostTraceFolder) - //.UseNetwork(networkServices.ToArray()) - .WithPortBinding(5004); - //.MountHostFolder(this.DockerPlatform, this.HostTraceFolder) - //.SetDockerCredentials(this.DockerCredentials); - TraceX("About to Call .Start()"); - foreach (INetwork networkService in networkServices) { - containerBuilder = containerBuilder.WithNetwork(networkService); - } - - IContainer? builtContainer = containerBuilder.Build(); - - try{ - - - await builtContainer.StartAsync(); - //builtContainer.WaitForPort("5004/tcp", 30000); - this.EstateManagementUiPort = builtContainer.GetMappedPublicPort($"5004"); - - await Task.Delay(5000); - - TraceX("Estate Management UI Started"); - - /*HttpClientHandler handler = new HttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = - HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; - // TODO: Refactor this code once it works... - using (HttpClient client = new HttpClient(handler)) { - HttpRequestMessage createRolesRequest = new (HttpMethod.Post, - $"https://localhost:{this.EstateManagementUiPort}/api/Permissions/createRoles"); - - List roles = ["Administrator"]; - - createRolesRequest.Content = new StringContent(JsonConvert.SerializeObject(roles), Encoding.UTF8, - "application/json"); - - var response = await client.SendAsync(createRolesRequest, CancellationToken.None); - - if (response.IsSuccessStatusCode == false) { - TraceX($"createRolesRequest failed [{response.StatusCode}]"); - } - TraceX($"Create Role Response is [{response.StatusCode}]"); - - HttpRequestMessage addUserToRoleRequest = new(HttpMethod.Post, - $"https://localhost:{this.EstateManagementUiPort}/api/Permissions/addUserToRole"); - List userRolesList = new List { - new AddUserToRole { UserName = "estateuser@testestate1.co.uk", RoleName = "Administrator" } - }; - - addUserToRoleRequest.Content = new StringContent(JsonConvert.SerializeObject(userRolesList), Encoding.UTF8, - "application/json"); - - response = await client.SendAsync(addUserToRoleRequest, CancellationToken.None); - if (response.IsSuccessStatusCode == false) - { - TraceX($"addUserToRoleRequest failed [{response.StatusCode}]"); - } - - TraceX($"Add User to Role Response is [{response.StatusCode}]"); - - HttpRequestMessage getRolePermissionsRequest = new(HttpMethod.Get, - $"https://localhost:{this.EstateManagementUiPort}/api/Permissions/getRolePermissions?roleName=Administrator"); - - response = await client.SendAsync(getRolePermissionsRequest, CancellationToken.None); - - if (response.IsSuccessStatusCode == false) - { - TraceX($"getRolePermissionsRequest failed [{response.StatusCode}]"); - } - - var x = await response.Content.ReadAsStringAsync(CancellationToken.None); - - RolePermissionsObject rolePermissionsObject = JsonConvert.DeserializeObject(x); - - List<(int, string, int, string, bool)> Permissions = new(); - foreach (ApplicationSection applicationSection in rolePermissionsObject.ApplicationSections) - { - List<(Function, bool)> functionAccess = rolePermissionsObject.PermissionsList.Where(p => - p.ApplicationSection.ApplicationSectionId == applicationSection.ApplicationSectionId).Select(x => (x.Function, x.HasAccess)).ToList(); - - foreach ((Function, bool) function in functionAccess) - { - Permissions.Add((applicationSection.ApplicationSectionId, applicationSection.Name, function.Item1.FunctionId, function.Item1.Name, function.Item2)); - } - } - - List<(int, int, bool)> newPermissions = Permissions.Select(p => (p.Item1, p.Item3, true)).ToList(); - - HttpRequestMessage addRolePermissionsRequest = new(HttpMethod.Post, - $"https://localhost:{this.EstateManagementUiPort}/api/Permissions/addRolePermissions"); - - List rolePermissions = new() { - new RolePermissions { NewPermissions = newPermissions, RoleName = "Administrator" } - }; - - addRolePermissionsRequest.Content = new StringContent(JsonConvert.SerializeObject(rolePermissions), Encoding.UTF8, - "application/json"); - - response = await client.SendAsync(addRolePermissionsRequest, CancellationToken.None); - if (response.IsSuccessStatusCode == false) - { - TraceX($"addRolePermissionsRequest failed [{response.StatusCode}]"); - } - }*/ - } - catch(Exception ex){ - TraceX(ex.GetCombinedExceptionMessages()); - - } - - TraceX("About to attach networkServices"); - //foreach (INetwork networkService in networkServices) - //{ - // //networkService..Attach(builtContainer, false); - // builtContainer. - //} - - //Trace("About to get port"); - //// Do a health check here - //var x = builtContainer.ToHostExposedEndpoint($"5004/tcp"); - //if (x == null){ - // Trace("x is null"); - //} - - - - - this.Containers.Add(((DockerServices)1024, builtContainer)); - //await Retry.For(async () => - //{ - // String healthCheck = - // await this.HealthCheckClient.PerformHealthCheck("http", "127.0.0.1", this.EstateManagementUiPort, CancellationToken.None); - - // var result = JsonConvert.DeserializeObject(healthCheck); - // result.Status.ShouldBe(HealthCheckStatus.Healthy.ToString(), $"Details {healthCheck}"); - //}); - - return builtContainer; - } - - public override ContainerBuilder SetupSecurityServiceContainer() - { - this.TraceX("About to Start Security Container"); - - Retry.For(() => { - DockerHelper.AddEntryToHostsFile("127.0.0.1", SecurityServiceContainerName); - return Task.CompletedTask; - }); - - Retry.For(() => { - DockerHelper.AddEntryToHostsFile("localhost", SecurityServiceContainerName); - return Task.CompletedTask; - }); - - - - var environmentVariables = this.GetCommonEnvironmentVariables(); - environmentVariables.Add($"ServiceOptions:PublicOrigin",$"https://{this.SecurityServiceContainerName}:{DockerPorts.SecurityServiceDockerPort}"); - environmentVariables.Add($"ServiceOptions:IssuerUrl",$"https://{this.SecurityServiceContainerName}:{DockerPorts.SecurityServiceDockerPort}"); - environmentVariables.Add("ASPNETCORE_ENVIRONMENT",$"IntegrationTest"); - environmentVariables.Add($"urls",$"https://*:{DockerPorts.SecurityServiceDockerPort}"); - - environmentVariables.Add($"ServiceOptions:PasswordOptions:RequiredLength","6"); - environmentVariables.Add($"ServiceOptions:PasswordOptions:RequireDigit","false"); - environmentVariables.Add($"ServiceOptions:PasswordOptions:RequireUpperCase","false"); - environmentVariables.Add($"ServiceOptions:UserOptions:RequireUniqueEmail","false"); - environmentVariables.Add($"ServiceOptions:SignInOptions:RequireConfirmedEmail","false"); - - environmentVariables.Add("ConnectionStrings:PersistedGrantDbContext",this.SetConnectionString($"PersistedGrantStore-{this.TestId}", this.UseSecureSqlServerDatabase)); - environmentVariables.Add("ConnectionStrings:ConfigurationDbContext", this.SetConnectionString($"Configuration-{this.TestId}", this.UseSecureSqlServerDatabase)); - environmentVariables.Add("ConnectionStrings:AuthenticationDbContext",this.SetConnectionString($"Authentication-{this.TestId}", this.UseSecureSqlServerDatabase)); - - environmentVariables.Add("Logging:LogLevel:Microsoft","Information"); - environmentVariables.Add("Logging:LogLevel:Default","Information"); - environmentVariables.Add("Logging:EventLog:LogLevel:Default","None"); - - var imageDetailsResult = this.GetImageDetails(ContainerType.SecurityService); - - ContainerBuilder securityServiceContainer = new ContainerBuilder() - .WithName(this.SecurityServiceContainerName) - .WithEnvironment(environmentVariables) - .WithImage(imageDetailsResult.Data.imageName) - .MountHostFolder(this.DockerPlatform, this.HostTraceFolder) - .WithPortBinding(DockerPorts.SecurityServiceDockerPort); - //.MountHostFolder(this.DockerPlatform, this.HostTraceFolder) - //.SetDockerCredentials(this.DockerCredentials); - - - // Now build and return the container - return securityServiceContainer; - } - - /// - /// Stops the containers for scenario run. - /// - public override async Task StopContainersForScenarioRun(DockerServices sharedDockerServices) - { - await this.RemoveEstateReadModel().ConfigureAwait(false); - - await base.StopContainersForScenarioRun(sharedDockerServices); - } - - private async Task RemoveEstateReadModel() - { - //List estateIdList = this.TestingContext.GetAllEstateIds(); - - //foreach (Guid estateId in estateIdList) - //{ - // String databaseName = $"EstateReportingReadModel{estateId}"; - - // // Build the connection string (to master) - // String connectionString = Setup.GetLocalConnectionString(databaseName); - // await Retry.For(async () => - // { - // EstateReportingSqlServerContext context = new EstateReportingSqlServerContext(connectionString); - // await context.Database.EnsureDeletedAsync(CancellationToken.None); - // }, - // retryFor: TimeSpan.FromMinutes(2), - // retryInterval: TimeSpan.FromSeconds(30)); - //} - } - - private async Task CreatePermissionsRepository(String dbConnString, CancellationToken cancellationToken) { - var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseSqlite(dbConnString); // Configure for your database provider - - var serviceProvider = new ServiceCollection() - .AddLogging(config => config.AddConsole()) // Add logging if needed - .BuildServiceProvider(); - - // Create the DbContextFactory instance - var contextFactory = new DbContextFactory(serviceProvider, optionsBuilder.Options, new DbContextFactorySource()); - - //var ctx = await contextFactory.CreateDbContextAsync(cancellationToken); - - return new PermissionsRepository(contextFactory); - } - - public void TraceX(String msg) { - Trace(msg); - Console.WriteLine(msg); - } - - #endregion - } -} diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/GenericSteps.cs b/EstateManagementUI.BlazorIntegrationTests/Common/GenericSteps.cs deleted file mode 100644 index ed8deb05..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/GenericSteps.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Threading.Tasks; -using NLog; -using Reqnroll; -using Shared.IntegrationTesting; -using Shared.Logger; - -namespace EstateManagementUI.IntegrationTests.Common -{ - [Binding] - [Scope(Tag = "base")] - public class GenericSteps - { - private readonly ScenarioContext ScenarioContext; - - private readonly TestingContext TestingContext; - - public GenericSteps(ScenarioContext scenarioContext, - TestingContext testingContext) - { - this.ScenarioContext = scenarioContext; - this.TestingContext = testingContext; - } - - [BeforeScenario(Order = 1)] - public async Task StartSystem() - { - // Initialise a logger - String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", ""); - NlogLogger logger = new NlogLogger(); - logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName); - LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly); - - DockerServices dockerServices = DockerServices.CallbackHandler | DockerServices.EventStore | - DockerServices.FileProcessor | DockerServices.MessagingService | DockerServices.SecurityService | - DockerServices.TestHost | DockerServices.SqlServer | DockerServices.TransactionProcessor | - DockerServices.TransactionProcessorAcl; - dockerServices = DockerServices.None; - - this.TestingContext.DockerHelper = new DockerHelper(); - this.TestingContext.DockerHelper.Logger = logger; - this.TestingContext.Logger = logger; - this.TestingContext.DockerHelper.RequiredDockerServices = dockerServices; - this.TestingContext.Logger.LogInformation("About to Start Global Setup"); - - await Setup.GlobalSetup(this.TestingContext.DockerHelper); - - this.TestingContext.DockerHelper.DockerCredentials = Setup.DockerCredentials; - this.TestingContext.DockerHelper.SqlCredentials = Setup.SqlCredentials; - this.TestingContext.DockerHelper.SqlServerContainerName = "sharedsqlserver"; - - this.TestingContext.Logger = logger; - this.TestingContext.Logger.LogInformation("About to Start Containers for Scenario Run"); - await this.TestingContext.DockerHelper.StartContainersForScenarioRun(scenarioName, dockerServices).ConfigureAwait(false); - this.TestingContext.Logger.LogInformation("Containers for Scenario Run Started"); - } - - [AfterScenario(Order = 1)] - public async Task StopSystem(){ - DockerServices sharedDockerServices = DockerServices.None; - await this.TestingContext.DockerHelper.StopContainersForScenarioRun(sharedDockerServices).ConfigureAwait(false); - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/Hooks.cs b/EstateManagementUI.BlazorIntegrationTests/Common/Hooks.cs deleted file mode 100644 index e14cdf10..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/Hooks.cs +++ /dev/null @@ -1,136 +0,0 @@ -using Microsoft.Playwright; -using Reqnroll; -using Reqnroll.BoDi; -using Shared.IntegrationTesting; - -namespace EstateManagementUI.BlazorIntegrationTests.Common -{ - [Binding] - public class Hooks - { - private readonly IObjectContainer ObjectContainer; - private ScenarioContext ScenarioContext; - private static IPlaywright? playwright; - private static IBrowser? browser; - - public Hooks(IObjectContainer objectContainer) - { - this.ObjectContainer = objectContainer; - } - - [BeforeTestRun] - public static async Task BeforeTestRun() - { - // Install Playwright browsers if needed - var exitCode = Microsoft.Playwright.Program.Main(new[] { "install" }); - if (exitCode != 0) - { - throw new Exception($"Playwright installation failed with exit code {exitCode}"); - } - - // Initialize Playwright - playwright = await Playwright.CreateAsync(); - } - - [BeforeScenario(Order = 0)] - public async Task BeforeScenario(ScenarioContext scenarioContext) - { - this.ScenarioContext = scenarioContext; - String scenarioName = scenarioContext.ScenarioInfo.Title.Replace(" ", ""); - - var page = await this.CreateBrowserPage(); - - // Register the page for this scenario - scenarioContext.ScenarioContainer.RegisterInstanceAs(page, scenarioName); - } - - [AfterScenario(Order = 0)] - public async Task AfterScenario() - { - String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", ""); - var page = this.ScenarioContext.ScenarioContainer.Resolve(scenarioName); - - if (page != null) - { - // Take screenshot on failure - if (this.ScenarioContext.TestError != null) - { - var screenshotPath = $"screenshot-{scenarioName}-{DateTime.Now:yyyyMMddHHmmss}.png"; - await page.ScreenshotAsync(new PageScreenshotOptions { Path = screenshotPath, FullPage = true }); - Console.WriteLine($"Screenshot saved to: {screenshotPath}"); - } - - await page.CloseAsync(); - } - } - - [AfterTestRun] - public static async Task AfterTestRun() - { - if (browser != null) - { - await browser.CloseAsync(); - browser = null; - } - - if (playwright != null) - { - playwright.Dispose(); - playwright = null; - } - } - - private async Task CreateBrowserPage() - { - String? browserType = Environment.GetEnvironmentVariable("Browser"); - String? isCi = Environment.GetEnvironmentVariable("IsCI"); - - if (browser == null) - { - switch (browserType) - { - case "Firefox": - browser = await playwright!.Firefox.LaunchAsync(new BrowserTypeLaunchOptions - { - Headless = String.Compare(isCi, Boolean.TrueString, StringComparison.InvariantCultureIgnoreCase) == 0, - Args = new[] { "--ignore-certificate-errors" } - }); - break; - case "WebKit": - browser = await playwright!.Webkit.LaunchAsync(new BrowserTypeLaunchOptions - { - Headless = String.Compare(isCi, Boolean.TrueString, StringComparison.InvariantCultureIgnoreCase) == 0, - Args = new[] { "--ignore-certificate-errors" } - }); - break; - case null: - case "Chrome": - default: - browser = await playwright!.Chromium.LaunchAsync(new BrowserTypeLaunchOptions - { - Headless = String.Compare(isCi, Boolean.TrueString, StringComparison.InvariantCultureIgnoreCase) == 0, - Args = new[] - { - "--ignore-certificate-errors", - "--no-sandbox", - "--disable-dev-shm-usage", - "--disable-gpu", - "--disable-extensions" - } - }); - break; - } - } - - var context = await browser.NewContextAsync(new BrowserNewContextOptions - { - IgnoreHTTPSErrors = true, - ViewportSize = new ViewportSize { Width = 1920, Height = 1080 } - }); - - var page = await context.NewPageAsync(); - - return page; - } - } -} diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/PlaywrightExtensions.cs b/EstateManagementUI.BlazorIntegrationTests/Common/PlaywrightExtensions.cs deleted file mode 100644 index 5de6971a..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/PlaywrightExtensions.cs +++ /dev/null @@ -1,225 +0,0 @@ -using Microsoft.Playwright; -using Shared.IntegrationTesting; -using Shouldly; -using System; -using System.Threading.Tasks; - -namespace EstateManagementUI.BlazorIntegrationTests.Common -{ - public static class PlaywrightExtensions - { - public static async Task FillIn(this IPage page, - String selector, - String value, - Boolean clearExistingText = false, - TimeSpan? timeout = null) - { - await Retry.For(async () => - { - var locator = page.Locator($"[name='{selector}']"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - - if (clearExistingText) - { - await locator.ClearAsync(); - } - - if (!String.IsNullOrEmpty(value)) - { - await locator.FillAsync(value); - } - }, timeout); - } - - public static async Task FillInNumeric(this IPage page, - String selector, - String value, - TimeSpan? timeout = null) - { - await Retry.For(async () => - { - var locator = page.Locator($"[name='{selector}']"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - - await locator.ClickAsync(); - await page.Keyboard.PressAsync("Control+A"); - await page.Keyboard.PressAsync("Delete"); - await locator.FillAsync(value); - }, timeout); - } - - public static async Task FillInById(this IPage page, - String elementId, - String value, - Boolean clearExistingText = false, - TimeSpan? timeout = null) - { - await Retry.For(async () => - { - var locator = page.Locator($"#{elementId}"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - - if (clearExistingText) - { - await locator.ClearAsync(); - } - - if (!String.IsNullOrEmpty(value)) - { - await locator.FillAsync(value); - } - }, timeout); - } - - public static async Task FindButtonById(this IPage page, - String buttonId, - TimeSpan? timeout = null) - { - ILocator locator = null; - await Retry.For(async () => - { - locator = page.Locator($"#{buttonId}"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - locator.ShouldNotBeNull(); - }, timeout); - return locator; - } - - public static async Task FindButtonByText(this IPage page, - String buttonText, - TimeSpan? timeout = null) - { - ILocator locator = null; - await Retry.For(async () => - { - locator = page.GetByRole(AriaRole.Button, new() { Name = buttonText }); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - locator.ShouldNotBeNull(); - }, timeout); - return locator; - } - - public static async Task ClickButtonById(this IPage page, String buttonId) - { - var locator = await page.FindButtonById(buttonId); - await locator.ClickAsync(); - } - - public static async Task ClickButtonByText(this IPage page, String buttonText) - { - var locator = await page.FindButtonByText(buttonText); - await locator.ClickAsync(); - } - - public static async Task ClickLinkByText(this IPage page, String linkText, TimeSpan? timeout = null) - { - await Retry.For(async () => - { - var locator = page.GetByRole(AriaRole.Link, new() { Name = linkText }); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - await locator.ClickAsync(); - }, timeout); - } - - public static async Task SelectDropDownByIdAndText(this IPage page, - String dropDownId, - String selectionText, - TimeSpan? timeout = null) - { - await Retry.For(async () => - { - var locator = page.Locator($"#{dropDownId}"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - await locator.SelectOptionAsync(new[] { selectionText }); - }, timeout); - } - - public static async Task SelectDropDownByIdAndValue(this IPage page, - String dropDownId, - String selectionValue, - TimeSpan? timeout = null) - { - await Retry.For(async () => - { - var locator = page.Locator($"#{dropDownId}"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - await locator.SelectOptionAsync(new[] { selectionValue }); - }, timeout); - } - - public static async Task SelectDropDownItemByText(this IPage page, - String dropDownName, - String selectionText, - TimeSpan? timeout = null) - { - await Retry.For(async () => - { - var locator = page.Locator($"[name='{dropDownName}']"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - await locator.SelectOptionAsync(new SelectOptionValue { Label = selectionText }); - }, timeout); - } - - public static async Task GetDropDownItemText(this IPage page, String dropDownName, TimeSpan? timeout = null) - { - String selectedText = null; - await Retry.For(async () => - { - var locator = page.Locator($"[name='{dropDownName}']"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - var selectedValue = await locator.InputValueAsync(); - - // Get the text of the selected option - var selectedOption = locator.Locator($"option[value='{selectedValue}']"); - selectedText = await selectedOption.TextContentAsync(); - }, timeout); - return selectedText; - } - - public static async Task GetTextById(this IPage page, String elementId, TimeSpan? timeout = null) - { - String text = null; - await Retry.For(async () => - { - var locator = page.Locator($"#{elementId}"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - text = await locator.TextContentAsync(); - }, timeout); - return text; - } - - public static async Task GetValueById(this IPage page, String elementId, TimeSpan? timeout = null) - { - String value = null; - await Retry.For(async () => - { - var locator = page.Locator($"#{elementId}"); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - value = await locator.InputValueAsync(); - }, timeout); - return value; - } - - public static async Task WaitForElement(this IPage page, String selector, TimeSpan? timeout = null) - { - await Retry.For(async () => - { - var locator = page.Locator(selector); - await locator.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Visible, Timeout = 30000 }); - }, timeout); - } - - public static async Task IsElementVisible(this IPage page, String selector) - { - try - { - var locator = page.Locator(selector); - return await locator.IsVisibleAsync(); - } - catch - { - return false; - } - } - } -} diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/Setup.cs b/EstateManagementUI.BlazorIntegrationTests/Common/Setup.cs deleted file mode 100644 index b6899766..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/Setup.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Ductus.FluentDocker.Services; -using Ductus.FluentDocker.Services.Extensions; -using Reqnroll; -using Shouldly; - -namespace EstateManagementUI.IntegrationTests.Common -{ - [Binding] - public class Setup - { - public static (String usename, String password) SqlCredentials = ("sa", "thisisalongpassword123!"); - public static (String url, String username, String password) DockerCredentials = ("https://www.docker.com", "stuartferguson", "Sc0tland"); - - public static async Task GlobalSetup(DockerHelper dockerHelper) - { - ShouldlyConfiguration.DefaultTaskTimeout = TimeSpan.FromMinutes(1); - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/SharedSteps.cs b/EstateManagementUI.BlazorIntegrationTests/Common/SharedSteps.cs deleted file mode 100644 index b83590e9..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/SharedSteps.cs +++ /dev/null @@ -1,432 +0,0 @@ -using JasperFx.Core; -using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Reqnroll; -using Reqnroll.BoDi; -using SecurityService.DataTransferObjects; -using SecurityService.DataTransferObjects.Requests; -using SecurityService.DataTransferObjects.Responses; -using SecurityService.IntegrationTesting.Helpers; -using Shared.IntegrationTesting; -using Shouldly; -using SimpleResults; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using EstateManagementUI.BlazorIntegrationTests.Common; -using TransactionProcessor.Database.Contexts; -using TransactionProcessor.DataTransferObjects.Requests.Contract; -using TransactionProcessor.DataTransferObjects.Requests.Estate; -using TransactionProcessor.DataTransferObjects.Requests.Merchant; -using TransactionProcessor.DataTransferObjects.Requests.Operator; -using TransactionProcessor.DataTransferObjects.Responses.Contract; -using TransactionProcessor.DataTransferObjects.Responses.Estate; -using TransactionProcessor.DataTransferObjects.Responses.Merchant; -using TransactionProcessor.IntegrationTesting.Helpers; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; -using AssignOperatorRequest = TransactionProcessor.DataTransferObjects.Requests.Estate.AssignOperatorRequest; -using ReqnrollTableHelper = Shared.IntegrationTesting.ReqnrollTableHelper; - -namespace EstateManagementUI.IntegrationTests.Common -{ - [Binding] - [Scope(Tag = "shared")] - public class SharedSteps - { - #region Fields - - - - private readonly SecurityServiceSteps SecurityServiceSteps; - - private readonly TestingContext TestingContext; - - //private readonly IWebDriver WebDriver; - - private readonly TransactionProcessorSteps TransactionProcessorSteps; - - //private readonly EstateMan EstateAdministrationUiSteps; - - #endregion - - #region Constructors - - public SharedSteps(ScenarioContext scenarioContext, TestingContext testingContext, IObjectContainer container) - { - //IWebDriver? webDriver = scenarioContext.ScenarioContainer.Resolve(scenarioContext.ScenarioInfo.Title.Replace(" ", "")); - - this.TestingContext = testingContext; - this.SecurityServiceSteps = new SecurityServiceSteps(this.TestingContext.DockerHelper.SecurityServiceClient); - this.TransactionProcessorSteps = new TransactionProcessorSteps(this.TestingContext.DockerHelper.TransactionProcessorClient, this.TestingContext.DockerHelper.TestHostHttpClient, this.TestingContext.DockerHelper.ProjectionManagementClient); - //this.EstateAdministrationUiSteps = new EstateAdministrationUISteps(webDriver, this.TestingContext.DockerHelper.EstateManagementUiPort); - } - - #endregion - - #region Methods - - - - [Given(@"I create the following api resources")] - public async Task GivenICreateTheFollowingApiResources(DataTable table) - { - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - List requests = table.Rows.ToCreateApiResourceRequests(); - foreach (CreateApiResourceRequest createApiResourceRequest in requests) - { - this.TestingContext.ApiResources.Add(createApiResourceRequest.Name); - } - return; - } - - List requests2 = table.Rows.ToCreateApiResourceRequests(); - await this.SecurityServiceSteps.GivenTheFollowingApiResourcesExist(requests2); - - foreach (CreateApiResourceRequest createApiResourceRequest in requests2) - { - this.TestingContext.ApiResources.Add(createApiResourceRequest.Name); - } - } - - [Given(@"I create the following api scopes")] - public async Task GivenICreateTheFollowingApiScopes(DataTable table) - { - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - return; - } - - List requests = table.Rows.ToCreateApiScopeRequests(); - await this.SecurityServiceSteps.GivenICreateTheFollowingApiScopes(requests); - } - - [Given(@"I create the following clients")] - public async Task GivenICreateTheFollowingClients(DataTable table) - { - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - // Just track client details locally - List requests = table.Rows.ToCreateClientRequests(Guid.Empty, 5004); - foreach (var request in requests) - { - this.TestingContext.AddClientDetails(request.ClientId, "Secret1", request.AllowedGrantTypes); - } - return; - } - - List requests2 = table.Rows.ToCreateClientRequests(this.TestingContext.DockerHelper.TestId, this.TestingContext.DockerHelper.EstateManagementUiPort); - List<(String clientId, String secret, List allowedGrantTypes)> clients = await this.SecurityServiceSteps.GivenTheFollowingClientsExist(requests2); - foreach ((String clientId, String secret, List allowedGrantTypes) client in clients) - { - this.TestingContext.AddClientDetails(client.clientId, client.secret, client.allowedGrantTypes); - } - } - - [Given(@"I create the following identity resources")] - public async Task GivenICreateTheFollowingIdentityResources(DataTable table) - { - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - foreach (DataTableRow tableRow in table.Rows) - { - String name = ReqnrollTableHelper.GetStringRowValue(tableRow, "Name"); - this.TestingContext.IdentityResources.Add(name); - } - return; - } - - foreach (DataTableRow tableRow in table.Rows) - { - // Get the scopes - String userClaims = ReqnrollTableHelper.GetStringRowValue(tableRow, "UserClaims"); - - CreateIdentityResourceRequest createIdentityResourceRequest = new CreateIdentityResourceRequest - { - Name = ReqnrollTableHelper.GetStringRowValue(tableRow, "Name"), - Claims = String.IsNullOrEmpty(userClaims) ? null : userClaims.Split(",").ToList(), - Description = ReqnrollTableHelper.GetStringRowValue(tableRow, "Description"), - DisplayName = ReqnrollTableHelper.GetStringRowValue(tableRow, "DisplayName") - }; - - await this.CreateIdentityResource(createIdentityResourceRequest, CancellationToken.None).ConfigureAwait(false); - } - } - - [Given(@"I create the following roles")] - public async Task GivenICreateTheFollowingRoles(DataTable table) - { - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - List requests = table.Rows.ToCreateRoleRequests(); - foreach (var request in requests) - { - this.TestingContext.Roles.Add(request.RoleName, Guid.NewGuid()); - } - return; - } - - List requests2 = table.Rows.ToCreateRoleRequests(); - List<(String, Guid)> responses = await this.SecurityServiceSteps.GivenICreateTheFollowingRoles(requests2, CancellationToken.None); - - foreach ((String, Guid) response in responses) - { - this.TestingContext.Roles.Add(response.Item1, response.Item2); - } - } - - [Given(@"I create the following users")] - public async Task GivenICreateTheFollowingUsers(DataTable table) - { - List requests = table.Rows.ToCreateUserRequests(); - - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - foreach (CreateUserRequest request in requests) - { - this.TestingContext.Users.Add(request.EmailAddress, Guid.NewGuid()); - } - return; - } - - foreach (CreateUserRequest createUserRequest in requests) - { - createUserRequest.EmailAddress = createUserRequest.EmailAddress.Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N")); - //createUserRequest.Roles.ForEach(r => r.Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N"))); - List newRoles = new List(); - foreach (String role in createUserRequest.Roles) - { - newRoles.Add(role.Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N"))); - } - createUserRequest.Roles = newRoles; - } - - List<(String, Guid)> results = await this.SecurityServiceSteps.GivenICreateTheFollowingUsers(requests, CancellationToken.None); - - foreach ((String, Guid) response in results) - { - this.TestingContext.Users.Add(response.Item1, response.Item2); - } - } - - [Given(@"I have a token to access the estate management resource")] - public async Task GivenIHaveATokenToAccessTheEstateManagementResource(DataTable table) - { - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - // Set a dummy token since authentication is bypassed - this.TestingContext.AccessToken = "test-mode-token"; - return; - } - - DataTableRow firstRow = table.Rows.First(); - String clientId = ReqnrollTableHelper.GetStringRowValue(firstRow, "ClientId").Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N")); - ClientDetails clientDetails = this.TestingContext.GetClientDetails(clientId); - - this.TestingContext.AccessToken = await this.SecurityServiceSteps.GetClientToken(clientDetails.ClientId, clientDetails.ClientSecret, CancellationToken.None); - } - - [Given(@"I have created the following estates")] - public async Task GivenIHaveCreatedTheFollowingEstates(DataTable table) - { - List requests = table.Rows.ToCreateEstateRequests(); - - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - // Use default estate ID from TestDataStore - foreach (var request in requests) - { - Guid estateId = Guid.Parse("11111111-1111-1111-1111-111111111111"); - this.TestingContext.AddEstateDetails(estateId, request.EstateName, request.EstateName); - this.TestingContext.Logger.LogInformation($"Estate {request.EstateName} registered with Id {estateId} (UI-only test mode)"); - } - return; - } - - List verifiedEstates = await this.TransactionProcessorSteps.WhenICreateTheFollowingEstatesX(this.TestingContext.AccessToken, requests); - - foreach (EstateResponse verifiedEstate in verifiedEstates) - { - this.TestingContext.AddEstateDetails(verifiedEstate.EstateId, verifiedEstate.EstateName, verifiedEstate.EstateReference); - this.TestingContext.Logger.LogInformation($"Estate {verifiedEstate.EstateName} created with Id {verifiedEstate.EstateId}"); - } - } - - [Given(@"I have created the following operators")] - public async Task GivenIHaveCreatedTheFollowingOperators(DataTable table) - { - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - // Operators are pre-populated in TestDataStore - this.TestingContext.Logger.LogInformation("Operators setup skipped (UI-only test mode - using TestDataStore)"); - return; - } - - List<(EstateDetails estate, CreateOperatorRequest request)> requests = table.Rows.ToCreateOperatorRequests(this.TestingContext.Estates); - - List<(Guid, EstateOperatorResponse)> results = await this.TransactionProcessorSteps.WhenICreateTheFollowingOperators(this.TestingContext.AccessToken, requests); - - foreach ((Guid, EstateOperatorResponse) result in results) - { - this.TestingContext.Logger.LogInformation($"Operator {result.Item2.Name} created with Id {result.Item2.OperatorId} for Estate {result.Item1}"); - } - } - - [Given("I have assigned the following operators to the estates")] - public async Task GivenIHaveAssignedTheFollowingOperatorsToTheEstates(DataTable dataTable) - { - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - this.TestingContext.Logger.LogInformation("Operator assignment skipped (UI-only test mode)"); - return; - } - - List<(EstateDetails estate, AssignOperatorRequest request)> requests = dataTable.Rows.ToAssignOperatorToEstateRequests(this.TestingContext.Estates); - - await this.TransactionProcessorSteps.GivenIHaveAssignedTheFollowingOperatorsToTheEstates(this.TestingContext.AccessToken, requests); - - // TODO Verify - } - - - - [When(@"I add the following devices to the merchant")] - public async Task WhenIAddTheFollowingDevicesToTheMerchant(DataTable table) - { - if (TestConfiguration.IsTestMode) - return; - List<(EstateDetails, Guid, AddMerchantDeviceRequest)> requests = table.Rows.ToAddMerchantDeviceRequests(this.TestingContext.Estates); - - List<(EstateDetails, MerchantResponse, String)> results = await this.TransactionProcessorSteps.GivenIHaveAssignedTheFollowingDevicesToTheMerchants(this.TestingContext.AccessToken, requests); - foreach ((EstateDetails, MerchantResponse, String) result in results) - { - this.TestingContext.Logger.LogInformation($"Device {result.Item3} assigned to Merchant {result.Item2.MerchantName} Estate {result.Item1.EstateName}"); - } - } - - [When(@"I assign the following operator to the merchants")] - public async Task WhenIAssignTheFollowingOperatorToTheMerchants(DataTable table) - { - if (TestConfiguration.IsTestMode) - return; - List<(EstateDetails, Guid, TransactionProcessor.DataTransferObjects.Requests.Merchant.AssignOperatorRequest)> requests = table.Rows.ToAssignOperatorRequests(this.TestingContext.Estates); - - List<(EstateDetails, TransactionProcessor.DataTransferObjects.Responses.Merchant.MerchantOperatorResponse)> results = await this.TransactionProcessorSteps.WhenIAssignTheFollowingOperatorToTheMerchants(this.TestingContext.AccessToken, requests); - - foreach ((EstateDetails, MerchantOperatorResponse) result in results) - { - this.TestingContext.Logger.LogInformation($"Operator {result.Item2.Name} assigned to Estate {result.Item1.EstateName}"); - } - } - - - - [Given("I create the following merchants")] - [When(@"I create the following merchants")] - public async Task WhenICreateTheFollowingMerchants(DataTable table) - { - if (TestConfiguration.IsTestMode) - return; - List<(EstateDetails estate, CreateMerchantRequest)> requests = table.Rows.ToCreateMerchantRequests(this.TestingContext.Estates); - - List verifiedMerchants = await this.TransactionProcessorSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, requests); - - foreach (MerchantResponse verifiedMerchant in verifiedMerchants) - { - EstateDetails estateDetails = this.TestingContext.GetEstateDetails(verifiedMerchant.EstateId); - estateDetails.AddMerchant(verifiedMerchant); - this.TestingContext.Logger.LogInformation($"Merchant {verifiedMerchant.MerchantName} created with Id {verifiedMerchant.MerchantId} for Estate {estateDetails.EstateName}"); - } - } - - [When(@"I create the following security users")] - [Given("I have created the following security users")] - public async Task WhenICreateTheFollowingSecurityUsers(DataTable table) - { - if (TestConfiguration.SkipRemoteCalls) - { - // Skip remote API call when running in UI-only test mode - this.TestingContext.Logger.LogInformation("Security users creation skipped (UI-only test mode)"); - return; - } - - List createUserRequests = table.Rows.ToCreateNewUserRequests(this.TestingContext.Estates); - await this.TransactionProcessorSteps.WhenICreateTheFollowingSecurityUsers(this.TestingContext.AccessToken, createUserRequests, this.TestingContext.Estates); - } - - [Given(@"I have created the following contracts")] - public async Task GivenIHaveCreatedTheFollowingContracts(DataTable table) - { - List<(EstateDetails, CreateContractRequest)> requests = table.Rows.ToCreateContractRequests(this.TestingContext.Estates); - - List responses = await this.TransactionProcessorSteps.GivenICreateAContractWithTheFollowingValues(this.TestingContext.AccessToken, requests); - - foreach (ContractResponse contractResponse in responses) - { - this.TestingContext.Logger.LogInformation($"Contract {contractResponse.Description} created with Id {contractResponse.ContractId} for Estate {contractResponse.EstateId}"); - EstateDetails estateDetails = this.TestingContext.GetEstateDetails(contractResponse.EstateId); - estateDetails.AddContract(contractResponse.ContractId, contractResponse.Description, contractResponse.OperatorId); - } - } - - [Given("I have created the following contract products")] - public async Task GivenIHaveCreatedTheFollowingContractProducts(DataTable table) - { - List<(EstateDetails, Contract, AddProductToContractRequest)> requests = table.Rows.ToAddProductToContractRequest(this.TestingContext.Estates); - await this.TransactionProcessorSteps.WhenICreateTheFollowingProducts(this.TestingContext.AccessToken, requests); - } - - - private async Task CreateIdentityResource(CreateIdentityResourceRequest createIdentityResourceRequest, - CancellationToken cancellationToken) - { - CreateIdentityResourceResponse createIdentityResourceResponse = null; - - Result> identityResourceList = await this.TestingContext.DockerHelper.SecurityServiceClient.GetIdentityResources(cancellationToken); - if (identityResourceList.IsFailed) - { - // TODO: Handle error properly, e.g., show a message to the user - } - if (identityResourceList.Data == null || identityResourceList.Data.Any() == false) - { - Result result= await this - .TestingContext.DockerHelper.SecurityServiceClient - .CreateIdentityResource(createIdentityResourceRequest, cancellationToken) - .ConfigureAwait(false); - result.IsSuccess.ShouldBeTrue(); - - this.TestingContext.IdentityResources.Add(createIdentityResourceRequest.Name); - } - else - { - if (identityResourceList.Data.Any(i => i.Name == createIdentityResourceRequest.Name)) - { - return; - } - - Result result = await this - .TestingContext.DockerHelper.SecurityServiceClient - .CreateIdentityResource(createIdentityResourceRequest, cancellationToken) - .ConfigureAwait(false); - result.IsSuccess.ShouldBeTrue(); - - result.IsSuccess.ShouldBeTrue(); - - this.TestingContext.IdentityResources.Add(createIdentityResourceRequest.Name); - } - } - - #endregion - } -} \ No newline at end of file diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/TestConfiguration.cs b/EstateManagementUI.BlazorIntegrationTests/Common/TestConfiguration.cs deleted file mode 100644 index 4627104c..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/TestConfiguration.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.IO; -using Microsoft.Extensions.Configuration; - -namespace EstateManagementUI.BlazorIntegrationTests.Common; - -/// -/// Configuration for test execution mode -/// Controls whether tests make remote calls to backend services or use in-memory test data -/// -public static class TestConfiguration -{ - private static IConfiguration? _configuration; - private static readonly object _lock = new object(); - - /// - /// Gets the configuration instance, loading from appsettings.json if not already loaded - /// - private static IConfiguration Configuration - { - get - { - if (_configuration == null) - { - lock (_lock) - { - if (_configuration == null) - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false); - - _configuration = builder.Build(); - } - } - } - return _configuration; - } - } - - /// - /// Gets whether the test is running in UI-only mode (skipping remote backend calls) - /// When true, tests will: - /// - Skip remote API calls to SecurityService, TransactionProcessor, etc. - /// - Use in-memory test data via TestDataStore - /// - Only interact with the UI container - /// - /// Configured via appsettings.json: TestSettings:SkipRemoteCalls - /// Falls back to environment variable: SKIP_REMOTE_CALLS - /// - public static bool SkipRemoteCalls - { - get - { - // First check appsettings.json - var configValue = Configuration["TestSettings:SkipRemoteCalls"]; - if (!string.IsNullOrEmpty(configValue)) - { - return configValue.Equals("true", StringComparison.OrdinalIgnoreCase) || - configValue.Equals("1", StringComparison.OrdinalIgnoreCase); - } - - // Fall back to environment variable for backward compatibility - var envValue = Environment.GetEnvironmentVariable("SKIP_REMOTE_CALLS"); - return !string.IsNullOrEmpty(envValue) && - (envValue.Equals("true", StringComparison.OrdinalIgnoreCase) || - envValue.Equals("1", StringComparison.OrdinalIgnoreCase)); - } - } - - /// - /// Gets whether the application is running in test mode (with TestDataStore) - /// This should match the AppSettings:TestMode in the Blazor application - /// - /// Configured via appsettings.json: TestSettings:EnableTestMode - /// Falls back to environment variable: APP_TEST_MODE - /// - public static bool IsTestMode - { - get - { - // First check appsettings.json - var configValue = Configuration["TestSettings:EnableTestMode"]; - if (!string.IsNullOrEmpty(configValue)) - { - return configValue.Equals("true", StringComparison.OrdinalIgnoreCase) || - configValue.Equals("1", StringComparison.OrdinalIgnoreCase); - } - - // Fall back to environment variable for backward compatibility - var envValue = Environment.GetEnvironmentVariable("APP_TEST_MODE"); - return !string.IsNullOrEmpty(envValue) && - (envValue.Equals("true", StringComparison.OrdinalIgnoreCase) || - envValue.Equals("1", StringComparison.OrdinalIgnoreCase)); - } - } - - /// - /// Gets whether to use UI-only test mode (combination of skip remote calls and test mode) - /// - public static bool IsUIOnlyTestMode => SkipRemoteCalls && IsTestMode; -} diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/TestDataHelper.cs b/EstateManagementUI.BlazorIntegrationTests/Common/TestDataHelper.cs deleted file mode 100644 index 07d10adb..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/TestDataHelper.cs +++ /dev/null @@ -1,96 +0,0 @@ -using EstateManagementUI.BlazorServer.Models; -using EstateManagementUI.BlazorServer.Services; - -namespace EstateManagementUI.BlazorIntegrationTests.Common; - -/// -/// Helper class for accessing and manipulating test data during integration tests -/// Provides easy access to the test data store for test setup and verification -/// -public class TestDataHelper -{ - private readonly ITestDataStore _testDataStore; - - public TestDataHelper(ITestDataStore testDataStore) - { - _testDataStore = testDataStore; - } - - // Estate Management - public EstateModel GetEstate(Guid estateId) => _testDataStore.GetEstate(estateId); - public void SetEstate(EstateModel estate) => _testDataStore.SetEstate(estate); - - // Merchant Management - public List GetMerchants(Guid estateId) => _testDataStore.GetMerchants(estateId); - public MerchantModel? GetMerchant(Guid estateId, Guid merchantId) => _testDataStore.GetMerchant(estateId, merchantId); - public void AddMerchant(Guid estateId, MerchantModel merchant) => _testDataStore.AddMerchant(estateId, merchant); - public void UpdateMerchant(Guid estateId, MerchantModel merchant) => _testDataStore.UpdateMerchant(estateId, merchant); - public void RemoveMerchant(Guid estateId, Guid merchantId) => _testDataStore.RemoveMerchant(estateId, merchantId); - - // Operator Management - public List GetOperators(Guid estateId) => _testDataStore.GetOperators(estateId); - public OperatorModel? GetOperator(Guid estateId, Guid operatorId) => _testDataStore.GetOperator(estateId, operatorId); - public void AddOperator(Guid estateId, OperatorModel operatorModel) => _testDataStore.AddOperator(estateId, operatorModel); - public void UpdateOperator(Guid estateId, OperatorModel operatorModel) => _testDataStore.UpdateOperator(estateId, operatorModel); - public void RemoveOperator(Guid estateId, Guid operatorId) => _testDataStore.RemoveOperator(estateId, operatorId); - - // Contract Management - public List GetContracts(Guid estateId) => _testDataStore.GetContracts(estateId); - public ContractModel? GetContract(Guid estateId, Guid contractId) => _testDataStore.GetContract(estateId, contractId); - public void AddContract(Guid estateId, ContractModel contract) => _testDataStore.AddContract(estateId, contract); - public void UpdateContract(Guid estateId, ContractModel contract) => _testDataStore.UpdateContract(estateId, contract); - public void RemoveContract(Guid estateId, Guid contractId) => _testDataStore.RemoveContract(estateId, contractId); - - // Reset all test data (for test isolation) - public void Reset() => _testDataStore.Reset(); - - // Helper methods for common test scenarios - public Guid DefaultEstateId => Guid.Parse("11111111-1111-1111-1111-111111111111"); - - public void ResetToDefaultState() - { - _testDataStore.Reset(); - } - - public MerchantModel CreateTestMerchant(Guid estateId, string name, string reference) - { - var merchant = new MerchantModel - { - MerchantId = Guid.NewGuid(), - MerchantName = name, - MerchantReference = reference, - Balance = 0, - AvailableBalance = 0, - SettlementSchedule = "Immediate" - }; - AddMerchant(estateId, merchant); - return merchant; - } - - public OperatorModel CreateTestOperator(Guid estateId, string name, bool requireCustomMerchantNumber = false, bool requireCustomTerminalNumber = false) - { - var operatorModel = new OperatorModel - { - OperatorId = Guid.NewGuid(), - Name = name, - RequireCustomMerchantNumber = requireCustomMerchantNumber, - RequireCustomTerminalNumber = requireCustomTerminalNumber - }; - AddOperator(estateId, operatorModel); - return operatorModel; - } - - public ContractModel CreateTestContract(Guid estateId, string description, Guid operatorId, string operatorName) - { - var contract = new ContractModel - { - ContractId = Guid.NewGuid(), - Description = description, - OperatorId = operatorId, - OperatorName = operatorName, - Products = new List() - }; - AddContract(estateId, contract); - return contract; - } -} diff --git a/EstateManagementUI.BlazorIntegrationTests/Common/TestingContext.cs b/EstateManagementUI.BlazorIntegrationTests/Common/TestingContext.cs deleted file mode 100644 index 74b8f3cb..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Common/TestingContext.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Reqnroll; -using SecurityService.DataTransferObjects.Responses; -using Shared.Logger; -using Shouldly; -using TransactionProcessor.IntegrationTesting.Helpers; -using ReqnrollTableHelper = Shared.IntegrationTesting.ReqnrollTableHelper; - -namespace EstateManagementUI.IntegrationTests.Common -{ - public class TestingContext - { - public EstateDetails GetEstateDetails(DataTableRow tableRow, Guid? testId = null) - { - String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName").Replace("[id]", testId.Value.ToString("N")); - - EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateName == estateName); - - estateDetails.ShouldNotBeNull(); - - return estateDetails; - } - - public List GetAllEstateIds() - { - return this.Estates.Select(e => e.EstateId).ToList(); - } - - public EstateDetails GetEstateDetails(String estateName) - { - EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateName == estateName); - - estateDetails.ShouldNotBeNull(); - - return estateDetails; - } - - public EstateDetails GetEstateDetails(Guid estateId) - { - EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateId == estateId); - - estateDetails.ShouldNotBeNull(); - - return estateDetails; - } - - public List Estates; - public void AddEstateDetails(Guid estateId, String estateName, String estateReference) - { - this.Estates.Add(EstateDetails.Create(estateId, estateName, estateReference)); - } - - public String AccessToken { get; set; } - - public DockerHelper DockerHelper { get; set; } - - public NlogLogger Logger { get; set; } - - public Dictionary Users; - public Dictionary Roles; - - public List Clients; - - public List ApiResources; - public List IdentityResources; - - public TokenResponse TokenResponse; - - public TestingContext() - { - this.Users = new Dictionary(); - this.Roles = new Dictionary(); - this.Clients = new List(); - this.ApiResources = new List(); - this.Estates = new List(); - this.IdentityResources = new List(); - } - - public ClientDetails GetClientDetails(String clientId) - { - ClientDetails clientDetails = this.Clients.SingleOrDefault(c => c.ClientId == clientId); - - clientDetails.ShouldNotBeNull(); - - return clientDetails; - } - - public void AddClientDetails(String clientId, - String clientSecret, - List grantTypes) - { - this.Clients.Add(ClientDetails.Create(clientId, clientSecret, grantTypes)); - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.BlazorIntegrationTests/EstateManagementUI.BlazorIntegrationTests.csproj b/EstateManagementUI.BlazorIntegrationTests/EstateManagementUI.BlazorIntegrationTests.csproj deleted file mode 100644 index 90e381ff..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/EstateManagementUI.BlazorIntegrationTests.csproj +++ /dev/null @@ -1,67 +0,0 @@ - - - - net10.0 - enable - enable - - false - true - - - - - - - - - - Always - true - PreserveNewest - - - Always - true - PreserveNewest - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/EstateManagementUI.BlazorIntegrationTests/MIGRATION_GUIDE.md b/EstateManagementUI.BlazorIntegrationTests/MIGRATION_GUIDE.md deleted file mode 100644 index 3d4c8e80..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/MIGRATION_GUIDE.md +++ /dev/null @@ -1,397 +0,0 @@ -# Migration Guide: Selenium to Playwright - -This guide helps developers understand the differences between the legacy Selenium-based tests and the new Playwright-based tests for the Blazor UI. - -## Overview - -| Aspect | Legacy Tests (Selenium) | New Tests (Playwright) | -|--------|------------------------|------------------------| -| **Target UI** | EstateManagementUI (ASP.NET Core) | EstateManagementUI.BlazorServer (Blazor Server) | -| **Test Framework** | Selenium WebDriver | Microsoft Playwright | -| **Project** | EstateManagementUI.IntegrationTests | EstateManagementUI.BlazorIntegrationTests | -| **Browser API** | Synchronous (with some async) | Fully Async | -| **Main Interface** | `IWebDriver` | `IPage` | - -## Key Differences - -### 1. Browser API Objects - -**Selenium:** -```csharp -IWebDriver webDriver; -IWebElement element = webDriver.FindElement(By.Id("myElement")); -``` - -**Playwright:** -```csharp -IPage page; -ILocator locator = page.Locator("#myElement"); -``` - -### 2. Async/Await - -Playwright is fully asynchronous, requiring `await` for all interactions. - -**Selenium:** -```csharp -public void ClickButton() -{ - var button = webDriver.FindElement(By.Id("submitButton")); - button.Click(); -} -``` - -**Playwright:** -```csharp -public async Task ClickButton() -{ - var button = page.Locator("#submitButton"); - await button.ClickAsync(); -} -``` - -### 3. Element Locators - -**Selenium:** -```csharp -// By ID -var element = webDriver.FindElement(By.Id("myId")); - -// By Name -var element = webDriver.FindElement(By.Name("myName")); - -// By CSS Selector -var element = webDriver.FindElement(By.CssSelector(".myClass")); - -// By XPath -var element = webDriver.FindElement(By.XPath("//div[@id='myId']")); -``` - -**Playwright:** -```csharp -// By ID -var locator = page.Locator("#myId"); - -// By Name -var locator = page.Locator("[name='myName']"); - -// By CSS Selector -var locator = page.Locator(".myClass"); - -// By Role (Recommended for accessibility) -var button = page.GetByRole(AriaRole.Button, new() { Name = "Submit" }); -var link = page.GetByRole(AriaRole.Link, new() { Name = "Home" }); -``` - -### 4. Form Interactions - -**Selenium:** -```csharp -// Fill text input -element.SendKeys("Hello World"); - -// Clear and fill -element.Clear(); -element.SendKeys("New Value"); - -// Select dropdown -var select = new SelectElement(element); -select.SelectByText("Option 1"); -``` - -**Playwright:** -```csharp -// Fill text input -await locator.FillAsync("Hello World"); - -// Clear and fill (FillAsync clears automatically) -await locator.FillAsync("New Value"); - -// Select dropdown -await locator.SelectOptionAsync(new SelectOptionValue { Label = "Option 1" }); -// or by value: -await locator.SelectOptionAsync("optionValue"); -``` - -### 5. Getting Element Properties - -**Selenium:** -```csharp -String text = element.Text; -String value = element.GetDomProperty("value"); -Boolean isDisplayed = element.Displayed; -Boolean isEnabled = element.Enabled; -``` - -**Playwright:** -```csharp -String text = await locator.TextContentAsync(); -String value = await locator.InputValueAsync(); -Boolean isVisible = await locator.IsVisibleAsync(); -Boolean isEnabled = await locator.IsEnabledAsync(); -``` - -### 6. Waiting for Elements - -**Selenium:** -```csharp -WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10)); -IWebElement element = wait.Until(driver => - driver.FindElement(By.Id("myElement")) -); -``` - -**Playwright:** -```csharp -// Auto-waiting built-in for most actions -await page.Locator("#myElement").ClickAsync(); // Waits automatically - -// Explicit wait -await page.Locator("#myElement").WaitForAsync(new LocatorWaitForOptions -{ - State = WaitForSelectorState.Visible, - Timeout = 10000 -}); -``` - -### 7. Navigation - -**Selenium:** -```csharp -webDriver.Navigate().GoToUrl("https://example.com"); -``` - -**Playwright:** -```csharp -await page.GotoAsync("https://example.com"); -``` - -### 8. Page Title - -**Selenium:** -```csharp -String title = webDriver.Title; -``` - -**Playwright:** -```csharp -String title = await page.TitleAsync(); -``` - -### 9. Screenshots - -**Selenium:** -```csharp -var screenshot = ((ITakesScreenshot)webDriver).GetScreenshot(); -screenshot.SaveAsFile("screenshot.png"); -``` - -**Playwright:** -```csharp -await page.ScreenshotAsync(new PageScreenshotOptions -{ - Path = "screenshot.png", - FullPage = true -}); -``` - -### 10. Browser Setup - -**Selenium (Hooks.cs):** -```csharp -ChromeOptions options = new(); -options.AddArgument("--headless"); -options.AcceptInsecureCertificates = true; -webDriver = new ChromeDriver(options); -``` - -**Playwright (Hooks.cs):** -```csharp -// BeforeTestRun - Install browsers -playwright = await Playwright.CreateAsync(); - -// BeforeScenario - Create browser -browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions -{ - Headless = true, - Args = new[] { "--ignore-certificate-errors" } -}); - -var context = await browser.NewContextAsync(new BrowserNewContextOptions -{ - IgnoreHTTPSErrors = true, - ViewportSize = new ViewportSize { Width = 1920, Height = 1080 } -}); - -var page = await context.NewPageAsync(); -``` - -## Extension Methods Comparison - -### Legacy (Selenium Extensions) - -```csharp -// EstateManagementUI.IntegrationTests/Common/Extensions.cs -await webDriver.FillIn("fieldName", "value"); -await webDriver.ClickButtonById("buttonId"); -IWebElement button = await webDriver.FindButtonByText("Login"); -``` - -### New (Playwright Extensions) - -```csharp -// EstateManagementUI.BlazorIntegrationTests/Common/PlaywrightExtensions.cs -await page.FillIn("fieldName", "value"); -await page.ClickButtonById("buttonId"); -ILocator button = await page.FindButtonByText("Login"); -``` - -## UI Helpers Comparison - -### Legacy - -```csharp -// EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs -public class EstateManagementUiHelpers -{ - private readonly IWebDriver WebDriver; - - public void NavigateToHomePage() - { - this.WebDriver.Navigate().GoToUrl($"https://localhost:{port}"); - this.WebDriver.Title.ShouldBe("Welcome - Estate Management"); - } -} -``` - -### New - -```csharp -// EstateManagementUI.BlazorIntegrationTests/Common/BlazorUiHelpers.cs -public class BlazorUiHelpers -{ - private readonly IPage Page; - - public async Task NavigateToHomePage() - { - await this.Page.GotoAsync($"https://localhost:{port}"); - var title = await this.Page.TitleAsync(); - title.ShouldBe("Welcome - Estate Management"); - } -} -``` - -## Step Definitions Comparison - -### Legacy - -```csharp -// EstateManagementUI.IntegrationTests/Steps/Gimp.cs -public EstateManagementUiSteps(ScenarioContext scenarioContext, ...) -{ - var webDriver = scenarioContext.ScenarioContainer.Resolve(...); - this.UiHelpers = new EstateManagementUiHelpers(webDriver, ...); -} - -[Given(@"I am on the application home page")] -public void GivenIAmOnTheApplicationHomePage() -{ - this.UiHelpers.NavigateToHomePage(); -} -``` - -### New - -```csharp -// EstateManagementUI.BlazorIntegrationTests/Steps/BlazorUiSteps.cs -public BlazorUiSteps(ScenarioContext scenarioContext, ...) -{ - var page = scenarioContext.ScenarioContainer.Resolve(...); - this.UiHelpers = new BlazorUiHelpers(page, ...); -} - -[Given(@"I am on the application home page")] -public async Task GivenIAmOnTheApplicationHomePage() -{ - await this.UiHelpers.NavigateToHomePage(); -} -``` - -## Docker Configuration Differences - -The main difference is in environment variable names for authentication: - -### Legacy UI (EstateManagementUI) -```csharp -environmentVariables.Add("AppSettings:Authority", ...); -environmentVariables.Add("AppSettings:ClientId", "estateUIClient"); -environmentVariables.Add("AppSettings:ClientSecret", "Secret1"); -``` - -### Blazor UI (EstateManagementUI.BlazorServer) -```csharp -environmentVariables.Add("Authentication:Authority", ...); -environmentVariables.Add("Authentication:ClientId", "estateUIClient"); -environmentVariables.Add("Authentication:ClientSecret", "Secret1"); -``` - -## Best Practices with Playwright - -1. **Use role-based selectors** when possible for better accessibility and stability: - ```csharp - await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).ClickAsync(); - ``` - -2. **Auto-waiting**: Playwright automatically waits for elements to be actionable. No need for explicit waits in most cases. - -3. **Locators are lazy**: They don't query the DOM until an action is performed. - -4. **Always use await**: All Playwright methods are async and must be awaited. - -5. **Screenshots on failure**: Already implemented in `Hooks.AfterScenario`. - -6. **Browser context isolation**: Each test gets its own browser context, ensuring test isolation. - -## Running Tests - -### Legacy Tests -```bash -cd EstateManagementUI.IntegrationTests -dotnet test -``` - -### New Tests -```bash -cd EstateManagementUI.BlazorIntegrationTests -# First time only: Install Playwright browsers -pwsh bin/Debug/net10.0/playwright.ps1 install - -dotnet test -``` - -## Troubleshooting - -### Playwright Installation Issues - -If you get errors about missing browsers: -```bash -# Install browsers manually -dotnet tool install --global Microsoft.Playwright.CLI -playwright install -``` - -### Timeout Issues - -Playwright has a default timeout of 30 seconds. If you need longer: -```csharp -await page.Locator("#slowElement").WaitForAsync(new LocatorWaitForOptions -{ - Timeout = 60000 // 60 seconds -}); -``` - -## Additional Resources - -- [Playwright for .NET Documentation](https://playwright.dev/dotnet/docs/intro) -- [Playwright API Reference](https://playwright.dev/dotnet/docs/api/class-playwright) -- [Selenium to Playwright Migration Guide](https://playwright.dev/docs/selenium-grid) diff --git a/EstateManagementUI.BlazorIntegrationTests/NuGet.Config b/EstateManagementUI.BlazorIntegrationTests/NuGet.Config deleted file mode 100644 index 3086e202..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/NuGet.Config +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/EstateManagementUI.BlazorIntegrationTests/README.md b/EstateManagementUI.BlazorIntegrationTests/README.md deleted file mode 100644 index d69b74b1..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/README.md +++ /dev/null @@ -1,160 +0,0 @@ -# EstateManagementUI.BlazorIntegrationTests - -This is a new integration test project that targets the **Blazor Server UI** (`EstateManagementUI.BlazorServer`) using **Playwright** for browser automation. - -## Overview - -This project replaces the Selenium-based integration tests in `EstateManagementUI.IntegrationTests` with a Playwright-based implementation targeting the new Blazor UI. - -### Key Differences from Original Integration Tests - -1. **Target Application**: Tests the Blazor Server UI (`EstateManagementUI.BlazorServer`) instead of the old ASP.NET Core UI (`EstateManagementUI`) -2. **Browser Automation**: Uses **Microsoft Playwright** instead of Selenium WebDriver -3. **Docker Image**: Targets the `estatemanagementuiblazor` Docker image - -## Project Structure - -``` -EstateManagementUI.BlazorIntegrationTests/ -├── Common/ -│ ├── BlazorUiHelpers.cs # Playwright-based UI helper methods -│ ├── PlaywrightExtensions.cs # Extension methods for Playwright IPage -│ ├── Hooks.cs # Reqnroll hooks for Playwright setup/teardown -│ ├── DockerHelper.cs # Docker infrastructure (adapted for Blazor) -│ ├── TestingContext.cs # Shared test context -│ ├── Setup.cs # Test setup configuration -│ ├── SharedSteps.cs # Shared step definitions -│ └── GenericSteps.cs # Generic step definitions -├── Steps/ -│ └── BlazorUiSteps.cs # Blazor UI-specific step definitions -├── Tests/ -│ ├── ContractTests.feature # Contract feature tests -│ ├── EstateTests.feature # Estate feature tests -│ ├── MerchantTests.feature # Merchant feature tests -│ └── OperatorTests.feature # Operator feature tests -└── EstateManagementUI.BlazorIntegrationTests.csproj -``` - -## Key Components - -### Playwright Extensions (`PlaywrightExtensions.cs`) - -Provides extension methods for `IPage` that mirror the Selenium extension patterns but use Playwright APIs: -- `FillIn()`, `FillInById()`, `FillInNumeric()` - Form field interactions -- `FindButtonById()`, `FindButtonByText()` - Button locators -- `ClickButtonById()`, `ClickButtonByText()` - Button click actions -- `SelectDropDownByIdAndText()`, `SelectDropDownByIdAndValue()` - Dropdown interactions -- `GetTextById()`, `GetValueById()` - Element value retrieval -- `WaitForElement()`, `IsElementVisible()` - Element visibility checks - -### Blazor UI Helpers (`BlazorUiHelpers.cs`) - -High-level test methods for interacting with the Blazor UI: -- Navigation methods (e.g., `NavigateToHomePage()`, `ClickContractsSidebarOption()`) -- Screen verification methods (e.g., `VerifyOnTheContractsListScreen()`) -- Table validation methods (e.g., `VerifyTheContractDetailsAreInTheList()`) - -### Hooks (`Hooks.cs`) - -Manages Playwright browser lifecycle: -- **BeforeTestRun**: Installs Playwright browsers -- **BeforeScenario**: Creates a new browser page for each scenario -- **AfterScenario**: Takes screenshots on failure and closes the page -- **AfterTestRun**: Closes browser and cleans up Playwright - -### Docker Helper (`DockerHelper.cs`) - -Manages Docker containers for integration tests, adapted for Blazor: -- Starts the Blazor UI container with proper environment variables -- Uses `Authentication:` prefix for OIDC settings (instead of `AppSettings:`) -- Configures API client credentials -- Sets up database connections and other dependencies - -## Environment Configuration - -The Blazor container is configured with: -- **Authentication**: OIDC with Security Service -- **API Client**: Backend service credentials -- **Database**: Transaction Processor Read Model connection -- **Development Mode**: Configured for integration testing - -## Running Tests - -### Prerequisites - -1. .NET 10.0 SDK -2. Docker -3. Access to private NuGet feed (feedz.io) - -### Installation - -```bash -# Install Playwright browsers -pwsh bin/Debug/net10.0/playwright.ps1 install -``` - -### Running Tests - -```bash -cd EstateManagementUI.BlazorIntegrationTests -dotnet test -``` - -### Environment Variables - -- `Browser`: Browser type (`Chrome`, `Firefox`, `WebKit`) - defaults to Chrome -- `IsCI`: Set to `true` for headless mode in CI/CD - -## Current Status - -### ✅ Completed -- Project structure created -- Playwright dependencies added -- Core Playwright extension methods implemented -- Basic UI helper methods implemented -- Docker infrastructure adapted for Blazor -- Test hooks implemented with Playwright lifecycle management -- Feature files copied from original tests - -### 🚧 In Progress -- Additional UI helper methods need implementation -- More step definitions needed to cover all scenarios -- Build and test execution validation - -### 📝 Next Steps -1. Complete all UI helper methods in `BlazorUiHelpers.cs` -2. Implement all step definitions in `BlazorUiSteps.cs` -3. Ensure all feature files are compatible with Blazor UI -4. Build and run tests to verify functionality -5. Add CI/CD integration - -## Differences from Selenium Tests - -### API Changes - -| Selenium | Playwright | -|----------|------------| -| `IWebDriver` | `IPage` | -| `FindElement(By.Id("x"))` | `Locator("#x")` | -| `element.SendKeys(text)` | `locator.FillAsync(text)` | -| `element.Click()` | `locator.ClickAsync()` | -| `element.Text` | `await locator.TextContentAsync()` | -| `element.GetDomProperty("value")` | `await locator.InputValueAsync()` | - -### Async/Await - -Playwright is fully async, so all methods must use `await` and return `Task`. - -### Locators - -Playwright uses modern selectors and encourages role-based selection: -- `page.GetByRole(AriaRole.Button, new() { Name = "Login" })` -- `page.Locator("#elementId")` -- `page.Locator("[name='fieldName']")` - -## Notes - -- The Docker image name for the Blazor UI is assumed to be `estatemanagementuiblazor` -- Authentication configuration uses the `Authentication:` prefix to match the Blazor app's configuration -- All tests use the same Docker infrastructure as the original integration tests -- The project maintains compatibility with Reqnroll (SpecFlow successor) for BDD-style tests diff --git a/EstateManagementUI.BlazorIntegrationTests/SKIP_REMOTE_CALLS.md b/EstateManagementUI.BlazorIntegrationTests/SKIP_REMOTE_CALLS.md deleted file mode 100644 index 7e95ec1e..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/SKIP_REMOTE_CALLS.md +++ /dev/null @@ -1,261 +0,0 @@ -# Skipping Remote Calls in Tests - -## Overview - -The test infrastructure now supports a "skip remote calls" mode that allows tests to run without making API calls to backend services (SecurityService, TransactionProcessor, etc.). This enables: - -- **UI-Only Testing**: Test the UI without requiring backend Docker containers -- **Faster Test Execution**: No network latency or backend service setup time -- **Simplified Setup**: Only the UI container needs to be running - -## How It Works - -When skip remote calls mode is enabled, the test steps will: - -1. **Skip all remote API calls** to SecurityService, TransactionProcessor, etc. -2. **Use the in-memory TestDataStore** in the Blazor application (when TestMode is enabled) -3. **Only interact with the UI** via Playwright browser automation - -## Configuration - -### Option 1: appsettings.json (Recommended) - -Configure the test behavior in `appsettings.json`: - -```json -{ - "TestSettings": { - "SkipRemoteCalls": true, - "EnableTestMode": true - } -} -``` - -### Option 2: Environment Variables (Backward Compatible) - -You can still use environment variables for configuration: - -```bash -# Skip remote API calls in test steps -export SKIP_REMOTE_CALLS=true - -# Enable test mode in the Blazor application -export APP_TEST_MODE=true -``` - -**Note:** appsettings.json values take precedence over environment variables if both are set. - -### Running Tests - -```bash -# Method 1: Using appsettings.json -# Edit appsettings.json to set SkipRemoteCalls and EnableTestMode to true -dotnet test EstateManagementUI.BlazorIntegrationTests/EstateManagementUI.BlazorIntegrationTests.csproj - -# Method 2: Using environment variables -export SKIP_REMOTE_CALLS=true -export APP_TEST_MODE=true -dotnet test EstateManagementUI.BlazorIntegrationTests/EstateManagementUI.BlazorIntegrationTests.csproj -``` - -### Docker Compose - -When running tests with Docker, you can use either approach: - -**Using appsettings.json:** -```yaml -services: - blazor-ui: - image: estatemanagementuiblazor:latest - environment: - - AppSettings__TestMode=true - ports: - - "5004:5004" - - tests: - image: test-runner:latest - volumes: - - ./appsettings.json:/app/appsettings.json # Mount custom appsettings - depends_on: - - blazor-ui -``` - -**Using environment variables:** -```yaml -services: - blazor-ui: - image: estatemanagementuiblazor:latest - environment: - - AppSettings__TestMode=true - ports: - - "5004:5004" - - tests: - image: test-runner:latest - environment: - - SKIP_REMOTE_CALLS=true - - APP_TEST_MODE=true - depends_on: - - blazor-ui -``` - -## What Gets Skipped - -When skip remote calls is enabled (via `TestSettings:SkipRemoteCalls` in appsettings.json or `SKIP_REMOTE_CALLS` environment variable), the following steps skip their remote API calls: - -### Security Service Steps -- `Given I create the following api resources` -- `Given I create the following api scopes` -- `Given I create the following clients` -- `Given I create the following identity resources` -- `Given I create the following roles` -- `Given I create the following users` -- `Given I have a token to access the estate management resource` - -### Transaction Processor Steps -- `Given I have created the following estates` -- `Given I have created the following operators` -- `Given I have assigned the following operators to the estates` -- `Given I have created the following security users` - -### What Still Runs -- All UI interaction steps (clicking, typing, verifying) -- Browser navigation and page interactions -- Screenshot capture on failures - -## Test Data - -When running in skip remote calls mode: - -1. **Default Test Data**: The TestDataStore initializes with default data: - - 1 Estate (ID: `11111111-1111-1111-1111-111111111111`) - - 3 Merchants (MERCH001, MERCH002, MERCH003) - - 2 Operators (Safaricom, Voucher) - - 2 Contracts with products - -2. **Test Context**: The TestingContext is populated with dummy IDs and references so tests can continue - -3. **Authentication**: A dummy token is set instead of requesting a real OAuth token - -## Example Scenarios - -### Full Integration Test (Default) -```bash -# Requires all Docker containers: SecurityService, TransactionProcessor, UI -export SKIP_REMOTE_CALLS=false -dotnet test -``` - -### UI-Only Test (Fast) -```bash -# Requires only UI Docker container -export SKIP_REMOTE_CALLS=true -export APP_TEST_MODE=true -dotnet test -``` - -## Configuration Checks - -The test infrastructure uses `TestConfiguration.SkipRemoteCalls` to check if remote calls should be skipped. You can verify the configuration: - -```csharp -if (TestConfiguration.SkipRemoteCalls) -{ - // Skip remote API call - return; -} - -// Normal remote API call -await this.SecurityServiceSteps.SomeRemoteCall(...); -``` - -## Benefits - -### Faster Tests -- No Docker container startup for backend services (~30-60s saved) -- No network latency for API calls -- Immediate test execution - -### Simpler Setup -- Only UI container required -- No backend service configuration -- Reduced infrastructure complexity - -### Local Development -- Easier to run tests locally -- No need for complex Docker setup -- Quick feedback loop - -## Limitations - -When running with skip remote calls: - -1. **Backend Logic Not Tested**: Only UI behavior is tested, not backend integration -2. **Default Data Only**: Tests work with pre-configured test data -3. **Limited Scenarios**: Some complex scenarios may require backend services - -## Combining With Test Mode - -For full UI-only testing, enable both features: - -**Using appsettings.json (Recommended):** -```json -{ - "TestSettings": { - "SkipRemoteCalls": true, - "EnableTestMode": true - } -} -``` - -**Using environment variables:** -```bash -# In the Blazor application -export AppSettings__TestMode=true - -# In the test project -export SKIP_REMOTE_CALLS=true -export APP_TEST_MODE=true -``` - -This combination: -- Skips OIDC authentication (TestAuthenticationHandler) -- Uses in-memory data (TestDataStore) -- Skips remote API calls in tests (TestConfiguration.SkipRemoteCalls) - -## Troubleshooting - -### Tests still making remote calls -- Check `TestSettings:SkipRemoteCalls` in appsettings.json or `SKIP_REMOTE_CALLS` environment variable is set to `true` -- Verify that the step definition uses `TestConfiguration.SkipRemoteCalls` -- Ensure appsettings.json is being copied to the output directory - -### Test data not found -- Ensure `TestSettings:EnableTestMode=true` in appsettings.json or `APP_TEST_MODE=true` environment variable -- Verify the TestDataStore is initialized with default data in the Blazor application -- Check that the test estate ID matches the default (`11111111-1111-1111-1111-111111111111`) - -### Authentication failures -- Confirm `AppSettings__TestMode=true` in the Blazor application -- Verify TestAuthenticationHandler is registered -- Check that dummy token is set in test context - -### Configuration not loading -- Verify appsettings.json is in the test project root -- Check that appsettings.json has "Copy to Output Directory" set to "Always" -- Ensure working directory is set correctly when running tests - -## Migration Guide - -To convert existing tests to support skip remote calls mode: - -1. **No changes needed** - Tests automatically respect the configuration -2. **Update configuration**: Set `TestSettings:SkipRemoteCalls` to `true` in appsettings.json -3. **Optional**: Add custom test data setup if default data is insufficient -4. **Verify**: Run tests to ensure they pass with skip remote calls enabled - -## See Also - -- [TEST_INFRASTRUCTURE.md](./TEST_INFRASTRUCTURE.md) - Complete test infrastructure guide -- [IMPLEMENTATION_GUIDE.md](../IMPLEMENTATION_GUIDE.md) - Implementation details -- [TestConfiguration.cs](./Common/TestConfiguration.cs) - Configuration source code diff --git a/EstateManagementUI.BlazorIntegrationTests/Steps/BlazorUiSteps.cs b/EstateManagementUI.BlazorIntegrationTests/Steps/BlazorUiSteps.cs deleted file mode 100644 index 72e5e193..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Steps/BlazorUiSteps.cs +++ /dev/null @@ -1,403 +0,0 @@ -using Reqnroll; -using System; -using System.Threading.Tasks; -using Shared.IntegrationTesting; -using EstateManagementUI.BlazorIntegrationTests.Common; -using EstateManagementUI.IntegrationTests.Common; -using Microsoft.Playwright; -using Reqnroll.BoDi; - -namespace EstateManagementUI.BlazorIntegrationTests.Steps -{ - [Binding] - [Scope(Tag = "uigeneral")] - public class BlazorUiSteps - { - private readonly TestingContext TestingContext; - private readonly BlazorUiHelpers UiHelpers; - - public BlazorUiSteps(ScenarioContext scenarioContext, TestingContext testingContext, IObjectContainer container) - { - var page = scenarioContext.ScenarioContainer.Resolve(scenarioContext.ScenarioInfo.Title.Replace(" ", "")); - - this.TestingContext = testingContext; - this.UiHelpers = new BlazorUiHelpers(page, this.TestingContext.DockerHelper.EstateManagementUiPort); - } - - [Given(@"I am on the application home page")] - public async Task GivenIAmOnTheApplicationHomePage() - { - await this.UiHelpers.NavigateToHomePage(); - } - - [Given(@"I click on the My Contracts sidebar option")] - public async Task GivenIClickOnTheMyContractsSidebarOption() - { - await this.UiHelpers.ClickContractsSidebarOption(); - } - - [Given(@"I click on the My Estate sidebar option")] - public async Task GivenIClickOnTheMyEstateSidebarOption() - { - await this.UiHelpers.ClickMyEstateSidebarOption(); - } - - [Given(@"I click on the My Merchants sidebar option")] - public async Task GivenIClickOnTheMyMerchantsSidebarOption() - { - await this.UiHelpers.ClickMyMerchantsSidebarOption(); - } - - [Given(@"I click on the My Operators sidebar option")] - public async Task GivenIClickOnTheMyOperatorsSidebarOption() - { - await this.UiHelpers.ClickMyOperatorsSidebarOption(); - } - - [Given(@"I click on the Sign In Button")] - public async Task GivenIClickOnTheSignInButton() - { - if (TestConfiguration.IsTestMode == false) { - await this.UiHelpers.ClickOnTheSignInButton(); - } - } - - [Then(@"I am presented with a login screen")] - public async Task ThenIAmPresentedWithALoginScreen() - { - if (TestConfiguration.IsTestMode == false) { - await this.UiHelpers.VerifyOnTheLoginScreen(); - } - } - - [Then(@"I am presented with the Contracts List Screen")] - public async Task ThenIAmPresentedWithTheContractsListScreen() - { - await this.UiHelpers.VerifyOnTheContractsListScreen(); - } - - [Then("the Contract Products List Screen is displayed")] - public async Task ThenTheContractProductsListScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheContractProductsListScreen(); - } - - [Then("the Contract Products Transaction Fees List Screen is displayed")] - public async Task ThenTheContractProductsTransactionFeesListScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheContractProductsFeesListScreen(); - } - - [Then(@"I am presented with the Estate Administrator Dashboard")] - public async Task ThenIAmPresentedWithTheEstateAdministratorDashboard() - { - await this.UiHelpers.VerifyOnTheDashboard(); - } - - [When("I click the Save Product Button")] - public async Task WhenIClickTheSaveProductButton() - { - await this.UiHelpers.ClickTheSaveProductButton(); - } - - [Then(@"I am presented with the View Estate Page")] - public async Task ThenIamPresentedWithTheViewEstatePage() - { - await this.UiHelpers.VerifyOnTheEstateDetailsScreen(); - } - - [Then(@"I am presented with the Merchants List Screen")] - public async Task ThenIAmPresentedWithTheMerchantsListScreen() - { - await this.UiHelpers.VerifyOnTheMerchantsListScreen(); - } - - [Then(@"I am presented with the Operators List Screen")] - public async Task ThenIAmPresentedWithTheOperatorsListScreen() - { - await this.UiHelpers.VerifyOnTheOperatorsListScreen(); - } - - [Then(@"My Estate Details will be shown")] - public async Task ThenMyEstateDetailsWillBeShown(DataTable table) - { - DataTableRow tableRow = table.Rows.Single(); - String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName").Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N")); - await this.UiHelpers.VerifyTheCorrectEstateDetailsAreDisplayed(estateName); - } - - [Then(@"the following contract details are in the list")] - public async Task ThenTheFollowingContractDetailsAreInTheList(DataTable table) - { - List<(String, String, Int32)> contractDescriptions = new List<(String, String, Int32)>(); - foreach (DataTableRow tableRow in table.Rows) - { - contractDescriptions.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "Description"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"), - ReqnrollTableHelper.GetIntValue(tableRow, "Products"))); - } - - await this.UiHelpers.VerifyTheContractDetailsAreInTheList(contractDescriptions); - } - - [When(@"I login with the username '(.*)' and password '(.*)'")] - public async Task WhenILoginWithTheUsernameAndPassword(String userName, String password) - { - if (TestConfiguration.IsTestMode == false) { - String username = userName.Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N")); - await this.UiHelpers.Login(username, password); - } - } - - [When("I click on the New Operator Button")] - public async Task WhenIClickOnTheNewOperatorButton() - { - await this.UiHelpers.ClickTheNewOperatorButton(); - } - - [When("I click on the New Merchant Button")] - public async Task WhenIClickOnTheNewMerchantButton() - { - await this.UiHelpers.ClickTheNewMerchantButton(); - } - - [Then("the Edit Merchant Screen is displayed")] - public async Task ThenTheEditMerchantScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheEditMerchantScreen(); - } - - [Then("the Make Deposit Screen is displayed")] - public async Task ThenTheMakeDepositScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheMakeDepositScreen(); - } - - [When("I click on the Operators tab")] - public async Task WhenIClickOnTheOperatorsTab() - { - await this.UiHelpers.ClickOnTheMerchantOperatorsTab(); - } - - [When("I click on the Contracts tab")] - 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(); - } - - [Then("I am presented with the Merchants Contract List Screen")] - 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() - { - await this.UiHelpers.VerifyOnTheViewMerchantScreen(); - } - - [When("click the Assign Operator button")] - public async Task WhenClickTheAssignOperatorButton() - { - await this.UiHelpers.ClickTheAssignOperatorButton(); - } - - [Then("the Add New Merchant Screen is displayed")] - public async Task ThenTheAddNewMerchantScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheNewMerchantScreen(); - } - - [When("I click on the Edit Operator Button for {string}")] - public async Task WhenIClickOnTheEditOperatorButtonFor(string operatorName) - { - await this.UiHelpers.ClickTheEditOperatorButton(operatorName); - } - - [When("I click on the Edit Merchant Button for {string}")] - public async Task WhenIClickOnTheEditMerchantButtonFor(string merchantName) - { - await this.UiHelpers.ClickTheEditMerchantButton(merchantName); - } - - [When("I click on the Make Deposit Button for {string}")] - public async Task WhenIClickOnTheMakeDepositButtonFor(string merchantName) - { - await this.UiHelpers.ClickTheMakeDepositButtonFor(merchantName); - } - - [Then("the Edit Operator Screen is displayed")] - public async Task ThenTheEditOperatorScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheEditOperatorScreen(); - } - - [Then("the New Operator Screen is displayed")] - public async Task ThenTheNewOperatorScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheNewOperatorScreen(); - } - - [Then(@"the following merchants details are in the list")] - public async Task ThenTheFollowingMerchantsDetailsAreInTheList(DataTable table) - { - List merchantDetailsList = new List(); - foreach (DataTableRow tableRow in table.Rows) - { - MerchantDetails m = new MerchantDetails( - tableRow["MerchantName"], - tableRow["SettlementSchedule"], - tableRow["ContactName"], - tableRow["AddressLine1"], - tableRow["Town"]); - merchantDetailsList.Add(m); - } - - await this.UiHelpers.VerifyMerchantDetailsAreInTheList(merchantDetailsList); - } - - [Then(@"the following operator details are in the list")] - public async Task ThenTheFollowingOperatorDetailsAreInTheList(DataTable table) - { - List<(String, String, String, String)> operatorsList = new(); - foreach (DataTableRow tableRow in table.Rows) - { - operatorsList.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "RequireCustomMerchantNumber"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "RequireCustomTerminalNumber"), - null)); - } - - await this.UiHelpers.VerifyOperatorDetailsAreInTheList("operatorList", operatorsList); - } - - [Then("the following operators are displayed in the list")] - public async Task ThenTheFollowingOperatorsAreDisplayedInTheList(DataTable table) - { - List<(String, String, String, String)> operatorsList = new(); - foreach (DataTableRow tableRow in table.Rows) - { - operatorsList.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantNumber"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "TerminalNumber"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "IsDeleted"))); - } - - await this.UiHelpers.VerifyOperatorDetailsAreInTheList("merchantOperatorList", operatorsList); - } - - [Then("the following contracts are displayed in the list")] - public async Task ThenTheFollowingContractsAreDisplayedInTheList(DataTable dataTable) - { - List<(String, String)> contractsList = new(); - foreach (DataTableRow tableRow in dataTable.Rows) - { - contractsList.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "ContractName"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "IsDeleted"))); - } - - await this.UiHelpers.VerifyContractDetailsAreInTheList("merchantContractList", contractsList); - } - - [When("I click on the New Contract Button")] - public async Task WhenIClickOnTheNewContractButton() - { - await this.UiHelpers.ClickAddNewContractButton(); - } - - [Then("the New Contract Screen is displayed")] - public async Task ThenTheNewContractScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheNewContractScreen(); - } - - [When("I enter the following details for the new Merchant")] - public async Task WhenIEnterTheFollowingDetailsForTheNewMerchant(DataTable dataTable) - { - DataTableRow row = dataTable.Rows.Single(); - - await this.UiHelpers.FillInNewMerchantForm( - ReqnrollTableHelper.GetStringRowValue(row, "MerchantName"), - ReqnrollTableHelper.GetStringRowValue(row, "SettlementSchedule"), - ReqnrollTableHelper.GetStringRowValue(row, "AddressLine1"), - ReqnrollTableHelper.GetStringRowValue(row, "Town"), - ReqnrollTableHelper.GetStringRowValue(row, "Region"), - ReqnrollTableHelper.GetStringRowValue(row, "Country"), - ReqnrollTableHelper.GetStringRowValue(row, "ContactName"), - ReqnrollTableHelper.GetStringRowValue(row, "EmailAddress")); - } - - [When("click the Create Merchant button")] - public async Task WhenClickTheCreateMerchantButton() - { - await this.UiHelpers.ClickTheCreateMerchantButton(); - } - - [When("click the Update Merchant button")] - public async Task WhenClickTheUpdateMerchantButton() - { - await this.UiHelpers.ClickTheUpdateMerchantButton(); - } - - [When("I enter the following details for the updated Merchant")] - public async Task WhenIEnterTheFollowingDetailsForTheUpdatedMerchant(DataTable dataTable) - { - foreach (DataTableRow row in dataTable.Rows) - { - String tab = ReqnrollTableHelper.GetStringRowValue(row, "Tab"); - String field = ReqnrollTableHelper.GetStringRowValue(row, "Field"); - String value = ReqnrollTableHelper.GetStringRowValue(row, "Value"); - - await this.UiHelpers.UpdateMerchantField(tab, field, value); - } - } - - [When("I enter the following details for the deposit")] - public async Task WhenIEnterTheFollowingDetailsForTheDeposit(DataTable dataTable) - { - DataTableRow row = dataTable.Rows.Single(); - - await this.UiHelpers.FillInDepositForm( - ReqnrollTableHelper.GetStringRowValue(row, "Amount"), - ReqnrollTableHelper.GetStringRowValue(row, "Date"), - ReqnrollTableHelper.GetStringRowValue(row, "Reference")); - } - - [When("click the Make Deposit button")] - public async Task WhenClickTheMakeDepositButton() - { - await this.UiHelpers.ClickTheMakeDepositButton(); - } - - [When("I click on the View Merchant Button for {string}")] - public async Task WhenIClickOnTheViewMerchantButtonFor(string merchantName) - { - await this.UiHelpers.ClickTheViewMerchantButton(merchantName); - } - } -} diff --git a/EstateManagementUI.BlazorIntegrationTests/Steps/TestDataManagementSteps.cs b/EstateManagementUI.BlazorIntegrationTests/Steps/TestDataManagementSteps.cs deleted file mode 100644 index 6747c4ef..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Steps/TestDataManagementSteps.cs +++ /dev/null @@ -1,170 +0,0 @@ -using EstateManagementUI.BlazorServer.Models; -using EstateManagementUI.BlazorServer.Services; -using Reqnroll; -using Shouldly; - -namespace EstateManagementUI.BlazorIntegrationTests.Steps; - -/// -/// Example step definitions showing how to use the test data store -/// These examples demonstrate CRUD operations on test data during integration tests -/// -[Binding] -public class TestDataManagementSteps -{ - private readonly ITestDataStore _testDataStore; - private readonly Guid _defaultEstateId = Guid.Parse("11111111-1111-1111-1111-111111111111"); - - public TestDataManagementSteps(ITestDataStore testDataStore) - { - _testDataStore = testDataStore; - } - - // Example: Adding a merchant dynamically during test - [Given(@"I have added a merchant with name ""(.*)"" and reference ""(.*)""")] - public void GivenIHaveAddedMerchant(string merchantName, string merchantReference) - { - var merchant = new MerchantModel - { - MerchantId = Guid.NewGuid(), - MerchantName = merchantName, - MerchantReference = merchantReference, - Balance = 0, - AvailableBalance = 0, - SettlementSchedule = "Immediate" - }; - - _testDataStore.AddMerchant(_defaultEstateId, merchant); - } - - // Example: Verifying merchant exists - [Then(@"the merchant ""(.*)"" should exist in the system")] - public void ThenMerchantShouldExist(string merchantReference) - { - var merchants = _testDataStore.GetMerchants(_defaultEstateId); - var merchant = merchants.FirstOrDefault(m => m.MerchantReference == merchantReference); - - merchant.ShouldNotBeNull(); - } - - // Example: Updating merchant balance - [When(@"I update the balance of merchant ""(.*)"" to (.*)")] - public void WhenIUpdateMerchantBalance(string merchantReference, decimal newBalance) - { - var merchants = _testDataStore.GetMerchants(_defaultEstateId); - var merchant = merchants.FirstOrDefault(m => m.MerchantReference == merchantReference); - - merchant.ShouldNotBeNull(); - merchant.Balance = newBalance; - - _testDataStore.UpdateMerchant(_defaultEstateId, merchant); - } - - // Example: Verifying merchant balance - [Then(@"the merchant ""(.*)"" should have a balance of (.*)")] - public void ThenMerchantShouldHaveBalance(string merchantReference, decimal expectedBalance) - { - var merchants = _testDataStore.GetMerchants(_defaultEstateId); - var merchant = merchants.FirstOrDefault(m => m.MerchantReference == merchantReference); - - merchant.ShouldNotBeNull(); - merchant.Balance.ShouldBe(expectedBalance); - } - - // Example: Removing a merchant - [When(@"I remove the merchant ""(.*)""")] - public void WhenIRemoveMerchant(string merchantReference) - { - var merchants = _testDataStore.GetMerchants(_defaultEstateId); - var merchant = merchants.FirstOrDefault(m => m.MerchantReference == merchantReference); - - merchant.ShouldNotBeNull(); - _testDataStore.RemoveMerchant(_defaultEstateId, merchant.MerchantId); - } - - // Example: Verifying merchant doesn't exist - [Then(@"the merchant ""(.*)"" should not exist in the system")] - public void ThenMerchantShouldNotExist(string merchantReference) - { - var merchants = _testDataStore.GetMerchants(_defaultEstateId); - var merchant = merchants.FirstOrDefault(m => m.MerchantReference == merchantReference); - - merchant.ShouldBeNull(); - } - - // Example: Adding an operator - [Given(@"I have added an operator with name ""(.*)""")] - public void GivenIHaveAddedOperator(string operatorName) - { - var operatorModel = new OperatorModel - { - OperatorId = Guid.NewGuid(), - Name = operatorName, - RequireCustomMerchantNumber = false, - RequireCustomTerminalNumber = false - }; - - _testDataStore.AddOperator(_defaultEstateId, operatorModel); - } - - // Example: Verifying operator count - [Then(@"there should be (.*) operators in the system")] - public void ThenThereShouldBeOperators(int expectedCount) - { - var operators = _testDataStore.GetOperators(_defaultEstateId); - operators.Count.ShouldBe(expectedCount); - } - - // Example: Adding a contract - [Given(@"I have added a contract with description ""(.*)"" for operator ""(.*)""")] - public void GivenIHaveAddedContract(string description, string operatorName) - { - var operators = _testDataStore.GetOperators(_defaultEstateId); - var operatorModel = operators.FirstOrDefault(o => o.Name == operatorName); - - operatorModel.ShouldNotBeNull(); - - var contract = new ContractModel - { - ContractId = Guid.NewGuid(), - Description = description, - OperatorId = operatorModel.OperatorId, - OperatorName = operatorModel.Name, - Products = new List() - }; - - _testDataStore.AddContract(_defaultEstateId, contract); - } - - // Example: Verifying contract exists - [Then(@"the contract ""(.*)"" should exist in the system")] - public void ThenContractShouldExist(string description) - { - var contracts = _testDataStore.GetContracts(_defaultEstateId); - var contract = contracts.FirstOrDefault(c => c.Description == description); - - contract.ShouldNotBeNull(); - } - - // Example: Resetting test data (useful in BeforeScenario hook) - [Given(@"the system is reset to default state")] - public void GivenSystemIsReset() - { - _testDataStore.Reset(); - } - - // Example: Verifying default merchants exist - [Then(@"the default test merchants should exist")] - public void ThenDefaultMerchantsShouldExist() - { - var merchants = _testDataStore.GetMerchants(_defaultEstateId); - - // Default setup includes 3 merchants - merchants.Count.ShouldBeGreaterThanOrEqualTo(3); - - // Verify specific default merchants - merchants.ShouldContain(m => m.MerchantReference == "MERCH001"); - merchants.ShouldContain(m => m.MerchantReference == "MERCH002"); - merchants.ShouldContain(m => m.MerchantReference == "MERCH003"); - } -} diff --git a/EstateManagementUI.BlazorIntegrationTests/TEST_INFRASTRUCTURE.md b/EstateManagementUI.BlazorIntegrationTests/TEST_INFRASTRUCTURE.md deleted file mode 100644 index e5687625..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/TEST_INFRASTRUCTURE.md +++ /dev/null @@ -1,247 +0,0 @@ -# Test Infrastructure Enhancement - -## Overview - -This document describes the enhanced test infrastructure that enables Blazor integration tests to run without Docker containers for OIDC authentication and provides editable test data management. - -## Key Features - -### 1. Test Mode Configuration - -The application can run in "Test Mode" by setting the `AppSettings:TestMode` configuration to `true`. In test mode: - -- **OIDC Authentication is bypassed** using a `TestAuthenticationHandler` -- **Test data is managed in-memory** using the `TestDataStore` -- **No external dependencies** are required for authentication or data storage - -#### Configuration - -In `appsettings.Test.json` or via environment variables: - -```json -{ - "AppSettings": { - "TestMode": true - } -} -``` - -### 2. OIDC Authentication Bypass - -The `TestAuthenticationHandler` provides automatic authentication for tests without requiring an OIDC server: - -- Automatically authenticates all requests -- Provides test user claims (user ID, name, email, estate ID, role) -- Eliminates the need for SecurityService Docker containers during testing - -**Implementation**: See `EstateManagementUI.BlazorServer/Common/TestAuthenticationHandler.cs` - -### 3. Editable In-Memory Test Data - -The test infrastructure provides a complete in-memory data store with CRUD operations: - -#### ITestDataStore Interface - -Provides methods for managing test data: - -- **Estate Management**: `GetEstate()`, `SetEstate()` -- **Merchant Management**: `GetMerchants()`, `GetMerchant()`, `AddMerchant()`, `UpdateMerchant()`, `RemoveMerchant()` -- **Operator Management**: `GetOperators()`, `GetOperator()`, `AddOperator()`, `UpdateOperator()`, `RemoveOperator()` -- **Contract Management**: `GetContracts()`, `GetContract()`, `AddContract()`, `UpdateContract()`, `RemoveContract()` -- **Reset**: `Reset()` - Clears all data and reinitializes with defaults - -**Implementation**: See `EstateManagementUI.BlazorServer/Services/ITestDataStore.cs` - -#### TestDataStore Implementation - -Thread-safe in-memory storage using `ConcurrentDictionary`: - -- Stores data organized by Estate ID -- Provides data isolation between estates -- Includes default test data on initialization -- Can be reset between test scenarios - -**Implementation**: See `EstateManagementUI.BlazorServer/Services/TestDataStore.cs` - -### 4. TestMediatorService - -The `TestMediatorService` maintains the mediator pattern while using the in-memory test data store: - -- All queries read from the `TestDataStore` -- All commands execute against the `TestDataStore` -- CRUD operations are properly reflected in test data -- Dashboard and file processing queries return mock data - -**Implementation**: See `EstateManagementUI.BlazorServer/Services/TestMediatorService.cs` - -## Default Test Data - -When the `TestDataStore` is initialized (or reset), it contains: - -### Estate -- **Estate ID**: `11111111-1111-1111-1111-111111111111` -- **Name**: "Test Estate" - -### Merchants -1. **Test Merchant 1** (ID: `22222222-2222-2222-2222-222222222222`) - - Reference: MERCH001 - - Balance: £10,000.00 - - Settlement: Immediate - -2. **Test Merchant 2** (ID: `22222222-2222-2222-2222-222222222223`) - - Reference: MERCH002 - - Balance: £5,000.00 - - Settlement: Weekly - -3. **Test Merchant 3** (ID: `22222222-2222-2222-2222-222222222224`) - - Reference: MERCH003 - - Balance: £15,000.00 - - Settlement: Monthly - -### Operators -1. **Safaricom** (ID: `33333333-3333-3333-3333-333333333333`) - - Requires Custom Merchant Number: Yes - - Requires Custom Terminal Number: No - -2. **Voucher** (ID: `33333333-3333-3333-3333-333333333334`) - - Requires Custom Merchant Number: No - - Requires Custom Terminal Number: No - -### Contracts -1. **Standard Transaction Contract** (ID: `44444444-4444-4444-4444-444444444444`) - - Operator: Safaricom - - Products: Mobile Topup with transaction fees - -2. **Voucher Sales Contract** (ID: `44444444-4444-4444-4444-444444444445`) - - Operator: Voucher - - Products: Voucher Purchase - -## Using Test Data in Integration Tests - -### TestDataHelper - -The `TestDataHelper` class provides easy access to test data operations: - -```csharp -// Access default estate -var estateId = testDataHelper.DefaultEstateId; - -// Get merchants -var merchants = testDataHelper.GetMerchants(estateId); - -// Add a new merchant -var newMerchant = testDataHelper.CreateTestMerchant( - estateId, - "New Merchant", - "NEWMERCH001" -); - -// Update a merchant -var merchant = testDataHelper.GetMerchant(estateId, merchantId); -merchant.MerchantName = "Updated Name"; -testDataHelper.UpdateMerchant(estateId, merchant); - -// Remove a merchant -testDataHelper.RemoveMerchant(estateId, merchantId); - -// Reset all data between tests -testDataHelper.Reset(); -``` - -### Test Isolation - -To ensure tests don't interfere with each other: - -1. **Use `Reset()` before each scenario**: Resets data to default state -2. **Create unique test data**: Use unique IDs for test-specific entities -3. **Clean up after tests**: Remove test-specific data if not using `Reset()` - -Example in Reqnroll hooks: - -```csharp -[BeforeScenario] -public void BeforeScenario() -{ - // Reset test data to default state - testDataHelper.Reset(); -} -``` - -## Running Tests in Test Mode - -### Option 1: Environment Variable - -Set the environment variable before running tests: - -```bash -export AppSettings__TestMode=true -dotnet test -``` - -### Option 2: Test Configuration File - -The application will automatically load `appsettings.Test.json` when running in test environment: - -```bash -ASPNETCORE_ENVIRONMENT=Test dotnet test -``` - -### Option 3: Docker Environment Variables - -When running the Blazor app in Docker for integration tests: - -```yaml -environment: - - AppSettings__TestMode=true -``` - -## Benefits - -1. **Faster Test Execution**: No need to start Docker containers for OIDC -2. **Simpler Setup**: Reduced infrastructure requirements -3. **Flexible Data Management**: Easy to create, modify, and verify test data -4. **Data Isolation**: Each test can have its own data state -5. **Maintains Architecture**: Continues using the mediator pattern - -## Architecture Notes - -The test infrastructure maintains the application's architectural patterns: - -- **Mediator Pattern**: `TestMediatorService` implements `IMediator` -- **Dependency Injection**: Test services are registered in the DI container -- **Configuration-Based**: Test mode is controlled via configuration -- **Clean Separation**: Test code is isolated in specific classes - -## Migration from Docker-Based Tests - -Existing tests can be migrated to use test mode: - -1. Remove Docker setup for OIDC containers -2. Set `AppSettings:TestMode=true` in test configuration -3. Use `TestDataHelper` to set up test data -4. Remove OIDC-specific test steps -5. Update test steps to use in-memory data - -## Troubleshooting - -### Tests can't authenticate -- Ensure `AppSettings:TestMode` is set to `true` -- Check that `TestAuthenticationHandler` is registered - -### Data not persisting between steps -- Verify you're not calling `Reset()` between steps in the same scenario -- Check that you're using the same `TestDataStore` instance (it's registered as singleton) - -### Data from previous tests appearing -- Call `Reset()` in `BeforeScenario` hooks to ensure clean state -- Verify test isolation is properly configured - -## Future Enhancements - -Potential improvements to consider: - -1. **Custom test user claims**: Allow tests to specify different user contexts -2. **Test data fixtures**: Pre-defined test data sets for common scenarios -3. **Data snapshots**: Save and restore test data states -4. **Query verification**: Track which queries were executed during tests -5. **Command history**: Record all commands executed for verification diff --git a/EstateManagementUI.BlazorIntegrationTests/Tests/ContractTests.feature b/EstateManagementUI.BlazorIntegrationTests/Tests/ContractTests.feature deleted file mode 100644 index 1d25d48d..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Tests/ContractTests.feature +++ /dev/null @@ -1,128 +0,0 @@ -@base @shared @uigeneral -Feature: Contract Tests - -Background: - - Given I create the following roles - | Role Name | - | Estate | - - Given I create the following api scopes - | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | - | transactionProcessor | Transaction Processor REST Scope | Scope for Transaction Processor REST | - | fileProcessor | File Processor REST Scope | Scope for File Processor REST | - - Given I create the following api resources - | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | merchantId,estateId,role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | merchantId,estateId,role | - | fileProcessor | File Processor REST | Secret1 | fileProcessor | merchantId,estateId,role | - - Given I create the following identity resources - | Name | DisplayName | Description | UserClaims | - | openid | Your user identifier | | sub | - | profile | User profile | Your user profile information (first name, last name, etc.) | name,role,email,given_name,middle_name,family_name,estateId,merchantId | - | email | Email | Email and Email Verified Flags | email_verified,email | - - Given I create the following clients - | ClientId | Name | Secret | Scopes | GrantTypes | RedirectUris | PostLogoutRedirectUris | RequireConsent | AllowOfflineAccess | ClientUri | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor | client_credentials | | | | | | - | estateUIClient | Merchant Client | Secret1 | estateManagement,fileProcessor,transactionProcessor,openid,email,profile | hybrid | https://localhost:[port]/signin-oidc | https://localhost:[port]/signout-oidc | false | true | https://[url]:[port] | - - Given I have a token to access the estate management resource - | ClientId | - | serviceClient | - - Given I have created the following estates - | EstateName | - | Test Estate | - - And I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator 1 | True | True | - | Test Estate | Test Operator 2 | True | False | - | Test Estate | Test Operator 3 | False | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator 1 | - | Test Estate | Test Operator 2 | - | Test Estate | Test Operator 3 | - - And I have created the following security users - | EmailAddress | Password | GivenName | FamilyName | EstateName | - | estateuser@testestate1.co.uk | 123456 | TestEstate | User1 | Test Estate | - - Given I have created the following contracts - | EstateName | OperatorName | ContractDescription | - | Test Estate | Test Operator 1 | Operator 1 Contract | - | Test Estate | Test Operator 2 | Operator 2 Contract | - - Given I have created the following contract products - | EstateName | OperatorName | ContractDescription | ProductName | DisplayText | Value | ProductType | - | Test Estate | Test Operator 1 | Operator 1 Contract | 100 KES Topup | 100 KES | 100.00 | MobileTopup | - | Test Estate | Test Operator 1 | Operator 1 Contract | Variable Topup 1 | Custom | | MobileTopup | - | Test Estate | Test Operator 2 | Operator 2 Contract | 200 KES Topup | 200 KES | 500.00 | MobileTopup | - | Test Estate | Test Operator 2 | Operator 2 Contract | 500 KES Topup | 500 KES | 500.00 | MobileTopup | - | Test Estate | Test Operator 2 | Operator 2 Contract | Variable Topup 1 | Custom | | MobileTopup | - - Given I am on the application home page - - And I click on the Sign In Button - - Then I am presented with a login screen - - When I login with the username 'estateuser@testestate1.co.uk' and password '123456' - - Then I am presented with the Estate Administrator Dashboard - -@PRTest -Scenario: Contract PR Test - - Given I click on the My Contracts sidebar option - Then I am presented with the Contracts List Screen - And the following contract details are in the list - | Description | OperatorName | Products | - | Operator 1 Contract | Test Operator 1 | 2 | - | Operator 2 Contract | Test Operator 2 | 3 | - When I click on the New Contract Button - Then the New Contract Screen is displayed - When I enter the following details for the new Contract - | Description | OperatorName | - | Operator 3 Contract | Test Operator 3 | - When I click the Save Contract Button - Then I am presented with the Contracts List Screen - And the following contract details are in the list - | Description | OperatorName | Products | - | Operator 1 Contract | Test Operator 1 | 2 | - | Operator 2 Contract | Test Operator 2 | 3 | - | Operator 3 Contract | Test Operator 3 | 0 | - When I click on the View Products Button for 'Operator 1 Contract' - Then the Contract Products List Screen is displayed - And the following contract product details are in the list - | ProductName | DisplayText | Value | ProductType | - | 100 KES Topup | 100 KES | 100.00 | MobileTopup | - | Variable Topup 1 | Custom | Variable | MobileTopup | - When I click on the New Contract Product Button - Then the New Product Screen is displayed - When I enter the following details for the new Product - | ProductName | DisplayText | Value | ProductType | - | 200 KES Topup | 200 KES | 200.00 | Mobile Topup | - When I click the Save Product Button - Then the Contract Products List Screen is displayed - And the following contract product details are in the list - | ProductName | DisplayText | Value | ProductType | - | 100 KES Topup | 100 KES | 100.00 | MobileTopup | - | 200 KES Topup | 200 KES | 200.00 | MobileTopup | - | Variable Topup 1 | Custom | Variable | MobileTopup | - When I click on the View Fees Button for '100 KES Topup' - Then the Contract Products Transaction Fees List Screen is displayed - When I click on the New Contract Product Transaction Button - Then the New Contract Product Transaction Screen is displayed - When I enter the following details for the new Transaction Fee - | Description | CalculationType | FeeType | Value | - | Test Fixed Fee | Fixed Value | Merchant | 0.25 | - When I click the Save Transaction Fee Button - Then the Contract Products Transaction Fees List Screen is displayed - #And the following contract product transaction fee details are in the list \ No newline at end of file diff --git a/EstateManagementUI.BlazorIntegrationTests/Tests/ContractTests.feature.cs b/EstateManagementUI.BlazorIntegrationTests/Tests/ContractTests.feature.cs deleted file mode 100644 index 634c7850..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Tests/ContractTests.feature.cs +++ /dev/null @@ -1,578 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://reqnroll.net/). -// Reqnroll Version:3.0.0.0 -// Reqnroll Generator Version:3.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -using Reqnroll; -namespace EstateManagementUI.BlazorIntegrationTests.Tests -{ - - - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "3.0.0.0")] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::NUnit.Framework.TestFixtureAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Contract Tests")] - [global::NUnit.Framework.FixtureLifeCycleAttribute(global::NUnit.Framework.LifeCycle.InstancePerTestCase)] - [global::NUnit.Framework.CategoryAttribute("base")] - [global::NUnit.Framework.CategoryAttribute("shared")] - [global::NUnit.Framework.CategoryAttribute("uigeneral")] - public partial class ContractTestsFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "base", - "shared", - "uigeneral"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Contract Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags, InitializeCucumberMessages()); - -#line 1 "ContractTests.feature" -#line hidden - - [global::NUnit.Framework.OneTimeSetUpAttribute()] - public static async global::System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [global::NUnit.Framework.OneTimeTearDownAttribute()] - public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() - { - await global::Reqnroll.TestRunnerManager.ReleaseFeatureAsync(featureInfo); - } - - [global::NUnit.Framework.SetUpAttribute()] - public async global::System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - try - { - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - } - finally - { - if (((testRunner.FeatureContext != null) - && testRunner.FeatureContext.BeforeFeatureHookFailed)) - { - throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - } - - [global::NUnit.Framework.TearDownAttribute()] - public async global::System.Threading.Tasks.Task TestTearDownAsync() - { - if ((testRunner == null)) - { - return; - } - try - { - await testRunner.OnScenarioEndAsync(); - } - finally - { - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - testRunner = null; - } - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, global::Reqnroll.RuleInfo ruleInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo, ruleInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(global::NUnit.Framework.TestContext.CurrentContext); - } - - public async global::System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() - { -#line 4 -#line hidden - global::Reqnroll.Table table1 = new global::Reqnroll.Table(new string[] { - "Role Name"}); - table1.AddRow(new string[] { - "Estate"}); -#line 6 - await testRunner.GivenAsync("I create the following roles", ((string)(null)), table1, "Given "); -#line hidden - global::Reqnroll.Table table2 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description"}); - table2.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); - table2.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST Scope", - "Scope for Transaction Processor REST"}); - table2.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)), table2, "Given "); -#line hidden - global::Reqnroll.Table table3 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Secret", - "Scopes", - "UserClaims"}); - table3.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "merchantId,estateId,role"}); - table3.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST", - "Secret1", - "transactionProcessor", - "merchantId,estateId,role"}); - table3.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)), table3, "Given "); -#line hidden - global::Reqnroll.Table table4 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description", - "UserClaims"}); - table4.AddRow(new string[] { - "openid", - "Your user identifier", - "", - "sub"}); - table4.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"}); - table4.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)), table4, "Given "); -#line hidden - global::Reqnroll.Table table5 = new global::Reqnroll.Table(new string[] { - "ClientId", - "Name", - "Secret", - "Scopes", - "GrantTypes", - "RedirectUris", - "PostLogoutRedirectUris", - "RequireConsent", - "AllowOfflineAccess", - "ClientUri"}); - table5.AddRow(new string[] { - "serviceClient", - "Service Client", - "Secret1", - "estateManagement,transactionProcessor", - "client_credentials", - "", - "", - "", - "", - ""}); - table5.AddRow(new string[] { - "estateUIClient", - "Merchant Client", - "Secret1", - "estateManagement,fileProcessor,transactionProcessor,openid,email,profile", - "hybrid", - "https://localhost:[port]/signin-oidc", - "https://localhost:[port]/signout-oidc", - "false", - "true", - "https://[url]:[port]"}); -#line 28 - await testRunner.GivenAsync("I create the following clients", ((string)(null)), table5, "Given "); -#line hidden - global::Reqnroll.Table table6 = new global::Reqnroll.Table(new string[] { - "ClientId"}); - table6.AddRow(new string[] { - "serviceClient"}); -#line 33 - await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table6, "Given "); -#line hidden - global::Reqnroll.Table table7 = new global::Reqnroll.Table(new string[] { - "EstateName"}); - table7.AddRow(new string[] { - "Test Estate"}); -#line 37 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table7, "Given "); -#line hidden - global::Reqnroll.Table table8 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table8.AddRow(new string[] { - "Test Estate", - "Test Operator 1", - "True", - "True"}); - table8.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "True", - "False"}); - table8.AddRow(new string[] { - "Test Estate", - "Test Operator 3", - "False", - "True"}); -#line 41 - await testRunner.AndAsync("I have created the following operators", ((string)(null)), table8, "And "); -#line hidden - global::Reqnroll.Table table9 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table9.AddRow(new string[] { - "Test Estate", - "Test Operator 1"}); - table9.AddRow(new string[] { - "Test Estate", - "Test Operator 2"}); - table9.AddRow(new string[] { - "Test Estate", - "Test Operator 3"}); -#line 47 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table9, "And "); -#line hidden - global::Reqnroll.Table table10 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "EstateName"}); - table10.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)), table10, "And "); -#line hidden - global::Reqnroll.Table table11 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "ContractDescription"}); - table11.AddRow(new string[] { - "Test Estate", - "Test Operator 1", - "Operator 1 Contract"}); - table11.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "Operator 2 Contract"}); -#line 57 - await testRunner.GivenAsync("I have created the following contracts", ((string)(null)), table11, "Given "); -#line hidden - global::Reqnroll.Table table12 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "ContractDescription", - "ProductName", - "DisplayText", - "Value", - "ProductType"}); - table12.AddRow(new string[] { - "Test Estate", - "Test Operator 1", - "Operator 1 Contract", - "100 KES Topup", - "100 KES", - "100.00", - "MobileTopup"}); - table12.AddRow(new string[] { - "Test Estate", - "Test Operator 1", - "Operator 1 Contract", - "Variable Topup 1", - "Custom", - "", - "MobileTopup"}); - table12.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "Operator 2 Contract", - "200 KES Topup", - "200 KES", - "500.00", - "MobileTopup"}); - table12.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "Operator 2 Contract", - "500 KES Topup", - "500 KES", - "500.00", - "MobileTopup"}); - table12.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "Operator 2 Contract", - "Variable Topup 1", - "Custom", - "", - "MobileTopup"}); -#line 62 - await testRunner.GivenAsync("I have created the following contract products", ((string)(null)), table12, "Given "); -#line hidden -#line 70 - await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 72 - await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 74 - await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 76 - 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 78 - await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - - private static global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages InitializeCucumberMessages() - { - return new global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages("Tests/ContractTests.feature.ndjson", 3); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Contract PR Test")] - [global::NUnit.Framework.CategoryAttribute("PRTest")] - public async global::System.Threading.Tasks.Task ContractPRTest() - { - string[] tagsOfScenario = new string[] { - "PRTest"}; - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "0"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Contract PR Test", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 81 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 83 - await testRunner.GivenAsync("I click on the My Contracts sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 84 - await testRunner.ThenAsync("I am presented with the Contracts List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table13 = new global::Reqnroll.Table(new string[] { - "Description", - "OperatorName", - "Products"}); - table13.AddRow(new string[] { - "Operator 1 Contract", - "Test Operator 1", - "2"}); - table13.AddRow(new string[] { - "Operator 2 Contract", - "Test Operator 2", - "3"}); -#line 85 - await testRunner.AndAsync("the following contract details are in the list", ((string)(null)), table13, "And "); -#line hidden -#line 89 - await testRunner.WhenAsync("I click on the New Contract Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 90 - await testRunner.ThenAsync("the New Contract Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table14 = new global::Reqnroll.Table(new string[] { - "Description", - "OperatorName"}); - table14.AddRow(new string[] { - "Operator 3 Contract", - "Test Operator 3"}); -#line 91 - await testRunner.WhenAsync("I enter the following details for the new Contract", ((string)(null)), table14, "When "); -#line hidden -#line 94 - await testRunner.WhenAsync("I click the Save Contract Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 95 - await testRunner.ThenAsync("I am presented with the Contracts List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table15 = new global::Reqnroll.Table(new string[] { - "Description", - "OperatorName", - "Products"}); - table15.AddRow(new string[] { - "Operator 1 Contract", - "Test Operator 1", - "2"}); - table15.AddRow(new string[] { - "Operator 2 Contract", - "Test Operator 2", - "3"}); - table15.AddRow(new string[] { - "Operator 3 Contract", - "Test Operator 3", - "0"}); -#line 96 - await testRunner.AndAsync("the following contract details are in the list", ((string)(null)), table15, "And "); -#line hidden -#line 101 - await testRunner.WhenAsync("I click on the View Products Button for \'Operator 1 Contract\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 102 - await testRunner.ThenAsync("the Contract Products List Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table16 = new global::Reqnroll.Table(new string[] { - "ProductName", - "DisplayText", - "Value", - "ProductType"}); - table16.AddRow(new string[] { - "100 KES Topup", - "100 KES", - "100.00", - "MobileTopup"}); - table16.AddRow(new string[] { - "Variable Topup 1", - "Custom", - "Variable", - "MobileTopup"}); -#line 103 - await testRunner.AndAsync("the following contract product details are in the list", ((string)(null)), table16, "And "); -#line hidden -#line 107 - await testRunner.WhenAsync("I click on the New Contract Product Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 108 - await testRunner.ThenAsync("the New Product Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table17 = new global::Reqnroll.Table(new string[] { - "ProductName", - "DisplayText", - "Value", - "ProductType"}); - table17.AddRow(new string[] { - "200 KES Topup", - "200 KES", - "200.00", - "Mobile Topup"}); -#line 109 - await testRunner.WhenAsync("I enter the following details for the new Product", ((string)(null)), table17, "When "); -#line hidden -#line 112 - await testRunner.WhenAsync("I click the Save Product Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 113 - await testRunner.ThenAsync("the Contract Products List Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table18 = new global::Reqnroll.Table(new string[] { - "ProductName", - "DisplayText", - "Value", - "ProductType"}); - table18.AddRow(new string[] { - "100 KES Topup", - "100 KES", - "100.00", - "MobileTopup"}); - table18.AddRow(new string[] { - "200 KES Topup", - "200 KES", - "200.00", - "MobileTopup"}); - table18.AddRow(new string[] { - "Variable Topup 1", - "Custom", - "Variable", - "MobileTopup"}); -#line 114 - await testRunner.AndAsync("the following contract product details are in the list", ((string)(null)), table18, "And "); -#line hidden -#line 119 - await testRunner.WhenAsync("I click on the View Fees Button for \'100 KES Topup\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 120 - await testRunner.ThenAsync("the Contract Products Transaction Fees List Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 121 - await testRunner.WhenAsync("I click on the New Contract Product Transaction Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 122 - await testRunner.ThenAsync("the New Contract Product Transaction Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table19 = new global::Reqnroll.Table(new string[] { - "Description", - "CalculationType", - "FeeType", - "Value"}); - table19.AddRow(new string[] { - "Test Fixed Fee", - "Fixed Value", - "Merchant", - "0.25"}); -#line 123 - await testRunner.WhenAsync("I enter the following details for the new Transaction Fee", ((string)(null)), table19, "When "); -#line hidden -#line 126 - await testRunner.WhenAsync("I click the Save Transaction Fee Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 127 - await testRunner.ThenAsync("the Contract Products Transaction Fees List Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/EstateManagementUI.BlazorIntegrationTests/Tests/EstateTests.feature b/EstateManagementUI.BlazorIntegrationTests/Tests/EstateTests.feature deleted file mode 100644 index 2343d9de..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Tests/EstateTests.feature +++ /dev/null @@ -1,85 +0,0 @@ -@base @shared @uigeneral -Feature: Estate Tests - -Background: - - Given I create the following roles - | Role Name | - | Estate | - - Given I create the following api scopes - | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | - | transactionProcessor | Transaction Processor REST Scope | Scope for Transaction Processor REST | - | fileProcessor | File Processor REST Scope | Scope for File Processor REST | - - Given I create the following api resources - | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | merchantId,estateId,role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | merchantId,estateId,role | - | fileProcessor | File Processor REST | Secret1 | fileProcessor | merchantId,estateId,role | - - Given I create the following identity resources - | Name | DisplayName | Description | UserClaims | - | openid | Your user identifier | | sub | - | profile | User profile | Your user profile information (first name, last name, etc.) | name,role,email,given_name,middle_name,family_name,estateId,merchantId | - | email | Email | Email and Email Verified Flags | email_verified,email | - - Given I create the following clients - | ClientId | Name | Secret | Scopes | GrantTypes | RedirectUris | PostLogoutRedirectUris | RequireConsent | AllowOfflineAccess | ClientUri | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor | client_credentials | | | | | | - | estateUIClient | Merchant Client | Secret1 | estateManagement,fileProcessor,transactionProcessor,openid,email,profile | hybrid | https://localhost:[port]/signin-oidc | https://localhost:[port]/signout-oidc | false | true | https://[url]:[port] | - - Given I have a token to access the estate management resource - | ClientId | - | serviceClient | - - Given I have created the following estates - | EstateName | - | Test Estate | - - And I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator | True | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator | - - And I have created the following security users - | EmailAddress | Password | GivenName | FamilyName | EstateName | - | estateuser@testestate1.co.uk | 123456 | TestEstate | User1 | Test Estate | - - -Scenario: I Can Log Into The Application - - Given I am on the application home page - - And I click on the Sign In Button - - Then I am presented with a login screen - - When I login with the username 'estateuser@testestate1.co.uk' and password '123456' - - Then I am presented with the Estate Administrator Dashboard - -@PRTest -Scenario: View Estate Details - - Given I am on the application home page - - And I click on the Sign In Button - - Then I am presented with a login screen - - When I login with the username 'estateuser@testestate1.co.uk' and password '123456' - - Then I am presented with the Estate Administrator Dashboard - - Given I click on the My Estate sidebar option - - Then I am presented with the View Estate Page - - And My Estate Details will be shown - | EstateName | - | Test Estate | \ No newline at end of file diff --git a/EstateManagementUI.BlazorIntegrationTests/Tests/EstateTests.feature.cs b/EstateManagementUI.BlazorIntegrationTests/Tests/EstateTests.feature.cs deleted file mode 100644 index 0fd73ed3..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Tests/EstateTests.feature.cs +++ /dev/null @@ -1,387 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://reqnroll.net/). -// Reqnroll Version:3.0.0.0 -// Reqnroll Generator Version:3.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -using Reqnroll; -namespace EstateManagementUI.BlazorIntegrationTests.Tests -{ - - - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "3.0.0.0")] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::NUnit.Framework.TestFixtureAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Estate Tests")] - [global::NUnit.Framework.FixtureLifeCycleAttribute(global::NUnit.Framework.LifeCycle.InstancePerTestCase)] - [global::NUnit.Framework.CategoryAttribute("base")] - [global::NUnit.Framework.CategoryAttribute("shared")] - [global::NUnit.Framework.CategoryAttribute("uigeneral")] - public partial class EstateTestsFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "base", - "shared", - "uigeneral"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Estate Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags, InitializeCucumberMessages()); - -#line 1 "EstateTests.feature" -#line hidden - - [global::NUnit.Framework.OneTimeSetUpAttribute()] - public static async global::System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [global::NUnit.Framework.OneTimeTearDownAttribute()] - public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() - { - await global::Reqnroll.TestRunnerManager.ReleaseFeatureAsync(featureInfo); - } - - [global::NUnit.Framework.SetUpAttribute()] - public async global::System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - try - { - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - } - finally - { - if (((testRunner.FeatureContext != null) - && testRunner.FeatureContext.BeforeFeatureHookFailed)) - { - throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - } - - [global::NUnit.Framework.TearDownAttribute()] - public async global::System.Threading.Tasks.Task TestTearDownAsync() - { - if ((testRunner == null)) - { - return; - } - try - { - await testRunner.OnScenarioEndAsync(); - } - finally - { - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - testRunner = null; - } - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, global::Reqnroll.RuleInfo ruleInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo, ruleInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(global::NUnit.Framework.TestContext.CurrentContext); - } - - public async global::System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() - { -#line 4 -#line hidden - global::Reqnroll.Table table20 = new global::Reqnroll.Table(new string[] { - "Role Name"}); - table20.AddRow(new string[] { - "Estate"}); -#line 6 - await testRunner.GivenAsync("I create the following roles", ((string)(null)), table20, "Given "); -#line hidden - global::Reqnroll.Table table21 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description"}); - table21.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); - table21.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST Scope", - "Scope for Transaction Processor REST"}); - table21.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)), table21, "Given "); -#line hidden - global::Reqnroll.Table table22 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Secret", - "Scopes", - "UserClaims"}); - table22.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "merchantId,estateId,role"}); - table22.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST", - "Secret1", - "transactionProcessor", - "merchantId,estateId,role"}); - table22.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)), table22, "Given "); -#line hidden - global::Reqnroll.Table table23 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description", - "UserClaims"}); - table23.AddRow(new string[] { - "openid", - "Your user identifier", - "", - "sub"}); - table23.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"}); - table23.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)), table23, "Given "); -#line hidden - global::Reqnroll.Table table24 = new global::Reqnroll.Table(new string[] { - "ClientId", - "Name", - "Secret", - "Scopes", - "GrantTypes", - "RedirectUris", - "PostLogoutRedirectUris", - "RequireConsent", - "AllowOfflineAccess", - "ClientUri"}); - table24.AddRow(new string[] { - "serviceClient", - "Service Client", - "Secret1", - "estateManagement,transactionProcessor", - "client_credentials", - "", - "", - "", - "", - ""}); - table24.AddRow(new string[] { - "estateUIClient", - "Merchant Client", - "Secret1", - "estateManagement,fileProcessor,transactionProcessor,openid,email,profile", - "hybrid", - "https://localhost:[port]/signin-oidc", - "https://localhost:[port]/signout-oidc", - "false", - "true", - "https://[url]:[port]"}); -#line 28 - await testRunner.GivenAsync("I create the following clients", ((string)(null)), table24, "Given "); -#line hidden - global::Reqnroll.Table table25 = new global::Reqnroll.Table(new string[] { - "ClientId"}); - table25.AddRow(new string[] { - "serviceClient"}); -#line 33 - await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table25, "Given "); -#line hidden - global::Reqnroll.Table table26 = new global::Reqnroll.Table(new string[] { - "EstateName"}); - table26.AddRow(new string[] { - "Test Estate"}); -#line 37 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table26, "Given "); -#line hidden - global::Reqnroll.Table table27 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table27.AddRow(new string[] { - "Test Estate", - "Test Operator", - "True", - "True"}); -#line 41 - await testRunner.AndAsync("I have created the following operators", ((string)(null)), table27, "And "); -#line hidden - global::Reqnroll.Table table28 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table28.AddRow(new string[] { - "Test Estate", - "Test Operator"}); -#line 45 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table28, "And "); -#line hidden - global::Reqnroll.Table table29 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "EstateName"}); - table29.AddRow(new string[] { - "estateuser@testestate1.co.uk", - "123456", - "TestEstate", - "User1", - "Test Estate"}); -#line 49 - await testRunner.AndAsync("I have created the following security users", ((string)(null)), table29, "And "); -#line hidden - } - - private static global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages InitializeCucumberMessages() - { - return new global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages("Tests/EstateTests.feature.ndjson", 4); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("I Can Log Into The Application")] - public async global::System.Threading.Tasks.Task ICanLogIntoTheApplication() - { - string[] tagsOfScenario = ((string[])(null)); - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "0"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("I Can Log Into The Application", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 54 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 56 - await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 58 - await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 60 - await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 62 - 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 64 - await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("View Estate Details")] - [global::NUnit.Framework.CategoryAttribute("PRTest")] - public async global::System.Threading.Tasks.Task ViewEstateDetails() - { - string[] tagsOfScenario = new string[] { - "PRTest"}; - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "1"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("View Estate Details", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 67 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 69 - await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 71 - await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 73 - await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 75 - 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 77 - await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 79 - await testRunner.GivenAsync("I click on the My Estate sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 81 - await testRunner.ThenAsync("I am presented with the View Estate Page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table30 = new global::Reqnroll.Table(new string[] { - "EstateName"}); - table30.AddRow(new string[] { - "Test Estate"}); -#line 83 - await testRunner.AndAsync("My Estate Details will be shown", ((string)(null)), table30, "And "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/EstateManagementUI.BlazorIntegrationTests/Tests/MerchantTests.feature b/EstateManagementUI.BlazorIntegrationTests/Tests/MerchantTests.feature deleted file mode 100644 index cf80f96f..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Tests/MerchantTests.feature +++ /dev/null @@ -1,254 +0,0 @@ -@base @shared @uigeneral -Feature: Merchant Tests - -Background: - - Given I create the following roles - | Role Name | - | Estate | - | Merchant | - - Given I create the following api scopes - | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | - | transactionProcessor | Transaction Processor REST Scope | Scope for Transaction Processor REST | - | fileProcessor | File Processor REST Scope | Scope for File Processor REST | - - Given I create the following api resources - | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | merchantId,estateId,role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | merchantId,estateId,role | - | fileProcessor | File Processor REST | Secret1 | fileProcessor | merchantId,estateId,role | - - Given I create the following identity resources - | Name | DisplayName | Description | UserClaims | - | openid | Your user identifier | | sub | - | profile | User profile | Your user profile information (first name, last name, etc.) | name,role,email,given_name,middle_name,family_name,estateId,merchantId | - | email | Email | Email and Email Verified Flags | email_verified,email | - - Given I create the following clients - | ClientId | Name | Secret | Scopes | GrantTypes | RedirectUris | PostLogoutRedirectUris | RequireConsent | AllowOfflineAccess | ClientUri | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor | client_credentials | | | | | | - | estateUIClient | Merchant Client | Secret1 | estateManagement,fileProcessor,transactionProcessor,openid,email,profile | hybrid | https://localhost:[port]/signin-oidc | https://localhost:[port]/signout-oidc | false | true | https://[url]:[port] | - - Given I have a token to access the estate management resource - | ClientId | - | serviceClient | - - Given I have created the following estates - | EstateName | - | Test Estate | - - And I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator | True | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator | - - And I have created the following security users - | EmailAddress | Password | GivenName | FamilyName | EstateName | - | estateuser@testestate1.co.uk | 123456 | TestEstate | User1 | Test Estate | - - Given I create the following merchants - | MerchantName | SettlementSchedule | AddressLine1 | Town | Region | Country | ContactName | EmailAddress | EstateName | - | Test Merchant 1 | Immediate | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant1.co.uk | Test Estate | - | Test Merchant 2 | Weekly | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant2.co.uk | Test Estate | - | Test Merchant 3 | Monthly | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant3.co.uk | Test Estate | - - When I assign the following operator to the merchants - | OperatorName | MerchantName | MerchantNumber | TerminalNumber | EstateName | - | Test Operator | Test Merchant 1 | 00000001 | 10000001 | Test Estate | - | Test Operator | Test Merchant 2 | 00000001 | 10000001 | Test Estate | - | Test Operator | Test Merchant 3 | 00000001 | 10000001 | Test Estate | - - When I create the following security users - | EmailAddress | Password | GivenName | FamilyName | MerchantName | EstateName | - | merchantuser1@testmerchant1.co.uk | 123456 | TestMerchant | User1 | Test Merchant 1 | Test Estate | - | merchantuser1@testmerchant2.co.uk | 123456 | TestMerchant | User1 | Test Merchant 2 | Test Estate | - | merchantuser1@testmerchant3.co.uk | 123456 | TestMerchant | User1 | Test Merchant 3 | Test Estate | - - When I add the following devices to the merchant - | DeviceIdentifier | MerchantName | EstateName | - | TestDevice1 | Test Merchant 1 | Test Estate | - | TestDevice2 | Test Merchant 2 | Test Estate | - - Given I am on the application home page - - And I click on the Sign In Button - - Then I am presented with a login screen - - When I login with the username 'estateuser@testestate1.co.uk' and password '123456' - - Then I am presented with the Estate Administrator Dashboard - -@PRTest -Scenario: Merchant PR Test - - 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 New Merchant Button - Then the Add New Merchant Screen is displayed - When I enter the following details for the new Merchant - | MerchantName | SettlementSchedule | AddressLine1 | Town | Region | Country | ContactName | EmailAddress | - | Test Merchant 4 | Immediate | Address Line 1 | TestTown | Region | Country | Test Contact 4 | 1@2.com | - And click the Create Merchant button - 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 | - | Test Merchant 4 | Immediate | Test Contact 4 | Address Line 1 | TestTown | - When I click on the Edit Merchant Button for 'Test Merchant 1' - Then the Edit Merchant Screen is displayed - When I enter the following details for the updated Merchant - | Tab | Field | Value | - | Merchant Details | MerchantName | Test Merchant 1 Update | - | Address Details | AddressLine1 | Address Line 1 Update | - | Contact Details | ContactName | Test Contact 1 Update | - And click the Update Merchant button - 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 Update | Immediate | Test Contact 1 Update | Address Line 1 Update | TestTown | - | Test Merchant 2 | Weekly | Test Contact 1 | Address Line 1 | TestTown | - | Test Merchant 3 | Monthly | Test Contact 1 | Address Line 1 | TestTown | - | Test Merchant 4 | Immediate | Test Contact 4 | Address Line 1 | TestTown | - #When I click on the Make Deposit Button for 'Test Merchant 1 Update' - #Then the Make Deposit Screen is displayed - #When I enter the following details for the deposit - #| Amount | Date | Reference | - #| 1000.00 | Today | Test Deposit 1 | - #And click the Make Deposit button - #Then I am presented with the Merchants List Screen - When I click on the View Merchant Button for 'Test Merchant 1 Update' - Then the View Merchant Screen is displayed - - -Scenario: Merchant Operator Management - Given I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator1 | True | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator1 | - - 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 1' - Then the Edit Merchant Screen is displayed - - When I click on the Operators tab - Then I am presented with the Merchants Operator List Screen - And the following operators are displayed in the list - | OperatorName | MerchantNumber | TerminalNumber | - | Test Operator | 00000001 | 10000001 | - When I click on the Add Operator Button - Then the Assign Operator Dialog will be displayed - When I enter the following details for the Operator - | OperatorName | MerchantNumber | TerminalNumber | - | Test Operator1 | 00000111 | 10000111 | - And click the Assign Operator button - Then I am presented with the Merchants Operator List Screen - And the following operators are displayed in the list - | OperatorName | MerchantNumber | TerminalNumber | IsDeleted | - | Test Operator | 00000001 | 10000001 | False | - | Test Operator1 | 00000111 | 10000111 | False | - When I click on the Remove Operator for 'Test Operator1' - Then I am presented with the Merchants Operator List Screen - And the following operators are displayed in the list - | OperatorName | MerchantNumber | TerminalNumber | IsDeleted | - | Test Operator | 00000001 | 10000001 | False | - | Test Operator1 | 00000111 | 10000111 | True | - -Scenario: Merchant Contract Management - Given I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator1 | True | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator1 | - - # Does this assignt the contract to the estate automatically ?? - Given I have created the following contracts - | EstateName | OperatorName | ContractDescription | - | Test Estate | Test Operator1 | Operator 1 Contract | - - 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 1' - Then the Edit Merchant Screen is displayed - - When I click on the Contracts tab - Then I am presented with the Merchants Contract List Screen - And the following contracts are displayed in the list - | ContractName | IsDeleted | - - When I click on the Add Contract Button - Then the Assign Contract Dialog will be displayed - When I enter the following details for the Contract - | ContractName | - | Operator 1 Contract | - And click the Assign Contract button - Then I am presented with the Merchants Contract List Screen - And the following contracts are displayed in the list - | ContractName | IsDeleted | - | Operator 1 Contract | False | - - When I click on the Remove Contract for 'Operator 1 Contract' - Then I am presented with the Merchants Contract List Screen - 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.BlazorIntegrationTests/Tests/MerchantTests.feature.cs b/EstateManagementUI.BlazorIntegrationTests/Tests/MerchantTests.feature.cs deleted file mode 100644 index f1fb2fcb..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Tests/MerchantTests.feature.cs +++ /dev/null @@ -1,1046 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://reqnroll.net/). -// Reqnroll Version:3.0.0.0 -// Reqnroll Generator Version:3.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -using Reqnroll; -namespace EstateManagementUI.BlazorIntegrationTests.Tests -{ - - - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "3.0.0.0")] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::NUnit.Framework.TestFixtureAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Merchant Tests")] - [global::NUnit.Framework.FixtureLifeCycleAttribute(global::NUnit.Framework.LifeCycle.InstancePerTestCase)] - [global::NUnit.Framework.CategoryAttribute("base")] - [global::NUnit.Framework.CategoryAttribute("shared")] - [global::NUnit.Framework.CategoryAttribute("uigeneral")] - public partial class MerchantTestsFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "base", - "shared", - "uigeneral"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Merchant Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags, InitializeCucumberMessages()); - -#line 1 "MerchantTests.feature" -#line hidden - - [global::NUnit.Framework.OneTimeSetUpAttribute()] - public static async global::System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [global::NUnit.Framework.OneTimeTearDownAttribute()] - public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() - { - await global::Reqnroll.TestRunnerManager.ReleaseFeatureAsync(featureInfo); - } - - [global::NUnit.Framework.SetUpAttribute()] - public async global::System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - try - { - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - } - finally - { - if (((testRunner.FeatureContext != null) - && testRunner.FeatureContext.BeforeFeatureHookFailed)) - { - throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - } - - [global::NUnit.Framework.TearDownAttribute()] - public async global::System.Threading.Tasks.Task TestTearDownAsync() - { - if ((testRunner == null)) - { - return; - } - try - { - await testRunner.OnScenarioEndAsync(); - } - finally - { - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - testRunner = null; - } - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, global::Reqnroll.RuleInfo ruleInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo, ruleInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(global::NUnit.Framework.TestContext.CurrentContext); - } - - public async global::System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() - { -#line 4 -#line hidden - global::Reqnroll.Table table31 = new global::Reqnroll.Table(new string[] { - "Role Name"}); - table31.AddRow(new string[] { - "Estate"}); - table31.AddRow(new string[] { - "Merchant"}); -#line 6 - await testRunner.GivenAsync("I create the following roles", ((string)(null)), table31, "Given "); -#line hidden - global::Reqnroll.Table table32 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description"}); - table32.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); - table32.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST Scope", - "Scope for Transaction Processor REST"}); - table32.AddRow(new string[] { - "fileProcessor", - "File Processor REST Scope", - "Scope for File Processor REST"}); -#line 11 - await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table32, "Given "); -#line hidden - global::Reqnroll.Table table33 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Secret", - "Scopes", - "UserClaims"}); - table33.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "merchantId,estateId,role"}); - table33.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST", - "Secret1", - "transactionProcessor", - "merchantId,estateId,role"}); - table33.AddRow(new string[] { - "fileProcessor", - "File Processor REST", - "Secret1", - "fileProcessor", - "merchantId,estateId,role"}); -#line 17 - await testRunner.GivenAsync("I create the following api resources", ((string)(null)), table33, "Given "); -#line hidden - global::Reqnroll.Table table34 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description", - "UserClaims"}); - table34.AddRow(new string[] { - "openid", - "Your user identifier", - "", - "sub"}); - table34.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"}); - table34.AddRow(new string[] { - "email", - "Email", - "Email and Email Verified Flags", - "email_verified,email"}); -#line 23 - await testRunner.GivenAsync("I create the following identity resources", ((string)(null)), table34, "Given "); -#line hidden - global::Reqnroll.Table table35 = new global::Reqnroll.Table(new string[] { - "ClientId", - "Name", - "Secret", - "Scopes", - "GrantTypes", - "RedirectUris", - "PostLogoutRedirectUris", - "RequireConsent", - "AllowOfflineAccess", - "ClientUri"}); - table35.AddRow(new string[] { - "serviceClient", - "Service Client", - "Secret1", - "estateManagement,transactionProcessor", - "client_credentials", - "", - "", - "", - "", - ""}); - table35.AddRow(new string[] { - "estateUIClient", - "Merchant Client", - "Secret1", - "estateManagement,fileProcessor,transactionProcessor,openid,email,profile", - "hybrid", - "https://localhost:[port]/signin-oidc", - "https://localhost:[port]/signout-oidc", - "false", - "true", - "https://[url]:[port]"}); -#line 29 - await testRunner.GivenAsync("I create the following clients", ((string)(null)), table35, "Given "); -#line hidden - global::Reqnroll.Table table36 = new global::Reqnroll.Table(new string[] { - "ClientId"}); - table36.AddRow(new string[] { - "serviceClient"}); -#line 34 - await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table36, "Given "); -#line hidden - global::Reqnroll.Table table37 = new global::Reqnroll.Table(new string[] { - "EstateName"}); - table37.AddRow(new string[] { - "Test Estate"}); -#line 38 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table37, "Given "); -#line hidden - global::Reqnroll.Table table38 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table38.AddRow(new string[] { - "Test Estate", - "Test Operator", - "True", - "True"}); -#line 42 - await testRunner.AndAsync("I have created the following operators", ((string)(null)), table38, "And "); -#line hidden - global::Reqnroll.Table table39 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table39.AddRow(new string[] { - "Test Estate", - "Test Operator"}); -#line 46 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table39, "And "); -#line hidden - global::Reqnroll.Table table40 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "EstateName"}); - table40.AddRow(new string[] { - "estateuser@testestate1.co.uk", - "123456", - "TestEstate", - "User1", - "Test Estate"}); -#line 50 - await testRunner.AndAsync("I have created the following security users", ((string)(null)), table40, "And "); -#line hidden - global::Reqnroll.Table table41 = new global::Reqnroll.Table(new string[] { - "MerchantName", - "SettlementSchedule", - "AddressLine1", - "Town", - "Region", - "Country", - "ContactName", - "EmailAddress", - "EstateName"}); - table41.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Address Line 1", - "TestTown", - "Test Region", - "United Kingdom", - "Test Contact 1", - "testcontact1@merchant1.co.uk", - "Test Estate"}); - table41.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Address Line 1", - "TestTown", - "Test Region", - "United Kingdom", - "Test Contact 1", - "testcontact1@merchant2.co.uk", - "Test Estate"}); - table41.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Address Line 1", - "TestTown", - "Test Region", - "United Kingdom", - "Test Contact 1", - "testcontact1@merchant3.co.uk", - "Test Estate"}); -#line 54 - await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table41, "Given "); -#line hidden - global::Reqnroll.Table table42 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "MerchantName", - "MerchantNumber", - "TerminalNumber", - "EstateName"}); - table42.AddRow(new string[] { - "Test Operator", - "Test Merchant 1", - "00000001", - "10000001", - "Test Estate"}); - table42.AddRow(new string[] { - "Test Operator", - "Test Merchant 2", - "00000001", - "10000001", - "Test Estate"}); - table42.AddRow(new string[] { - "Test Operator", - "Test Merchant 3", - "00000001", - "10000001", - "Test Estate"}); -#line 60 - await testRunner.WhenAsync("I assign the following operator to the merchants", ((string)(null)), table42, "When "); -#line hidden - global::Reqnroll.Table table43 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "MerchantName", - "EstateName"}); - table43.AddRow(new string[] { - "merchantuser1@testmerchant1.co.uk", - "123456", - "TestMerchant", - "User1", - "Test Merchant 1", - "Test Estate"}); - table43.AddRow(new string[] { - "merchantuser1@testmerchant2.co.uk", - "123456", - "TestMerchant", - "User1", - "Test Merchant 2", - "Test Estate"}); - table43.AddRow(new string[] { - "merchantuser1@testmerchant3.co.uk", - "123456", - "TestMerchant", - "User1", - "Test Merchant 3", - "Test Estate"}); -#line 66 - await testRunner.WhenAsync("I create the following security users", ((string)(null)), table43, "When "); -#line hidden - global::Reqnroll.Table table44 = new global::Reqnroll.Table(new string[] { - "DeviceIdentifier", - "MerchantName", - "EstateName"}); - table44.AddRow(new string[] { - "TestDevice1", - "Test Merchant 1", - "Test Estate"}); - table44.AddRow(new string[] { - "TestDevice2", - "Test Merchant 2", - "Test Estate"}); -#line 72 - await testRunner.WhenAsync("I add the following devices to the merchant", ((string)(null)), table44, "When "); -#line hidden -#line 77 - await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 79 - await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 81 - await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#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 85 - await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - - private static global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages InitializeCucumberMessages() - { - return new global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages("Tests/MerchantTests.feature.ndjson", 6); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Merchant PR Test")] - [global::NUnit.Framework.CategoryAttribute("PRTest")] - public async global::System.Threading.Tasks.Task MerchantPRTest() - { - string[] tagsOfScenario = new string[] { - "PRTest"}; - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "0"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant PR Test", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 88 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 90 - await testRunner.GivenAsync("I click on the My Merchants sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#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[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table45.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table45.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table45.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); -#line 92 - await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table45, "And "); -#line hidden -#line 97 - await testRunner.WhenAsync("I click on the New Merchant Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#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[] { - "MerchantName", - "SettlementSchedule", - "AddressLine1", - "Town", - "Region", - "Country", - "ContactName", - "EmailAddress"}); - table46.AddRow(new string[] { - "Test Merchant 4", - "Immediate", - "Address Line 1", - "TestTown", - "Region", - "Country", - "Test Contact 4", - "1@2.com"}); -#line 99 - await testRunner.WhenAsync("I enter the following details for the new Merchant", ((string)(null)), table46, "When "); -#line hidden -#line 102 - await testRunner.AndAsync("click the Create Merchant button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table47.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table47.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table47.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table47.AddRow(new string[] { - "Test Merchant 4", - "Immediate", - "Test Contact 4", - "Address Line 1", - "TestTown"}); -#line 104 - await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table47, "And "); -#line hidden -#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 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[] { - "Tab", - "Field", - "Value"}); - table48.AddRow(new string[] { - "Merchant Details", - "MerchantName", - "Test Merchant 1 Update"}); - table48.AddRow(new string[] { - "Address Details", - "AddressLine1", - "Address Line 1 Update"}); - table48.AddRow(new string[] { - "Contact Details", - "ContactName", - "Test Contact 1 Update"}); -#line 112 - await testRunner.WhenAsync("I enter the following details for the updated Merchant", ((string)(null)), table48, "When "); -#line hidden -#line 117 - await testRunner.AndAsync("click the Update Merchant button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table49.AddRow(new string[] { - "Test Merchant 1 Update", - "Immediate", - "Test Contact 1 Update", - "Address Line 1 Update", - "TestTown"}); - table49.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table49.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table49.AddRow(new string[] { - "Test Merchant 4", - "Immediate", - "Test Contact 4", - "Address Line 1", - "TestTown"}); -#line 119 - await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table49, "And "); -#line hidden -#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 133 - await testRunner.ThenAsync("the View Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Merchant Operator Management")] - public async global::System.Threading.Tasks.Task MerchantOperatorManagement() - { - string[] tagsOfScenario = ((string[])(null)); - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "1"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Operator Management", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 136 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden - global::Reqnroll.Table table50 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table50.AddRow(new string[] { - "Test Estate", - "Test Operator1", - "True", - "True"}); -#line 137 - await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table50, "Given "); -#line hidden - global::Reqnroll.Table table51 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table51.AddRow(new string[] { - "Test Estate", - "Test Operator1"}); -#line 141 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table51, "And "); -#line hidden -#line 145 - await testRunner.GivenAsync("I click on the My Merchants sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#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 table52 = new global::Reqnroll.Table(new string[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table52.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table52.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table52.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); -#line 147 - await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table52, "And "); -#line hidden -#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 154 - await testRunner.ThenAsync("the Edit Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 156 - await testRunner.WhenAsync("I click on the Operators tab", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#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 table53 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "MerchantNumber", - "TerminalNumber"}); - table53.AddRow(new string[] { - "Test Operator", - "00000001", - "10000001"}); -#line 158 - await testRunner.AndAsync("the following operators are displayed in the list", ((string)(null)), table53, "And "); -#line hidden -#line 161 - await testRunner.WhenAsync("I click on the Add Operator Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 162 - await testRunner.ThenAsync("the Assign Operator Dialog will be displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table54 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "MerchantNumber", - "TerminalNumber"}); - table54.AddRow(new string[] { - "Test Operator1", - "00000111", - "10000111"}); -#line 163 - await testRunner.WhenAsync("I enter the following details for the Operator", ((string)(null)), table54, "When "); -#line hidden -#line 166 - await testRunner.AndAsync("click the Assign Operator button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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 table55 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "MerchantNumber", - "TerminalNumber", - "IsDeleted"}); - table55.AddRow(new string[] { - "Test Operator", - "00000001", - "10000001", - "False"}); - table55.AddRow(new string[] { - "Test Operator1", - "00000111", - "10000111", - "False"}); -#line 168 - await testRunner.AndAsync("the following operators are displayed in the list", ((string)(null)), table55, "And "); -#line hidden -#line 172 - await testRunner.WhenAsync("I click on the Remove Operator for \'Test Operator1\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#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 table56 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "MerchantNumber", - "TerminalNumber", - "IsDeleted"}); - table56.AddRow(new string[] { - "Test Operator", - "00000001", - "10000001", - "False"}); - table56.AddRow(new string[] { - "Test Operator1", - "00000111", - "10000111", - "True"}); -#line 174 - await testRunner.AndAsync("the following operators are displayed in the list", ((string)(null)), table56, "And "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Merchant Contract Management")] - public async global::System.Threading.Tasks.Task MerchantContractManagement() - { - string[] tagsOfScenario = ((string[])(null)); - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "2"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Contract Management", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 179 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden - global::Reqnroll.Table table57 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table57.AddRow(new string[] { - "Test Estate", - "Test Operator1", - "True", - "True"}); -#line 180 - await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table57, "Given "); -#line hidden - global::Reqnroll.Table table58 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table58.AddRow(new string[] { - "Test Estate", - "Test Operator1"}); -#line 184 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table58, "And "); -#line hidden - global::Reqnroll.Table table59 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "ContractDescription"}); - table59.AddRow(new string[] { - "Test Estate", - "Test Operator1", - "Operator 1 Contract"}); -#line 189 - await testRunner.GivenAsync("I have created the following contracts", ((string)(null)), table59, "Given "); -#line hidden -#line 193 - await testRunner.GivenAsync("I click on the My Merchants sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#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 table60 = new global::Reqnroll.Table(new string[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table60.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table60.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table60.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); -#line 195 - await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table60, "And "); -#line hidden -#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 202 - await testRunner.ThenAsync("the Edit Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 204 - await testRunner.WhenAsync("I click on the Contracts tab", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#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 table61 = new global::Reqnroll.Table(new string[] { - "ContractName", - "IsDeleted"}); -#line 206 - await testRunner.AndAsync("the following contracts are displayed in the list", ((string)(null)), table61, "And "); -#line hidden -#line 209 - await testRunner.WhenAsync("I click on the Add Contract Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 210 - await testRunner.ThenAsync("the Assign Contract Dialog will be displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table62 = new global::Reqnroll.Table(new string[] { - "ContractName"}); - table62.AddRow(new string[] { - "Operator 1 Contract"}); -#line 211 - await testRunner.WhenAsync("I enter the following details for the Contract", ((string)(null)), table62, "When "); -#line hidden -#line 214 - await testRunner.AndAsync("click the Assign Contract button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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 table63 = new global::Reqnroll.Table(new string[] { - "ContractName", - "IsDeleted"}); - table63.AddRow(new string[] { - "Operator 1 Contract", - "False"}); -#line 216 - await testRunner.AndAsync("the following contracts are displayed in the list", ((string)(null)), table63, "And "); -#line hidden -#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 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 table64 = new global::Reqnroll.Table(new string[] { - "ContractName", - "IsDeleted"}); - table64.AddRow(new string[] { - "Operator 1 Contract", - "True"}); -#line 222 - await testRunner.AndAsync("the following contracts are displayed in the list", ((string)(null)), table64, "And "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Merchant Device Management")] - public async global::System.Threading.Tasks.Task MerchantDeviceManagement() - { - string[] tagsOfScenario = ((string[])(null)); - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "3"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Device Management", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 227 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - 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 table65 = new global::Reqnroll.Table(new string[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table65.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table65.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table65.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)), table65, "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 table66 = new global::Reqnroll.Table(new string[] { - "DeviceIdentifier"}); -#line 242 - await testRunner.AndAsync("the following devices are displayed in the list", ((string)(null)), table66, "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 table67 = new global::Reqnroll.Table(new string[] { - "MerchantDevice"}); - table67.AddRow(new string[] { - "123456ABCDEF"}); -#line 247 - await testRunner.WhenAsync("I enter the following details for the Device", ((string)(null)), table67, "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 table68 = new global::Reqnroll.Table(new string[] { - "DeviceIdentifier"}); - table68.AddRow(new string[] { - "123456ABCDEF"}); -#line 252 - await testRunner.AndAsync("the following devices are displayed in the list", ((string)(null)), table68, "And "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/EstateManagementUI.BlazorIntegrationTests/Tests/OperatorTests.feature b/EstateManagementUI.BlazorIntegrationTests/Tests/OperatorTests.feature deleted file mode 100644 index 4fbc56a9..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Tests/OperatorTests.feature +++ /dev/null @@ -1,102 +0,0 @@ -@base @shared @uigeneral -Feature: Operator Tests - -Background: - - Given I create the following roles - | Role Name | - | Estate | - - Given I create the following api scopes - | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | - | transactionProcessor | Transaction Processor REST Scope | Scope for Transaction Processor REST | - | fileProcessor | File Processor REST Scope | Scope for File Processor REST | - - Given I create the following api resources - | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | merchantId,estateId,role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | merchantId,estateId,role | - | fileProcessor | File Processor REST | Secret1 | fileProcessor | merchantId,estateId,role | - - Given I create the following identity resources - | Name | DisplayName | Description | UserClaims | - | openid | Your user identifier | | sub | - | profile | User profile | Your user profile information (first name, last name, etc.) | name,role,email,given_name,middle_name,family_name,estateId,merchantId | - | email | Email | Email and Email Verified Flags | email_verified,email | - - Given I create the following clients - | ClientId | Name | Secret | Scopes | GrantTypes | RedirectUris | PostLogoutRedirectUris | RequireConsent | AllowOfflineAccess | ClientUri | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor | client_credentials | | | | | | - | estateUIClient | Merchant Client | Secret1 | estateManagement,fileProcessor,transactionProcessor,openid,email,profile | hybrid | https://localhost:[port]/signin-oidc | https://localhost:[port]/signout-oidc | false | true | https://[url]:[port] | - - Given I have a token to access the estate management resource - | ClientId | - | serviceClient | - - Given I have created the following estates - | EstateName | - | Test Estate | - - And I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator 1 | True | True | - | Test Estate | Test Operator 2 | True | False | - | Test Estate | Test Operator 3 | False | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator 1 | - | Test Estate | Test Operator 2 | - | Test Estate | Test Operator 3 | - - And I have created the following security users - | EmailAddress | Password | GivenName | FamilyName | EstateName | - | estateuser@testestate1.co.uk | 123456 | TestEstate | User1 | Test Estate | - - Given I am on the application home page - - And I click on the Sign In Button - - Then I am presented with a login screen - - When I login with the username 'estateuser@testestate1.co.uk' and password '123456' - - Then I am presented with the Estate Administrator Dashboard - -@PRTest -Scenario: Operator PR Test - - Given I click on the My Operators sidebar option - Then I am presented with the Operators List Screen - And the following operator details are in the list - | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Operator 1 | Yes | Yes | - | Test Operator 2 | Yes | No | - | Test Operator 3 | No | Yes | - When I click on the New Operator Button - Then the Add New Operator Screen is displayed - When I enter the following details for the new Operator - | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Operator 4 | Yes | Yes | - And click the Save Operator button - Then I am presented with the Operators List Screen - And the following operator details are in the list - | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Operator 1 | Yes | Yes | - | Test Operator 2 | Yes | No | - | Test Operator 3 | No | Yes | - | Test Operator 4 | Yes | Yes | - When I click on the Edit Operator Button for 'Test Operator 1' - Then the Edit Operator Screen is displayed - When I enter the following new details for the Operator - | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Operator 1 update | No | No | - And click the Save Operator button - Then I am presented with the Operators List Screen - And the following operator details are in the list - | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Operator 1 update | No | No | - | Test Operator 2 | Yes | No | - | Test Operator 3 | No | Yes | - | Test Operator 4 | Yes | Yes | \ No newline at end of file diff --git a/EstateManagementUI.BlazorIntegrationTests/Tests/OperatorTests.feature.cs b/EstateManagementUI.BlazorIntegrationTests/Tests/OperatorTests.feature.cs deleted file mode 100644 index b1b13694..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/Tests/OperatorTests.feature.cs +++ /dev/null @@ -1,465 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://reqnroll.net/). -// Reqnroll Version:3.0.0.0 -// Reqnroll Generator Version:3.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -using Reqnroll; -namespace EstateManagementUI.BlazorIntegrationTests.Tests -{ - - - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "3.0.0.0")] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::NUnit.Framework.TestFixtureAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Operator Tests")] - [global::NUnit.Framework.FixtureLifeCycleAttribute(global::NUnit.Framework.LifeCycle.InstancePerTestCase)] - [global::NUnit.Framework.CategoryAttribute("base")] - [global::NUnit.Framework.CategoryAttribute("shared")] - [global::NUnit.Framework.CategoryAttribute("uigeneral")] - public partial class OperatorTestsFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "base", - "shared", - "uigeneral"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Operator Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags, InitializeCucumberMessages()); - -#line 1 "OperatorTests.feature" -#line hidden - - [global::NUnit.Framework.OneTimeSetUpAttribute()] - public static async global::System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [global::NUnit.Framework.OneTimeTearDownAttribute()] - public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() - { - await global::Reqnroll.TestRunnerManager.ReleaseFeatureAsync(featureInfo); - } - - [global::NUnit.Framework.SetUpAttribute()] - public async global::System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - try - { - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - } - finally - { - if (((testRunner.FeatureContext != null) - && testRunner.FeatureContext.BeforeFeatureHookFailed)) - { - throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - } - - [global::NUnit.Framework.TearDownAttribute()] - public async global::System.Threading.Tasks.Task TestTearDownAsync() - { - if ((testRunner == null)) - { - return; - } - try - { - await testRunner.OnScenarioEndAsync(); - } - finally - { - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - testRunner = null; - } - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, global::Reqnroll.RuleInfo ruleInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo, ruleInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(global::NUnit.Framework.TestContext.CurrentContext); - } - - public async global::System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() - { -#line 4 -#line hidden - global::Reqnroll.Table table69 = new global::Reqnroll.Table(new string[] { - "Role Name"}); - table69.AddRow(new string[] { - "Estate"}); -#line 6 - await testRunner.GivenAsync("I create the following roles", ((string)(null)), table69, "Given "); -#line hidden - global::Reqnroll.Table table70 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description"}); - table70.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); - table70.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST Scope", - "Scope for Transaction Processor REST"}); - table70.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)), table70, "Given "); -#line hidden - global::Reqnroll.Table table71 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Secret", - "Scopes", - "UserClaims"}); - table71.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "merchantId,estateId,role"}); - table71.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST", - "Secret1", - "transactionProcessor", - "merchantId,estateId,role"}); - table71.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)), table71, "Given "); -#line hidden - global::Reqnroll.Table table72 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description", - "UserClaims"}); - table72.AddRow(new string[] { - "openid", - "Your user identifier", - "", - "sub"}); - table72.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"}); - table72.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)), table72, "Given "); -#line hidden - global::Reqnroll.Table table73 = new global::Reqnroll.Table(new string[] { - "ClientId", - "Name", - "Secret", - "Scopes", - "GrantTypes", - "RedirectUris", - "PostLogoutRedirectUris", - "RequireConsent", - "AllowOfflineAccess", - "ClientUri"}); - table73.AddRow(new string[] { - "serviceClient", - "Service Client", - "Secret1", - "estateManagement,transactionProcessor", - "client_credentials", - "", - "", - "", - "", - ""}); - table73.AddRow(new string[] { - "estateUIClient", - "Merchant Client", - "Secret1", - "estateManagement,fileProcessor,transactionProcessor,openid,email,profile", - "hybrid", - "https://localhost:[port]/signin-oidc", - "https://localhost:[port]/signout-oidc", - "false", - "true", - "https://[url]:[port]"}); -#line 28 - await testRunner.GivenAsync("I create the following clients", ((string)(null)), table73, "Given "); -#line hidden - global::Reqnroll.Table table74 = new global::Reqnroll.Table(new string[] { - "ClientId"}); - table74.AddRow(new string[] { - "serviceClient"}); -#line 33 - await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table74, "Given "); -#line hidden - global::Reqnroll.Table table75 = new global::Reqnroll.Table(new string[] { - "EstateName"}); - table75.AddRow(new string[] { - "Test Estate"}); -#line 37 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table75, "Given "); -#line hidden - global::Reqnroll.Table table76 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table76.AddRow(new string[] { - "Test Estate", - "Test Operator 1", - "True", - "True"}); - table76.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "True", - "False"}); - table76.AddRow(new string[] { - "Test Estate", - "Test Operator 3", - "False", - "True"}); -#line 41 - await testRunner.AndAsync("I have created the following operators", ((string)(null)), table76, "And "); -#line hidden - global::Reqnroll.Table table77 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table77.AddRow(new string[] { - "Test Estate", - "Test Operator 1"}); - table77.AddRow(new string[] { - "Test Estate", - "Test Operator 2"}); - table77.AddRow(new string[] { - "Test Estate", - "Test Operator 3"}); -#line 47 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table77, "And "); -#line hidden - global::Reqnroll.Table table78 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "EstateName"}); - table78.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)), table78, "And "); -#line hidden -#line 57 - await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 59 - await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 61 - await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 63 - 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 65 - await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - - private static global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages InitializeCucumberMessages() - { - return new global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages("Tests/OperatorTests.feature.ndjson", 3); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Operator PR Test")] - [global::NUnit.Framework.CategoryAttribute("PRTest")] - public async global::System.Threading.Tasks.Task OperatorPRTest() - { - string[] tagsOfScenario = new string[] { - "PRTest"}; - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "0"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Operator PR Test", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 68 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 70 - await testRunner.GivenAsync("I click on the My Operators sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#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 table79 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table79.AddRow(new string[] { - "Test Operator 1", - "Yes", - "Yes"}); - table79.AddRow(new string[] { - "Test Operator 2", - "Yes", - "No"}); - table79.AddRow(new string[] { - "Test Operator 3", - "No", - "Yes"}); -#line 72 - await testRunner.AndAsync("the following operator details are in the list", ((string)(null)), table79, "And "); -#line hidden -#line 77 - await testRunner.WhenAsync("I click on the New Operator Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 78 - await testRunner.ThenAsync("the Add New Operator Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table80 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table80.AddRow(new string[] { - "Test Operator 4", - "Yes", - "Yes"}); -#line 79 - await testRunner.WhenAsync("I enter the following details for the new Operator", ((string)(null)), table80, "When "); -#line hidden -#line 82 - await testRunner.AndAsync("click the Save Operator button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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 table81 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table81.AddRow(new string[] { - "Test Operator 1", - "Yes", - "Yes"}); - table81.AddRow(new string[] { - "Test Operator 2", - "Yes", - "No"}); - table81.AddRow(new string[] { - "Test Operator 3", - "No", - "Yes"}); - table81.AddRow(new string[] { - "Test Operator 4", - "Yes", - "Yes"}); -#line 84 - await testRunner.AndAsync("the following operator details are in the list", ((string)(null)), table81, "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 "); -#line hidden -#line 91 - await testRunner.ThenAsync("the Edit Operator Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table82 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table82.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)), table82, "When "); -#line hidden -#line 95 - await testRunner.AndAsync("click the Save Operator button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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 table83 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table83.AddRow(new string[] { - "Test Operator 1 update", - "No", - "No"}); - table83.AddRow(new string[] { - "Test Operator 2", - "Yes", - "No"}); - table83.AddRow(new string[] { - "Test Operator 3", - "No", - "Yes"}); - table83.AddRow(new string[] { - "Test Operator 4", - "Yes", - "Yes"}); -#line 97 - await testRunner.AndAsync("the following operator details are in the list", ((string)(null)), table83, "And "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/EstateManagementUI.BlazorIntegrationTests/appsettings.json b/EstateManagementUI.BlazorIntegrationTests/appsettings.json deleted file mode 100644 index e4fcd302..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/appsettings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "TestSettings": { - "SkipRemoteCalls": true, - "EnableTestMode": true - } -} diff --git a/EstateManagementUI.BlazorIntegrationTests/nlog.config b/EstateManagementUI.BlazorIntegrationTests/nlog.config deleted file mode 100644 index b2c330e9..00000000 --- a/EstateManagementUI.BlazorIntegrationTests/nlog.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs b/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs deleted file mode 100644 index bb1533f2..00000000 --- a/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs +++ /dev/null @@ -1,817 +0,0 @@ -using EstateManagementUI.BusinessLogic.Clients; -using EstateManagementUI.BusinessLogic.Models; -using EstateManagementUI.Pages.Merchant; -using EstateManagementUI.Testing; -using EstateReportingAPI.Client; -using EstateReportingAPI.DataTransferObjects; -using FileProcessor.Client; -using Microsoft.Extensions.Configuration; -using Moq; -using SecurityService.Client; -using SecurityService.DataTransferObjects.Responses; -using Shared.General; -using Shared.Logger; -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; -using TransactionProcessor.DataTransferObjects.Responses.Merchant; -using TransactionProcessor.DataTransferObjects.Responses.Operator; -using CreateMerchantModel = EstateManagementUI.BusinessLogic.Models.CreateMerchantModel; -using SettlementSchedule = EstateManagementUI.BusinessLogic.Models.SettlementSchedule; - -namespace EstateManagementUI.BusinessLogic.Tests; - -public class ApiClientTests { - private readonly IApiClient ApiClient; - private readonly Mock TransactionProcessorClient; - private readonly Mock FileProcessorClient; - private readonly Mock EstateReportingApiClient; - private readonly Mock SecurityServiceClient; - - public ApiClientTests() { - Logger.Initialise(NullLogger.Instance); - - this.TransactionProcessorClient = new Mock(); - this.FileProcessorClient = new Mock(); - this.EstateReportingApiClient = new Mock(); - this.SecurityServiceClient = new Mock(); - IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build(); - ConfigurationReader.Initialise(configurationRoot); - this.ApiClient = new ApiClient(this.TransactionProcessorClient.Object, this.FileProcessorClient.Object, this.EstateReportingApiClient.Object, - this.SecurityServiceClient.Object); - } - - - [Fact] - public async Task ApiClient_GetEstate_EstateReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.EstateResponse)); - - var result= await this.ApiClient.GetEstate(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - result.Data.ShouldNotBeNull(); - result.Data.EstateName.ShouldBe(TestData.EstateName); - } - - [Fact] - public async Task ApiClient_GetEstate_ClientCallFailed_ResultFailed() - { - this.TransactionProcessorClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - var result = await this.ApiClient.GetEstate(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetEstate_ClientCallThrewException_ResultFailed() - { - this.TransactionProcessorClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - var result = await this.ApiClient.GetEstate(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetMerchants_MerchantsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.GetMerchants(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantResponses)); - - var result = await this.ApiClient.GetMerchants(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - result.Data.ShouldNotBeNull(); - result.Data.ShouldNotBeEmpty(); - result.Data.Count.ShouldBe(3); - - foreach (MerchantResponse merchantResponse in TestData.MerchantResponses) { - MerchantModel? merchant = result.Data.SingleOrDefault(m => m.MerchantId == merchantResponse.MerchantId); - merchant.ShouldNotBeNull(); - } - } - - [Fact] - public async Task ApiClient_GetMerchants_ClientCallFailed_ResultFailed() - { - this.TransactionProcessorClient.Setup(e => e.GetMerchants(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - Result> result = await this.ApiClient.GetMerchants(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetMerchant_ClientCallFailed_ResultFailed() { - this.TransactionProcessorClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - Result result = await this.ApiClient.GetMerchant(TestData.AccessToken, Guid.NewGuid(), Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetMerchant_MerchantReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantResponse)); - - var result= await this.ApiClient.GetMerchant(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Merchant1Id, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - result.Data.ShouldNotBeNull(); - } - - [Fact] - public async Task ApiClient_GetOperators_OperatorsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.GetOperators(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.OperatorResponses)); - - var result = await this.ApiClient.GetOperators(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - result.Data.ShouldNotBeNull(); - result.Data.ShouldNotBeEmpty(); - result.Data.Count.ShouldBe(2); - - foreach (OperatorResponse operatorResponse in TestData.OperatorResponses) { - OperatorModel? @operatorModel = result.Data.SingleOrDefault(m => m.OperatorId == operatorResponse.OperatorId); - operatorModel.ShouldNotBeNull(); - } - } - - [Fact] - public async Task ApiClient_GetOperators_ClientCallFailed_ResultFailed() { - this.TransactionProcessorClient.Setup(e => e.GetOperators(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - - Result> result = await this.ApiClient.GetOperators(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetOperator_OperatorIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.GetOperator(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.OperatorResponse)); - - Result @operator = await this.ApiClient.GetOperator(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Operator1Id, CancellationToken.None); - @operator.IsSuccess.ShouldBeTrue(); - @operator.ShouldNotBeNull(); - } - - [Fact] - public async Task ApiClient_GetOperator_ClientCallFailed_ResultFailed() { - this.TransactionProcessorClient.Setup(e => e.GetOperator(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - Result result = await this.ApiClient.GetOperator(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Operator1Id, CancellationToken.None); - - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetContracts_ContractsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.GetContracts(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractResponses)); - - - var result = await this.ApiClient.GetContracts(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - - result.Data.ShouldNotBeNull(); - result.Data.ShouldNotBeEmpty(); - result.Data.Count.ShouldBe(1); - - foreach (ContractResponse contractResponse in TestData.ContractResponses) { - ContractModel? contractModel = result.Data.SingleOrDefault(m => m.ContractId == contractResponse.ContractId); - contractModel.ShouldNotBeNull(); - } - } - - [Fact] - public async Task ApiClient_GetContracts_ClientCallFailed_ResultFailed() - { - this.TransactionProcessorClient.Setup(e => e.GetContracts(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - var result = await this.ApiClient.GetContracts(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetContract_ContractIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.GetContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractResponse1)); - - var result = await this.ApiClient.GetContract(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Contract1Id, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - result.Data.ShouldNotBeNull(); - result.Data.ContractId.ShouldBe(TestData.ContractResponse1.ContractId); - result.Data.Description.ShouldBe(TestData.ContractResponse1.Description); - result.Data.OperatorName.ShouldBe(TestData.ContractResponse1.OperatorName); - result.Data.NumberOfProducts.ShouldBe(TestData.ContractResponse1.Products.Count); - foreach (ContractProduct contractResponse1Product in TestData.ContractResponse1.Products) { - ContractProductModel? modelProduct = result.Data.ContractProducts.SingleOrDefault(cp => cp.ContractProductId == contractResponse1Product.ProductId); - modelProduct.ShouldNotBeNull(); - } - } - - [Fact] - public async Task ApiClient_GetContract_ClientCallFailed_ResultFailed() - { - this.TransactionProcessorClient.Setup(e => e.GetContract(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - - var result= await this.ApiClient.GetContract(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Contract1Id, CancellationToken.None); - - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_CreateOperator_OperatorIsCreated() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.CreateOperator(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - - CreateOperatorModel createOperatorModel = new() { RequireCustomMerchantNumber = TestData.RequireCustomMerchantNumber, RequireCustomTerminalNumber = TestData.RequireCustomTerminalNumber, OperatorName = TestData.Operator1Name, OperatorId = TestData.Operator1Id }; - - Result result = await this.ApiClient.CreateOperator(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, createOperatorModel, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_CreateOperator_ErrorAtServer_OperatorIsNotCreated() { - Logger.Initialise(NullLogger.Instance); - this.TransactionProcessorClient.Setup(e => e.CreateOperator(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - - CreateOperatorModel createOperatorModel = new() { RequireCustomMerchantNumber = TestData.RequireCustomMerchantNumber, RequireCustomTerminalNumber = TestData.RequireCustomTerminalNumber, OperatorName = TestData.Operator1Name, OperatorId = TestData.Operator1Id }; - - Result result = await this.ApiClient.CreateOperator(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, createOperatorModel, CancellationToken.None); - - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_UpdateOperator_OperatorIsUpdated() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.UpdateOperator(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); - - UpdateOperatorModel updateOperatorModel = new() { RequireCustomMerchantNumber = TestData.RequireCustomMerchantNumber, RequireCustomTerminalNumber = TestData.RequireCustomTerminalNumber, OperatorName = TestData.Operator1Name, OperatorId = TestData.Operator1Id }; - - Result result = await this.ApiClient.UpdateOperator(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, updateOperatorModel, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_UpdateOperator_ErrorAtServer_OperatorIsNotUpdated() { - this.TransactionProcessorClient.Setup(e => e.UpdateOperator(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - - UpdateOperatorModel updateOperatorModel = new() { RequireCustomMerchantNumber = TestData.RequireCustomMerchantNumber, RequireCustomTerminalNumber = TestData.RequireCustomTerminalNumber, OperatorName = TestData.Operator1Name, OperatorId = TestData.Operator1Id }; - - Result result = await this.ApiClient.UpdateOperator(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, updateOperatorModel, CancellationToken.None); - - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetFileImportLogList_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.FileProcessorClient.Setup(e => e.GetFileImportLogs(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync( Result.Success(TestData.FileImportLogList)); - - Result> result = await this.ApiClient.GetFileImportLogList(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Merchant1Id, TestData.FileImportLogQueryStartDate, TestData.FileImportLogQueryEndDate, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.ShouldNotBeNull(); - result.Data.ShouldNotBeEmpty(); - result.Data.Count.ShouldBe(TestData.FileImportLogList.FileImportLogs.Count); - } - - [Fact] - public async Task ApiClient_GetFileImportLogList_ErrorAtServer_NoDataIsReturned() { - this.FileProcessorClient.Setup(e => e.GetFileImportLogs(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result> result = await this.ApiClient.GetFileImportLogList(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Merchant1Id, TestData.FileImportLogQueryStartDate, TestData.FileImportLogQueryEndDate, CancellationToken.None); - - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetFileImportLog_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.FileProcessorClient.Setup(e => e.GetFileImportLog(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync( Result.Success(TestData.FileImportLog1)); - - Result result = await this.ApiClient.GetFileImportLog(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Merchant1Id, TestData.FileImportLogId, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetFileImportLog_ErrorAtServer_NoDataIsReturned() { - this.FileProcessorClient.Setup(e => e.GetFileImportLog(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - Result result = await this.ApiClient.GetFileImportLog(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Merchant1Id, TestData.FileImportLogId, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetFileDetails_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.FileProcessorClient.Setup(e => e.GetFile(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.FileDetails1)); - - Result result = await this.ApiClient.GetFileDetails(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.FileId1, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetFileDetails_ErrorAtServer_NoDataIsReturned() { - this.FileProcessorClient.Setup(e => e.GetFile(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - Result result = await this.ApiClient.GetFileDetails(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.FileId1, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - - [Fact] - public async Task ApiClient_GetComparisonDates_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetComparisonDates(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ComparisonDates)); - - Result> result = await this.ApiClient.GetComparisonDates(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetComparisonDates_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetComparisonDates(It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result> result = await this.ApiClient.GetComparisonDates(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTodaysSales_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetTodaysSales(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.TodaysSales); - - Result result = await this.ApiClient.GetTodaysSales(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, null, null, TestData.ComparisonDate, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTodaysSales_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetComparisonDates(It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result result = await this.ApiClient.GetTodaysSales(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, null, null, TestData.ComparisonDate, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTodaysSettlement_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetTodaysSettlement(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.TodaysSettlement); - - Result result = await this.ApiClient.GetTodaysSettlement(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, null, null, TestData.ComparisonDate, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTodaysSettlement_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetTodaysSettlement(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result result = await this.ApiClient.GetTodaysSettlement(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, null, null, TestData.ComparisonDate, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTodaysSalesCountByHour_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetTodaysSalesCountByHour(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.TodaysSalesCountByHour); - - Result> result = await this.ApiClient.GetTodaysSalesCountByHour(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Merchant1Id, TestData.Operator1Id, TestData.ComparisonDate, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTodaysSalesCountByHour_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetTodaysSalesCountByHour(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result> result = await this.ApiClient.GetTodaysSalesCountByHour(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Merchant1Id, TestData.Operator1Id, TestData.ComparisonDate, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTodaysSalesValueByHour_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetTodaysSalesValueByHour(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.TodaysSalesValueByHour); - - Result> result = await this.ApiClient.GetTodaysSalesValueByHour(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Merchant1Id, TestData.Operator1Id, TestData.ComparisonDate, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTodaysSalesValueByHour_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetTodaysSalesValueByHour(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result> result = await this.ApiClient.GetTodaysSalesValueByHour(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Merchant1Id, TestData.Operator1Id, TestData.ComparisonDate, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetMerchantKpi_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetMerchantKpi(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.MerchantKpi); - - Result result = await this.ApiClient.GetMerchantKpi(TestData.AccessToken, TestData.EstateId, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetMerchantKpi_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetMerchantKpi(It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result result = await this.ApiClient.GetMerchantKpi(TestData.AccessToken, TestData.EstateId, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - - [Fact] - public async Task ApiClient_GetTodaysFailedSales_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetTodaysFailedSales(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.TodaysSales); - - Result result = await this.ApiClient.GetTodaysFailedSales(TestData.AccessToken, TestData.EstateId, "1009", TestData.ComparisonDate, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTodaysFailedSales_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetTodaysFailedSales(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result result = await this.ApiClient.GetTodaysFailedSales(TestData.AccessToken, TestData.EstateId, "1009", TestData.ComparisonDate, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - - [Fact] - public async Task ApiClient_GetTopBottomMerchantData_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetTopBottomMerchantData(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.TopBottomMerchantDataList); - - Result> result = await this.ApiClient.GetTopBottomMerchantData(TestData.AccessToken, TestData.EstateId, TopBottom.Bottom, 10, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTopBottomMerchantData_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetTopBottomMerchantData(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result> result = await this.ApiClient.GetTopBottomMerchantData(TestData.AccessToken, TestData.EstateId, TopBottom.Bottom, 10, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTopBottomProductData_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetTopBottomProductData(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.TopBottomProductDataList); - - Result> result = await this.ApiClient.GetTopBottomProductData(TestData.AccessToken, TestData.EstateId, TopBottom.Bottom, 10, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTopBottomProductData_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetTopBottomProductData(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result> result = await this.ApiClient.GetTopBottomProductData(TestData.AccessToken, TestData.EstateId, TopBottom.Bottom, 10, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTopBottomOperatorData_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetTopBottomOperatorData(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.TopBottomOperatorDataList); - - Result> result = await this.ApiClient.GetTopBottomOperatorData(TestData.AccessToken, TestData.EstateId, TopBottom.Bottom, 10, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetTopBottomOperatorData_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetTopBottomOperatorData(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result> result = await this.ApiClient.GetTopBottomOperatorData(TestData.AccessToken, TestData.EstateId, TopBottom.Bottom, 10, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetLastSettlement_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.EstateReportingApiClient.Setup(e => e.GetLastSettlement(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.LastSettlement); - - Result result = await this.ApiClient.GetLastSettlement(TestData.AccessToken, TestData.EstateId, null, null, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_GetLastSettlement_ErrorAtServer_NoDataIsReturned() { - this.EstateReportingApiClient.Setup(e => e.GetLastSettlement(It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result result = await this.ApiClient.GetLastSettlement(TestData.AccessToken, TestData.EstateId, null, null, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_CreateMerchant_DataIsReturned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.CreateMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - - Result result = await this.ApiClient.CreateMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.CreateMerchantModel(SettlementSchedule.Immediate), CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_CreateMerchant_ErrorAtServer_NoDataIsReturned() { - this.TransactionProcessorClient.Setup(e => e.CreateMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - Result result = await this.ApiClient.CreateMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.CreateMerchantModel(SettlementSchedule.Immediate), CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_CreateMerchant_ClientThrowsException_ResultIsFailed() - { - this.TransactionProcessorClient.Setup(e => e.CreateMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result result = await this.ApiClient.CreateMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.CreateMerchantModel(SettlementSchedule.Immediate), CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_UpdateMerchant_MerchantIsUpdated() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.UpdateMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - - Result result = await this.ApiClient.UpdateMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, TestData.UpdateMerchantModel(SettlementSchedule.Immediate), CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_UpdateMerchant_ErrorAtServer_ResultIsFailed() - { - this.TransactionProcessorClient.Setup(e => e.UpdateMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - - Result result = await this.ApiClient.UpdateMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, TestData.UpdateMerchantModel(SettlementSchedule.Immediate), CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_UpdateMerchantAddress_MerchantAddressIsUpdated() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.UpdateMerchantAddress(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny
(), It.IsAny())).ReturnsAsync(Result.Success); - - Result result = await this.ApiClient.UpdateMerchantAddress(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, TestData.AddressModel, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_UpdateMerchantAddress_ErrorAtServer_ResultIsFailed() - { - this.TransactionProcessorClient.Setup(e => e.UpdateMerchantAddress(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny
(), It.IsAny())).ReturnsAsync(Result.Failure); - - Result result = await this.ApiClient.UpdateMerchantAddress(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, TestData.AddressModel, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_UpdateMerchantContact_MerchantContactIsUpdated() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.UpdateMerchantContact(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - - Result result = await this.ApiClient.UpdateMerchantContact(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, TestData.ContactModel, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_UpdateMerchantContact_ErrorAtServer_ResultIsFailed() - { - this.TransactionProcessorClient.Setup(e => e.UpdateMerchantContact(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - - Result result = await this.ApiClient.UpdateMerchantContact(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, TestData.ContactModel, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_AssignContractToMerchant_ContractAssigned() { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.AddContractToMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - - Result result = await this.ApiClient.AssignContractToMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, - TestData.AssignContractToMerchantModel, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_AssignContractToMerchant_ClientCallFailed_ResultIsFailed() - { - this.TransactionProcessorClient.Setup(e => e.AddContractToMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - - Result result = await this.ApiClient.AssignContractToMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, - TestData.AssignContractToMerchantModel, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_RemoveContractFromMerchant_ContractRemoved() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.RemoveContractFromMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - - Result result = await this.ApiClient.RemoveContractFromMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, - TestData.Contract1Id, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_RemoveContractFromMerchant_ClientCallFailed_ResultIsFailed() - { - this.TransactionProcessorClient.Setup(e => e.RemoveContractFromMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - - Result result = await this.ApiClient.RemoveContractFromMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, - TestData.Contract1Id, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_AssignOperatorToMerchant_OperatorAssigned() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.AssignOperatorToMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - - Result result = await this.ApiClient.AssignOperatorToMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, - TestData.AssignOperatorToMerchantModel, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_AssignOperatorToMerchant_ClientCallFailed_ResultIsFailed() - { - this.TransactionProcessorClient.Setup(e => e.AssignOperatorToMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - - Result result = await this.ApiClient.AssignOperatorToMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, - TestData.AssignOperatorToMerchantModel, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_RemoveOperatorFromMerchant_OperatorRemoved() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - this.TransactionProcessorClient.Setup(e => e.RemoveOperatorFromMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - - Result result = await this.ApiClient.RemoveOperatorFromMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, - TestData.Operator1Id, CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_RemoveOperatorFromMerchant_ClientCallFailed_ResultIsFailed() - { - this.TransactionProcessorClient.Setup(e => e.RemoveOperatorFromMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - - Result result = await this.ApiClient.RemoveOperatorFromMerchant(TestData.AccessToken, Guid.Empty, TestData.EstateId, TestData.Merchant1Id, - TestData.Operator1Id, CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ApiClient_AssignDeviceToMerchant_DeviceAssigned() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - 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.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - 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.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - 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.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - 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.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TokenResponse.Create(TestData.AccessToken, TestData.AccessToken, 1000))); - 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/EstateManagementUI.BusinessLogic.Tests.csproj b/EstateManagementUI.BusinessLogic.Tests/EstateManagementUI.BusinessLogic.Tests.csproj deleted file mode 100644 index f699725a..00000000 --- a/EstateManagementUI.BusinessLogic.Tests/EstateManagementUI.BusinessLogic.Tests.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - net10.0 - enable - enable - None - false - true - - - - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - diff --git a/EstateManagementUI.BusinessLogic.Tests/ExtensionsTests.cs b/EstateManagementUI.BusinessLogic.Tests/ExtensionsTests.cs deleted file mode 100644 index 1c322178..00000000 --- a/EstateManagementUI.BusinessLogic.Tests/ExtensionsTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using EstateManagementUI.BusinessLogic.Common; -using Shared.Exceptions; -using Shouldly; - -namespace EstateManagementUI.BusinessLogic.Tests -{ - public class ExtensionsTests - { - [Fact] - public void ExceptionHelper_GetCombinedExceptionMessages_ExpectedMessageReturned() { - Exception innerInnerException = new Exception("This is inner inner exception"); - Exception innerException = new Exception("This is inner exception",innerInnerException); - Exception exception = new Exception("This is exception", innerException); - - String messages = exception.GetCombinedExceptionMessages(); - messages.ShouldBe($"This is exception{Environment.NewLine}This is inner exception{Environment.NewLine}This is inner inner exception{Environment.NewLine}"); - } - - [Fact] - public void ExceptionHelper_GetCombinedExceptionMessages_ExceptionIsNull_NothingReturned() - { - Exception exception = null; - - String messages = ExceptionHelper.GetCombinedExceptionMessages(exception); - messages.ShouldBeNullOrEmpty(); - } - } -} diff --git a/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs b/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs deleted file mode 100644 index 4458d3dc..00000000 --- a/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs +++ /dev/null @@ -1,151 +0,0 @@ -using EstateManagementUI.Testing; -using MediatR; -using MediatR.Registration; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; -using System.Diagnostics; -using Lamar; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Identity.Client; -using Moq; -using Shared.Logger; -using static EstateManagmentUI.BusinessLogic.Requests.Queries; - -namespace EstateManagementUI.BusinessLogic.Tests { - public class MediatorTests { - private readonly List Requests = new(); - - private IMediator mediator; - - public MediatorTests() { - // Queries - this.Requests.Add(TestData.GetEstateQuery); - this.Requests.Add(TestData.GetMerchantsQuery); - this.Requests.Add(TestData.GetMerchantQuery); - this.Requests.Add(TestData.GetOperatorsQuery); - this.Requests.Add(TestData.GetOperatorQuery); - this.Requests.Add(TestData.GetContractsQuery); - this.Requests.Add(TestData.GetContractQuery); - this.Requests.Add(TestData.GetFileImportLogsListQuery); - this.Requests.Add(TestData.GetFileImportLogQuery); - this.Requests.Add(TestData.GetFileDetailsQuery); - this.Requests.Add(TestData.GetComparisonDatesQuery); - this.Requests.Add(TestData.GetTodaysSalesQuery); - this.Requests.Add(TestData.GetTodaysSettlementQuery); - this.Requests.Add(TestData.GetTodaysSalesCountByHourQuery); - this.Requests.Add(TestData.GetTodaysSalesValueByHourQuery); - this.Requests.Add(TestData.GetMerchantKpiQuery); - this.Requests.Add(TestData.GetTodaysFailedSalesQuery); - this.Requests.Add(TestData.GetTopProductDataQuery); - this.Requests.Add(TestData.GetBottomProductDataQuery); - this.Requests.Add(TestData.GetTopMerchantDataQuery); - this.Requests.Add(TestData.GetBottomMerchantDataQuery); - this.Requests.Add(TestData.GetTopOperatorDataQuery); - this.Requests.Add(TestData.GetBottomOperatorDataQuery); - this.Requests.Add(TestData.GetLastSettlementQuery); - this.Requests.Add(TestData.GetProductPerformanceQuery); - - // Commands - this.Requests.Add(TestData.AddNewOperatorCommand); - this.Requests.Add(TestData.UpdateOperatorCommand); - - this.Requests.Add(TestData.AddNewMerchantCommand); - this.Requests.Add(TestData.UpdateMerchantCommand); - this.Requests.Add(TestData.UpdateMerchantAddressCommand); - this.Requests.Add(TestData.UpdateMerchantContactCommand); - this.Requests.Add(TestData.AssignOperatorToMerchantCommand); - 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); - - - - Mock hostingEnvironment = new Mock(); - hostingEnvironment.Setup(he => he.EnvironmentName).Returns("IntegrationTest"); - hostingEnvironment.Setup(he => he.ContentRootPath).Returns("/home"); - hostingEnvironment.Setup(he => he.ApplicationName).Returns("Test Application"); - - ServiceRegistry services = new ServiceRegistry(); - Startup s = new Startup(hostingEnvironment.Object); - Startup.Configuration = this.SetupMemoryConfiguration(); - - this.AddTestRegistrations(services, hostingEnvironment.Object); - s.ConfigureContainer(services); - - Startup.Container.AssertConfigurationIsValid(AssertMode.Full); - Shared.Logger.Logger.Initialise(new NullLogger()); - this.mediator = Startup.Container.GetService(); - } - - [Fact] - public async Task Mediator_Send_RequestHandled() { - List errors = new List(); - - foreach (IBaseRequest baseRequest in this.Requests) { - try { - await mediator.Send(baseRequest); - } - catch (Exception ex) { - errors.Add($"{ex.Message} Request type {baseRequest.GetType()}"); - } - } - - if (errors.Any() == true) { - String errorMessage = String.Join(Environment.NewLine, errors); - throw new Exception(errorMessage); - } - } - - private IConfigurationRoot SetupMemoryConfiguration() - { - Dictionary configuration = new Dictionary(); - - IConfigurationBuilder builder = new ConfigurationBuilder(); - - configuration.Add("ConnectionStrings:HealthCheck", "HeathCheckConnString"); - configuration.Add("SecurityConfiguration:Authority", "https://127.0.0.1"); - configuration.Add("EventStoreSettings:ConnectionString", "esdb://127.0.0.1:2113"); - configuration.Add("EventStoreSettings:ConnectionName", "UnitTestConnection"); - configuration.Add("EventStoreSettings:UserName", "admin"); - configuration.Add("EventStoreSettings:Password", "changeit"); - configuration.Add("AppSettings:UseConnectionStringConfig", "false"); - configuration.Add("AppSettings:SecurityService", "http://127.0.0.1"); - configuration.Add("AppSettings:MessagingServiceApi", "http://127.0.0.1"); - configuration.Add("AppSettings:TransactionProcessorApi", "http://127.0.0.1"); - configuration.Add("AppSettings:FileProcessorApi", "http://127.0.0.1"); - configuration.Add("AppSettings:DatabaseEngine", "SqlServer"); - configuration.Add("AppSettings:EstateReportingApi", "http://127.0.0.1"); - - builder.AddInMemoryCollection(configuration); - - return builder.Build(); - } - - private void AddTestRegistrations(ServiceRegistry services, - IWebHostEnvironment hostingEnvironment) - { - services.AddLogging(); - DiagnosticListener diagnosticSource = new DiagnosticListener(hostingEnvironment.ApplicationName); - services.AddSingleton(diagnosticSource); - services.AddSingleton(diagnosticSource); - services.AddSingleton(hostingEnvironment); - services.AddSingleton(hostingEnvironment); - services.AddSingleton(Startup.Configuration); - - //services.OverrideServices(s => { - // s.AddSingleton(); - // s.AddSingleton(); - // s.AddSingleton(); - // s.AddSingleton(); - // s.AddSingleton(); - // s.AddSingleton(); - //}); - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.BusinessLogic.Tests/ModelFactoryTests.cs b/EstateManagementUI.BusinessLogic.Tests/ModelFactoryTests.cs deleted file mode 100644 index 24745ed8..00000000 --- a/EstateManagementUI.BusinessLogic.Tests/ModelFactoryTests.cs +++ /dev/null @@ -1,871 +0,0 @@ -using EstateManagementUI.Testing; -using EstateManagementUI.BusinessLogic.Models; -using Shouldly; -using EstateManagementUI.BusinessLogic.Common; -using EstateReportingAPI.DataTransferObjects; -using FileProcessor.DataTransferObjects.Responses; -using EstateReportingAPI.DataTrasferObjects; -using TransactionProcessor.DataTransferObjects.Requests.Merchant; -using TransactionProcessor.DataTransferObjects.Responses.Contract; -using TransactionProcessor.DataTransferObjects.Responses.Estate; -using TransactionProcessor.DataTransferObjects.Responses.Merchant; -using TransactionProcessor.DataTransferObjects.Responses.Operator; -using FileImportLogList = FileProcessor.DataTransferObjects.Responses.FileImportLogList; -using FileLineProcessingResult = FileProcessor.DataTransferObjects.Responses.FileLineProcessingResult; -using LastSettlement = EstateReportingAPI.DataTransferObjects.LastSettlement; -using MerchantKpi = EstateReportingAPI.DataTransferObjects.MerchantKpi; -using SettlementSchedule = EstateManagementUI.BusinessLogic.Models.SettlementSchedule; -using TodaysSales = EstateReportingAPI.DataTransferObjects.TodaysSales; -using TodaysSalesCountByHour = EstateReportingAPI.DataTransferObjects.TodaysSalesCountByHour; -using TodaysSalesCountByHourModel = EstateManagementUI.BusinessLogic.Models.TodaysSalesCountByHourModel; -using TodaysSalesValueByHour = EstateReportingAPI.DataTransferObjects.TodaysSalesValueByHour; -using TodaysSalesValueByHourModel = EstateManagementUI.BusinessLogic.Models.TodaysSalesValueByHourModel; -using TodaysSettlement = EstateReportingAPI.DataTransferObjects.TodaysSettlement; - -namespace EstateManagementUI.BusinessLogic.Tests { - public class ModelFactoryTests { - - [Fact] - public void ModelFactory_ConvertFrom_TodaysSettlement_ModelIsConverted() { - TodaysSettlement response = TestData.TodaysSettlement; - - TodaysSettlementModel model = ModelFactory.ConvertFrom(response); - model.ComparisonSettlementValue.ShouldBe(response.ComparisonSettlementValue); - model.ComparisonSettlementCount.ShouldBe(response.ComparisonSettlementCount); - model.TodaysSettlementCount.ShouldBe(response.TodaysSettlementCount); - model.TodaysSettlementValue.ShouldBe(response.TodaysSettlementValue); - } - - [Fact] - public void ModelFactory_ConvertFrom_TodaysSales_ResponseIsNull_ErrorThrown() { - TodaysSales response = null; - - Should.Throw(() => { ModelFactory.ConvertFrom(response); }); - } - - [Fact] - public void ModelFactory_ConvertFrom_TodaysSales_ModelIsConverted() { - TodaysSales response = TestData.TodaysSales; - - TodaysSalesModel model = ModelFactory.ConvertFrom(response); - model.ComparisonSalesValue.ShouldBe(response.ComparisonSalesValue); - model.ComparisonSalesCount.ShouldBe(response.ComparisonSalesCount); - model.TodaysSalesCount.ShouldBe(response.TodaysSalesCount); - model.TodaysSalesValue.ShouldBe(response.TodaysSalesValue); - } - - [Fact] - public void ModelFactory_ConvertFrom_TodaysSettlement_ResponseIsNull_ErrorThrown() { - TodaysSettlement response = null; - - Should.Throw(() => { ModelFactory.ConvertFrom(response); }); - } - - [Fact] - public void ModelFactory_ConvertFrom_EstateResponse_EmptyOperators_ModelIsConverted() { - EstateResponse response = TestData.EstateResponse; - response.Operators = new List(); - - EstateModel model = ModelFactory.ConvertFrom(response); - - model.EstateName.ShouldBe(response.EstateName); - model.EstateId.ShouldBe(response.EstateId); - model.Operators.ShouldBeNull(); - response.SecurityUsers.ForEach(u => { - SecurityUserModel securityUserModel = model.SecurityUsers.SingleOrDefault(su => su.SecurityUserId == u.SecurityUserId); - securityUserModel.ShouldNotBeNull(); - securityUserModel.EmailAddress.ShouldBe(u.EmailAddress); - }); - } - - [Fact] - public void ModelFactory_ConvertFrom_EstateResponse_EmptySecurityUsers_ModelIsConverted() { - EstateResponse response = TestData.EstateResponse; - response.SecurityUsers = new List(); - - EstateModel model = ModelFactory.ConvertFrom(response); - - model.EstateName.ShouldBe(response.EstateName); - model.EstateId.ShouldBe(response.EstateId); - model.Operators.Count.ShouldBe(response.Operators.Count); - response.Operators.ForEach(o => { - EstateOperatorModel operatorModel = model.Operators.SingleOrDefault(mo => mo.OperatorId == o.OperatorId); - operatorModel.ShouldNotBeNull(); - operatorModel.RequireCustomMerchantNumber.ShouldBe(o.RequireCustomMerchantNumber); - operatorModel.RequireCustomTerminalNumber.ShouldBe(o.RequireCustomTerminalNumber); - operatorModel.Name.ShouldBe(o.Name); - }); - model.SecurityUsers.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_EstateResponse_ModelIsConverted() { - EstateResponse response = TestData.EstateResponse; - - EstateModel model = ModelFactory.ConvertFrom(response); - - model.EstateName.ShouldBe(response.EstateName); - model.EstateId.ShouldBe(response.EstateId); - model.Operators.Count.ShouldBe(response.Operators.Count); - response.Operators.ForEach(o => { - EstateOperatorModel operatorModel = model.Operators.SingleOrDefault(mo => mo.OperatorId == o.OperatorId); - operatorModel.ShouldNotBeNull(); - operatorModel.RequireCustomMerchantNumber.ShouldBe(o.RequireCustomMerchantNumber); - operatorModel.RequireCustomTerminalNumber.ShouldBe(o.RequireCustomTerminalNumber); - operatorModel.Name.ShouldBe(o.Name); - }); - response.SecurityUsers.ForEach(u => { - SecurityUserModel securityUserModel = model.SecurityUsers.SingleOrDefault(su => su.SecurityUserId == u.SecurityUserId); - securityUserModel.ShouldNotBeNull(); - securityUserModel.EmailAddress.ShouldBe(u.EmailAddress); - }); - } - - [Fact] - public void ModelFactory_ConvertFrom_EstateResponse_NullOperators_ModelIsConverted() { - EstateResponse response = TestData.EstateResponse; - response.Operators = null; - - EstateModel model = ModelFactory.ConvertFrom(response); - - model.EstateName.ShouldBe(response.EstateName); - model.EstateId.ShouldBe(response.EstateId); - model.Operators.ShouldBeNull(); - response.SecurityUsers.ForEach(u => { - SecurityUserModel securityUserModel = model.SecurityUsers.SingleOrDefault(su => su.SecurityUserId == u.SecurityUserId); - securityUserModel.ShouldNotBeNull(); - securityUserModel.EmailAddress.ShouldBe(u.EmailAddress); - }); - } - - [Fact] - public void ModelFactory_ConvertFrom_EstateResponse_NullResponse_ErrorThrown() { - EstateResponse response = null; - - Should.Throw(() => { ModelFactory.ConvertFrom(response); }); - } - - [Fact] - public void ModelFactory_ConvertFrom_EstateResponse_NullSecurityUsers_ModelIsConverted() { - EstateResponse response = TestData.EstateResponse; - response.SecurityUsers = null; - - EstateModel model = ModelFactory.ConvertFrom(response); - - model.EstateName.ShouldBe(response.EstateName); - model.EstateId.ShouldBe(response.EstateId); - model.Operators.Count.ShouldBe(response.Operators.Count); - response.Operators.ForEach(o => { - EstateOperatorModel operatorModel = model.Operators.SingleOrDefault(mo => mo.OperatorId == o.OperatorId); - operatorModel.ShouldNotBeNull(); - operatorModel.RequireCustomMerchantNumber.ShouldBe(o.RequireCustomMerchantNumber); - operatorModel.RequireCustomTerminalNumber.ShouldBe(o.RequireCustomTerminalNumber); - operatorModel.Name.ShouldBe(o.Name); - }); - model.SecurityUsers.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_MerchantResponsesList_ModelIsConverted() { - List response = TestData.MerchantResponses; - - List models = ModelFactory.ConvertFrom(response); - - foreach (MerchantResponse merchantResponse in response) { - MerchantModel? model = models.SingleOrDefault(m => m.MerchantId == merchantResponse.MerchantId); - model.ShouldNotBeNull(); - model.MerchantName.ShouldBe(merchantResponse.MerchantName.ToString()); - model.SettlementSchedule.ShouldBe(merchantResponse.SettlementSchedule.ToString()); - model.MerchantReference.ShouldBe(merchantResponse.MerchantReference.ToString()); - model.Address.AddressLine1.ShouldBe(merchantResponse.Addresses.First().AddressLine1); - model.Address.Town.ShouldBe(merchantResponse.Addresses.First().Town); - model.Contact.ContactName.ShouldBe(merchantResponse.Contacts.First().ContactName); - } - } - - [Fact] - public void ModelFactory_ConvertFrom_MerchantResponsesList_NullList_ModelIsConverted() { - List response = null; - - List models = ModelFactory.ConvertFrom(response); - - models.ShouldBeEmpty(); - } - - [Fact] - public void ModelFactory_ConvertFrom_MerchantResponsesList_EmptyList_ModelIsConverted() { - List response = new List(); - - List models = ModelFactory.ConvertFrom(response); - - models.ShouldBeEmpty(); - } - - [Fact] - public void ModelFactory_ConvertFrom_OperatorResponsesList_ModelIsConverted() { - List response = TestData.OperatorResponses; - - List models = ModelFactory.ConvertFrom(response); - - foreach (OperatorResponse operatorResponse in response) { - OperatorModel? model = models.SingleOrDefault(m => m.OperatorId == operatorResponse.OperatorId); - model.ShouldNotBeNull(); - model.Name.ShouldBe(operatorResponse.Name); - model.RequireCustomTerminalNumber.ShouldBe(operatorResponse.RequireCustomTerminalNumber); - model.RequireCustomMerchantNumber.ShouldBe(operatorResponse.RequireCustomMerchantNumber); - } - } - - [Fact] - public void ModelFactory_ConvertFrom_OperatorResponsesList_NullList_ModelIsConverted() { - List response = null; - - List models = ModelFactory.ConvertFrom(response); - - models.ShouldBeEmpty(); - } - - [Fact] - public void ModelFactory_ConvertFrom_OperatorResponsesList_EmptyList_ModelIsConverted() { - List response = new List(); - - List models = ModelFactory.ConvertFrom(response); - - models.ShouldBeEmpty(); - } - - [Fact] - public void ModelFactory_ConvertFrom_OperatorResponse_OperatorIsNull_ModelIsConverted() { - OperatorResponse response = null; - - OperatorModel model = ModelFactory.ConvertFrom(response); - - model.ShouldBeNull(); - } - - - [Fact] - public void ModelFactory_ConvertFrom_ContractResponsesList_ModelIsConverted() { - List response = TestData.ContractResponses; - - List models = ModelFactory.ConvertFrom(response); - - foreach (ContractResponse contractResponse in response) { - ContractModel? model = models.SingleOrDefault(m => m.ContractId == contractResponse.ContractId); - model.ShouldNotBeNull(); - model.Description.ShouldBe(contractResponse.Description); - model.OperatorName.ShouldBe(contractResponse.OperatorName); - model.NumberOfProducts.ShouldBe(contractResponse.Products.Count); - } - } - - [Fact] - public void ModelFactory_ConvertFrom_ContractResponsesList_NullList_ModelIsConverted() { - List response = null; - - List models = ModelFactory.ConvertFrom(response); - - models.ShouldBeEmpty(); - } - - [Fact] - public void ModelFactory_ConvertFrom_ContractResponsesList_EmptyList_ModelIsConverted() { - List response = new List(); - - List models = ModelFactory.ConvertFrom(response); - - models.ShouldBeEmpty(); - } - - [Fact] - public void ModelFactory_ConvertFrom_ContractResponse_NullProducts_ModelIsConverted() { - ContractResponse response = TestData.ContractResponseNullProducts; - - ContractModel model = ModelFactory.ConvertFrom(response); - - model.ShouldNotBeNull(); - model.Description.ShouldBe(response.Description); - model.OperatorName.ShouldBe(response.OperatorName); - model.NumberOfProducts.ShouldBe(0); - } - - [Fact] - public void ModelFactory_ConvertFrom_ContractResponse_EmptyProducts_ModelIsConverted() { - ContractResponse response = TestData.ContractResponseEmptyProducts; - - ContractModel model = ModelFactory.ConvertFrom(response); - - model.ShouldNotBeNull(); - model.Description.ShouldBe(response.Description); - model.OperatorName.ShouldBe(response.OperatorName); - model.NumberOfProducts.ShouldBe(0); - } - - [Fact] - public void ModelFactory_ConvertFrom_ContractProduct_ModelIsConverted() { - ContractProduct contractProduct = TestData.ContractProduct1; - - ContractProductModel model = ModelFactory.ConvertFrom(contractProduct); - model.ShouldNotBeNull(); - model.Value.ShouldBe(contractProduct.Value.ToString()); - model.DisplayText.ShouldBe(contractProduct.DisplayText); - model.ContractProductId.ShouldBe(contractProduct.ProductId); - model.ProductName.ShouldBe(contractProduct.Name); - model.ProductType.ShouldBe(contractProduct.ProductType.ToString()); - model.NumberOfFees.ShouldBe(contractProduct.TransactionFees.Count); - - foreach (ContractProductTransactionFee contractProductTransactionFee in contractProduct.TransactionFees) { - ContractProductTransactionFeeModel? modelFee = model.ContractProductTransactionFees.SingleOrDefault(p => p.ContractProductTransactionFeeId == contractProductTransactionFee.TransactionFeeId); - modelFee.ShouldNotBeNull(); - modelFee.Value.ShouldBe(contractProductTransactionFee.Value); - modelFee.CalculationType.ShouldBe(contractProductTransactionFee.CalculationType.ToString()); - modelFee.Description.ShouldBe(contractProductTransactionFee.Description); - modelFee.FeeType.ShouldBe(contractProductTransactionFee.FeeType.ToString()); - } - } - - [Fact] - public void ModelFactory_ConvertFrom_FileImportLogList_ModelIsConverted() { - FileImportLogList fileImportLogList = TestData.FileImportLogList; - - List model = ModelFactory.ConvertFrom(fileImportLogList); - - model.ShouldNotBeNull(); - model.Count.ShouldBe(fileImportLogList.FileImportLogs.Count); - - foreach (FileImportLog fileImportLog in fileImportLogList.FileImportLogs) { - FileImportLogModel? fileImportLogModel = model.SingleOrDefault(m => m.FileImportLogId == fileImportLog.FileImportLogId); - fileImportLogModel.ShouldNotBeNull(); - fileImportLogModel.ImportLogDateTime.ShouldBe(fileImportLog.ImportLogDateTime); - fileImportLogModel.FileCount.ShouldBe(fileImportLog.FileCount); - fileImportLogModel.ImportLogDate.ShouldBe(fileImportLog.ImportLogDate); - fileImportLogModel.ImportLogTime.ShouldBe(fileImportLog.ImportLogTime); - - foreach (FileImportLogFile fileImportLogFile in fileImportLog.Files) { - FileImportLogFileModel? fileModel = fileImportLogModel.Files.SingleOrDefault(f => f.FileId == fileImportLogFile.FileId); - fileModel.ShouldNotBeNull(); - fileModel.MerchantId.ShouldBe(fileImportLogFile.MerchantId); - fileModel.FilePath.ShouldBe(fileImportLogFile.FilePath); - fileModel.OriginalFileName.ShouldBe(fileImportLogFile.OriginalFileName); - fileModel.FileUploadedDateTime.ShouldBe(fileImportLogFile.FileUploadedDateTime); - fileModel.UserId.ShouldBe(fileImportLogFile.UserId); - } - } - } - - [Fact] - public void ModelFactory_ConvertFrom_FileImportLogList_NullInput_ModelIsConverted() { - FileImportLogList fileImportLogList = null; - List model = ModelFactory.ConvertFrom(fileImportLogList); - model.ShouldNotBeNull(); - model.ShouldBeEmpty(); - } - - [Fact] - public void ModelFactory_ConvertFrom_ComparisonDates_ModelIsConverted() { - List response = TestData.ComparisonDates; - - List model = ModelFactory.ConvertFrom(response); - - foreach (ComparisonDate comparisonDate in response) { - ComparisonDateModel? dateModel = model.SingleOrDefault(m => m.Date == comparisonDate.Date); - dateModel.ShouldNotBeNull(); - dateModel.Description.ShouldBe(comparisonDate.Description); - dateModel.OrderValue.ShouldBe(comparisonDate.OrderValue); - } - } - - [Fact] - public void ModelFactory_ConvertFrom_ComparisonDates_NullList_ModelIsConverted() { - List response = null; - - List model = ModelFactory.ConvertFrom(response); - - model.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_ComparisonDates_EmptyList_ModelIsConverted() { - List response = new List(); - - List model = ModelFactory.ConvertFrom(response); - - model.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_TodaysSalesCountByHourModel_ModelIsConverted() { - List response = TestData.TodaysSalesCountByHour; - - List model = ModelFactory.ConvertFrom(response); - - foreach (TodaysSalesCountByHour todaysSalesCountByHour in response) { - TodaysSalesCountByHourModel? hourModel = model.SingleOrDefault(m => m.Hour == todaysSalesCountByHour.Hour); - hourModel.ShouldNotBeNull(); - hourModel.TodaysSalesCount.ShouldBe(todaysSalesCountByHour.TodaysSalesCount); - hourModel.ComparisonSalesCount.ShouldBe(todaysSalesCountByHour.ComparisonSalesCount); - } - } - - [Fact] - public void ModelFactory_ConvertFrom_TodaysSalesCountByHourModel_NullResponse_ModelIsConverted() { - List response = null; - - List model = ModelFactory.ConvertFrom(response); - - model.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_TodaysSalesCountByHourModel_EmptyList_ModelIsConverted() { - List response = new List(); - - List model = ModelFactory.ConvertFrom(response); - - model.ShouldBeNull(); - } - - - - - [Fact] - public void ModelFactory_ConvertFrom_TodaysSalesValueByHourModel_ModelIsConverted() { - List response = TestData.TodaysSalesValueByHour; - - List model = ModelFactory.ConvertFrom(response); - - foreach (TodaysSalesValueByHour todaysSalesValueByHour in response) { - TodaysSalesValueByHourModel? hourModel = model.SingleOrDefault(m => m.Hour == todaysSalesValueByHour.Hour); - hourModel.ShouldNotBeNull(); - hourModel.TodaysSalesValue.ShouldBe(todaysSalesValueByHour.TodaysSalesValue); - hourModel.ComparisonSalesValue.ShouldBe(todaysSalesValueByHour.ComparisonSalesValue); - } - } - - [Fact] - public void ModelFactory_ConvertFrom_TodaysSalesValueByHourModel_NullResponse_ModelIsConverted() { - List response = null; - - List model = ModelFactory.ConvertFrom(response); - - model.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_TodaysSalesValueByHourModel_EmptyList_ModelIsConverted() { - List response = new List(); - - List model = ModelFactory.ConvertFrom(response); - - model.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_MerchantKpi_IsConverted() { - - MerchantKpi model = new MerchantKpi() { MerchantsWithNoSaleInLast7Days = 1, MerchantsWithNoSaleToday = 2, MerchantsWithSaleInLastHour = 3 }; - var result = ModelFactory.ConvertFrom(model); - result.ShouldNotBeNull(); - result.MerchantsWithNoSaleInLast7Days.ShouldBe(model.MerchantsWithNoSaleInLast7Days); - result.MerchantsWithNoSaleToday.ShouldBe(model.MerchantsWithNoSaleToday); - result.MerchantsWithSaleInLastHour.ShouldBe(model.MerchantsWithSaleInLastHour); - } - - [Fact] - public void ModelFactory_ConvertFrom_MerchantKpi_ModelIsNull_ErrorThrown() { - - MerchantKpi model = null; - Should.Throw(() => { ModelFactory.ConvertFrom(model); }); - } - - [Fact] - public void ModelFactory_ConvertFrom_TopBottomOperatorData_IsConverted() { - List model = TestData.TopBottomOperatorDataList; - var result = ModelFactory.ConvertFrom(model); - - result.Count.ShouldBe(model.Count); - foreach (TopBottomOperatorData topBottomOperatorData in model) { - var d = result.SingleOrDefault(r => r.OperatorName == topBottomOperatorData.OperatorName); - d.ShouldNotBeNull(); - d.SalesValue.ShouldBe(topBottomOperatorData.SalesValue); - } - } - - [Fact] - public void ModelFactory_ConvertFrom_TopBottomOperatorData_ModelIsNull_NullReturned() { - - List model = null; - var result = ModelFactory.ConvertFrom(model); - result.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_TopBottomOperatorData_ModelIsEmpty_NullReturned() { - - List model = new List(); - var result = ModelFactory.ConvertFrom(model); - result.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_TopBottomMerchantData_IsConverted() { - List model = TestData.TopBottomMerchantDataList; - var result = ModelFactory.ConvertFrom(model); - - result.Count.ShouldBe(model.Count); - foreach (TopBottomMerchantData topBottomMerchantData in model) { - var d = result.SingleOrDefault(r => r.MerchantName == topBottomMerchantData.MerchantName); - d.ShouldNotBeNull(); - d.SalesValue.ShouldBe(topBottomMerchantData.SalesValue); - } - } - - [Fact] - public void ModelFactory_ConvertFrom_TopBottomMerchantData_ModelIsNull_NullReturned() { - - List model = null; - var result = ModelFactory.ConvertFrom(model); - result.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_TopBottomMerchantData_ModelIsEmpty_NullReturned() { - - List model = new List(); - var result = ModelFactory.ConvertFrom(model); - result.ShouldBeNull(); - } - - - [Fact] - public void ModelFactory_ConvertFrom_TopBottomProductData_IsConverted() { - List model = TestData.TopBottomProductDataList; - - var result = ModelFactory.ConvertFrom(model); - - result.Count.ShouldBe(model.Count); - foreach (TopBottomProductData topBottomProductData in model) { - var d = result.SingleOrDefault(r => r.ProductName == topBottomProductData.ProductName); - d.ShouldNotBeNull(); - d.SalesValue.ShouldBe(topBottomProductData.SalesValue); - } - } - - [Fact] - public void ModelFactory_ConvertFrom_TopBottomProductData_ModelIsNull_NullReturned() { - - List model = null; - var result = ModelFactory.ConvertFrom(model); - result.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_TopBottomProductData_ModelIsEmpty_NullReturned() { - - List model = new List(); - var result = ModelFactory.ConvertFrom(model); - result.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_LastSettlement_IsConverted() { - LastSettlement model = TestData.LastSettlement; - - LastSettlementModel result = ModelFactory.ConvertFrom(model); - result.ShouldNotBeNull(); - result.FeesValue.ShouldBe(model.FeesValue); - result.SalesCount.ShouldBe(model.SalesCount); - result.SalesValue.ShouldBe(model.SalesValue); - result.SettlementDate.ShouldBe(model.SettlementDate); - } - - [Fact] - public void ModelFactory_ConvertFrom_LastSettlement_ModelIsNull_IsConverted() { - LastSettlement model = null; - - var result = ModelFactory.ConvertFrom(model); - result.ShouldBeNull(); - } - - [Theory] - [InlineData(Models.SettlementSchedule.Immediate, TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Immediate)] - [InlineData(Models.SettlementSchedule.Monthly, TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Monthly)] - [InlineData(Models.SettlementSchedule.Weekly, TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Weekly)] - [InlineData((Models.SettlementSchedule)99, TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Immediate)] - public void ModelFactory_ConvertFrom_SettlementSchedule_IsConverted(Models.SettlementSchedule settlementSchedule, - TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule expectedResult) { - TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule result = ModelFactory.ConvertFrom(settlementSchedule); - result.ShouldBe(expectedResult); - } - - [Theory] - [InlineData(BusinessLogic.Models.SettlementSchedule.Immediate, TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Immediate)] - [InlineData(BusinessLogic.Models.SettlementSchedule.Weekly, TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Weekly)] - [InlineData(BusinessLogic.Models.SettlementSchedule.Monthly, TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Monthly)] - public void ModelFactory_ConvertFrom_CreateMerchantModel_ModelIsConverted(BusinessLogic.Models.SettlementSchedule settlementSchedule, - TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule expectedSettlementSchedule) { - CreateMerchantModel model = TestData.CreateMerchantModel(settlementSchedule); - - CreateMerchantRequest request = ModelFactory.ConvertFrom(model); - - request.Contact.ShouldNotBeNull(); - request.Contact.EmailAddress.ShouldBe(model.Contact.ContactEmailAddress); - request.Contact.PhoneNumber.ShouldBe(model.Contact.ContactPhoneNumber); - request.Contact.ContactName.ShouldBe(model.Contact.ContactName); - - request.Address.ShouldNotBeNull(); - request.Address.AddressLine1.ShouldBe(model.Address.AddressLine1); - request.Address.AddressLine2.ShouldBe(model.Address.AddressLine2); - request.Address.AddressLine3.ShouldBe(model.Address.AddressLine3); - request.Address.AddressLine4.ShouldBe(model.Address.AddressLine4); - request.Address.Town.ShouldBe(model.Address.Town); - request.Address.Region.ShouldBe(model.Address.Region); - request.Address.Country.ShouldBe(model.Address.Country); - request.Address.PostalCode.ShouldBe(model.Address.PostalCode); - - request.Name.ShouldBe(model.MerchantName); - request.SettlementSchedule.ShouldBe(expectedSettlementSchedule); - } - - [Fact] - public void ModelFactory_ConvertFrom_CreateMerchantModel_ModelIsNull_ModelIsConverted() { - CreateMerchantModel model = null; - - CreateMerchantRequest request = ModelFactory.ConvertFrom(model); - - request.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_Address_ModelIsConverted() { - CreateMerchantModel model = TestData.CreateMerchantModel(SettlementSchedule.Immediate); - - Address request = ModelFactory.ConvertFrom(model.Address); - - request.ShouldNotBeNull(); - request.AddressLine1.ShouldBe(model.Address.AddressLine1); - request.AddressLine2.ShouldBe(model.Address.AddressLine2); - request.AddressLine3.ShouldBe(model.Address.AddressLine3); - request.AddressLine4.ShouldBe(model.Address.AddressLine4); - request.Town.ShouldBe(model.Address.Town); - request.Region.ShouldBe(model.Address.Region); - request.Country.ShouldBe(model.Address.Country); - request.PostalCode.ShouldBe(model.Address.PostalCode); - } - - [Fact] - public void ModelFactory_ConvertFrom_Address_AddressIsNull_ModelIsConverted() { - CreateMerchantModel model = TestData.CreateMerchantModel(SettlementSchedule.Immediate); - model.Address = null; - - var request = ModelFactory.ConvertFrom(model.Address); - - request.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_Contact_ModelIsConverted() { - CreateMerchantModel model = TestData.CreateMerchantModel(SettlementSchedule.Immediate); - - Contact request = ModelFactory.ConvertFrom(model.Contact); - - request.ShouldNotBeNull(); - request.EmailAddress.ShouldBe(model.Contact.ContactEmailAddress); - request.PhoneNumber.ShouldBe(model.Contact.ContactPhoneNumber); - request.ContactName.ShouldBe(model.Contact.ContactName); - } - - [Fact] - public void ModelFactory_ConvertFrom_Contact_ContactIsNull_ModelIsConverted() { - CreateMerchantModel model = TestData.CreateMerchantModel(SettlementSchedule.Immediate); - model.Contact = null; - Contact request = ModelFactory.ConvertFrom(model.Contact); - - request.ShouldBeNull(); - } - - [Theory] - [InlineData(BusinessLogic.Models.SettlementSchedule.Immediate, TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Immediate)] - [InlineData(BusinessLogic.Models.SettlementSchedule.Weekly, TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Weekly)] - [InlineData(BusinessLogic.Models.SettlementSchedule.Monthly, TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Monthly)] - public void ModelFactory_ConvertFrom_UpdateMerchantModel_ModelIsConverted(BusinessLogic.Models.SettlementSchedule settlementSchedule, - TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule expectedSettlementSchedule) { - UpdateMerchantModel model = TestData.UpdateMerchantModel(settlementSchedule); - - var request = ModelFactory.ConvertFrom(model); - - request.Name.ShouldBe(model.MerchantName); - request.SettlementSchedule.ShouldBe(expectedSettlementSchedule); - } - - [Fact] - public void ModelFactory_ConvertFrom_UpdateMerchantModel_ModelIsNull_ModelIsConverted() { - UpdateMerchantModel model = null; - - var request = ModelFactory.ConvertFrom(model); - - request.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_MerchantResponse_ResponseIsConverted() { - MerchantResponse response = TestData.MerchantResponse; - - var model = ModelFactory.ConvertFrom(response); - - model.ShouldNotBeNull(); - model.MerchantId.ShouldBe(response.MerchantId); - model.MerchantName.ShouldBe(response.MerchantName); - model.SettlementSchedule.ShouldBe(response.SettlementSchedule.ToString()); - model.MerchantReference.ShouldBe(response.MerchantReference); - model.Address.AddressLine1.ShouldBe(response.Addresses.First().AddressLine1); - model.Address.AddressLine2.ShouldBe(response.Addresses.First().AddressLine2); - model.Address.AddressLine3.ShouldBe(response.Addresses.First().AddressLine3); - model.Address.AddressLine4.ShouldBe(response.Addresses.First().AddressLine4); - model.Address.Town.ShouldBe(response.Addresses.First().Town); - model.Address.Region.ShouldBe(response.Addresses.First().Region); - model.Address.Country.ShouldBe(response.Addresses.First().Country); - model.Address.PostalCode.ShouldBe(response.Addresses.First().PostalCode); - model.Contact.ContactName.ShouldBe(response.Contacts.First().ContactName); - model.Contact.ContactEmailAddress.ShouldBe(response.Contacts.First().ContactEmailAddress); - model.Contact.ContactPhoneNumber.ShouldBe(response.Contacts.First().ContactPhoneNumber); - - model.Operators.Count.ShouldBe(response.Operators.Count); - response.Operators.ForEach(o => { - var operatorModel = model.Operators.SingleOrDefault(mo => mo.OperatorId == o.OperatorId); - operatorModel.ShouldNotBeNull(); - operatorModel.Name.ShouldBe(o.Name); - operatorModel.IsDeleted.ShouldBe(o.IsDeleted); - operatorModel.MerchantNumber.ShouldBe(o.MerchantNumber); - operatorModel.TerminalNumber.ShouldBe(o.TerminalNumber); - }); - - model.Devices.Count.ShouldBe(response.Devices.Count); - foreach (var device in response.Devices) { - model.Devices.ShouldContainKeyAndValue(device.Key, device.Value); - } - - model.Contracts.Count.ShouldBe(response.Contracts.Count); - response.Contracts.ForEach(c => { - var contractModel = model.Contracts.SingleOrDefault(mc => mc.ContractId == c.ContractId); - contractModel.ShouldNotBeNull(); - contractModel.IsDeleted.ShouldBe(c.IsDeleted); - }); - } - - [Fact] - public void ModelFactory_ConvertFrom_MerchantResponse_ResponseIsNull_ResponseIsConverted() { - MerchantResponse response = null; - - var model = ModelFactory.ConvertFrom(response); - - model.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_AssignOperatorToMerchantModel_ModelIsConverted() - { - var model = TestData.AssignOperatorToMerchantModel; - var request = ModelFactory.ConvertFrom(model); - request.ShouldNotBeNull(); - request.OperatorId.ShouldBe(model.OperatorId); - } - - [Fact] - public void ModelFactory_ConvertFrom_AssignOperatorToMerchantModel_ModelIsNull_ModelIsConverted() { - AssignOperatorToMerchantModel model = null; - var request = ModelFactory.ConvertFrom(model); - request.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_AssignContractToMerchantModel_ModelIsConverted() - { - var model = TestData.AssignContractToMerchantModel; - var request = ModelFactory.ConvertFrom(model); - request.ShouldNotBeNull(); - request.ContractId.ShouldBe(model.ContractId); - } - - [Fact] - public void ModelFactory_ConvertFrom_AssignContractToMerchantModel_ModelIsNull_ModelIsConverted() - { - AssignContractToMerchantModel model = null; - var request = ModelFactory.ConvertFrom(model); - 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() - { - FileDetails source = null; - - var result = ModelFactory.ConvertFrom(source); - - result.ShouldBeNull(); - } - - [Fact] - public void ModelFactory_ConvertFrom_FileDetails_SourceIsConverted() - { - FileDetails source = TestData.FileDetails; - - var result = ModelFactory.ConvertFrom(source); - - result.ShouldNotBeNull(); - result.FileId.ShouldBe(source.FileId); - result.FileProfileId.ShouldBe(source.FileProfileId); - result.FileProfileName.ShouldBe(source.FileProfileName); - result.FileImportLogId.ShouldBe(source.FileImportLogId); - result.FileLocation.ShouldBe(source.FileLocation); - result.ProcessingCompleted.ShouldBe(source.ProcessingCompleted); - result.EstateId.ShouldBe(source.EstateId); - result.UserId.ShouldBe(source.UserId); - result.UserEmailAddress.ShouldBe(source.UserEmailAddress); - result.MerchantId.ShouldBe(source.MerchantId); - result.MerchantName.ShouldBe(source.MerchantName); - result.ProcessingSummary.FailedLines.ShouldBe(source.ProcessingSummary.FailedLines); - result.ProcessingSummary.IgnoredLines.ShouldBe(source.ProcessingSummary.IgnoredLines); - result.ProcessingSummary.NotProcessedLines.ShouldBe(source.ProcessingSummary.NotProcessedLines); - result.ProcessingSummary.RejectedLines.ShouldBe(source.ProcessingSummary.RejectedLines); - result.ProcessingSummary.SuccessfullyProcessedLines.ShouldBe(source.ProcessingSummary.SuccessfullyProcessedLines); - result.ProcessingSummary.TotalLines.ShouldBe(source.ProcessingSummary.TotalLines); - - result.FileLines.Count.ShouldBe(source.FileLines.Count); - foreach (var fileLine in source.FileLines) - { - FileLineModel? fileLineModel = result.FileLines.SingleOrDefault(fl => fl.LineNumber == fileLine.LineNumber); - fileLineModel.ShouldNotBeNull(); - fileLineModel.LineData.ShouldBe(fileLine.LineData); - fileLineModel.RejectionReason.ShouldBe(fileLine.RejectionReason); - fileLineModel.TransactionId.ShouldBe(fileLine.TransactionId); - fileLineModel.ProcessingResult.ShouldBe(fileLine.ProcessingResult switch - { - FileLineProcessingResult.Failed => Models.FileLineProcessingResult.Failed, - FileLineProcessingResult.Ignored => Models.FileLineProcessingResult.Ignored, - FileLineProcessingResult.NotProcessed => Models.FileLineProcessingResult.NotProcessed, - FileLineProcessingResult.Rejected => Models.FileLineProcessingResult.Rejected, - FileLineProcessingResult.Successful => Models.FileLineProcessingResult.Successful, - _ => Models.FileLineProcessingResult.Unknown - }); - } - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.BusinessLogic.Tests/PermissionsServiceTests.cs b/EstateManagementUI.BusinessLogic.Tests/PermissionsServiceTests.cs deleted file mode 100644 index bf57229d..00000000 --- a/EstateManagementUI.BusinessLogic.Tests/PermissionsServiceTests.cs +++ /dev/null @@ -1,253 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Testing; -using Microsoft.Extensions.Configuration; -using Moq; -using Shared.General; -using Shouldly; -using SimpleResults; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using EstateManagementUI.BusinessLogic.Common; -using EstateManagementUI.BusinessLogic.PermissionService.Database.Entities; -using Xunit; - -namespace EstateManagementUI.BusinessLogic.Tests -{ - public class PermissionsServiceTests - { - private readonly Mock _permissionsRepositoryMock; - private readonly Mock _configurationServiceMock; - private readonly PermissionsService _permissionsService; - - public PermissionsServiceTests() - { - _permissionsRepositoryMock = new Mock(); - _configurationServiceMock = new Mock(); - _permissionsService = new PermissionsService(_permissionsRepositoryMock.Object, this._configurationServiceMock.Object); - - } - - [Fact] - public async Task DoIHavePermissions_BypassPermissions_ReturnsSuccess() - { - // Arrange - this._configurationServiceMock.Setup(service => service.GetPermissionsBypass()).Returns(true); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section", "function"); - - // Assert - Assert.True(result.IsSuccess); - } - - [Theory] - [InlineData(null)] - [InlineData("")] - public async Task DoIHavePermissions_UserNameValidation_ReturnsForbidden(String userName) - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)>()); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)>()); - - // Act - var result = await _permissionsService.DoIHavePermissions(userName, "section", "function"); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Theory] - [InlineData(null)] - [InlineData("")] - public async Task DoIHavePermissions_SectionNameValidation_ReturnsForbidden(String sectionName) - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)>()); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)>()); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", sectionName, "function"); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Theory] - [InlineData(null)] - [InlineData("")] - public async Task DoIHavePermissions_FunctionValidation_ReturnsForbidden(String function) - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)>()); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)>()); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section", function); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Fact] - public async Task DoIHavePermissions_NoRolesAssigned_ReturnsForbidden() - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)>()); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)>()); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section", "function"); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Fact] - public async Task DoIHavePermissions_NoFunctionsAssigned_ReturnsForbidden() - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)>()); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)> { ("user", "role") }); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section", "function"); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Fact] - public async Task DoIHavePermissions_NoPermissions_ReturnsSuccess() - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)> { ("role", "section", "function") }); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)> { ("user", "role") }); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section", "function1"); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Fact] - public async Task DoIHavePermissions_PermissionGranted_ReturnsSuccess() - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)> { ("role", "section", "function") }); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)> { ("user", "role") }); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section", "function"); - - // Assert - result.IsSuccess.ShouldBeTrue(); - } - - [Fact] - public async Task DoIHavePermissions_SectionOnly_BypassPermissions_ReturnsSuccess() - { - // Arrange - this._configurationServiceMock.Setup(service => service.GetPermissionsBypass()).Returns(true); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section"); - - // Assert - result.IsSuccess.ShouldBeTrue(); - } - - [Theory] - [InlineData(null)] - [InlineData("")] - public async Task DoIHavePermissions_SectionOnly_UserNameValidation_ReturnsForbidden(String userName) - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)>()); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)>()); - - // Act - var result = await _permissionsService.DoIHavePermissions(userName, "section"); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Theory] - [InlineData(null)] - [InlineData("")] - public async Task DoIHavePermissions_SectionOnly_SectionNameValidation_ReturnsForbidden(String sectionName) - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)>()); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)>()); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", sectionName); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Fact] - public async Task DoIHavePermissions_SectionOnly_NoRolesAssigned_ReturnsForbidden() - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)>()); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)>()); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section"); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Fact] - public async Task DoIHavePermissions_SectionOnly_NoFunctionsAssigned_ReturnsForbidden() - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)>()); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)> { ("user", "role") }); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section"); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Fact] - public async Task DoIHavePermissions_SectionOnly_NoPermission_ReturnsForbidden() - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)>() { - ("role", "section1", "function") - }); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)> { ("user", "role") }); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section"); - - // Assert - result.Status.ShouldBe(ResultStatus.Forbidden); - } - - [Fact] - public async Task DoIHavePermissions_SectionOnly_PermissionGranted_ReturnsSuccess() - { - // Arrange - _permissionsRepositoryMock.Setup(repo => repo.GetRolesFunctions()).ReturnsAsync(new List<(string, string, string)> { ("role", "section", "function") }); - _permissionsRepositoryMock.Setup(repo => repo.GetUsers(It.IsAny())).ReturnsAsync(new List<(string, string)> { ("user", "role") }); - - // Act - var result = await _permissionsService.DoIHavePermissions("user", "section"); - - // Assert - result.IsSuccess.ShouldBeTrue(); - } - } -} diff --git a/EstateManagementUI.IntegrationTests/Common/ClientDetails.cs b/EstateManagementUI.IntegrationTests/Common/ClientDetails.cs deleted file mode 100644 index 793b03e5..00000000 --- a/EstateManagementUI.IntegrationTests/Common/ClientDetails.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace EstateManagementUI.IntegrationTests.Common -{ - public class ClientDetails - { - public String ClientId { get; private set; } - public String ClientSecret { get; private set; } - public List GrantTypes { get; private set; } - - private ClientDetails(String clientId, - String clientSecret, - List grantTypes) - { - this.ClientId = clientId; - this.ClientSecret = clientSecret; - this.GrantTypes = grantTypes; - } - - public static ClientDetails Create(String clientId, - String clientSecret, - List grantTypes) - { - return new ClientDetails(clientId, clientSecret, grantTypes); - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/Common/DockerHelper.cs b/EstateManagementUI.IntegrationTests/Common/DockerHelper.cs deleted file mode 100644 index b05b2811..00000000 --- a/EstateManagementUI.IntegrationTests/Common/DockerHelper.cs +++ /dev/null @@ -1,467 +0,0 @@ -using System; -using System.Collections.Generic; -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.BusinessLogic.PermissionService.Database; -using EstateManagementUI.BusinessLogic.PermissionService.Database.Entities; -using EstateManagementUI.Controllers; -using EventStore.Client; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using SecurityService.Client; -using Shared.Exceptions; -using Shared.IntegrationTesting; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using DotNet.Testcontainers.Builders; -using DotNet.Testcontainers.Containers; -using DotNet.Testcontainers.Networks; -using Shared.IntegrationTesting.TestContainers; -using TransactionProcessor.Client; - -namespace EstateManagementUI.IntegrationTests.Common -{ - public class DockerHelper : global::Shared.IntegrationTesting.TestContainers.DockerHelper - { - #region Fields - - public ITransactionProcessorClient TransactionProcessorClient; - - public HttpClient HttpClient; - - public ISecurityServiceClient SecurityServiceClient; - - public EventStoreProjectionManagementClient ProjectionManagementClient; - - public HttpClient TestHostHttpClient; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The logger. - public DockerHelper() - { - this.TestingContext = new TestingContext(); - } - - #endregion - - #region Methods - - public Int32 EstateManagementUiPort; - - protected String EstateManagementUiContainerName; - - private readonly TestingContext TestingContext; - - public override void SetupContainerNames() { - base.SetupContainerNames(); - this.SecurityServiceContainerName = $"identity-server{this.TestId:N}"; - this.EstateManagementUiContainerName = $"estateadministrationui{this.TestId:N}"; - } - - private static void AddEntryToHostsFile(String ipaddress, - String hostname) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - var hostsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), @"drivers\etc\hosts"); - using (StreamWriter w = File.AppendText(hostsPath)) - { - w.WriteLine($"{ipaddress} {hostname}"); - } - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - DockerHelper.ExecuteBashCommand($"echo {ipaddress} {hostname} | sudo tee -a /etc/hosts"); - } - } - - /// - /// Executes the bash command. - /// - /// The command. - /// - private static void ExecuteBashCommand(String command) - { - // according to: https://stackoverflow.com/a/15262019/637142 - // thans to this we will pass everything as one command - command = command.Replace("\"", "\"\""); - - var proc = new Process - { - StartInfo = new ProcessStartInfo - { - FileName = "/bin/bash", - Arguments = "-c \"" + command + "\"", - UseShellExecute = false, - RedirectStandardOutput = true, - CreateNoWindow = true - } - }; - Console.WriteLine(proc.StartInfo.Arguments); - - proc.Start(); - proc.WaitForExit(); - } - - public override async Task CreateSubscriptions(){ - List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new(); - subscriptions.AddRange(MessagingService.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); - subscriptions.AddRange(TransactionProcessor.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); - - // TODO: Add File Processor Subscriptions - - foreach ((String streamName, String groupName, Int32 maxRetries) subscription in subscriptions) - { - var x = subscription; - x.maxRetries = 2; - await this.CreatePersistentSubscription(x); - } - } - - protected override List GetRequiredProjections() - { - List requiredProjections = new List(); - - requiredProjections.Add("EstateAggregator.js"); - requiredProjections.Add("MerchantAggregator.js"); - requiredProjections.Add("MerchantBalanceCalculator.js"); - requiredProjections.Add("MerchantBalanceProjection.js"); - - return requiredProjections; - } - - public override ContainerBuilder SetupTransactionProcessorContainer() - { - - Dictionary variables = new Dictionary(); - variables.Add($"OperatorConfiguration:PataPawaPrePay:Url",$"http://{this.TestHostContainerName}:{DockerPorts.TestHostPort}/api/patapawaprepay"); - - this.AdditionalVariables.Add(ContainerType.FileProcessor, variables); - - return base.SetupTransactionProcessorContainer(); - } - - /// - /// Starts the containers for scenario run. - /// - /// Name of the scenario. - public override async Task StartContainersForScenarioRun(String scenarioName, DockerServices dockerServices) - { - await base.StartContainersForScenarioRun(scenarioName, dockerServices); - - await this.StartEstateManagementUiContainer(this.TestNetworks, this.SecurityServicePort, DockerPorts.SecurityServiceDockerPort); - - // Setup the base address resolvers - String TransactionProcessorBaseAddressResolver(String api) => $"http://127.0.0.1:{this.TransactionProcessorPort}"; - - HttpClientHandler clientHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (message, - certificate2, - arg3, - arg4) => - { - return true; - } - - }; - HttpClient httpClient = new HttpClient(clientHandler); - this.TransactionProcessorClient = new TransactionProcessorClient(TransactionProcessorBaseAddressResolver, httpClient); - Func securityServiceBaseAddressResolver = api => $"https://127.0.0.1:{this.SecurityServicePort}"; - this.SecurityServiceClient = new SecurityServiceClient(securityServiceBaseAddressResolver, httpClient); - this.TestHostHttpClient = new HttpClient(clientHandler); - this.TestHostHttpClient.BaseAddress = new Uri($"http://127.0.0.1:{this.TestHostServicePort}"); - this.ProjectionManagementClient = new EventStoreProjectionManagementClient(ConfigureEventStoreSettings()); - } - - private async Task StartEstateManagementUiContainer(List networkServices, - Int32 securityServiceContainerPort, - Int32 securityServiceLocalPort) - { - TraceX("About to Start Estate Management UI Container"); - - var environmentVariables = this.GetCommonEnvironmentVariables(); - - environmentVariables.Remove("AppSettings:ClientId"); - environmentVariables.Remove("AppSettings:ClientSecret"); - - environmentVariables.Add("AppSettings:Authority",$"https://{this.SecurityServiceContainerName}:0"); // The port is set to 0 to stop defaulting to 443 - environmentVariables.Add("AppSettings:SecurityServiceLocalPort",$"{securityServiceLocalPort}"); - environmentVariables.Add("AppSettings:SecurityServicePort",$"{securityServiceContainerPort}"); - environmentVariables.Add("AppSettings:HttpClientIgnoreCertificateErrors",$"true"); - //environmentVariables.Add($"AppSettings:PermissionsBypass=true"); - environmentVariables.Add("AppSettings:IsIntegrationTest","true"); - environmentVariables.Add("ASPNETCORE_ENVIRONMENT","Development"); - environmentVariables.Add("EstateManagementScope","estateManagement"); - environmentVariables.Add("urls","https://*:5004"); - environmentVariables.Add($"AppSettings:ClientId","estateUIClient"); - environmentVariables.Add($"AppSettings:ClientSecret","Secret1"); - environmentVariables.Add($"AppSettings:BackEndClientId", "serviceClient"); - environmentVariables.Add($"AppSettings:BackEndClientSecret", "Secret1"); - environmentVariables.Add($"DataReloadConfig:DefaultInSeconds","1"); - environmentVariables.Add("ConnectionStrings:TransactionProcessorReadModel", this.SetConnectionString( "TransactionProcessorReadModel", this.UseSecureSqlServerDatabase)); - - TraceX("About to Built Estate Management UI Container"); - ContainerBuilder containerBuilder = new ContainerBuilder() - .WithName(this.EstateManagementUiContainerName) - .WithImage("estatemanagementui") - .WithEnvironment(environmentVariables) - .MountHostFolder(this.DockerPlatform, this.HostTraceFolder) - //.UseNetwork(networkServices.ToArray()) - .WithPortBinding(5004); - //.MountHostFolder(this.DockerPlatform, this.HostTraceFolder) - //.SetDockerCredentials(this.DockerCredentials); - TraceX("About to Call .Start()"); - foreach (INetwork networkService in networkServices) { - containerBuilder = containerBuilder.WithNetwork(networkService); - } - - IContainer? builtContainer = containerBuilder.Build(); - - try{ - - await builtContainer.StartAsync(); - //builtContainer.WaitForPort("5004/tcp", 30000); - this.EstateManagementUiPort = builtContainer.GetMappedPublicPort($"5004"); - - await Task.Delay(5000); - - TraceX("Estate Management UI Started"); - - HttpClientHandler handler = new HttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = - HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; - // TODO: Refactor this code once it works... - using (HttpClient client = new HttpClient(handler)) { - HttpRequestMessage createRolesRequest = new (HttpMethod.Post, - $"https://localhost:{this.EstateManagementUiPort}/api/Permissions/createRoles"); - - List roles = ["Administrator"]; - - createRolesRequest.Content = new StringContent(JsonConvert.SerializeObject(roles), Encoding.UTF8, - "application/json"); - - var response = await client.SendAsync(createRolesRequest, CancellationToken.None); - - if (response.IsSuccessStatusCode == false) { - TraceX($"createRolesRequest failed [{response.StatusCode}]"); - } - TraceX($"Create Role Response is [{response.StatusCode}]"); - - HttpRequestMessage addUserToRoleRequest = new(HttpMethod.Post, - $"https://localhost:{this.EstateManagementUiPort}/api/Permissions/addUserToRole"); - List userRolesList = new List { - new AddUserToRole { UserName = "estateuser@testestate1.co.uk", RoleName = "Administrator" } - }; - - addUserToRoleRequest.Content = new StringContent(JsonConvert.SerializeObject(userRolesList), Encoding.UTF8, - "application/json"); - - response = await client.SendAsync(addUserToRoleRequest, CancellationToken.None); - if (response.IsSuccessStatusCode == false) - { - TraceX($"addUserToRoleRequest failed [{response.StatusCode}]"); - } - - TraceX($"Add User to Role Response is [{response.StatusCode}]"); - - HttpRequestMessage getRolePermissionsRequest = new(HttpMethod.Get, - $"https://localhost:{this.EstateManagementUiPort}/api/Permissions/getRolePermissions?roleName=Administrator"); - - response = await client.SendAsync(getRolePermissionsRequest, CancellationToken.None); - - if (response.IsSuccessStatusCode == false) - { - TraceX($"getRolePermissionsRequest failed [{response.StatusCode}]"); - } - - var x = await response.Content.ReadAsStringAsync(CancellationToken.None); - - RolePermissionsObject rolePermissionsObject = JsonConvert.DeserializeObject(x); - - List<(int, string, int, string, bool)> Permissions = new(); - foreach (ApplicationSection applicationSection in rolePermissionsObject.ApplicationSections) - { - List<(Function, bool)> functionAccess = rolePermissionsObject.PermissionsList.Where(p => - p.ApplicationSection.ApplicationSectionId == applicationSection.ApplicationSectionId).Select(x => (x.Function, x.HasAccess)).ToList(); - - foreach ((Function, bool) function in functionAccess) - { - Permissions.Add((applicationSection.ApplicationSectionId, applicationSection.Name, function.Item1.FunctionId, function.Item1.Name, function.Item2)); - } - } - - List<(int, int, bool)> newPermissions = Permissions.Select(p => (p.Item1, p.Item3, true)).ToList(); - - HttpRequestMessage addRolePermissionsRequest = new(HttpMethod.Post, - $"https://localhost:{this.EstateManagementUiPort}/api/Permissions/addRolePermissions"); - - List rolePermissions = new() { - new RolePermissions { NewPermissions = newPermissions, RoleName = "Administrator" } - }; - - addRolePermissionsRequest.Content = new StringContent(JsonConvert.SerializeObject(rolePermissions), Encoding.UTF8, - "application/json"); - - response = await client.SendAsync(addRolePermissionsRequest, CancellationToken.None); - if (response.IsSuccessStatusCode == false) - { - TraceX($"addRolePermissionsRequest failed [{response.StatusCode}]"); - } - } - } - catch(Exception ex){ - TraceX(ex.GetCombinedExceptionMessages()); - - } - - TraceX("About to attach networkServices"); - //foreach (INetwork networkService in networkServices) - //{ - // //networkService..Attach(builtContainer, false); - // builtContainer. - //} - - //Trace("About to get port"); - //// Do a health check here - //var x = builtContainer.ToHostExposedEndpoint($"5004/tcp"); - //if (x == null){ - // Trace("x is null"); - //} - - - - - this.Containers.Add(((DockerServices)1024, builtContainer)); - //await Retry.For(async () => - //{ - // String healthCheck = - // await this.HealthCheckClient.PerformHealthCheck("http", "127.0.0.1", this.EstateManagementUiPort, CancellationToken.None); - - // var result = JsonConvert.DeserializeObject(healthCheck); - // result.Status.ShouldBe(HealthCheckStatus.Healthy.ToString(), $"Details {healthCheck}"); - //}); - - return builtContainer; - } - - public override ContainerBuilder SetupSecurityServiceContainer() - { - this.TraceX("About to Start Security Container"); - - Retry.For(() => { - DockerHelper.AddEntryToHostsFile("127.0.0.1", SecurityServiceContainerName); - return Task.CompletedTask; - }); - - Retry.For(() => { - DockerHelper.AddEntryToHostsFile("localhost", SecurityServiceContainerName); - return Task.CompletedTask; - }); - - - - var environmentVariables = this.GetCommonEnvironmentVariables(); - environmentVariables.Add($"ServiceOptions:PublicOrigin",$"https://{this.SecurityServiceContainerName}:{DockerPorts.SecurityServiceDockerPort}"); - environmentVariables.Add($"ServiceOptions:IssuerUrl",$"https://{this.SecurityServiceContainerName}:{DockerPorts.SecurityServiceDockerPort}"); - environmentVariables.Add("ASPNETCORE_ENVIRONMENT",$"IntegrationTest"); - environmentVariables.Add($"urls",$"https://*:{DockerPorts.SecurityServiceDockerPort}"); - - environmentVariables.Add($"ServiceOptions:PasswordOptions:RequiredLength","6"); - environmentVariables.Add($"ServiceOptions:PasswordOptions:RequireDigit","false"); - environmentVariables.Add($"ServiceOptions:PasswordOptions:RequireUpperCase","false"); - environmentVariables.Add($"ServiceOptions:UserOptions:RequireUniqueEmail","false"); - environmentVariables.Add($"ServiceOptions:SignInOptions:RequireConfirmedEmail","false"); - - environmentVariables.Add("ConnectionStrings:PersistedGrantDbContext",this.SetConnectionString($"PersistedGrantStore-{this.TestId}", this.UseSecureSqlServerDatabase)); - environmentVariables.Add("ConnectionStrings:ConfigurationDbContext", this.SetConnectionString($"Configuration-{this.TestId}", this.UseSecureSqlServerDatabase)); - environmentVariables.Add("ConnectionStrings:AuthenticationDbContext",this.SetConnectionString($"Authentication-{this.TestId}", this.UseSecureSqlServerDatabase)); - - environmentVariables.Add("Logging:LogLevel:Microsoft","Information"); - environmentVariables.Add("Logging:LogLevel:Default","Information"); - environmentVariables.Add("Logging:EventLog:LogLevel:Default","None"); - - var imageDetailsResult = this.GetImageDetails(ContainerType.SecurityService); - - ContainerBuilder securityServiceContainer = new ContainerBuilder() - .WithName(this.SecurityServiceContainerName) - .WithEnvironment(environmentVariables) - .WithImage(imageDetailsResult.Data.imageName) - .MountHostFolder(this.DockerPlatform, this.HostTraceFolder) - .WithPortBinding(DockerPorts.SecurityServiceDockerPort); - //.MountHostFolder(this.DockerPlatform, this.HostTraceFolder) - //.SetDockerCredentials(this.DockerCredentials); - - - // Now build and return the container - return securityServiceContainer; - } - - /// - /// Stops the containers for scenario run. - /// - public override async Task StopContainersForScenarioRun(DockerServices sharedDockerServices) - { - await this.RemoveEstateReadModel().ConfigureAwait(false); - - await base.StopContainersForScenarioRun(sharedDockerServices); - } - - private async Task RemoveEstateReadModel() - { - //List estateIdList = this.TestingContext.GetAllEstateIds(); - - //foreach (Guid estateId in estateIdList) - //{ - // String databaseName = $"EstateReportingReadModel{estateId}"; - - // // Build the connection string (to master) - // String connectionString = Setup.GetLocalConnectionString(databaseName); - // await Retry.For(async () => - // { - // EstateReportingSqlServerContext context = new EstateReportingSqlServerContext(connectionString); - // await context.Database.EnsureDeletedAsync(CancellationToken.None); - // }, - // retryFor: TimeSpan.FromMinutes(2), - // retryInterval: TimeSpan.FromSeconds(30)); - //} - } - - private async Task CreatePermissionsRepository(String dbConnString, CancellationToken cancellationToken) { - var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseSqlite(dbConnString); // Configure for your database provider - - var serviceProvider = new ServiceCollection() - .AddLogging(config => config.AddConsole()) // Add logging if needed - .BuildServiceProvider(); - - // Create the DbContextFactory instance - var contextFactory = new DbContextFactory(serviceProvider, optionsBuilder.Options, new DbContextFactorySource()); - - //var ctx = await contextFactory.CreateDbContextAsync(cancellationToken); - - return new PermissionsRepository(contextFactory); - } - - public void TraceX(String msg) { - Trace(msg); - Console.WriteLine(msg); - } - - #endregion - } -} diff --git a/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs b/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs deleted file mode 100644 index b0fe9eb5..00000000 --- a/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs +++ /dev/null @@ -1,1133 +0,0 @@ -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; - -public class EstateManagementUiHelpers{ - private readonly IWebDriver WebDriver; - - private readonly Int32 EstateManagementUiPort; - - public EstateManagementUiHelpers(IWebDriver webDriver, Int32 estateManagementUiPort){ - this.WebDriver = webDriver; - this.EstateManagementUiPort = estateManagementUiPort; - } - - private void VerifyPageTitle(String expectedTitle) { - this.WebDriver.Title.ShouldBe($"{expectedTitle} - Estate Management"); - } - - public void NavigateToHomePage(){ - this.WebDriver.Navigate().GoToUrl($"https://localhost:{this.EstateManagementUiPort}"); - // Reapply size in headless mode - this.WebDriver.Manage().Window.Size = new System.Drawing.Size(1920, 1080); - this.VerifyPageTitle("Welcome"); - } - - public async Task ClickContractsSidebarOption(){ - await this.WebDriver.ClickButtonById("contractsLink"); - } - - public async Task ClickMyEstateSidebarOption(){ - await this.WebDriver.ClickButtonById("estateDetailsLink"); - } - - public async Task ClickMyMerchantsSidebarOption(){ - await this.WebDriver.ClickButtonById("merchantsLink"); - } - - public async Task ClickMyOperatorsSidebarOption(){ - await this.WebDriver.ClickButtonById("operatorsLink"); - } - - public async Task ClickOnTheSignInButton(){ - await this.WebDriver.ClickButtonById("loginButton"); - } - - public async Task VerifyOnTheMakeMerchantDepositScreen(){ - await Retry.For(async () => { this.WebDriver.Title.ShouldBe("Make Merchant Deposit"); }); - } - - public async Task VerifyOnTheTheMerchantDetailsScreen(String merchantName){ - - await Retry.For(async () => { - IWebElement element = this.WebDriver.FindElement(By.Id("MerchantName")); - element.ShouldNotBeNull(); - String elementValue = element.GetDomProperty("value"); - elementValue.ShouldBe(merchantName); - }); - } - - public async Task VerifyOnTheNewContractScreen(){ - await Retry.For(async () => { this.VerifyPageTitle("New Contract"); }); - } - - public async Task VerifyOnTheNewContractProductScreen() - { - await Retry.For(async () => { this.VerifyPageTitle("New Contract Product" ); }); - } - - public async Task VerifyOnTheNewMerchantScreen(){ - await Retry.For(async () => { this.VerifyPageTitle("New Merchant"); }); - } - - public async Task VerifyOnTheEditMerchantScreen() - { - await Retry.For(async () => { this.VerifyPageTitle("Edit Merchant"); }); - } - - public async Task VerifyOnTheMakeDepositScreen() - { - await Retry.For(async () => { this.VerifyPageTitle("Make Deposit"); }); - } - - public async Task VerifyOnTheViewMerchantScreen() - { - await Retry.For(async () => { this.VerifyPageTitle("View Merchant"); }); - } - - public async Task VerifyOnTheNewOperatorScreen() - { - await Retry.For(async () => { this.VerifyPageTitle("New Operator"); }); - } - - public async Task VerifyOnTheEditOperatorScreen() - { - await Retry.For(async () => { this.VerifyPageTitle("Edit Operator"); }); - } - - public async Task VerifyOnTheContractsListScreen(){ - await Retry.For(async () => { this.VerifyPageTitle("View Contracts"); }); - } - - public async Task VerifyOnTheContractProductsListScreen() - { - await Retry.For(async () => { this.VerifyPageTitle("View Contract Products"); }); - } - - public async Task VerifyOnTheContractProductsFeesListScreen() { - await Retry.For(async () => { this.VerifyPageTitle("View Contract Product Fees"); }); - } - - public async Task VerifyOnTheNewTransactionFeeScreen() - { - await Retry.For(async () => { this.VerifyPageTitle("New Transaction Fee"); }); - } - - public async Task VerifyOnTheLoginScreen(){ - await Retry.For(async () => { - IWebElement loginButton = await this.WebDriver.FindButtonByText("Login", TimeSpan.FromMinutes(2)); - loginButton.ShouldNotBeNull(); - }); - } - - public async Task ClickOnTheMerchantOperatorsTab() - { - await this.ClickTab("nav-operators-tab"); - } - - 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(); - } - - public async Task VerifyOnMerchantContractsTab() - { - IWebElement element = this.WebDriver.FindElement(By.Id("merchantContractList")); - element.ShouldNotBeNull(); - } - - public async Task VerifyOnMerchantDevicesTab() - { - IWebElement element = this.WebDriver.FindElement(By.Id("merchantDeviceList")); - element.ShouldNotBeNull(); - } - - public async Task VerifyOnTheDashboard() - { - await Retry.For(async () => { - //if (this.WebDriver.Title != "Dashboard - Estate Management") - //{ - // var screenshot = this.WebDriver.TakeScreenshot(); - // var stringVersion = screenshot.AsBase64EncodedString; - // Console.WriteLine(stringVersion); - //} - - await Retry.For(async () => { this.VerifyPageTitle("Dashboard"); }); - }); - } - - public async Task VerifyOnTheEstateDetailsScreen() - { - await Retry.For(async () => { this.VerifyPageTitle("View Estate"); }); - } - - public async Task VerifyOnTheMerchantsListScreen() - { - await Retry.For(async () => { this.VerifyPageTitle("View Merchants"); }); - } - - public async Task VerifyOnTheOperatorsListScreen(){ - await Retry.For(async () => { this.VerifyPageTitle("View Operators"); }); - } - - public async Task VerifyOnTheProductsListScreen() - { - await Retry.For(async () => { this.WebDriver.Title.ShouldContain("Products for Contract - "); }); - } - - public async Task VerifyOnTheTransactionFeeListScreen() - { - await Retry.For(async () => { this.WebDriver.Title.ShouldContain("Transaction Fees for Product - "); }); - } - - public async Task VerifyTheCorrectEstateDetailsAreDisplayed(String estateName){ - await Retry.For(async () => { - IWebElement element = this.WebDriver.FindElement(By.Id("Estate_Name")); - element.ShouldNotBeNull(); - String elementValue = element.GetDomProperty("value"); - elementValue.ShouldBe(estateName); - - element = this.WebDriver.FindElement(By.Id("Estate_Reference")); - element.ShouldNotBeNull(); - elementValue = element.GetDomProperty("value"); - elementValue.ShouldNotBeNull(); - elementValue.ShouldNotBeEmpty(); - }); - } - - public async Task VerifyTheAvailableBalanceIsDisplayed(Decimal availableBalance){ - await Retry.For(async () => { - IWebElement element = this.WebDriver.FindElement(By.Id("merchantAvailableBalanceLabel")); - element.ShouldNotBeNull(); - String elementValue = element.GetDomProperty("value"); - Decimal actualBalance = Decimal.Parse(elementValue); - actualBalance.ShouldBe(availableBalance); - }, - TimeSpan.FromMinutes(2), - TimeSpan.FromSeconds(30)); - } - - public async Task VerifyTheContractDetailsAreInTheList(List<(String, String, Int32)> contractDescriptions){ - await Retry.For(async () => { - Int32 foundRowCount = 0; - IWebElement tableElement = this.WebDriver.FindElement(By.Id("contractList")); - IList rows = tableElement.FindElements(By.TagName("tr")); - - rows.Count.ShouldBe(contractDescriptions.Count + 1); - foreach ((String, String, Int32) contractDescription in contractDescriptions){ - 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 == contractDescription.Item1){ - // Compare other fields - rowTD[0].Text.ShouldBe(contractDescription.Item1); - rowTD[1].Text.ShouldBe(contractDescription.Item2); - rowTD[2].Text.ShouldBe(contractDescription.Item3.ToString()); - - // We have found the row - foundRowCount++; - break; - } - } - } - - foundRowCount.ShouldBe(contractDescriptions.Count); - }, - TimeSpan.FromSeconds(120)); - } - - public async Task VerifyTheContractProductDetailsAreInTheList(List<(String, String, String, String)> contractProductDescriptions) - { - await Retry.For(async () => { - Int32 foundRowCount = 0; - IWebElement tableElement = this.WebDriver.FindElement(By.Id("contractProductList")); - IList rows = tableElement.FindElements(By.TagName("tr")); - - rows.Count.ShouldBe(contractProductDescriptions.Count + 1); - foreach ((String, String, String,String) contractProductDescription in contractProductDescriptions) - { - 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 == contractProductDescription.Item1) - { - // Compare other fields - rowTD[0].Text.ShouldBe(contractProductDescription.Item1); - rowTD[1].Text.ShouldBe(contractProductDescription.Item2); - rowTD[2].Text.ShouldBe(contractProductDescription.Item3.ToString()); - rowTD[3].Text.ShouldBe(contractProductDescription.Item4.ToString()); - - // We have found the row - foundRowCount++; - break; - } - } - } - - foundRowCount.ShouldBe(contractProductDescriptions.Count); - }, - TimeSpan.FromSeconds(120)); - } - - public async Task VerifyTheFeeDetailsAreInTheList(List feeDescriptions) - { - await Retry.For(async () => { - Int32 foundRowCount = 0; - IWebElement tableElement = this.WebDriver.FindElement(By.Id("contractProductTransactionFeeList")); - IList rows = tableElement.FindElements(By.TagName("tr")); - - rows.Count.ShouldBe(feeDescriptions.Count + 1); - foreach (String feeDescription in feeDescriptions) - { - 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 == feeDescription) - { - // Compare other fields - rowTD[0].Text.ShouldBe(feeDescription); - - // We have found the row - foundRowCount++; - break; - } - } - } - - foundRowCount.ShouldBe(feeDescriptions.Count); - }, - TimeSpan.FromSeconds(120)); - } - - public async Task VerifyMerchantDetailsAreInTheList(List merchantDetails){ - await Retry.For(async () => { - Int32 foundRowCount = 0; - IWebElement tableElement = this.WebDriver.FindElement(By.Id("merchantList")); - IList rows = tableElement.FindElements(By.TagName("tr")); - - rows.Count.ShouldBe(merchantDetails.Count + 1); - foreach (MerchantDetails merchant in merchantDetails) - { - 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 == merchant.MerchantName) { - // Compare other fields - rowTD[2].Text.ShouldBe(merchant.SettlementSchedule); - rowTD[3].Text.ShouldBe(merchant.ContactName); - rowTD[4].Text.ShouldBe(merchant.AddressLine1); - rowTD[5].Text.ShouldBe(merchant.Town); - - // We have found the row - foundRowCount++; - break; - } - } - } - - foundRowCount.ShouldBe(merchantDetails.Count); - }, - TimeSpan.FromSeconds(180)); - } - - public async Task VerifyOperatorDetailsAreInTheList(String tableId, List<(String, String, String, String)> operatorDetails) { - 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(operatorDetails.Count + 1); - StringBuilder sb = new StringBuilder(); - foreach ((String, String, String, String) operatorDetail in operatorDetails) { - 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 == operatorDetail.Item1) { - // Compare other fields - rowTD[0].Text.ShouldBe(operatorDetail.Item1); - rowTD[1].Text.ShouldBe(operatorDetail.Item2); - rowTD[2].Text.ShouldBe(operatorDetail.Item3); - if (String.IsNullOrEmpty(operatorDetail.Item4) == false) { - rowTD[3].Text.ShouldBe(operatorDetail.Item4); - } - - // We have found the row - foundRowCount++; - sb.AppendLine($"Found {operatorDetail.Item1}"); - break; - } - else { - sb.AppendLine($"Not Found {operatorDetail.Item1}"); - } - } - } - - foundRowCount.ShouldBe(operatorDetails.Count, sb.ToString()); - }, TimeSpan.FromSeconds(120)); - } - - public async Task VerifyContractDetailsAreInTheList(String tableId, List<(String, String)> contractDetails) - { - 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(contractDetails.Count + 1); - StringBuilder sb = new StringBuilder(); - foreach ((String, String) contractDetail in contractDetails) - { - 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 == contractDetail.Item1) - { - // Compare other fields - rowTD[0].Text.ShouldBe(contractDetail.Item1); - rowTD[1].Text.ShouldBe(contractDetail.Item2); - - // We have found the row - foundRowCount++; - sb.AppendLine($"Found {contractDetail.Item1}"); - break; - } - else - { - sb.AppendLine($"Not Found {contractDetail.Item1}"); - } - } - } - - foundRowCount.ShouldBe(contractDetails.Count, sb.ToString()); - }, TimeSpan.FromSeconds(120)); - } - - public async Task VerifyProductDetailsAreInTheList(List productDetails) - { - await Retry.For(async () => { - Int32 foundRowCount = 0; - IWebElement tableElement = this.WebDriver.FindElement(By.Id("contractProductList")); - IList rows = tableElement.FindElements(By.TagName("tr")); - - rows.Count.ShouldBe(productDetails.Count + 1); - foreach (String productDetail in productDetails) - { - 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 == productDetail) - { - // Compare other fields - rowTD[0].Text.ShouldBe(productDetail); - - // We have found the row - foundRowCount++; - break; - } - } - } - - foundRowCount.ShouldBe(productDetails.Count); - }, - TimeSpan.FromSeconds(120)); - } - - public async Task VerifyMerchantsSettlementSchedule(String settlementSchedule){ - String selectedText = await this.WebDriver.GetDropDownItemText("settlementScheduleList"); - selectedText.ShouldBe(settlementSchedule); - } - - public async Task ClickAddNewContractButton(){ - await Retry.For(async () => { await this.WebDriver.ClickButtonById("newContractButton"); }); - } - - public async Task ClickAddNewMerchantButton() - { - await Retry.For(async () => { await this.WebDriver.ClickButtonById("newMerchantButton"); }); - } - - public async Task ClickAddNewProductButton() - { - await Retry.For(async () => { await this.WebDriver.ClickButtonById("newContractProductButton"); }); - } - - public async Task ClickAddNewTransactionFeeButton(){ - await Retry.For(async () => { await this.WebDriver.ClickButtonById("newContractProductTransactionFeeButton"); }); - } - - public async Task ClickTheCreateContractButton(){ - await this.WebDriver.ClickButtonById("createContractButton"); - } - - public async Task ClickTheNewMerchantButton() - { - await this.WebDriver.ClickButtonById("newMerchantButton"); - } - - 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"); - } - - public async Task ClickTheAssignOperatorButton() - { - await this.WebDriver.ClickButtonById("saveMerchantOperatorButton"); - } - - 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"); - } - - public async Task ClickTheMakeDepositButton() - { - await this.WebDriver.ClickButtonById("makeDepositButton"); - } - - public async Task ClickTheSaveContractButton() - { - await this.WebDriver.ClickButtonById("saveContractButton"); - } - - public async Task ClickTheSaveProductButton() - { - await this.WebDriver.ClickButtonById("saveContractProductButton"); - } - - public async Task ClickTheNewContractButton() - { - await this.WebDriver.ClickButtonById("newContractButton"); - } - - public async Task ClickTheNewContractProductButton() - { - await this.WebDriver.ClickButtonById("newContractProductButton"); - } - - public async Task ClickTheCreateProductButton() - { - await this.WebDriver.ClickButtonById("createContractProductButton"); - } - - public async Task ClickTheCreateTransactionFeeButton() - { - await this.WebDriver.ClickButtonById("createTransactionFeeButton"); - } - - public async Task ClickTheProductsLinkForContract(String contractDescription){ - await this.ClickElementInTable("contractList", contractDescription, "numberOfProductsLink"); - } - - public async Task ClickTheTransactionFeesLinkForTheProduct(String productName) - { - await this.ClickElementInTable("contractProductList", productName, "numberOfTransactionFeesLink"); - } - - public async Task ClickTheMakeDepositButtonForTheMerchant(String merchantName) - { - await this.ClickElementInTable("merchantList", merchantName, "makeDepositLink"); - } - - public async Task EnterContractDetails(String contractDescription, String operatorName){ - await this.WebDriver.FillIn("Name", contractDescription); - await this.WebDriver.SelectDropDownItemByText("operatorList", operatorName); - } - - public async Task EnterContractProductDetails(String productName, String productType, String displayText, String value, Boolean isVariableValue=false) - { - await this.WebDriver.FillIn("Name", productName); - await this.WebDriver.FillIn("DisplayText", displayText); - await this.WebDriver.SelectDropDownItemByText("productTypeList", productType); - if (isVariableValue) { - await this.WebDriver.ClickCheckBoxById("isVariableValue"); - } - else { - await this.WebDriver.FillIn("Value", value); - } - } - - public async Task ClickTab(String tabName) { - await this.WebDriver.ClickButtonById(tabName); - } - - public async Task EnterMerchantUpdateDetails(List updates) { - foreach (EstateManagementUiSteps.MerchantUpdate update in updates) { - // Navigate to the tab - switch (update.tab) { - case "Details": - await this.ClickTab("nav-merchantdetails-tab"); - break; - case "Address": - await this.ClickTab("nav-address-tab"); - break; - case "Contact": - await this.ClickTab("nav-contacts-tab"); - break; - } - // Fill in the field - switch (update.field) { - case "Name": - await this.WebDriver.FillIn("Name", update.value, true); - break; - case "AddressLine1": - await this.WebDriver.FillIn("Address.AddressLine1", update.value, true); - break; - case "ContactName": - await this.WebDriver.FillIn("Contact.ContactName", update.value, true); - break; - } - } - } - - public async Task EnterDepositDetails(String amount, - String date, - String reference) { - await this.WebDriver.FillInNumeric("Amount", amount); - await this.WebDriver.FillIn("Date", date); - await this.WebDriver.FillIn("Reference", reference); - } - - public async Task EnterMerchantDetails(String merchantName, String addressLine1, String town, String region, String postCode, String country, String contactName, String contactEmail, String contactPhoneNumber, String settlementSchedule){ - await this.WebDriver.FillIn("Name", merchantName); - await this.WebDriver.FillIn("Address.AddressLine1", addressLine1); - await this.WebDriver.FillIn("Address.Town", town); - await this.WebDriver.FillIn("Address.Region", region); - await this.WebDriver.FillIn("Address.PostCode", postCode); - await this.WebDriver.FillIn("Address.Country", country); - await this.WebDriver.FillIn("Contact.ContactName", contactName); - await this.WebDriver.FillIn("Contact.EmailAddress", contactEmail); - await this.WebDriver.FillIn("Contact.PhoneNumber", contactPhoneNumber); - await this.WebDriver.SelectDropDownItemByText("settlementSchedule", settlementSchedule); - } - - public async Task EnterOperatorDetails(String operatorName, - Boolean requireCustomMerchantNumber, - Boolean requireCustomTerminalNumber) { - await this.WebDriver.FillInById("operatorName", operatorName, true); - Boolean requireCustomMerchantNumberIsChecked = await this.WebDriver.IsCheckboxChecked("requireCustomMerchantNumber"); - Boolean clickRequireCustomMerchantNumberCheckBox = (requireCustomMerchantNumber, requireCustomMerchantNumberIsChecked) switch { - (true, true) => false, - (true, false) => true, - (false, false) => false, - _ => true - }; - - if (clickRequireCustomMerchantNumberCheckBox) { - await this.WebDriver.ClickCheckBoxById("requireCustomMerchantNumber"); - } - - Boolean requireCustomTerminalNumberIsChecked = await this.WebDriver.IsCheckboxChecked("requireCustomTerminalNumber"); - Boolean clickRequireCustomTerminalNumberCheckBox = (requireCustomTerminalNumber, requireCustomTerminalNumberIsChecked) switch - { - (true, true) => false, - (true, false) => true, - (false, false) => false, - _ => true - }; - - if (clickRequireCustomTerminalNumberCheckBox) { - await this.WebDriver.ClickCheckBoxById("requireCustomTerminalNumber"); - } - } - - public async Task EnterOperatorDetails(String operatorName, - String merchantNumber, - String terminalNumber) - { - await this.WebDriver.SelectDropDownItemByText("operatorName", operatorName); - await this.WebDriver.FillInById("merchantNumber", merchantNumber, true); - await this.WebDriver.FillInById("terminalNumber", terminalNumber, true); - } - - 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); - await this.WebDriver.SelectDropDownItemByText("productTypeList", productType); - - if (String.IsNullOrEmpty(productValue)) - { - // Set the IsVariable flag - await this.WebDriver.FillIn("isVariable", "true"); - } - else - { - // Set the product value - await this.WebDriver.FillIn("value", productValue); - } - } - - public async Task Login(String username, String password){ - await this.WebDriver.FillIn("Input.Username", username); - await this.WebDriver.FillIn("Input.Password", password); - await this.WebDriver.ClickButtonByText("Login"); - } - - public async Task EnterTransactionFeeDetails(String description, String calculationType, String feeType, String feeValue) - { - await this.WebDriver.FillIn("Description", description); - await this.WebDriver.SelectDropDownItemByText("calculationTypeList", calculationType); - await this.WebDriver.SelectDropDownItemByText("feeTypeList", feeType); - await this.WebDriver.FillInNumeric("Value", feeValue); - } - - public async Task ClickTheMerchantLinkForMerchant(String merchantName) - { - await this.ClickElementInTable("merchantList", merchantName, "editMerchantLink"); - } - - - private async Task ClickElementInTable(String tableId, - String textToSearchFor, - String elementToClickId) { - Boolean foundRow = false; - IWebElement itemrow = null; - await Retry.For(async () => { - IWebElement tableElement = this.WebDriver.FindElement(By.Id(tableId)); - IList rows = tableElement.FindElements(By.TagName("tr")); - - rows.ShouldNotBeNull(); - rows.Any().ShouldBeTrue(); - 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 == textToSearchFor) { - itemrow = row; - foundRow = true; - break; - } - } - - - foundRow.ShouldBeTrue(); - itemrow.ShouldNotBeNull(); - }, TimeSpan.FromSeconds(120)).ConfigureAwait(false); - - - await Retry.For(async () => { - IWebElement element = itemrow.FindElement(By.Id(elementToClickId)); - if (element.Displayed) { - element.Click(); - } - else { - this.WebDriver.ExecuteJavaScript($"document.getElementById('{elementToClickId}').click();"); - } - }, TimeSpan.FromSeconds(120)); - } - - private async Task GetButtonInDropdown(IWebElement dropdownButton, - String buttonId) { - IWebElement result = null; - dropdownButton.Click(); - IWebElement button = this.WebDriver.FindElement(By.Id(buttonId)); - if (button.Displayed && button.Enabled) { - result = button; - } - else { - dropdownButton.Click(); - } - - return result; - } - - public async Task ClickTheEditOperatorButton(String operatorName) { - IWebElement tableElement = this.WebDriver.FindElement(By.Id("operatorList")); - var x = tableElement.FindElements(By.Id("dropdownMenuButton")); - IWebElement editButton = null; - foreach (IWebElement webElement in x) { - var gg = await GetButtonInDropdown(webElement, $"{operatorName}Edit"); - if (gg != null) { - editButton = gg; - break; - } - } - - if (editButton != null) { - editButton.Click(); - } - else { - throw new Exception($"Edit button not found for operator {operatorName}"); - } - } - - public async Task ClickTheRemoveOperatorButton(String operatorName) - { - IWebElement tableElement = this.WebDriver.FindElement(By.Id("merchantOperatorList")); - var x = tableElement.FindElements(By.Id("dropdownMenuButton")); - IWebElement editButton = null; - foreach (IWebElement webElement in x) { - var gg = await GetButtonInDropdown(webElement, $"{operatorName}Remove"); - if (gg != null) { - editButton = gg; - break; - } - } - - if (editButton != null) { - editButton.Click(); - } - else { - throw new Exception($"Remove button not found for operator {operatorName}"); - } - } - - public async Task ClickTheRemoveContractButton(String contractName) - { - IWebElement tableElement = this.WebDriver.FindElement(By.Id("merchantContractList")); - var x = tableElement.FindElements(By.Id("dropdownMenuButton")); - IWebElement editButton = null; - foreach (IWebElement webElement in x) - { - var gg = await GetButtonInDropdown(webElement, $"{contractName}Remove"); - if (gg != null) - { - editButton = gg; - break; - } - } - - if (editButton != null) - { - editButton.Click(); - } - else - { - throw new Exception($"Remove button not found for contract {contractName}"); - } - } - - public async Task ClickTheEditMerchantButton(String merchantName) - { - IWebElement tableElement = this.WebDriver.FindElement(By.Id("merchantList")); - var x = tableElement.FindElements(By.Id("dropdownMenuButton")); - IWebElement editButton = null; - foreach (IWebElement webElement in x) - { - var gg = await GetButtonInDropdown(webElement, $"{merchantName}Edit"); - if (gg != null) - { - editButton = gg; - break; - } - } - - if (editButton != null) - { - editButton.Click(); - } - else - { - throw new Exception($"Edit button not found for merchant {merchantName}"); - } - } - - public async Task ClickTheMakeDepositButton(String merchantName) - { - IWebElement tableElement = this.WebDriver.FindElement(By.Id("merchantList")); - var x = tableElement.FindElements(By.Id("dropdownMenuButton")); - IWebElement editButton = null; - foreach (IWebElement webElement in x) - { - var gg = await GetButtonInDropdown(webElement, $"{merchantName}MakeDeposit"); - if (gg != null) - { - editButton = gg; - break; - } - } - - if (editButton != null) - { - editButton.Click(); - } - else - { - throw new Exception($"Make Deposit button not found for merchant {merchantName}"); - } - } - - public async Task ClickTheViewMerchantButton(String merchantName) - { - IWebElement tableElement = this.WebDriver.FindElement(By.Id("merchantList")); - var x = tableElement.FindElements(By.Id("dropdownMenuButton")); - IWebElement editButton = null; - foreach (IWebElement webElement in x) - { - var gg = await GetButtonInDropdown(webElement, $"{merchantName}View"); - if (gg != null) - { - editButton = gg; - break; - } - } - - if (editButton != null) - { - editButton.Click(); - } - else - { - throw new Exception($"View button not found for merchant {merchantName}"); - } - } - - public async Task ClickTheViewContractProductsButton(String contractName) - { - IWebElement tableElement = this.WebDriver.FindElement(By.Id("contractList")); - var x = tableElement.FindElements(By.Id("dropdownMenuButton")); - IWebElement editButton = null; - foreach (IWebElement webElement in x) - { - var gg = await GetButtonInDropdown(webElement, $"{contractName}ViewProducts"); - if (gg != null) - { - editButton = gg; - break; - } - } - - if (editButton != null) - { - editButton.Click(); - } - else - { - throw new Exception($"View Products button not found for contract {contractName}"); - } - } - - public async Task ClickTheViewContractProductFeesButton(String productName) - { - //IWebElement tableElement = this.WebDriver.FindElement(By.Id("contractProductList")); - //var dropdownMenuButton = tableElement.FindElement(By.Id("dropdownMenuButton")); - //dropdownMenuButton.Click(); - //IWebElement editButton = this.WebDriver.FindElement(By.Id($"{productName.Replace(" ", "")}ViewFees")); - //editButton.Click(); - IWebElement tableElement = this.WebDriver.FindElement(By.Id("contractProductList")); - var x = tableElement.FindElements(By.Id("dropdownMenuButton")); - IWebElement editButton = null; - foreach (IWebElement webElement in x) - { - var gg = await GetButtonInDropdown(webElement, $"{productName.Replace(" ", "")}ViewFees"); - if (gg != null) - { - editButton = gg; - break; - } - } - - if (editButton != null) - { - editButton.Click(); - } - else - { - throw new Exception($"View Fees button not found for product {productName}"); - } - } - - public async Task ClickTheAddOperatorButton() { - await this.WebDriver.ClickButtonById("addOperatorButton"); - } - - public async Task ClickTheAddContractButton() - { - await this.WebDriver.ClickButtonById("addContractButton"); - } - - - public async Task VerifyAssignOperatorDialogIsDisplayed() { - await Retry.For(async () => { - IWebElement element = this.WebDriver.FindElement(By.Id("AssignOperatorDialog")); - element.ShouldNotBeNull(); - }); - } - - public async Task VerifyAssignContractDialogIsDisplayed() - { - await Retry.For(async () => { - IWebElement element = this.WebDriver.FindElement(By.Id("AssignContractDialog")); - element.ShouldNotBeNull(); - }); - } - - 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/Common/Extensions.cs b/EstateManagementUI.IntegrationTests/Common/Extensions.cs deleted file mode 100644 index d5523c06..00000000 --- a/EstateManagementUI.IntegrationTests/Common/Extensions.cs +++ /dev/null @@ -1,214 +0,0 @@ -using OpenQA.Selenium; -using OpenQA.Selenium.Support.UI; -using Shared.IntegrationTesting; -using Shouldly; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Threading.Tasks; -using System.Xml.Linq; -using OpenQA.Selenium.Support.Extensions; -using TransactionProcessor.Database.Entities.Summary; - -namespace EstateManagementUI.IntegrationTests.Common -{ - public static class Extensions - { - public static async Task FillIn(this IWebDriver webDriver, - String elementName, - String value, - Boolean clearExistingText = false, - TimeSpan? timeout = null) - { - await Retry.For(async () => - { - IWebElement webElement = webDriver.FindElement(By.Name(elementName)); - webElement.ShouldNotBeNull(); - webElement.Displayed.ShouldBe(true); - webElement.Enabled.ShouldBe(true); - if (clearExistingText) - { - webElement.Clear(); - } - - if (String.IsNullOrEmpty(value) == false) { - webElement.SendKeys(value); - } - }, timeout); - } - - public static async Task FillInNumeric(this IWebDriver webDriver, - String elementName, - String value, - TimeSpan? timeout = null) - { - await Retry.For(async () => - { - IWebElement webElement = webDriver.FindElement(By.Name(elementName)); - webElement.ShouldNotBeNull(); - webElement.Displayed.ShouldBe(true); - webElement.Enabled.ShouldBe(true); - - webElement.Click(); // Ensure it's focused - webElement.SendKeys(Keys.Control + "a"); // Select existing text - webElement.SendKeys(Keys.Delete); // Delete it - webElement.SendKeys(value); - - }, timeout); - } - - public static async Task FillInById(this IWebDriver webDriver, - String elementId, - String value, - Boolean clearExistingText = false, - TimeSpan? timeout = null) - { - await Retry.For(async () => - { - IWebElement webElement = webDriver.FindElement(By.Id(elementId)); - webElement.ShouldNotBeNull(); - webElement.Displayed.ShouldBe(true); - webElement.Enabled.ShouldBe(true); - if (clearExistingText) - { - webElement.Clear(); - } - if (String.IsNullOrEmpty(value) == false) - { - webElement.SendKeys(value); - } - }, timeout); - } - - public static async Task FindButtonById(this IWebDriver webDriver, - String buttonId, - TimeSpan? timeout = null) - { - IWebElement element = null; - await Retry.For(async () => - { - element = webDriver.FindElement(By.Id(buttonId)); - - element.ShouldNotBeNull(); - }, timeout); - return element; - } - - public static async Task FindButtonByText(this IWebDriver webDriver, - String buttonText, - TimeSpan? timeout = null) - { - IWebElement element = null; - await Retry.For(async () => - { - ReadOnlyCollection elements = webDriver.FindElements(By.TagName("button")); - - List e = elements.Where(e => e.GetAttribute("innerText") == buttonText).ToList(); - - e.ShouldHaveSingleItem(); - - element = e.Single(); - },timeout); - return element; - } - - public static void ClickLink(this IWebDriver webDriver, - String linkText) - { - IWebElement webElement = webDriver.FindElement(By.LinkText(linkText)); - webElement.ShouldNotBeNull(); - webElement.Click(); - } - - public static async Task ClickCheckBox(this IWebDriver webDriver, - String elementName, - TimeSpan? timeout = null) { - await Retry.For(async () => { - IWebElement webElement = webDriver.FindElement(By.Name(elementName)); - webElement.ShouldNotBeNull(); - webElement.Displayed.ShouldBe(true); - webElement.Enabled.ShouldBe(true); - webElement.Click(); - }, timeout); - } - - public static async Task ClickCheckBoxById(this IWebDriver webDriver, - String elementId, - TimeSpan? timeout = null) - { - await Retry.For(async () => { - IWebElement webElement = webDriver.FindElement(By.Id(elementId)); - webElement.ShouldNotBeNull(); - webElement.Displayed.ShouldBe(true); - webElement.Enabled.ShouldBe(true); - webElement.Click(); - }, timeout); - } - - public static async Task IsCheckboxChecked(this IWebDriver webDriver, - String elementId, - TimeSpan? timeout = null) { - Boolean isChecked = false; - await Retry.For(async () => { - IWebElement webElement = webDriver.FindElement(By.Id(elementId)); - webElement.ShouldNotBeNull(); - webElement.Displayed.ShouldBe(true); - webElement.Enabled.ShouldBe(true); - isChecked = webElement.Selected; - }, timeout); - return isChecked; - } - - public static async Task ClickButtonById(this IWebDriver webDriver, - String buttonId) { - await Retry.For(async () => { - IWebElement webElement = await webDriver.FindButtonById(buttonId); - webElement.ShouldNotBeNull(); - webElement.Displayed.ShouldBe(true); - webElement.Enabled.ShouldBe(true); - webElement.Click(); - }); - } - - public static async Task ClickButtonByText(this IWebDriver webDriver, - String buttonText) - { - IWebElement webElement = await webDriver.FindButtonByText(buttonText); - webElement.ShouldNotBeNull(); - webElement.Click(); - } - - public static async Task SelectDropDownItemByText(this IWebDriver webDriver, String dropdownId, String textToSelect, - TimeSpan? timeout = null) - { - IWebElement element = null; - await Retry.For(async () => - { - element = webDriver.FindElement(By.Id(dropdownId)); - - element.ShouldNotBeNull(); - - SelectElement dropdown = new SelectElement(element); - dropdown.SelectByText(textToSelect); - }, timeout); - } - - public static async Task GetDropDownItemText(this IWebDriver webDriver, String dropdownId, - TimeSpan? timeout = null) - { - String selectedText = null; - await Retry.For(async () => - { - IWebElement element = webDriver.FindElement(By.Id(dropdownId)); - - element.ShouldNotBeNull(); - - SelectElement dropdown = new SelectElement(element); - selectedText = dropdown.SelectedOption.Text; - },timeout); - - return selectedText; - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/Common/GenericSteps.cs b/EstateManagementUI.IntegrationTests/Common/GenericSteps.cs deleted file mode 100644 index 59b16295..00000000 --- a/EstateManagementUI.IntegrationTests/Common/GenericSteps.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Threading.Tasks; -using NLog; -using Reqnroll; -using Shared.IntegrationTesting; -using Shared.Logger; - -namespace EstateManagementUI.IntegrationTests.Common -{ - [Binding] - [Scope(Tag = "base")] - public class GenericSteps - { - private readonly ScenarioContext ScenarioContext; - - private readonly TestingContext TestingContext; - - public GenericSteps(ScenarioContext scenarioContext, - TestingContext testingContext) - { - this.ScenarioContext = scenarioContext; - this.TestingContext = testingContext; - } - - [BeforeScenario(Order = 1)] - public async Task StartSystem() - { - // Initialise a logger - String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", ""); - NlogLogger logger = new NlogLogger(); - logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName); - LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly); - - DockerServices dockerServices = DockerServices.CallbackHandler | DockerServices.EventStore | - DockerServices.FileProcessor | DockerServices.MessagingService | DockerServices.SecurityService | - DockerServices.TestHost | DockerServices.SqlServer | DockerServices.TransactionProcessor | - DockerServices.TransactionProcessorAcl; - - this.TestingContext.DockerHelper = new DockerHelper(); - this.TestingContext.DockerHelper.Logger = logger; - this.TestingContext.Logger = logger; - this.TestingContext.DockerHelper.RequiredDockerServices = dockerServices; - this.TestingContext.Logger.LogInformation("About to Start Global Setup"); - - await Setup.GlobalSetup(this.TestingContext.DockerHelper); - - this.TestingContext.DockerHelper.DockerCredentials = Setup.DockerCredentials; - this.TestingContext.DockerHelper.SqlCredentials = Setup.SqlCredentials; - this.TestingContext.DockerHelper.SqlServerContainerName = "sharedsqlserver"; - - this.TestingContext.Logger = logger; - this.TestingContext.Logger.LogInformation("About to Start Containers for Scenario Run"); - await this.TestingContext.DockerHelper.StartContainersForScenarioRun(scenarioName, dockerServices).ConfigureAwait(false); - this.TestingContext.Logger.LogInformation("Containers for Scenario Run Started"); - } - - [AfterScenario(Order = 1)] - public async Task StopSystem(){ - DockerServices sharedDockerServices = DockerServices.None; - await this.TestingContext.DockerHelper.StopContainersForScenarioRun(sharedDockerServices).ConfigureAwait(false); - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/Common/Hooks.cs b/EstateManagementUI.IntegrationTests/Common/Hooks.cs deleted file mode 100644 index b504ff67..00000000 --- a/EstateManagementUI.IntegrationTests/Common/Hooks.cs +++ /dev/null @@ -1,209 +0,0 @@ -using Google.Protobuf.Reflection; -using OpenQA.Selenium; -using OpenQA.Selenium.Chrome; -using OpenQA.Selenium.Edge; -using OpenQA.Selenium.Firefox; -using Reqnroll; -using Reqnroll.BoDi; -using Shared.IntegrationTesting; -using System.Diagnostics.Contracts; -using System.Drawing; - -namespace EstateManagementUI.IntegrationTests.Common -{ - [Binding] - public class Hooks - { - private readonly IObjectContainer ObjectContainer; - private ScenarioContext ScenarioContext; - - - public Hooks(IObjectContainer objectContainer) - { - this.ObjectContainer = objectContainer; - } - - [BeforeScenario(Order = 0)] - public async Task BeforeScenario(ScenarioContext scenarioContext){ - this.ScenarioContext = scenarioContext; - String scenarioName = scenarioContext.ScenarioInfo.Title.Replace(" ", ""); - IWebDriver webDriver = await this.CreateWebDriver(); - - webDriver.Manage().Window.Maximize(); - //this.ObjectContainer.RegisterInstanceAs(this.WebDriver, scenarioName); - scenarioContext.ScenarioContainer.RegisterInstanceAs(webDriver, scenarioName); - } - - [AfterScenario(Order = 0)] - public void AfterScenario() - { - String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", ""); - IWebDriver webDriver = this.ScenarioContext.ScenarioContainer.Resolve(this.ScenarioContext.ScenarioInfo.Title.Replace(" ", "")); - if (webDriver != null) - { - webDriver.Quit(); //.Dispose(); - } - } - - private async Task CreateWebDriver(){ - IWebDriver webDriver = null; - - String? browser = Environment.GetEnvironmentVariable("Browser"); - String? isCi = Environment.GetEnvironmentVariable("IsCI"); - //isCi = "true"; - //browser = "Edge"; - switch (browser) - { - case null: - case "Chrome": - { - Environment.SetEnvironmentVariable("SE_MANAGER", "0"); - ChromeOptions options = new(); - - options = options.WithNoSandBox() - .WithAcceptInsecureCertificate() - .WithDisableDevShmUsage() - .WithDisableExtensions() - .WithDisableGpu() - .WithDisableInfobars() - .WithHeadless(isCi) - .WithWindowSize(1920, 1080); - var service = ChromeDriverService.CreateDefaultService("/usr/bin"); - webDriver = new ChromeDriver(service, options); - - break; - } - case "Firefox": - { - FirefoxOptions options = new FirefoxOptions(); - options = options.WithAcceptInsecureCertificate() - .WithHeadless(isCi) - .WithNetworkCookieBehaviour(); - - await Retry.For(async () => - { - webDriver = new FirefoxDriver(options); - }, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(60)); - break; - } - case "Edge": { - EdgeOptions options = new EdgeOptions(); - options = options.WithAcceptInsecureCertificate() - .WithHeadless(isCi) - .WithWindowSize(1920, 1080); - - await Retry.For(async () => { webDriver = new EdgeDriver(options); }, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(60)); - break; - } - } - - return webDriver; - } - } - - public static class ChromeOptionsBuilder{ - - [Pure] - public static ChromeOptions WithDisableGpu(this ChromeOptions options){ - options.AddArgument("--disable-gpu"); - return options; - } - - [Pure] - public static ChromeOptions WithNoSandBox(this ChromeOptions options){ - options.AddArgument("--no-sandbox"); - return options; - } - - [Pure] - public static ChromeOptions WithDisableDevShmUsage(this ChromeOptions options){ - options.AddArgument("--disable-dev-shm-usage"); - return options; - } - - [Pure] - public static ChromeOptions WithHeadless(this ChromeOptions options, String isCI){ - if (String.Compare(isCI, Boolean.TrueString, StringComparison.InvariantCultureIgnoreCase) == 0){ - options.AddArgument("--headless"); - } - return options; - } - - [Pure] - public static ChromeOptions WithDisableInfobars(this ChromeOptions options){ - options.AddArguments("--disable-infobars"); - return options; - } - - [Pure] - public static ChromeOptions WithDisableExtensions(this ChromeOptions options) - { - options.AddArguments("--disable-extensions"); - return options; - } - - [Pure] - public static ChromeOptions WithWindowSize(this ChromeOptions options, Int32 height, Int32 width){ - String windowSize = $"--window-size={height}x{width}"; - options.AddArguments(windowSize); - return options; - } - - public static ChromeOptions WithAcceptInsecureCertificate(this ChromeOptions options){ - options.AcceptInsecureCertificates = true; - return options; - } - } - - public static class FirefoxOptionsBuilder{ - [Pure] - public static FirefoxOptions WithHeadless(this FirefoxOptions options, String isCi){ - if (String.Compare(isCi, Boolean.TrueString, StringComparison.InvariantCultureIgnoreCase) == 0) - { - options.AddArguments("--headless"); - } - return options; - } - - [Pure] - public static FirefoxOptions WithNetworkCookieBehaviour(this FirefoxOptions options){ - options.SetPreference("network.cookie.cookieBehavior", 0); - return options; - } - - [Pure] - public static FirefoxOptions WithAcceptInsecureCertificate(this FirefoxOptions options) - { - options.AcceptInsecureCertificates = true; - return options; - } - } - - public static class EdgeOptionsBuilder{ - - [Pure] - public static EdgeOptions WithAcceptInsecureCertificate(this EdgeOptions options) - { - options.AcceptInsecureCertificates = true; - return options; - } - - [Pure] - public static EdgeOptions WithHeadless(this EdgeOptions options, String isCi) - { - if (String.Compare(isCi, Boolean.TrueString, StringComparison.InvariantCultureIgnoreCase) == 0) - { - options.AddArguments("--headless"); - } - return options; - } - - [Pure] - public static EdgeOptions WithWindowSize(this EdgeOptions options, Int32 height, Int32 width) - { - String windowSize = $"--window-size={height},{width}"; - options.AddArguments(windowSize); - return options; - } - } -} diff --git a/EstateManagementUI.IntegrationTests/Common/Setup.cs b/EstateManagementUI.IntegrationTests/Common/Setup.cs deleted file mode 100644 index b6899766..00000000 --- a/EstateManagementUI.IntegrationTests/Common/Setup.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Ductus.FluentDocker.Services; -using Ductus.FluentDocker.Services.Extensions; -using Reqnroll; -using Shouldly; - -namespace EstateManagementUI.IntegrationTests.Common -{ - [Binding] - public class Setup - { - public static (String usename, String password) SqlCredentials = ("sa", "thisisalongpassword123!"); - public static (String url, String username, String password) DockerCredentials = ("https://www.docker.com", "stuartferguson", "Sc0tland"); - - public static async Task GlobalSetup(DockerHelper dockerHelper) - { - ShouldlyConfiguration.DefaultTaskTimeout = TimeSpan.FromMinutes(1); - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/Common/SharedSteps.cs b/EstateManagementUI.IntegrationTests/Common/SharedSteps.cs deleted file mode 100644 index f12d24ec..00000000 --- a/EstateManagementUI.IntegrationTests/Common/SharedSteps.cs +++ /dev/null @@ -1,331 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using JasperFx.Core; -using Microsoft.EntityFrameworkCore.Metadata.Internal; -using OpenQA.Selenium; -using Reqnroll; -using Reqnroll.BoDi; -using SecurityService.DataTransferObjects; -using SecurityService.DataTransferObjects.Requests; -using SecurityService.DataTransferObjects.Responses; -using SecurityService.IntegrationTesting.Helpers; -using Shared.IntegrationTesting; -using Shouldly; -using SimpleResults; -using TransactionProcessor.Database.Contexts; -using TransactionProcessor.DataTransferObjects.Requests.Contract; -using TransactionProcessor.DataTransferObjects.Requests.Estate; -using TransactionProcessor.DataTransferObjects.Requests.Merchant; -using TransactionProcessor.DataTransferObjects.Requests.Operator; -using TransactionProcessor.DataTransferObjects.Responses.Contract; -using TransactionProcessor.DataTransferObjects.Responses.Estate; -using TransactionProcessor.DataTransferObjects.Responses.Merchant; -using TransactionProcessor.IntegrationTesting.Helpers; -using AssignOperatorRequest = TransactionProcessor.DataTransferObjects.Requests.Estate.AssignOperatorRequest; -using ReqnrollTableHelper = Shared.IntegrationTesting.ReqnrollTableHelper; - -namespace EstateManagementUI.IntegrationTests.Common -{ - [Binding] - [Scope(Tag = "shared")] - public class SharedSteps - { - #region Fields - - - - private readonly SecurityServiceSteps SecurityServiceSteps; - - private readonly TestingContext TestingContext; - - private readonly IWebDriver WebDriver; - - private readonly TransactionProcessorSteps TransactionProcessorSteps; - - //private readonly EstateMan EstateAdministrationUiSteps; - - #endregion - - #region Constructors - - public SharedSteps(ScenarioContext scenarioContext, TestingContext testingContext, IObjectContainer container) - { - IWebDriver? webDriver = scenarioContext.ScenarioContainer.Resolve(scenarioContext.ScenarioInfo.Title.Replace(" ", "")); - - this.TestingContext = testingContext; - this.SecurityServiceSteps = new SecurityServiceSteps(this.TestingContext.DockerHelper.SecurityServiceClient); - this.TransactionProcessorSteps = new TransactionProcessorSteps(this.TestingContext.DockerHelper.TransactionProcessorClient, this.TestingContext.DockerHelper.TestHostHttpClient, this.TestingContext.DockerHelper.ProjectionManagementClient); - //this.EstateAdministrationUiSteps = new EstateAdministrationUISteps(webDriver, this.TestingContext.DockerHelper.EstateManagementUiPort); - } - - #endregion - - #region Methods - - - - [Given(@"I create the following api resources")] - public async Task GivenICreateTheFollowingApiResources(DataTable table) - { - List requests = table.Rows.ToCreateApiResourceRequests(); - await this.SecurityServiceSteps.GivenTheFollowingApiResourcesExist(requests); - - foreach (CreateApiResourceRequest createApiResourceRequest in requests) - { - this.TestingContext.ApiResources.Add(createApiResourceRequest.Name); - } - } - - [Given(@"I create the following api scopes")] - public async Task GivenICreateTheFollowingApiScopes(DataTable table) - { - List requests = table.Rows.ToCreateApiScopeRequests(); - await this.SecurityServiceSteps.GivenICreateTheFollowingApiScopes(requests); - } - - [Given(@"I create the following clients")] - public async Task GivenICreateTheFollowingClients(DataTable table) - { - List requests = table.Rows.ToCreateClientRequests(this.TestingContext.DockerHelper.TestId, this.TestingContext.DockerHelper.EstateManagementUiPort); - List<(String clientId, String secret, List allowedGrantTypes)> clients = await this.SecurityServiceSteps.GivenTheFollowingClientsExist(requests); - foreach ((String clientId, String secret, List allowedGrantTypes) client in clients) - { - this.TestingContext.AddClientDetails(client.clientId, client.secret, client.allowedGrantTypes); - } - } - - [Given(@"I create the following identity resources")] - public async Task GivenICreateTheFollowingIdentityResources(DataTable table) - { - foreach (DataTableRow tableRow in table.Rows) - { - // Get the scopes - String userClaims = ReqnrollTableHelper.GetStringRowValue(tableRow, "UserClaims"); - - CreateIdentityResourceRequest createIdentityResourceRequest = new CreateIdentityResourceRequest - { - Name = ReqnrollTableHelper.GetStringRowValue(tableRow, "Name"), - Claims = String.IsNullOrEmpty(userClaims) ? null : userClaims.Split(",").ToList(), - Description = ReqnrollTableHelper.GetStringRowValue(tableRow, "Description"), - DisplayName = ReqnrollTableHelper.GetStringRowValue(tableRow, "DisplayName") - }; - - await this.CreateIdentityResource(createIdentityResourceRequest, CancellationToken.None).ConfigureAwait(false); - } - } - - [Given(@"I create the following roles")] - public async Task GivenICreateTheFollowingRoles(DataTable table) - { - List requests = table.Rows.ToCreateRoleRequests(); - List<(String, Guid)> responses = await this.SecurityServiceSteps.GivenICreateTheFollowingRoles(requests, CancellationToken.None); - - foreach ((String, Guid) response in responses) - { - this.TestingContext.Roles.Add(response.Item1, response.Item2); - } - } - - [Given(@"I create the following users")] - public async Task GivenICreateTheFollowingUsers(DataTable table) - { - List requests = table.Rows.ToCreateUserRequests(); - foreach (CreateUserRequest createUserRequest in requests) - { - createUserRequest.EmailAddress = createUserRequest.EmailAddress.Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N")); - //createUserRequest.Roles.ForEach(r => r.Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N"))); - List newRoles = new List(); - foreach (String role in createUserRequest.Roles) - { - newRoles.Add(role.Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N"))); - } - createUserRequest.Roles = newRoles; - } - - List<(String, Guid)> results = await this.SecurityServiceSteps.GivenICreateTheFollowingUsers(requests, CancellationToken.None); - - foreach ((String, Guid) response in results) - { - this.TestingContext.Users.Add(response.Item1, response.Item2); - } - } - - [Given(@"I have a token to access the estate management resource")] - public async Task GivenIHaveATokenToAccessTheEstateManagementResource(DataTable table) - { - DataTableRow firstRow = table.Rows.First(); - String clientId = ReqnrollTableHelper.GetStringRowValue(firstRow, "ClientId").Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N")); - ClientDetails clientDetails = this.TestingContext.GetClientDetails(clientId); - - this.TestingContext.AccessToken = await this.SecurityServiceSteps.GetClientToken(clientDetails.ClientId, clientDetails.ClientSecret, CancellationToken.None); - } - - [Given(@"I have created the following estates")] - public async Task GivenIHaveCreatedTheFollowingEstates(DataTable table) - { - List requests = table.Rows.ToCreateEstateRequests(); - - List verifiedEstates = await this.TransactionProcessorSteps.WhenICreateTheFollowingEstatesX(this.TestingContext.AccessToken, requests); - - foreach (EstateResponse verifiedEstate in verifiedEstates) - { - //await Retry.For(async () => - //{ - // String databaseName = $"EstateReportingReadModel{verifiedEstate.EstateId}"; - // var connString = Setup.GetLocalConnectionString(databaseName); - // connString = $"{connString};Encrypt=false"; - // var ctx = new EstateManagementContext(connString); - - // var estates = ctx.Estates.ToList(); - // estates.Count.ShouldBe(1); - - this.TestingContext.AddEstateDetails(verifiedEstate.EstateId, verifiedEstate.EstateName, verifiedEstate.EstateReference); - this.TestingContext.Logger.LogInformation($"Estate {verifiedEstate.EstateName} created with Id {verifiedEstate.EstateId}"); - //}); - } - } - - [Given(@"I have created the following operators")] - public async Task GivenIHaveCreatedTheFollowingOperators(DataTable table) - { - List<(EstateDetails estate, CreateOperatorRequest request)> requests = table.Rows.ToCreateOperatorRequests(this.TestingContext.Estates); - - List<(Guid, EstateOperatorResponse)> results = await this.TransactionProcessorSteps.WhenICreateTheFollowingOperators(this.TestingContext.AccessToken, requests); - - foreach ((Guid, EstateOperatorResponse) result in results) - { - this.TestingContext.Logger.LogInformation($"Operator {result.Item2.Name} created with Id {result.Item2.OperatorId} for Estate {result.Item1}"); - } - } - - [Given("I have assigned the following operators to the estates")] - public async Task GivenIHaveAssignedTheFollowingOperatorsToTheEstates(DataTable dataTable) - { - List<(EstateDetails estate, AssignOperatorRequest request)> requests = dataTable.Rows.ToAssignOperatorToEstateRequests(this.TestingContext.Estates); - - await this.TransactionProcessorSteps.GivenIHaveAssignedTheFollowingOperatorsToTheEstates(this.TestingContext.AccessToken, requests); - - // TODO Verify - } - - - - [When(@"I add the following devices to the merchant")] - public async Task WhenIAddTheFollowingDevicesToTheMerchant(DataTable table) - { - List<(EstateDetails, Guid, AddMerchantDeviceRequest)> requests = table.Rows.ToAddMerchantDeviceRequests(this.TestingContext.Estates); - - List<(EstateDetails, MerchantResponse, String)> results = await this.TransactionProcessorSteps.GivenIHaveAssignedTheFollowingDevicesToTheMerchants(this.TestingContext.AccessToken, requests); - foreach ((EstateDetails, MerchantResponse, String) result in results) - { - this.TestingContext.Logger.LogInformation($"Device {result.Item3} assigned to Merchant {result.Item2.MerchantName} Estate {result.Item1.EstateName}"); - } - } - - [When(@"I assign the following operator to the merchants")] - public async Task WhenIAssignTheFollowingOperatorToTheMerchants(DataTable table) - { - List<(EstateDetails, Guid, TransactionProcessor.DataTransferObjects.Requests.Merchant.AssignOperatorRequest)> requests = table.Rows.ToAssignOperatorRequests(this.TestingContext.Estates); - - List<(EstateDetails, TransactionProcessor.DataTransferObjects.Responses.Merchant.MerchantOperatorResponse)> results = await this.TransactionProcessorSteps.WhenIAssignTheFollowingOperatorToTheMerchants(this.TestingContext.AccessToken, requests); - - foreach ((EstateDetails, MerchantOperatorResponse) result in results) - { - this.TestingContext.Logger.LogInformation($"Operator {result.Item2.Name} assigned to Estate {result.Item1.EstateName}"); - } - } - - - - [Given("I create the following merchants")] - [When(@"I create the following merchants")] - public async Task WhenICreateTheFollowingMerchants(DataTable table) - { - List<(EstateDetails estate, CreateMerchantRequest)> requests = table.Rows.ToCreateMerchantRequests(this.TestingContext.Estates); - - List verifiedMerchants = await this.TransactionProcessorSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, requests); - - foreach (MerchantResponse verifiedMerchant in verifiedMerchants) - { - EstateDetails estateDetails = this.TestingContext.GetEstateDetails(verifiedMerchant.EstateId); - estateDetails.AddMerchant(verifiedMerchant); - this.TestingContext.Logger.LogInformation($"Merchant {verifiedMerchant.MerchantName} created with Id {verifiedMerchant.MerchantId} for Estate {estateDetails.EstateName}"); - } - } - - [When(@"I create the following security users")] - [Given("I have created the following security users")] - public async Task WhenICreateTheFollowingSecurityUsers(DataTable table) - { - List createUserRequests = table.Rows.ToCreateNewUserRequests(this.TestingContext.Estates); - await this.TransactionProcessorSteps.WhenICreateTheFollowingSecurityUsers(this.TestingContext.AccessToken, createUserRequests, this.TestingContext.Estates); - } - - [Given(@"I have created the following contracts")] - public async Task GivenIHaveCreatedTheFollowingContracts(DataTable table) - { - List<(EstateDetails, CreateContractRequest)> requests = table.Rows.ToCreateContractRequests(this.TestingContext.Estates); - - List responses = await this.TransactionProcessorSteps.GivenICreateAContractWithTheFollowingValues(this.TestingContext.AccessToken, requests); - - foreach (ContractResponse contractResponse in responses) - { - this.TestingContext.Logger.LogInformation($"Contract {contractResponse.Description} created with Id {contractResponse.ContractId} for Estate {contractResponse.EstateId}"); - EstateDetails estateDetails = this.TestingContext.GetEstateDetails(contractResponse.EstateId); - estateDetails.AddContract(contractResponse.ContractId, contractResponse.Description, contractResponse.OperatorId); - } - } - - [Given("I have created the following contract products")] - public async Task GivenIHaveCreatedTheFollowingContractProducts(DataTable table) - { - List<(EstateDetails, Contract, AddProductToContractRequest)> requests = table.Rows.ToAddProductToContractRequest(this.TestingContext.Estates); - await this.TransactionProcessorSteps.WhenICreateTheFollowingProducts(this.TestingContext.AccessToken, requests); - } - - - private async Task CreateIdentityResource(CreateIdentityResourceRequest createIdentityResourceRequest, - CancellationToken cancellationToken) - { - CreateIdentityResourceResponse createIdentityResourceResponse = null; - - Result> identityResourceList = await this.TestingContext.DockerHelper.SecurityServiceClient.GetIdentityResources(cancellationToken); - if (identityResourceList.IsFailed) - { - // TODO: Handle error properly, e.g., show a message to the user - } - if (identityResourceList.Data == null || identityResourceList.Data.Any() == false) - { - Result result= await this - .TestingContext.DockerHelper.SecurityServiceClient - .CreateIdentityResource(createIdentityResourceRequest, cancellationToken) - .ConfigureAwait(false); - result.IsSuccess.ShouldBeTrue(); - - this.TestingContext.IdentityResources.Add(createIdentityResourceRequest.Name); - } - else - { - if (identityResourceList.Data.Any(i => i.Name == createIdentityResourceRequest.Name)) - { - return; - } - - Result result = await this - .TestingContext.DockerHelper.SecurityServiceClient - .CreateIdentityResource(createIdentityResourceRequest, cancellationToken) - .ConfigureAwait(false); - result.IsSuccess.ShouldBeTrue(); - - result.IsSuccess.ShouldBeTrue(); - - this.TestingContext.IdentityResources.Add(createIdentityResourceRequest.Name); - } - } - - #endregion - } -} \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/Common/TestingContext.cs b/EstateManagementUI.IntegrationTests/Common/TestingContext.cs deleted file mode 100644 index 74b8f3cb..00000000 --- a/EstateManagementUI.IntegrationTests/Common/TestingContext.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Reqnroll; -using SecurityService.DataTransferObjects.Responses; -using Shared.Logger; -using Shouldly; -using TransactionProcessor.IntegrationTesting.Helpers; -using ReqnrollTableHelper = Shared.IntegrationTesting.ReqnrollTableHelper; - -namespace EstateManagementUI.IntegrationTests.Common -{ - public class TestingContext - { - public EstateDetails GetEstateDetails(DataTableRow tableRow, Guid? testId = null) - { - String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName").Replace("[id]", testId.Value.ToString("N")); - - EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateName == estateName); - - estateDetails.ShouldNotBeNull(); - - return estateDetails; - } - - public List GetAllEstateIds() - { - return this.Estates.Select(e => e.EstateId).ToList(); - } - - public EstateDetails GetEstateDetails(String estateName) - { - EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateName == estateName); - - estateDetails.ShouldNotBeNull(); - - return estateDetails; - } - - public EstateDetails GetEstateDetails(Guid estateId) - { - EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateId == estateId); - - estateDetails.ShouldNotBeNull(); - - return estateDetails; - } - - public List Estates; - public void AddEstateDetails(Guid estateId, String estateName, String estateReference) - { - this.Estates.Add(EstateDetails.Create(estateId, estateName, estateReference)); - } - - public String AccessToken { get; set; } - - public DockerHelper DockerHelper { get; set; } - - public NlogLogger Logger { get; set; } - - public Dictionary Users; - public Dictionary Roles; - - public List Clients; - - public List ApiResources; - public List IdentityResources; - - public TokenResponse TokenResponse; - - public TestingContext() - { - this.Users = new Dictionary(); - this.Roles = new Dictionary(); - this.Clients = new List(); - this.ApiResources = new List(); - this.Estates = new List(); - this.IdentityResources = new List(); - } - - public ClientDetails GetClientDetails(String clientId) - { - ClientDetails clientDetails = this.Clients.SingleOrDefault(c => c.ClientId == clientId); - - clientDetails.ShouldNotBeNull(); - - return clientDetails; - } - - public void AddClientDetails(String clientId, - String clientSecret, - List grantTypes) - { - this.Clients.Add(ClientDetails.Create(clientId, clientSecret, grantTypes)); - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj b/EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj deleted file mode 100644 index 4f843513..00000000 --- a/EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj +++ /dev/null @@ -1,60 +0,0 @@ - - - - net10.0 - enable - enable - - false - true - - - - - - - - - Always - true - PreserveNewest - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/EstateManagementUI.IntegrationTests/Steps/Gimp.cs b/EstateManagementUI.IntegrationTests/Steps/Gimp.cs deleted file mode 100644 index ae418079..00000000 --- a/EstateManagementUI.IntegrationTests/Steps/Gimp.cs +++ /dev/null @@ -1,632 +0,0 @@ -using Reqnroll; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Shared.IntegrationTesting; -using EstateManagementUI.IntegrationTests.Common; -using OpenQA.Selenium; -using Reqnroll.BoDi; -using SecurityService.IntegrationTesting.Helpers; -using Microsoft.EntityFrameworkCore.Metadata.Internal; -using EstateManagementUI.Pages.Operator.OperatorsList; -using EstateManagementUI.Pages.Estate.OperatorList; -using SQLite; - -namespace EstateManagementUI.IntegrationTests.Steps -{ - [Binding] - [Scope(Tag = "uigeneral")] - public class EstateManagementUiSteps - { - private readonly TestingContext TestingContext; - private readonly EstateManagementUiHelpers UiHelpers; - - public EstateManagementUiSteps(ScenarioContext scenarioContext, TestingContext testingContext, IObjectContainer container) - { - var webDriver = scenarioContext.ScenarioContainer.Resolve(scenarioContext.ScenarioInfo.Title.Replace(" ", "")); - - this.TestingContext = testingContext; - this.UiHelpers = new EstateManagementUiHelpers(webDriver, this.TestingContext.DockerHelper.EstateManagementUiPort); - } - - [Given(@"I am on the application home page")] - public void GivenIAmOnTheApplicationHomePage() - { - this.UiHelpers.NavigateToHomePage(); - } - - [Given(@"I click on the My Contracts sidebar option")] - public async Task GivenIClickOnTheMyContractsSidebarOption() - { - await this.UiHelpers.ClickContractsSidebarOption(); - } - - [Given(@"I click on the My Estate sidebar option")] - public async Task GivenIClickOnTheMyEstateSidebarOption() - { - await this.UiHelpers.ClickMyEstateSidebarOption(); - } - - [Given(@"I click on the My Merchants sidebar option")] - public async Task GivenIClickOnTheMyMerchantsSidebarOption() - { - await this.UiHelpers.ClickMyMerchantsSidebarOption(); - } - - [Given(@"I click on the My Operators sidebar option")] - public async Task GivenIClickOnTheMyOperatorsSidebarOption() { - await this.UiHelpers.ClickMyOperatorsSidebarOption(); - } - - [Given(@"I click on the Sign In Button")] - public async Task GivenIClickOnTheSignInButton() - { - await this.UiHelpers.ClickOnTheSignInButton(); - } - - [Then(@"I am presented with a login screen")] - public async Task ThenIAmPresentedWithALoginScreen() - { - await this.UiHelpers.VerifyOnTheLoginScreen(); - } - - [Then(@"I am presented with the Contracts List Screen")] - public async Task ThenIAmPresentedWithTheContractsListScreen() - { - await this.UiHelpers.VerifyOnTheContractsListScreen(); - } - - [Then("the Contract Products List Screen is displayed")] - public async Task ThenTheContractProductsListScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheContractProductsListScreen(); - } - - [Then("the Contract Products Transaction Fees List Screen is displayed")] - public async Task ThenTheContractProductsTransactionFeesListScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheContractProductsFeesListScreen(); - } - - [Then(@"I am presented with the Estate Administrator Dashboard")] - public async Task ThenIAmPresentedWithTheEstateAdministratorDashboard() - { - await this.UiHelpers.VerifyOnTheDashboard(); - } - - [When("I click the Save Product Button")] - public async Task WhenIClickTheSaveProductButton() - { - await this.UiHelpers.ClickTheSaveProductButton(); - } - - [Then(@"I am presented with the View Estate Page")] - public async Task ThenIamPresentedWithTheViewEstatePage() - { - await this.UiHelpers.VerifyOnTheEstateDetailsScreen(); - } - - [Then(@"I am presented with the Merchants List Screen")] - public async Task ThenIAmPresentedWithTheMerchantsListScreen() - { - await this.UiHelpers.VerifyOnTheMerchantsListScreen(); - } - - [Then(@"I am presented with the Operators List Screen")] - public async Task ThenIAmPresentedWithTheOperatorsListScreen() - { - await this.UiHelpers.VerifyOnTheOperatorsListScreen(); - } - - [Then(@"My Estate Details will be shown")] - public async Task ThenMyEstateDetailsWillBeShown(DataTable table) - { - DataTableRow tableRow = table.Rows.Single(); - String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName").Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N")); - //String estateReference = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateReference"); - await this.UiHelpers.VerifyTheCorrectEstateDetailsAreDisplayed(estateName); - } - - [Then(@"the following contract details are in the list")] - public async Task ThenTheFollowingContractDetailsAreInTheList(DataTable table) - { - List<(String, String, Int32)> contractDescriptions = new List<(String, String, Int32)>(); - foreach (DataTableRow tableRow in table.Rows) - { - contractDescriptions.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "Description"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"), - ReqnrollTableHelper.GetIntValue(tableRow, "Products"))); - } - - await this.UiHelpers.VerifyTheContractDetailsAreInTheList(contractDescriptions); - } - - [Then(@"the following merchants details are in the list")] - public async Task ThenTheFollowingMerchantsDetailsAreInTheList(DataTable table) - { - List merchantDetailsList = new List(); - foreach (DataTableRow tableRow in table.Rows) { - MerchantDetails m = new MerchantDetails(tableRow["MerchantName"], tableRow["SettlementSchedule"], - tableRow["ContactName"], tableRow["AddressLine1"], tableRow["Town"]); - merchantDetailsList.Add(m); - } - - await this.UiHelpers.VerifyMerchantDetailsAreInTheList(merchantDetailsList); - } - - [Then(@"the following operator details are in the list")] - public async Task ThenTheFollowingOperatorDetailsAreInTheList(DataTable table) - { - List<(String, String, String, String)> operatorsList = new(); - foreach (DataTableRow tableRow in table.Rows) - { - operatorsList.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "RequireCustomMerchantNumber"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "RequireCustomTerminalNumber"), - null)); - } - - await this.UiHelpers.VerifyOperatorDetailsAreInTheList("operatorList", operatorsList); - } - - [Then("the following operators are displayed in the list")] - public async Task ThenTheFollowingOperatorsAreDisplayedInTheList(DataTable table) - { - List<(String, String, String, String)> operatorsList = new(); - foreach (DataTableRow tableRow in table.Rows) - { - operatorsList.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantNumber"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "TerminalNumber"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "IsDeleted"))); - } - - await this.UiHelpers.VerifyOperatorDetailsAreInTheList("merchantOperatorList", operatorsList); - } - - [Then("the following contracts are displayed in the list")] - public async Task ThenTheFollowingContractsAreDisplayedInTheList(DataTable dataTable) - { - List<(String, String)> contractsList = new(); - foreach (DataTableRow tableRow in dataTable.Rows) - { - contractsList.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "ContractName"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "IsDeleted"))); - } - - 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() - { - await this.UiHelpers.ClickTheAddOperatorButton(); - } - - [When("I click on the Add Contract Button")] - public async Task WhenIClickOnTheAddContractButton() { - await this.UiHelpers.ClickTheAddContractButton(); - } - - [Then("the Assign Operator Dialog will be displayed")] - public async Task ThenTheAssignOperatorDialogWillBeDisplayed() { - await this.UiHelpers.VerifyAssignOperatorDialogIsDisplayed(); - } - - [Then("the Assign Contract Dialog will be displayed")] - 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) - { - List contractsList = new List(); - foreach (DataTableRow tableRow in dataTable.Rows) - { - contractsList.Add(ReqnrollTableHelper.GetStringRowValue(tableRow, "ContractName")); - } - - foreach (String contract in contractsList) - { - await this.UiHelpers.EnterContractDetails(contract); - } - } - - [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) - { - List<(String, String, String)> operatorsList = new List<(String, String, String)>(); - foreach (DataTableRow tableRow in dataTable.Rows) - { - operatorsList.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantNumber"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "TerminalNumber"))); - } - - foreach ((String, String, String) @operator in operatorsList) { - await this.UiHelpers.EnterOperatorDetails(@operator.Item1, @operator.Item2, @operator.Item3); - } - } - - [When(@"I login with the username '(.*)' and password '(.*)'")] - public async Task WhenILoginWithTheUsernameAndPassword(String userName, String password) - { - - String username = userName.Replace("[id]", this.TestingContext.DockerHelper.TestId.ToString("N")); - await this.UiHelpers.Login(username, password); - } - - [When("I click on the New Operator Button")] - public async Task WhenIClickOnTheNewOperatorButton() - { - await this.UiHelpers.ClickTheNewOperatorButton(); - } - - [When("I click on the New Merchant Button")] - public async Task WhenIClickOnTheNewMerchantButton() - { - await this.UiHelpers.ClickTheNewMerchantButton(); - } - - [Then("the Edit Merchant Screen is displayed")] - public async Task ThenTheEditMerchantScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheEditMerchantScreen(); - } - - [Then("the Make Deposit Screen is displayed")] - public async Task ThenTheMakeDepositScreenIsDisplayed() { - await this.UiHelpers.VerifyOnTheMakeDepositScreen(); - } - - [When("I click on the Operators tab")] - public async Task WhenIClickOnTheOperatorsTab() { - await this.UiHelpers.ClickOnTheMerchantOperatorsTab(); - } - - [When("I click on the Contracts tab")] - 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(); - } - - [Then("I am presented with the Merchants Contract List Screen")] - 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() - { - await this.UiHelpers.VerifyOnTheViewMerchantScreen(); - } - - [When("click the Assign Operator button")] - public async Task WhenClickTheAssignOperatorButton() { - await this.UiHelpers.ClickTheAssignOperatorButton(); - } - - - [Then("the Add New Merchant Screen is displayed")] - public async Task ThenTheAddNewMerchantScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheNewMerchantScreen(); - } - - [When("I click on the Edit Operator Button for {string}")] - public async Task WhenIClickOnTheEditOperatorButtonFor(string operatorName) - { - await this.UiHelpers.ClickTheEditOperatorButton(operatorName); - } - - [When("I click on the Edit Merchant Button for {string}")] - public async Task WhenIClickOnTheEditMerchantButtonFor(string merchantName) - { - await this.UiHelpers.ClickTheEditMerchantButton(merchantName); - } - - [When("I click on the Make Deposit Button for {string}")] - public async Task WhenIClickOnTheMakeDepositButtonFor(string merchantName) - { - await this.UiHelpers.ClickTheMakeDepositButton(merchantName); - } - - - [When("I click on the Remove Operator for {string}")] - public async Task WhenIClickOnTheRemoveOperatorFor(string operatorName) { - await this.UiHelpers.ClickTheRemoveOperatorButton(operatorName); - } - - [When("I click on the Remove Contract for {string}")] - public async Task WhenIClickOnTheRemoveContractFor(string contractName) - { - await this.UiHelpers.ClickTheRemoveContractButton(contractName); - } - - - - [When("I click on the View Merchant Button for {string}")] - public async Task WhenIClickOnTheViewMerchantButtonFor(string merchantName) - { - await this.UiHelpers.ClickTheViewMerchantButton(merchantName); - } - - [When("I enter the following details for the updated Merchant")] - public async Task WhenIEnterTheFollowingDetailsForTheUpdatedMerchant(DataTable dataTable) { - List updates = new List(); - foreach (DataTableRow? row in dataTable.Rows) { - updates.Add(new MerchantUpdate(ReqnrollTableHelper.GetStringRowValue(row, "Tab"), ReqnrollTableHelper.GetStringRowValue(row, "Field"), ReqnrollTableHelper.GetStringRowValue(row, "Value"))); - } - - await this.UiHelpers.EnterMerchantUpdateDetails(updates); - } - - [When("I enter the following details for the deposit")] - public async Task WhenIEnterTheFollowingDetailsForTheDeposit(DataTable dataTable) - { - DataTableRow merchantDetails = dataTable.Rows.Single(); - String depositAmount = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "Amount"); - String dateString = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "Date"); - String depositDate = ReqnrollTableHelper.GetDateForDateString(dateString, DateTime.Now).ToString("dd/MM/yyyy"); - String reference = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "Reference"); - - await this.UiHelpers.EnterDepositDetails(depositAmount, depositDate, reference); - } - - - public record MerchantUpdate(String tab, String field, String value); - - [When("I enter the following details for the new Merchant")] - public async Task WhenIEnterTheFollowingDetailsForTheNewMerchant(DataTable dataTable) - { - DataTableRow merchantDetails = dataTable.Rows.Single(); - String merchantName = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "MerchantName"); - String addressLine1 = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "AddressLine1"); - String town = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "Town"); - String region = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "Region"); - String country = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "Country"); - String contactName = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "ContactName"); - String contactEmail = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "EmailAddress"); - String settlementSchedule = ReqnrollTableHelper.GetStringRowValue(merchantDetails, "SettlementSchedule"); - - await this.UiHelpers.EnterMerchantDetails(merchantName, addressLine1, town, region, null, country, contactName, - contactEmail, null, settlementSchedule); - } - - [Then("the Add New Operator Screen is displayed")] - public async Task ThenTheAddNewOperatorScreenIsDisplayed() { - await this.UiHelpers.VerifyOnTheNewOperatorScreen(); - } - - [Then("the Edit Operator Screen is displayed")] - public async Task ThenTheEditOperatorScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheEditOperatorScreen(); - } - - [When("I enter the following details for the new Operator")] - [When("I enter the following new details for the Operator")] - public async Task WhenIEnterTheFollowingDetailsForTheNewOperator(DataTable dataTable) - { - DataTableRow operatorDetails = dataTable.Rows.Single(); - String operatorName= ReqnrollTableHelper.GetStringRowValue(operatorDetails, "OperatorName"); - String requireCustomMerchantNumberString = ReqnrollTableHelper.GetStringRowValue(operatorDetails, "RequireCustomMerchantNumber"); - String requireCustomTerminalNumberString = ReqnrollTableHelper.GetStringRowValue(operatorDetails, "RequireCustomTerminalNumber"); - - // Translate the boolean flags - Boolean requireCustomMerchantNumber = requireCustomMerchantNumberString switch { - "Yes" => true, - _ => false - }; - - Boolean requireCustomTerminalNumber = requireCustomTerminalNumberString switch - { - "Yes" => true, - _ => false - }; - - - await this.UiHelpers.EnterOperatorDetails(operatorName, requireCustomMerchantNumber, - requireCustomTerminalNumber); - } - - [When("click the Save Operator button")] - public async Task WhenClickTheSaveOperatorButton() { - await this.UiHelpers.ClickTheSaveOperatorButton(); - } - - [When("click the Save Merchant button")] - public async Task WhenClickTheSaveMerchantButton() - { - await this.UiHelpers.ClickTheSaveMerchantButton(); - } - - [When("click the Make Deposit button")] - public async Task WhenClickTheMakeDepositButton() - { - await this.UiHelpers.ClickTheMakeDepositButton(); - } - - - [When("I click on the View Products Button for {string}")] - public async Task WhenIClickOnTheViewProductsButtonFor(string contractName) { - await this.UiHelpers.ClickTheViewContractProductsButton(contractName); - } - - [Then("the New Contract Screen is displayed")] - public async Task ThenTheNewContractScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheNewContractScreen(); - } - - [Then("the New Product Screen is displayed")] - public async Task ThenTheNewProductScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheNewContractProductScreen(); - } - - [When("I click on the New Contract Product Button")] - public async Task WhenIClickOnTheNewContractProductButton() - { - await this.UiHelpers.ClickTheNewContractProductButton(); - } - - - [When("I click on the New Contract Button")] - public async Task WhenIClickOnTheNewContractButton() - { - await this.UiHelpers.ClickAddNewContractButton(); - } - - [When("I enter the following details for the new Contract")] - public async Task WhenIEnterTheFollowingDetailsForTheNewContract(DataTable dataTable) - { - var tableRow = dataTable.Rows.Single(); - var contractDescription = ReqnrollTableHelper.GetStringRowValue(tableRow, "Description"); - var operatorName = ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"); - - await this.UiHelpers.EnterContractDetails(contractDescription, operatorName); - } - - [When("I enter the following details for the new Product")] - public async Task WhenIEnterTheFollowingDetailsForTheNewProduct(DataTable dataTable) - { - var tableRow = dataTable.Rows.Single(); - var productName = ReqnrollTableHelper.GetStringRowValue(tableRow, "ProductName"); - var productType = ReqnrollTableHelper.GetStringRowValue(tableRow, "ProductType"); - var displayText = ReqnrollTableHelper.GetStringRowValue(tableRow, "DisplayText"); - var value = ReqnrollTableHelper.GetStringRowValue(tableRow, "Value"); - - await this.UiHelpers.EnterContractProductDetails(productName, productType, displayText, value); - } - - [When("I click on the View Fees Button for {string}")] - public async Task WhenIClickOnTheViewFeesButtonFor(string productName) - { - await this.UiHelpers.ClickTheViewContractProductFeesButton(productName); - } - - [When("I click the Save Contract Button")] - public async Task WhenIClickTheSaveContractButton() - { - await this.UiHelpers.ClickTheSaveContractButton(); - } - - [Then("the following contract product details are in the list")] - public async Task ThenTheFollowingContractProductDetailsAreInTheList(DataTable dataTable) - { - List<(String, String, String,String)> contractProductsDescriptions = new List<(String, String, String, String)>(); - foreach (DataTableRow tableRow in dataTable.Rows) - { - contractProductsDescriptions.Add((ReqnrollTableHelper.GetStringRowValue(tableRow, "ProductName"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "ProductType"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "DisplayText"), - ReqnrollTableHelper.GetStringRowValue(tableRow, "Value"))); - } - - await this.UiHelpers.VerifyTheContractProductDetailsAreInTheList(contractProductsDescriptions); - } - - [When("I click on the New Contract Product Transaction Button")] - public async Task WhenIClickOnTheNewContractProductTransactionButton() - { - await this.UiHelpers.ClickAddNewTransactionFeeButton(); - } - - [Then("the New Contract Product Transaction Screen is displayed")] - public async Task ThenTheNewContractProductTransactionScreenIsDisplayed() - { - await this.UiHelpers.VerifyOnTheNewTransactionFeeScreen(); - } - - [When("I enter the following details for the new Transaction Fee")] - public async Task WhenIEnterTheFollowingDetailsForTheNewTransactionFee(DataTable dataTable) { - String description = ReqnrollTableHelper.GetStringRowValue(dataTable.Rows.First(), "Description"); - String calculationType = ReqnrollTableHelper.GetStringRowValue(dataTable.Rows.First(), "CalculationType"); - String feeType = ReqnrollTableHelper.GetStringRowValue(dataTable.Rows.First(), "FeeType"); - String feeValue = ReqnrollTableHelper.GetStringRowValue(dataTable.Rows.First(), "Value"); - await this.UiHelpers.EnterTransactionFeeDetails(description, calculationType, feeType, feeValue); - } - - [When("I click the Save Transaction Fee Button")] - public async Task WhenIClickTheSaveTransactionFeeButton() - { - await this.UiHelpers.ClickTheSaveTransactionFeeButton(); - } - - - - } - public record MerchantDetails(String MerchantName, String SettlementSchedule,String ContactName, String AddressLine1, String Town); -} diff --git a/EstateManagementUI.IntegrationTests/Tests/ContractTests.feature b/EstateManagementUI.IntegrationTests/Tests/ContractTests.feature deleted file mode 100644 index 1d25d48d..00000000 --- a/EstateManagementUI.IntegrationTests/Tests/ContractTests.feature +++ /dev/null @@ -1,128 +0,0 @@ -@base @shared @uigeneral -Feature: Contract Tests - -Background: - - Given I create the following roles - | Role Name | - | Estate | - - Given I create the following api scopes - | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | - | transactionProcessor | Transaction Processor REST Scope | Scope for Transaction Processor REST | - | fileProcessor | File Processor REST Scope | Scope for File Processor REST | - - Given I create the following api resources - | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | merchantId,estateId,role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | merchantId,estateId,role | - | fileProcessor | File Processor REST | Secret1 | fileProcessor | merchantId,estateId,role | - - Given I create the following identity resources - | Name | DisplayName | Description | UserClaims | - | openid | Your user identifier | | sub | - | profile | User profile | Your user profile information (first name, last name, etc.) | name,role,email,given_name,middle_name,family_name,estateId,merchantId | - | email | Email | Email and Email Verified Flags | email_verified,email | - - Given I create the following clients - | ClientId | Name | Secret | Scopes | GrantTypes | RedirectUris | PostLogoutRedirectUris | RequireConsent | AllowOfflineAccess | ClientUri | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor | client_credentials | | | | | | - | estateUIClient | Merchant Client | Secret1 | estateManagement,fileProcessor,transactionProcessor,openid,email,profile | hybrid | https://localhost:[port]/signin-oidc | https://localhost:[port]/signout-oidc | false | true | https://[url]:[port] | - - Given I have a token to access the estate management resource - | ClientId | - | serviceClient | - - Given I have created the following estates - | EstateName | - | Test Estate | - - And I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator 1 | True | True | - | Test Estate | Test Operator 2 | True | False | - | Test Estate | Test Operator 3 | False | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator 1 | - | Test Estate | Test Operator 2 | - | Test Estate | Test Operator 3 | - - And I have created the following security users - | EmailAddress | Password | GivenName | FamilyName | EstateName | - | estateuser@testestate1.co.uk | 123456 | TestEstate | User1 | Test Estate | - - Given I have created the following contracts - | EstateName | OperatorName | ContractDescription | - | Test Estate | Test Operator 1 | Operator 1 Contract | - | Test Estate | Test Operator 2 | Operator 2 Contract | - - Given I have created the following contract products - | EstateName | OperatorName | ContractDescription | ProductName | DisplayText | Value | ProductType | - | Test Estate | Test Operator 1 | Operator 1 Contract | 100 KES Topup | 100 KES | 100.00 | MobileTopup | - | Test Estate | Test Operator 1 | Operator 1 Contract | Variable Topup 1 | Custom | | MobileTopup | - | Test Estate | Test Operator 2 | Operator 2 Contract | 200 KES Topup | 200 KES | 500.00 | MobileTopup | - | Test Estate | Test Operator 2 | Operator 2 Contract | 500 KES Topup | 500 KES | 500.00 | MobileTopup | - | Test Estate | Test Operator 2 | Operator 2 Contract | Variable Topup 1 | Custom | | MobileTopup | - - Given I am on the application home page - - And I click on the Sign In Button - - Then I am presented with a login screen - - When I login with the username 'estateuser@testestate1.co.uk' and password '123456' - - Then I am presented with the Estate Administrator Dashboard - -@PRTest -Scenario: Contract PR Test - - Given I click on the My Contracts sidebar option - Then I am presented with the Contracts List Screen - And the following contract details are in the list - | Description | OperatorName | Products | - | Operator 1 Contract | Test Operator 1 | 2 | - | Operator 2 Contract | Test Operator 2 | 3 | - When I click on the New Contract Button - Then the New Contract Screen is displayed - When I enter the following details for the new Contract - | Description | OperatorName | - | Operator 3 Contract | Test Operator 3 | - When I click the Save Contract Button - Then I am presented with the Contracts List Screen - And the following contract details are in the list - | Description | OperatorName | Products | - | Operator 1 Contract | Test Operator 1 | 2 | - | Operator 2 Contract | Test Operator 2 | 3 | - | Operator 3 Contract | Test Operator 3 | 0 | - When I click on the View Products Button for 'Operator 1 Contract' - Then the Contract Products List Screen is displayed - And the following contract product details are in the list - | ProductName | DisplayText | Value | ProductType | - | 100 KES Topup | 100 KES | 100.00 | MobileTopup | - | Variable Topup 1 | Custom | Variable | MobileTopup | - When I click on the New Contract Product Button - Then the New Product Screen is displayed - When I enter the following details for the new Product - | ProductName | DisplayText | Value | ProductType | - | 200 KES Topup | 200 KES | 200.00 | Mobile Topup | - When I click the Save Product Button - Then the Contract Products List Screen is displayed - And the following contract product details are in the list - | ProductName | DisplayText | Value | ProductType | - | 100 KES Topup | 100 KES | 100.00 | MobileTopup | - | 200 KES Topup | 200 KES | 200.00 | MobileTopup | - | Variable Topup 1 | Custom | Variable | MobileTopup | - When I click on the View Fees Button for '100 KES Topup' - Then the Contract Products Transaction Fees List Screen is displayed - When I click on the New Contract Product Transaction Button - Then the New Contract Product Transaction Screen is displayed - When I enter the following details for the new Transaction Fee - | Description | CalculationType | FeeType | Value | - | Test Fixed Fee | Fixed Value | Merchant | 0.25 | - When I click the Save Transaction Fee Button - Then the Contract Products Transaction Fees List Screen is displayed - #And the following contract product transaction fee details are in the list \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/Tests/ContractTests.feature.cs b/EstateManagementUI.IntegrationTests/Tests/ContractTests.feature.cs deleted file mode 100644 index 210d0f37..00000000 --- a/EstateManagementUI.IntegrationTests/Tests/ContractTests.feature.cs +++ /dev/null @@ -1,578 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://reqnroll.net/). -// Reqnroll Version:3.0.0.0 -// Reqnroll Generator Version:3.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -using Reqnroll; -namespace EstateManagementUI.IntegrationTests.Tests -{ - - - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "3.0.0.0")] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::NUnit.Framework.TestFixtureAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Contract Tests")] - [global::NUnit.Framework.FixtureLifeCycleAttribute(global::NUnit.Framework.LifeCycle.InstancePerTestCase)] - [global::NUnit.Framework.CategoryAttribute("base")] - [global::NUnit.Framework.CategoryAttribute("shared")] - [global::NUnit.Framework.CategoryAttribute("uigeneral")] - public partial class ContractTestsFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "base", - "shared", - "uigeneral"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Contract Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags, InitializeCucumberMessages()); - -#line 1 "ContractTests.feature" -#line hidden - - [global::NUnit.Framework.OneTimeSetUpAttribute()] - public static async global::System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [global::NUnit.Framework.OneTimeTearDownAttribute()] - public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() - { - await global::Reqnroll.TestRunnerManager.ReleaseFeatureAsync(featureInfo); - } - - [global::NUnit.Framework.SetUpAttribute()] - public async global::System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - try - { - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - } - finally - { - if (((testRunner.FeatureContext != null) - && testRunner.FeatureContext.BeforeFeatureHookFailed)) - { - throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - } - - [global::NUnit.Framework.TearDownAttribute()] - public async global::System.Threading.Tasks.Task TestTearDownAsync() - { - if ((testRunner == null)) - { - return; - } - try - { - await testRunner.OnScenarioEndAsync(); - } - finally - { - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - testRunner = null; - } - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, global::Reqnroll.RuleInfo ruleInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo, ruleInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(global::NUnit.Framework.TestContext.CurrentContext); - } - - public async global::System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() - { -#line 4 -#line hidden - global::Reqnroll.Table table1 = new global::Reqnroll.Table(new string[] { - "Role Name"}); - table1.AddRow(new string[] { - "Estate"}); -#line 6 - await testRunner.GivenAsync("I create the following roles", ((string)(null)), table1, "Given "); -#line hidden - global::Reqnroll.Table table2 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description"}); - table2.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); - table2.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST Scope", - "Scope for Transaction Processor REST"}); - table2.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)), table2, "Given "); -#line hidden - global::Reqnroll.Table table3 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Secret", - "Scopes", - "UserClaims"}); - table3.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "merchantId,estateId,role"}); - table3.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST", - "Secret1", - "transactionProcessor", - "merchantId,estateId,role"}); - table3.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)), table3, "Given "); -#line hidden - global::Reqnroll.Table table4 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description", - "UserClaims"}); - table4.AddRow(new string[] { - "openid", - "Your user identifier", - "", - "sub"}); - table4.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"}); - table4.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)), table4, "Given "); -#line hidden - global::Reqnroll.Table table5 = new global::Reqnroll.Table(new string[] { - "ClientId", - "Name", - "Secret", - "Scopes", - "GrantTypes", - "RedirectUris", - "PostLogoutRedirectUris", - "RequireConsent", - "AllowOfflineAccess", - "ClientUri"}); - table5.AddRow(new string[] { - "serviceClient", - "Service Client", - "Secret1", - "estateManagement,transactionProcessor", - "client_credentials", - "", - "", - "", - "", - ""}); - table5.AddRow(new string[] { - "estateUIClient", - "Merchant Client", - "Secret1", - "estateManagement,fileProcessor,transactionProcessor,openid,email,profile", - "hybrid", - "https://localhost:[port]/signin-oidc", - "https://localhost:[port]/signout-oidc", - "false", - "true", - "https://[url]:[port]"}); -#line 28 - await testRunner.GivenAsync("I create the following clients", ((string)(null)), table5, "Given "); -#line hidden - global::Reqnroll.Table table6 = new global::Reqnroll.Table(new string[] { - "ClientId"}); - table6.AddRow(new string[] { - "serviceClient"}); -#line 33 - await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table6, "Given "); -#line hidden - global::Reqnroll.Table table7 = new global::Reqnroll.Table(new string[] { - "EstateName"}); - table7.AddRow(new string[] { - "Test Estate"}); -#line 37 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table7, "Given "); -#line hidden - global::Reqnroll.Table table8 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table8.AddRow(new string[] { - "Test Estate", - "Test Operator 1", - "True", - "True"}); - table8.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "True", - "False"}); - table8.AddRow(new string[] { - "Test Estate", - "Test Operator 3", - "False", - "True"}); -#line 41 - await testRunner.AndAsync("I have created the following operators", ((string)(null)), table8, "And "); -#line hidden - global::Reqnroll.Table table9 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table9.AddRow(new string[] { - "Test Estate", - "Test Operator 1"}); - table9.AddRow(new string[] { - "Test Estate", - "Test Operator 2"}); - table9.AddRow(new string[] { - "Test Estate", - "Test Operator 3"}); -#line 47 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table9, "And "); -#line hidden - global::Reqnroll.Table table10 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "EstateName"}); - table10.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)), table10, "And "); -#line hidden - global::Reqnroll.Table table11 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "ContractDescription"}); - table11.AddRow(new string[] { - "Test Estate", - "Test Operator 1", - "Operator 1 Contract"}); - table11.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "Operator 2 Contract"}); -#line 57 - await testRunner.GivenAsync("I have created the following contracts", ((string)(null)), table11, "Given "); -#line hidden - global::Reqnroll.Table table12 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "ContractDescription", - "ProductName", - "DisplayText", - "Value", - "ProductType"}); - table12.AddRow(new string[] { - "Test Estate", - "Test Operator 1", - "Operator 1 Contract", - "100 KES Topup", - "100 KES", - "100.00", - "MobileTopup"}); - table12.AddRow(new string[] { - "Test Estate", - "Test Operator 1", - "Operator 1 Contract", - "Variable Topup 1", - "Custom", - "", - "MobileTopup"}); - table12.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "Operator 2 Contract", - "200 KES Topup", - "200 KES", - "500.00", - "MobileTopup"}); - table12.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "Operator 2 Contract", - "500 KES Topup", - "500 KES", - "500.00", - "MobileTopup"}); - table12.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "Operator 2 Contract", - "Variable Topup 1", - "Custom", - "", - "MobileTopup"}); -#line 62 - await testRunner.GivenAsync("I have created the following contract products", ((string)(null)), table12, "Given "); -#line hidden -#line 70 - await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 72 - await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 74 - await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 76 - 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 78 - await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - - private static global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages InitializeCucumberMessages() - { - return new global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages("Tests/ContractTests.feature.ndjson", 3); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Contract PR Test")] - [global::NUnit.Framework.CategoryAttribute("PRTest")] - public async global::System.Threading.Tasks.Task ContractPRTest() - { - string[] tagsOfScenario = new string[] { - "PRTest"}; - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "0"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Contract PR Test", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 81 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 83 - await testRunner.GivenAsync("I click on the My Contracts sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 84 - await testRunner.ThenAsync("I am presented with the Contracts List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table13 = new global::Reqnroll.Table(new string[] { - "Description", - "OperatorName", - "Products"}); - table13.AddRow(new string[] { - "Operator 1 Contract", - "Test Operator 1", - "2"}); - table13.AddRow(new string[] { - "Operator 2 Contract", - "Test Operator 2", - "3"}); -#line 85 - await testRunner.AndAsync("the following contract details are in the list", ((string)(null)), table13, "And "); -#line hidden -#line 89 - await testRunner.WhenAsync("I click on the New Contract Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 90 - await testRunner.ThenAsync("the New Contract Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table14 = new global::Reqnroll.Table(new string[] { - "Description", - "OperatorName"}); - table14.AddRow(new string[] { - "Operator 3 Contract", - "Test Operator 3"}); -#line 91 - await testRunner.WhenAsync("I enter the following details for the new Contract", ((string)(null)), table14, "When "); -#line hidden -#line 94 - await testRunner.WhenAsync("I click the Save Contract Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 95 - await testRunner.ThenAsync("I am presented with the Contracts List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table15 = new global::Reqnroll.Table(new string[] { - "Description", - "OperatorName", - "Products"}); - table15.AddRow(new string[] { - "Operator 1 Contract", - "Test Operator 1", - "2"}); - table15.AddRow(new string[] { - "Operator 2 Contract", - "Test Operator 2", - "3"}); - table15.AddRow(new string[] { - "Operator 3 Contract", - "Test Operator 3", - "0"}); -#line 96 - await testRunner.AndAsync("the following contract details are in the list", ((string)(null)), table15, "And "); -#line hidden -#line 101 - await testRunner.WhenAsync("I click on the View Products Button for \'Operator 1 Contract\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 102 - await testRunner.ThenAsync("the Contract Products List Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table16 = new global::Reqnroll.Table(new string[] { - "ProductName", - "DisplayText", - "Value", - "ProductType"}); - table16.AddRow(new string[] { - "100 KES Topup", - "100 KES", - "100.00", - "MobileTopup"}); - table16.AddRow(new string[] { - "Variable Topup 1", - "Custom", - "Variable", - "MobileTopup"}); -#line 103 - await testRunner.AndAsync("the following contract product details are in the list", ((string)(null)), table16, "And "); -#line hidden -#line 107 - await testRunner.WhenAsync("I click on the New Contract Product Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 108 - await testRunner.ThenAsync("the New Product Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table17 = new global::Reqnroll.Table(new string[] { - "ProductName", - "DisplayText", - "Value", - "ProductType"}); - table17.AddRow(new string[] { - "200 KES Topup", - "200 KES", - "200.00", - "Mobile Topup"}); -#line 109 - await testRunner.WhenAsync("I enter the following details for the new Product", ((string)(null)), table17, "When "); -#line hidden -#line 112 - await testRunner.WhenAsync("I click the Save Product Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 113 - await testRunner.ThenAsync("the Contract Products List Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table18 = new global::Reqnroll.Table(new string[] { - "ProductName", - "DisplayText", - "Value", - "ProductType"}); - table18.AddRow(new string[] { - "100 KES Topup", - "100 KES", - "100.00", - "MobileTopup"}); - table18.AddRow(new string[] { - "200 KES Topup", - "200 KES", - "200.00", - "MobileTopup"}); - table18.AddRow(new string[] { - "Variable Topup 1", - "Custom", - "Variable", - "MobileTopup"}); -#line 114 - await testRunner.AndAsync("the following contract product details are in the list", ((string)(null)), table18, "And "); -#line hidden -#line 119 - await testRunner.WhenAsync("I click on the View Fees Button for \'100 KES Topup\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 120 - await testRunner.ThenAsync("the Contract Products Transaction Fees List Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 121 - await testRunner.WhenAsync("I click on the New Contract Product Transaction Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 122 - await testRunner.ThenAsync("the New Contract Product Transaction Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table19 = new global::Reqnroll.Table(new string[] { - "Description", - "CalculationType", - "FeeType", - "Value"}); - table19.AddRow(new string[] { - "Test Fixed Fee", - "Fixed Value", - "Merchant", - "0.25"}); -#line 123 - await testRunner.WhenAsync("I enter the following details for the new Transaction Fee", ((string)(null)), table19, "When "); -#line hidden -#line 126 - await testRunner.WhenAsync("I click the Save Transaction Fee Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 127 - await testRunner.ThenAsync("the Contract Products Transaction Fees List Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/EstateManagementUI.IntegrationTests/Tests/EstateTests.feature b/EstateManagementUI.IntegrationTests/Tests/EstateTests.feature deleted file mode 100644 index 356c780c..00000000 --- a/EstateManagementUI.IntegrationTests/Tests/EstateTests.feature +++ /dev/null @@ -1,85 +0,0 @@ -@base @shared @uigeneral -Feature: Estate Tests - -Background: - - Given I create the following roles - | Role Name | - | Estate | - - Given I create the following api scopes - | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | - | transactionProcessor | Transaction Processor REST Scope | Scope for Transaction Processor REST | - | fileProcessor | File Processor REST Scope | Scope for File Processor REST | - - Given I create the following api resources - | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | merchantId,estateId,role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | merchantId,estateId,role | - | fileProcessor | File Processor REST | Secret1 | fileProcessor | merchantId,estateId,role | - - Given I create the following identity resources - | Name | DisplayName | Description | UserClaims | - | openid | Your user identifier | | sub | - | profile | User profile | Your user profile information (first name, last name, etc.) | name,role,email,given_name,middle_name,family_name,estateId,merchantId | - | email | Email | Email and Email Verified Flags | email_verified,email | - - Given I create the following clients - | ClientId | Name | Secret | Scopes | GrantTypes | RedirectUris | PostLogoutRedirectUris | RequireConsent | AllowOfflineAccess | ClientUri | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor | client_credentials | | | | | | - | estateUIClient | Merchant Client | Secret1 | estateManagement,fileProcessor,transactionProcessor,openid,email,profile | hybrid | https://localhost:[port]/signin-oidc | https://localhost:[port]/signout-oidc | false | true | https://[url]:[port] | - - Given I have a token to access the estate management resource - | ClientId | - | serviceClient | - - Given I have created the following estates - | EstateName | - | Test Estate | - - And I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator | True | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator | - - And I have created the following security users - | EmailAddress | Password | GivenName | FamilyName | EstateName | - | estateuser@testestate1.co.uk | 123456 | TestEstate | User1 | Test Estate | - - -Scenario: I Can Log Into The Application - - Given I am on the application home page - - And I click on the Sign In Button - - Then I am presented with a login screen - - When I login with the username 'estateuser@testestate1.co.uk' and password '123456' - - Then I am presented with the Estate Administrator Dashboard - -@PRTest -Scenario: View Estate Details - - Given I am on the application home page - - And I click on the Sign In Button - - Then I am presented with a login screen - - When I login with the username 'estateuser@testestate1.co.uk' and password '123456' - - Then I am presented with the Estate Administrator Dashboard - - Given I click on the My Estate sidebar option - - Then I am presented with the View Estate Page - - And My Estate Details will be shown - | EstateName | EstateReference | - | Test Estate | Test Estate | \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/Tests/EstateTests.feature.cs b/EstateManagementUI.IntegrationTests/Tests/EstateTests.feature.cs deleted file mode 100644 index ccfc66f8..00000000 --- a/EstateManagementUI.IntegrationTests/Tests/EstateTests.feature.cs +++ /dev/null @@ -1,389 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://reqnroll.net/). -// Reqnroll Version:3.0.0.0 -// Reqnroll Generator Version:3.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -using Reqnroll; -namespace EstateManagementUI.IntegrationTests.Tests -{ - - - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "3.0.0.0")] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::NUnit.Framework.TestFixtureAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Estate Tests")] - [global::NUnit.Framework.FixtureLifeCycleAttribute(global::NUnit.Framework.LifeCycle.InstancePerTestCase)] - [global::NUnit.Framework.CategoryAttribute("base")] - [global::NUnit.Framework.CategoryAttribute("shared")] - [global::NUnit.Framework.CategoryAttribute("uigeneral")] - public partial class EstateTestsFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "base", - "shared", - "uigeneral"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Estate Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags, InitializeCucumberMessages()); - -#line 1 "EstateTests.feature" -#line hidden - - [global::NUnit.Framework.OneTimeSetUpAttribute()] - public static async global::System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [global::NUnit.Framework.OneTimeTearDownAttribute()] - public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() - { - await global::Reqnroll.TestRunnerManager.ReleaseFeatureAsync(featureInfo); - } - - [global::NUnit.Framework.SetUpAttribute()] - public async global::System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - try - { - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - } - finally - { - if (((testRunner.FeatureContext != null) - && testRunner.FeatureContext.BeforeFeatureHookFailed)) - { - throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - } - - [global::NUnit.Framework.TearDownAttribute()] - public async global::System.Threading.Tasks.Task TestTearDownAsync() - { - if ((testRunner == null)) - { - return; - } - try - { - await testRunner.OnScenarioEndAsync(); - } - finally - { - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - testRunner = null; - } - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, global::Reqnroll.RuleInfo ruleInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo, ruleInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(global::NUnit.Framework.TestContext.CurrentContext); - } - - public async global::System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() - { -#line 4 -#line hidden - global::Reqnroll.Table table20 = new global::Reqnroll.Table(new string[] { - "Role Name"}); - table20.AddRow(new string[] { - "Estate"}); -#line 6 - await testRunner.GivenAsync("I create the following roles", ((string)(null)), table20, "Given "); -#line hidden - global::Reqnroll.Table table21 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description"}); - table21.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); - table21.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST Scope", - "Scope for Transaction Processor REST"}); - table21.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)), table21, "Given "); -#line hidden - global::Reqnroll.Table table22 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Secret", - "Scopes", - "UserClaims"}); - table22.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "merchantId,estateId,role"}); - table22.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST", - "Secret1", - "transactionProcessor", - "merchantId,estateId,role"}); - table22.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)), table22, "Given "); -#line hidden - global::Reqnroll.Table table23 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description", - "UserClaims"}); - table23.AddRow(new string[] { - "openid", - "Your user identifier", - "", - "sub"}); - table23.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"}); - table23.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)), table23, "Given "); -#line hidden - global::Reqnroll.Table table24 = new global::Reqnroll.Table(new string[] { - "ClientId", - "Name", - "Secret", - "Scopes", - "GrantTypes", - "RedirectUris", - "PostLogoutRedirectUris", - "RequireConsent", - "AllowOfflineAccess", - "ClientUri"}); - table24.AddRow(new string[] { - "serviceClient", - "Service Client", - "Secret1", - "estateManagement,transactionProcessor", - "client_credentials", - "", - "", - "", - "", - ""}); - table24.AddRow(new string[] { - "estateUIClient", - "Merchant Client", - "Secret1", - "estateManagement,fileProcessor,transactionProcessor,openid,email,profile", - "hybrid", - "https://localhost:[port]/signin-oidc", - "https://localhost:[port]/signout-oidc", - "false", - "true", - "https://[url]:[port]"}); -#line 28 - await testRunner.GivenAsync("I create the following clients", ((string)(null)), table24, "Given "); -#line hidden - global::Reqnroll.Table table25 = new global::Reqnroll.Table(new string[] { - "ClientId"}); - table25.AddRow(new string[] { - "serviceClient"}); -#line 33 - await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table25, "Given "); -#line hidden - global::Reqnroll.Table table26 = new global::Reqnroll.Table(new string[] { - "EstateName"}); - table26.AddRow(new string[] { - "Test Estate"}); -#line 37 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table26, "Given "); -#line hidden - global::Reqnroll.Table table27 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table27.AddRow(new string[] { - "Test Estate", - "Test Operator", - "True", - "True"}); -#line 41 - await testRunner.AndAsync("I have created the following operators", ((string)(null)), table27, "And "); -#line hidden - global::Reqnroll.Table table28 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table28.AddRow(new string[] { - "Test Estate", - "Test Operator"}); -#line 45 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table28, "And "); -#line hidden - global::Reqnroll.Table table29 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "EstateName"}); - table29.AddRow(new string[] { - "estateuser@testestate1.co.uk", - "123456", - "TestEstate", - "User1", - "Test Estate"}); -#line 49 - await testRunner.AndAsync("I have created the following security users", ((string)(null)), table29, "And "); -#line hidden - } - - private static global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages InitializeCucumberMessages() - { - return new global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages("Tests/EstateTests.feature.ndjson", 4); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("I Can Log Into The Application")] - public async global::System.Threading.Tasks.Task ICanLogIntoTheApplication() - { - string[] tagsOfScenario = ((string[])(null)); - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "0"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("I Can Log Into The Application", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 54 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 56 - await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 58 - await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 60 - await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 62 - 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 64 - await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("View Estate Details")] - [global::NUnit.Framework.CategoryAttribute("PRTest")] - public async global::System.Threading.Tasks.Task ViewEstateDetails() - { - string[] tagsOfScenario = new string[] { - "PRTest"}; - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "1"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("View Estate Details", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 67 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 69 - await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 71 - await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 73 - await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 75 - 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 77 - await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 79 - await testRunner.GivenAsync("I click on the My Estate sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 81 - await testRunner.ThenAsync("I am presented with the View Estate Page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table30 = new global::Reqnroll.Table(new string[] { - "EstateName", - "EstateReference"}); - table30.AddRow(new string[] { - "Test Estate", - "Test Estate"}); -#line 83 - await testRunner.AndAsync("My Estate Details will be shown", ((string)(null)), table30, "And "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature b/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature deleted file mode 100644 index 3fb2d4da..00000000 --- a/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature +++ /dev/null @@ -1,254 +0,0 @@ -@base @shared @uigeneral -Feature: Merchant Tests - -Background: - - Given I create the following roles - | Role Name | - | Estate | - | Merchant | - - Given I create the following api scopes - | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | - | transactionProcessor | Transaction Processor REST Scope | Scope for Transaction Processor REST | - | fileProcessor | File Processor REST Scope | Scope for File Processor REST | - - Given I create the following api resources - | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | merchantId,estateId,role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | merchantId,estateId,role | - | fileProcessor | File Processor REST | Secret1 | fileProcessor | merchantId,estateId,role | - - Given I create the following identity resources - | Name | DisplayName | Description | UserClaims | - | openid | Your user identifier | | sub | - | profile | User profile | Your user profile information (first name, last name, etc.) | name,role,email,given_name,middle_name,family_name,estateId,merchantId | - | email | Email | Email and Email Verified Flags | email_verified,email | - - Given I create the following clients - | ClientId | Name | Secret | Scopes | GrantTypes | RedirectUris | PostLogoutRedirectUris | RequireConsent | AllowOfflineAccess | ClientUri | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor | client_credentials | | | | | | - | estateUIClient | Merchant Client | Secret1 | estateManagement,fileProcessor,transactionProcessor,openid,email,profile | hybrid | https://localhost:[port]/signin-oidc | https://localhost:[port]/signout-oidc | false | true | https://[url]:[port] | - - Given I have a token to access the estate management resource - | ClientId | - | serviceClient | - - Given I have created the following estates - | EstateName | - | Test Estate | - - And I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator | True | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator | - - And I have created the following security users - | EmailAddress | Password | GivenName | FamilyName | EstateName | - | estateuser@testestate1.co.uk | 123456 | TestEstate | User1 | Test Estate | - - Given I create the following merchants - | MerchantName | SettlementSchedule | AddressLine1 | Town | Region | Country | ContactName | EmailAddress | EstateName | - | Test Merchant 1 | Immediate | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant1.co.uk | Test Estate | - | Test Merchant 2 | Weekly | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant2.co.uk | Test Estate | - | Test Merchant 3 | Monthly | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant3.co.uk | Test Estate | - - When I assign the following operator to the merchants - | OperatorName | MerchantName | MerchantNumber | TerminalNumber | EstateName | - | Test Operator | Test Merchant 1 | 00000001 | 10000001 | Test Estate | - | Test Operator | Test Merchant 2 | 00000001 | 10000001 | Test Estate | - | Test Operator | Test Merchant 3 | 00000001 | 10000001 | Test Estate | - - When I create the following security users - | EmailAddress | Password | GivenName | FamilyName | MerchantName | EstateName | - | merchantuser1@testmerchant1.co.uk | 123456 | TestMerchant | User1 | Test Merchant 1 | Test Estate | - | merchantuser1@testmerchant2.co.uk | 123456 | TestMerchant | User1 | Test Merchant 2 | Test Estate | - | merchantuser1@testmerchant3.co.uk | 123456 | TestMerchant | User1 | Test Merchant 3 | Test Estate | - - When I add the following devices to the merchant - | DeviceIdentifier | MerchantName | EstateName | - | TestDevice1 | Test Merchant 1 | Test Estate | - | TestDevice2 | Test Merchant 2 | Test Estate | - - Given I am on the application home page - - And I click on the Sign In Button - - Then I am presented with a login screen - - When I login with the username 'estateuser@testestate1.co.uk' and password '123456' - - Then I am presented with the Estate Administrator Dashboard - -@PRTest -Scenario: Merchant PR Test - - 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 New Merchant Button - Then the Add New Merchant Screen is displayed - When I enter the following details for the new Merchant - | MerchantName | SettlementSchedule | AddressLine1 | Town | Region | Country | ContactName | EmailAddress | - | Test Merchant 4 | Immediate | Address Line 1 | TestTown | Region | Country | Test Contact 4 | 1@2.com | - And click the Save Merchant button - 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 | - | Test Merchant 4 | Immediate | Test Contact 4 | Address Line 1 | TestTown | - When I click on the Edit Merchant Button for 'Test Merchant 1' - Then the Edit Merchant Screen is displayed - When I enter the following details for the updated Merchant - | Tab | Field | Value | - | Details | Name | Test Merchant 1 Update | - | Address | AddressLine1 | Address Line 1 Update | - | Contact | ContactName | Test Contact 1 Update | - And click the Save Merchant button - 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 Update | Immediate | Test Contact 1 Update | Address Line 1 Update | TestTown | - | Test Merchant 2 | Weekly | Test Contact 1 | Address Line 1 | TestTown | - | Test Merchant 3 | Monthly | Test Contact 1 | Address Line 1 | TestTown | - | Test Merchant 4 | Immediate | Test Contact 4 | Address Line 1 | TestTown | - When I click on the Make Deposit Button for 'Test Merchant 1 Update' - Then the Make Deposit Screen is displayed - When I enter the following details for the deposit - | Amount | Date | Reference | - | 1000.00 | Today | Test Deposit 1 | - And click the Make Deposit button - Then I am presented with the Merchants List Screen - When I click on the View Merchant Button for 'Test Merchant 1 Update' - Then the View Merchant Screen is displayed - - -Scenario: Merchant Operator Management - Given I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator1 | True | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator1 | - - 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 1' - Then the Edit Merchant Screen is displayed - - When I click on the Operators tab - Then I am presented with the Merchants Operator List Screen - And the following operators are displayed in the list - | OperatorName | MerchantNumber | TerminalNumber | - | Test Operator | 00000001 | 10000001 | - When I click on the Add Operator Button - Then the Assign Operator Dialog will be displayed - When I enter the following details for the Operator - | OperatorName | MerchantNumber | TerminalNumber | - | Test Operator1 | 00000111 | 10000111 | - And click the Assign Operator button - Then I am presented with the Merchants Operator List Screen - And the following operators are displayed in the list - | OperatorName | MerchantNumber | TerminalNumber | IsDeleted | - | Test Operator | 00000001 | 10000001 | False | - | Test Operator1 | 00000111 | 10000111 | False | - When I click on the Remove Operator for 'Test Operator1' - Then I am presented with the Merchants Operator List Screen - And the following operators are displayed in the list - | OperatorName | MerchantNumber | TerminalNumber | IsDeleted | - | Test Operator | 00000001 | 10000001 | False | - | Test Operator1 | 00000111 | 10000111 | True | - -Scenario: Merchant Contract Management - Given I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator1 | True | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator1 | - - # Does this assignt the contract to the estate automatically ?? - Given I have created the following contracts - | EstateName | OperatorName | ContractDescription | - | Test Estate | Test Operator1 | Operator 1 Contract | - - 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 1' - Then the Edit Merchant Screen is displayed - - When I click on the Contracts tab - Then I am presented with the Merchants Contract List Screen - And the following contracts are displayed in the list - | ContractName | IsDeleted | - - When I click on the Add Contract Button - Then the Assign Contract Dialog will be displayed - When I enter the following details for the Contract - | ContractName | - | Operator 1 Contract | - And click the Assign Contract button - Then I am presented with the Merchants Contract List Screen - And the following contracts are displayed in the list - | ContractName | IsDeleted | - | Operator 1 Contract | False | - - When I click on the Remove Contract for 'Operator 1 Contract' - Then I am presented with the Merchants Contract List Screen - 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 deleted file mode 100644 index c7c44652..00000000 --- a/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature.cs +++ /dev/null @@ -1,1069 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://reqnroll.net/). -// Reqnroll Version:3.0.0.0 -// Reqnroll Generator Version:3.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -using Reqnroll; -namespace EstateManagementUI.IntegrationTests.Tests -{ - - - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "3.0.0.0")] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::NUnit.Framework.TestFixtureAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Merchant Tests")] - [global::NUnit.Framework.FixtureLifeCycleAttribute(global::NUnit.Framework.LifeCycle.InstancePerTestCase)] - [global::NUnit.Framework.CategoryAttribute("base")] - [global::NUnit.Framework.CategoryAttribute("shared")] - [global::NUnit.Framework.CategoryAttribute("uigeneral")] - public partial class MerchantTestsFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "base", - "shared", - "uigeneral"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Merchant Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags, InitializeCucumberMessages()); - -#line 1 "MerchantTests.feature" -#line hidden - - [global::NUnit.Framework.OneTimeSetUpAttribute()] - public static async global::System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [global::NUnit.Framework.OneTimeTearDownAttribute()] - public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() - { - await global::Reqnroll.TestRunnerManager.ReleaseFeatureAsync(featureInfo); - } - - [global::NUnit.Framework.SetUpAttribute()] - public async global::System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - try - { - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - } - finally - { - if (((testRunner.FeatureContext != null) - && testRunner.FeatureContext.BeforeFeatureHookFailed)) - { - throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - } - - [global::NUnit.Framework.TearDownAttribute()] - public async global::System.Threading.Tasks.Task TestTearDownAsync() - { - if ((testRunner == null)) - { - return; - } - try - { - await testRunner.OnScenarioEndAsync(); - } - finally - { - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - testRunner = null; - } - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, global::Reqnroll.RuleInfo ruleInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo, ruleInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(global::NUnit.Framework.TestContext.CurrentContext); - } - - public async global::System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() - { -#line 4 -#line hidden - global::Reqnroll.Table table31 = new global::Reqnroll.Table(new string[] { - "Role Name"}); - table31.AddRow(new string[] { - "Estate"}); - table31.AddRow(new string[] { - "Merchant"}); -#line 6 - await testRunner.GivenAsync("I create the following roles", ((string)(null)), table31, "Given "); -#line hidden - global::Reqnroll.Table table32 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description"}); - table32.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); - table32.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST Scope", - "Scope for Transaction Processor REST"}); - table32.AddRow(new string[] { - "fileProcessor", - "File Processor REST Scope", - "Scope for File Processor REST"}); -#line 11 - await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table32, "Given "); -#line hidden - global::Reqnroll.Table table33 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Secret", - "Scopes", - "UserClaims"}); - table33.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "merchantId,estateId,role"}); - table33.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST", - "Secret1", - "transactionProcessor", - "merchantId,estateId,role"}); - table33.AddRow(new string[] { - "fileProcessor", - "File Processor REST", - "Secret1", - "fileProcessor", - "merchantId,estateId,role"}); -#line 17 - await testRunner.GivenAsync("I create the following api resources", ((string)(null)), table33, "Given "); -#line hidden - global::Reqnroll.Table table34 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description", - "UserClaims"}); - table34.AddRow(new string[] { - "openid", - "Your user identifier", - "", - "sub"}); - table34.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"}); - table34.AddRow(new string[] { - "email", - "Email", - "Email and Email Verified Flags", - "email_verified,email"}); -#line 23 - await testRunner.GivenAsync("I create the following identity resources", ((string)(null)), table34, "Given "); -#line hidden - global::Reqnroll.Table table35 = new global::Reqnroll.Table(new string[] { - "ClientId", - "Name", - "Secret", - "Scopes", - "GrantTypes", - "RedirectUris", - "PostLogoutRedirectUris", - "RequireConsent", - "AllowOfflineAccess", - "ClientUri"}); - table35.AddRow(new string[] { - "serviceClient", - "Service Client", - "Secret1", - "estateManagement,transactionProcessor", - "client_credentials", - "", - "", - "", - "", - ""}); - table35.AddRow(new string[] { - "estateUIClient", - "Merchant Client", - "Secret1", - "estateManagement,fileProcessor,transactionProcessor,openid,email,profile", - "hybrid", - "https://localhost:[port]/signin-oidc", - "https://localhost:[port]/signout-oidc", - "false", - "true", - "https://[url]:[port]"}); -#line 29 - await testRunner.GivenAsync("I create the following clients", ((string)(null)), table35, "Given "); -#line hidden - global::Reqnroll.Table table36 = new global::Reqnroll.Table(new string[] { - "ClientId"}); - table36.AddRow(new string[] { - "serviceClient"}); -#line 34 - await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table36, "Given "); -#line hidden - global::Reqnroll.Table table37 = new global::Reqnroll.Table(new string[] { - "EstateName"}); - table37.AddRow(new string[] { - "Test Estate"}); -#line 38 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table37, "Given "); -#line hidden - global::Reqnroll.Table table38 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table38.AddRow(new string[] { - "Test Estate", - "Test Operator", - "True", - "True"}); -#line 42 - await testRunner.AndAsync("I have created the following operators", ((string)(null)), table38, "And "); -#line hidden - global::Reqnroll.Table table39 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table39.AddRow(new string[] { - "Test Estate", - "Test Operator"}); -#line 46 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table39, "And "); -#line hidden - global::Reqnroll.Table table40 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "EstateName"}); - table40.AddRow(new string[] { - "estateuser@testestate1.co.uk", - "123456", - "TestEstate", - "User1", - "Test Estate"}); -#line 50 - await testRunner.AndAsync("I have created the following security users", ((string)(null)), table40, "And "); -#line hidden - global::Reqnroll.Table table41 = new global::Reqnroll.Table(new string[] { - "MerchantName", - "SettlementSchedule", - "AddressLine1", - "Town", - "Region", - "Country", - "ContactName", - "EmailAddress", - "EstateName"}); - table41.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Address Line 1", - "TestTown", - "Test Region", - "United Kingdom", - "Test Contact 1", - "testcontact1@merchant1.co.uk", - "Test Estate"}); - table41.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Address Line 1", - "TestTown", - "Test Region", - "United Kingdom", - "Test Contact 1", - "testcontact1@merchant2.co.uk", - "Test Estate"}); - table41.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Address Line 1", - "TestTown", - "Test Region", - "United Kingdom", - "Test Contact 1", - "testcontact1@merchant3.co.uk", - "Test Estate"}); -#line 54 - await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table41, "Given "); -#line hidden - global::Reqnroll.Table table42 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "MerchantName", - "MerchantNumber", - "TerminalNumber", - "EstateName"}); - table42.AddRow(new string[] { - "Test Operator", - "Test Merchant 1", - "00000001", - "10000001", - "Test Estate"}); - table42.AddRow(new string[] { - "Test Operator", - "Test Merchant 2", - "00000001", - "10000001", - "Test Estate"}); - table42.AddRow(new string[] { - "Test Operator", - "Test Merchant 3", - "00000001", - "10000001", - "Test Estate"}); -#line 60 - await testRunner.WhenAsync("I assign the following operator to the merchants", ((string)(null)), table42, "When "); -#line hidden - global::Reqnroll.Table table43 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "MerchantName", - "EstateName"}); - table43.AddRow(new string[] { - "merchantuser1@testmerchant1.co.uk", - "123456", - "TestMerchant", - "User1", - "Test Merchant 1", - "Test Estate"}); - table43.AddRow(new string[] { - "merchantuser1@testmerchant2.co.uk", - "123456", - "TestMerchant", - "User1", - "Test Merchant 2", - "Test Estate"}); - table43.AddRow(new string[] { - "merchantuser1@testmerchant3.co.uk", - "123456", - "TestMerchant", - "User1", - "Test Merchant 3", - "Test Estate"}); -#line 66 - await testRunner.WhenAsync("I create the following security users", ((string)(null)), table43, "When "); -#line hidden - global::Reqnroll.Table table44 = new global::Reqnroll.Table(new string[] { - "DeviceIdentifier", - "MerchantName", - "EstateName"}); - table44.AddRow(new string[] { - "TestDevice1", - "Test Merchant 1", - "Test Estate"}); - table44.AddRow(new string[] { - "TestDevice2", - "Test Merchant 2", - "Test Estate"}); -#line 72 - await testRunner.WhenAsync("I add the following devices to the merchant", ((string)(null)), table44, "When "); -#line hidden -#line 77 - await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 79 - await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 81 - await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#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 85 - await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - - private static global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages InitializeCucumberMessages() - { - return new global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages("Tests/MerchantTests.feature.ndjson", 6); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Merchant PR Test")] - [global::NUnit.Framework.CategoryAttribute("PRTest")] - public async global::System.Threading.Tasks.Task MerchantPRTest() - { - string[] tagsOfScenario = new string[] { - "PRTest"}; - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "0"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant PR Test", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 88 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 90 - await testRunner.GivenAsync("I click on the My Merchants sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#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[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table45.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table45.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table45.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); -#line 92 - await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table45, "And "); -#line hidden -#line 97 - await testRunner.WhenAsync("I click on the New Merchant Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#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[] { - "MerchantName", - "SettlementSchedule", - "AddressLine1", - "Town", - "Region", - "Country", - "ContactName", - "EmailAddress"}); - table46.AddRow(new string[] { - "Test Merchant 4", - "Immediate", - "Address Line 1", - "TestTown", - "Region", - "Country", - "Test Contact 4", - "1@2.com"}); -#line 99 - await testRunner.WhenAsync("I enter the following details for the new Merchant", ((string)(null)), table46, "When "); -#line hidden -#line 102 - await testRunner.AndAsync("click the Save Merchant button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table47.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table47.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table47.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table47.AddRow(new string[] { - "Test Merchant 4", - "Immediate", - "Test Contact 4", - "Address Line 1", - "TestTown"}); -#line 104 - await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table47, "And "); -#line hidden -#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 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[] { - "Tab", - "Field", - "Value"}); - table48.AddRow(new string[] { - "Details", - "Name", - "Test Merchant 1 Update"}); - table48.AddRow(new string[] { - "Address", - "AddressLine1", - "Address Line 1 Update"}); - table48.AddRow(new string[] { - "Contact", - "ContactName", - "Test Contact 1 Update"}); -#line 112 - await testRunner.WhenAsync("I enter the following details for the updated Merchant", ((string)(null)), table48, "When "); -#line hidden -#line 117 - await testRunner.AndAsync("click the Save Merchant button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table49.AddRow(new string[] { - "Test Merchant 1 Update", - "Immediate", - "Test Contact 1 Update", - "Address Line 1 Update", - "TestTown"}); - table49.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table49.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table49.AddRow(new string[] { - "Test Merchant 4", - "Immediate", - "Test Contact 4", - "Address Line 1", - "TestTown"}); -#line 119 - await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table49, "And "); -#line hidden -#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 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[] { - "Amount", - "Date", - "Reference"}); - table50.AddRow(new string[] { - "1000.00", - "Today", - "Test Deposit 1"}); -#line 127 - await testRunner.WhenAsync("I enter the following details for the deposit", ((string)(null)), table50, "When "); -#line hidden -#line 130 - await testRunner.AndAsync("click the Make Deposit button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 131 - await testRunner.ThenAsync("I am presented with the Merchants List Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#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 133 - await testRunner.ThenAsync("the View Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Merchant Operator Management")] - public async global::System.Threading.Tasks.Task MerchantOperatorManagement() - { - string[] tagsOfScenario = ((string[])(null)); - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "1"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Operator Management", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 136 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden - global::Reqnroll.Table table51 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table51.AddRow(new string[] { - "Test Estate", - "Test Operator1", - "True", - "True"}); -#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[] { - "EstateName", - "OperatorName"}); - table52.AddRow(new string[] { - "Test Estate", - "Test Operator1"}); -#line 141 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table52, "And "); -#line hidden -#line 145 - await testRunner.GivenAsync("I click on the My Merchants sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#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[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table53.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table53.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table53.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); -#line 147 - await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table53, "And "); -#line hidden -#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 154 - await testRunner.ThenAsync("the Edit Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 156 - await testRunner.WhenAsync("I click on the Operators tab", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#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[] { - "OperatorName", - "MerchantNumber", - "TerminalNumber"}); - table54.AddRow(new string[] { - "Test Operator", - "00000001", - "10000001"}); -#line 158 - await testRunner.AndAsync("the following operators are displayed in the list", ((string)(null)), table54, "And "); -#line hidden -#line 161 - await testRunner.WhenAsync("I click on the Add Operator Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#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[] { - "OperatorName", - "MerchantNumber", - "TerminalNumber"}); - table55.AddRow(new string[] { - "Test Operator1", - "00000111", - "10000111"}); -#line 163 - await testRunner.WhenAsync("I enter the following details for the Operator", ((string)(null)), table55, "When "); -#line hidden -#line 166 - await testRunner.AndAsync("click the Assign Operator button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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[] { - "OperatorName", - "MerchantNumber", - "TerminalNumber", - "IsDeleted"}); - table56.AddRow(new string[] { - "Test Operator", - "00000001", - "10000001", - "False"}); - table56.AddRow(new string[] { - "Test Operator1", - "00000111", - "10000111", - "False"}); -#line 168 - await testRunner.AndAsync("the following operators are displayed in the list", ((string)(null)), table56, "And "); -#line hidden -#line 172 - await testRunner.WhenAsync("I click on the Remove Operator for \'Test Operator1\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#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[] { - "OperatorName", - "MerchantNumber", - "TerminalNumber", - "IsDeleted"}); - table57.AddRow(new string[] { - "Test Operator", - "00000001", - "10000001", - "False"}); - table57.AddRow(new string[] { - "Test Operator1", - "00000111", - "10000111", - "True"}); -#line 174 - await testRunner.AndAsync("the following operators are displayed in the list", ((string)(null)), table57, "And "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Merchant Contract Management")] - public async global::System.Threading.Tasks.Task MerchantContractManagement() - { - string[] tagsOfScenario = ((string[])(null)); - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "2"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Contract Management", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 179 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden - global::Reqnroll.Table table58 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table58.AddRow(new string[] { - "Test Estate", - "Test Operator1", - "True", - "True"}); -#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[] { - "EstateName", - "OperatorName"}); - table59.AddRow(new string[] { - "Test Estate", - "Test Operator1"}); -#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[] { - "EstateName", - "OperatorName", - "ContractDescription"}); - table60.AddRow(new string[] { - "Test Estate", - "Test Operator1", - "Operator 1 Contract"}); -#line 189 - await testRunner.GivenAsync("I have created the following contracts", ((string)(null)), table60, "Given "); -#line hidden -#line 193 - await testRunner.GivenAsync("I click on the My Merchants sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#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[] { - "MerchantName", - "SettlementSchedule", - "ContactName", - "AddressLine1", - "Town"}); - table61.AddRow(new string[] { - "Test Merchant 1", - "Immediate", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table61.AddRow(new string[] { - "Test Merchant 2", - "Weekly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); - table61.AddRow(new string[] { - "Test Merchant 3", - "Monthly", - "Test Contact 1", - "Address Line 1", - "TestTown"}); -#line 195 - await testRunner.AndAsync("the following merchants details are in the list", ((string)(null)), table61, "And "); -#line hidden -#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 202 - await testRunner.ThenAsync("the Edit Merchant Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 204 - await testRunner.WhenAsync("I click on the Contracts tab", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#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 206 - await testRunner.AndAsync("the following contracts are displayed in the list", ((string)(null)), table62, "And "); -#line hidden -#line 209 - await testRunner.WhenAsync("I click on the Add Contract Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#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 211 - await testRunner.WhenAsync("I enter the following details for the Contract", ((string)(null)), table63, "When "); -#line hidden -#line 214 - await testRunner.AndAsync("click the Assign Contract button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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[] { - "ContractName", - "IsDeleted"}); - table64.AddRow(new string[] { - "Operator 1 Contract", - "False"}); -#line 216 - await testRunner.AndAsync("the following contracts are displayed in the list", ((string)(null)), table64, "And "); -#line hidden -#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 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[] { - "ContractName", - "IsDeleted"}); - table65.AddRow(new string[] { - "Operator 1 Contract", - "True"}); -#line 222 - await testRunner.AndAsync("the following contracts are displayed in the list", ((string)(null)), table65, "And "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Merchant Device Management")] - public async global::System.Threading.Tasks.Task MerchantDeviceManagement() - { - string[] tagsOfScenario = ((string[])(null)); - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "3"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Device Management", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 227 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - 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(); - } - } -} -#pragma warning restore -#endregion diff --git a/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature b/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature deleted file mode 100644 index 4fbc56a9..00000000 --- a/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature +++ /dev/null @@ -1,102 +0,0 @@ -@base @shared @uigeneral -Feature: Operator Tests - -Background: - - Given I create the following roles - | Role Name | - | Estate | - - Given I create the following api scopes - | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | - | transactionProcessor | Transaction Processor REST Scope | Scope for Transaction Processor REST | - | fileProcessor | File Processor REST Scope | Scope for File Processor REST | - - Given I create the following api resources - | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | merchantId,estateId,role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | merchantId,estateId,role | - | fileProcessor | File Processor REST | Secret1 | fileProcessor | merchantId,estateId,role | - - Given I create the following identity resources - | Name | DisplayName | Description | UserClaims | - | openid | Your user identifier | | sub | - | profile | User profile | Your user profile information (first name, last name, etc.) | name,role,email,given_name,middle_name,family_name,estateId,merchantId | - | email | Email | Email and Email Verified Flags | email_verified,email | - - Given I create the following clients - | ClientId | Name | Secret | Scopes | GrantTypes | RedirectUris | PostLogoutRedirectUris | RequireConsent | AllowOfflineAccess | ClientUri | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor | client_credentials | | | | | | - | estateUIClient | Merchant Client | Secret1 | estateManagement,fileProcessor,transactionProcessor,openid,email,profile | hybrid | https://localhost:[port]/signin-oidc | https://localhost:[port]/signout-oidc | false | true | https://[url]:[port] | - - Given I have a token to access the estate management resource - | ClientId | - | serviceClient | - - Given I have created the following estates - | EstateName | - | Test Estate | - - And I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate | Test Operator 1 | True | True | - | Test Estate | Test Operator 2 | True | False | - | Test Estate | Test Operator 3 | False | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate | Test Operator 1 | - | Test Estate | Test Operator 2 | - | Test Estate | Test Operator 3 | - - And I have created the following security users - | EmailAddress | Password | GivenName | FamilyName | EstateName | - | estateuser@testestate1.co.uk | 123456 | TestEstate | User1 | Test Estate | - - Given I am on the application home page - - And I click on the Sign In Button - - Then I am presented with a login screen - - When I login with the username 'estateuser@testestate1.co.uk' and password '123456' - - Then I am presented with the Estate Administrator Dashboard - -@PRTest -Scenario: Operator PR Test - - Given I click on the My Operators sidebar option - Then I am presented with the Operators List Screen - And the following operator details are in the list - | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Operator 1 | Yes | Yes | - | Test Operator 2 | Yes | No | - | Test Operator 3 | No | Yes | - When I click on the New Operator Button - Then the Add New Operator Screen is displayed - When I enter the following details for the new Operator - | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Operator 4 | Yes | Yes | - And click the Save Operator button - Then I am presented with the Operators List Screen - And the following operator details are in the list - | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Operator 1 | Yes | Yes | - | Test Operator 2 | Yes | No | - | Test Operator 3 | No | Yes | - | Test Operator 4 | Yes | Yes | - When I click on the Edit Operator Button for 'Test Operator 1' - Then the Edit Operator Screen is displayed - When I enter the following new details for the Operator - | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Operator 1 update | No | No | - And click the Save Operator button - Then I am presented with the Operators List Screen - And the following operator details are in the list - | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Operator 1 update | No | No | - | Test Operator 2 | Yes | No | - | Test Operator 3 | No | Yes | - | Test Operator 4 | Yes | Yes | \ No newline at end of file diff --git a/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs b/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs deleted file mode 100644 index 4c32cb21..00000000 --- a/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs +++ /dev/null @@ -1,465 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://reqnroll.net/). -// Reqnroll Version:3.0.0.0 -// Reqnroll Generator Version:3.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -using Reqnroll; -namespace EstateManagementUI.IntegrationTests.Tests -{ - - - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "3.0.0.0")] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::NUnit.Framework.TestFixtureAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Operator Tests")] - [global::NUnit.Framework.FixtureLifeCycleAttribute(global::NUnit.Framework.LifeCycle.InstancePerTestCase)] - [global::NUnit.Framework.CategoryAttribute("base")] - [global::NUnit.Framework.CategoryAttribute("shared")] - [global::NUnit.Framework.CategoryAttribute("uigeneral")] - public partial class OperatorTestsFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "base", - "shared", - "uigeneral"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Operator Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags, InitializeCucumberMessages()); - -#line 1 "OperatorTests.feature" -#line hidden - - [global::NUnit.Framework.OneTimeSetUpAttribute()] - public static async global::System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [global::NUnit.Framework.OneTimeTearDownAttribute()] - public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() - { - await global::Reqnroll.TestRunnerManager.ReleaseFeatureAsync(featureInfo); - } - - [global::NUnit.Framework.SetUpAttribute()] - public async global::System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - try - { - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - } - finally - { - if (((testRunner.FeatureContext != null) - && testRunner.FeatureContext.BeforeFeatureHookFailed)) - { - throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - } - - [global::NUnit.Framework.TearDownAttribute()] - public async global::System.Threading.Tasks.Task TestTearDownAsync() - { - if ((testRunner == null)) - { - return; - } - try - { - await testRunner.OnScenarioEndAsync(); - } - finally - { - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - testRunner = null; - } - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, global::Reqnroll.RuleInfo ruleInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo, ruleInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(global::NUnit.Framework.TestContext.CurrentContext); - } - - public async global::System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() - { -#line 4 -#line hidden - global::Reqnroll.Table table70 = new global::Reqnroll.Table(new string[] { - "Role Name"}); - table70.AddRow(new string[] { - "Estate"}); -#line 6 - await testRunner.GivenAsync("I create the following roles", ((string)(null)), table70, "Given "); -#line hidden - global::Reqnroll.Table table71 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description"}); - table71.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); - table71.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST Scope", - "Scope for Transaction Processor REST"}); - 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)), table71, "Given "); -#line hidden - global::Reqnroll.Table table72 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Secret", - "Scopes", - "UserClaims"}); - table72.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "merchantId,estateId,role"}); - table72.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST", - "Secret1", - "transactionProcessor", - "merchantId,estateId,role"}); - 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)), table72, "Given "); -#line hidden - global::Reqnroll.Table table73 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description", - "UserClaims"}); - table73.AddRow(new string[] { - "openid", - "Your user identifier", - "", - "sub"}); - 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"}); - 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)), table73, "Given "); -#line hidden - global::Reqnroll.Table table74 = new global::Reqnroll.Table(new string[] { - "ClientId", - "Name", - "Secret", - "Scopes", - "GrantTypes", - "RedirectUris", - "PostLogoutRedirectUris", - "RequireConsent", - "AllowOfflineAccess", - "ClientUri"}); - table74.AddRow(new string[] { - "serviceClient", - "Service Client", - "Secret1", - "estateManagement,transactionProcessor", - "client_credentials", - "", - "", - "", - "", - ""}); - table74.AddRow(new string[] { - "estateUIClient", - "Merchant Client", - "Secret1", - "estateManagement,fileProcessor,transactionProcessor,openid,email,profile", - "hybrid", - "https://localhost:[port]/signin-oidc", - "https://localhost:[port]/signout-oidc", - "false", - "true", - "https://[url]:[port]"}); -#line 28 - await testRunner.GivenAsync("I create the following clients", ((string)(null)), table74, "Given "); -#line hidden - global::Reqnroll.Table table75 = new global::Reqnroll.Table(new string[] { - "ClientId"}); - table75.AddRow(new string[] { - "serviceClient"}); -#line 33 - await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table75, "Given "); -#line hidden - global::Reqnroll.Table table76 = new global::Reqnroll.Table(new string[] { - "EstateName"}); - table76.AddRow(new string[] { - "Test Estate"}); -#line 37 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table76, "Given "); -#line hidden - global::Reqnroll.Table table77 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table77.AddRow(new string[] { - "Test Estate", - "Test Operator 1", - "True", - "True"}); - table77.AddRow(new string[] { - "Test Estate", - "Test Operator 2", - "True", - "False"}); - table77.AddRow(new string[] { - "Test Estate", - "Test Operator 3", - "False", - "True"}); -#line 41 - await testRunner.AndAsync("I have created the following operators", ((string)(null)), table77, "And "); -#line hidden - global::Reqnroll.Table table78 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table78.AddRow(new string[] { - "Test Estate", - "Test Operator 1"}); - table78.AddRow(new string[] { - "Test Estate", - "Test Operator 2"}); - 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)), table78, "And "); -#line hidden - global::Reqnroll.Table table79 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "EstateName"}); - 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)), table79, "And "); -#line hidden -#line 57 - await testRunner.GivenAsync("I am on the application home page", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 59 - await testRunner.AndAsync("I click on the Sign In Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 61 - await testRunner.ThenAsync("I am presented with a login screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 63 - 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 65 - await testRunner.ThenAsync("I am presented with the Estate Administrator Dashboard", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - - private static global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages InitializeCucumberMessages() - { - return new global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages("Tests/OperatorTests.feature.ndjson", 3); - } - - [global::NUnit.Framework.TestAttribute()] - [global::NUnit.Framework.DescriptionAttribute("Operator PR Test")] - [global::NUnit.Framework.CategoryAttribute("PRTest")] - public async global::System.Threading.Tasks.Task OperatorPRTest() - { - string[] tagsOfScenario = new string[] { - "PRTest"}; - global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - string pickleIndex = "0"; - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Operator PR Test", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); - string[] tagsOfRule = ((string[])(null)); - global::Reqnroll.RuleInfo ruleInfo = null; -#line 68 -this.ScenarioInitialize(scenarioInfo, ruleInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - await testRunner.SkipScenarioAsync(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 70 - await testRunner.GivenAsync("I click on the My Operators sidebar option", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#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 table80 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table80.AddRow(new string[] { - "Test Operator 1", - "Yes", - "Yes"}); - table80.AddRow(new string[] { - "Test Operator 2", - "Yes", - "No"}); - table80.AddRow(new string[] { - "Test Operator 3", - "No", - "Yes"}); -#line 72 - 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 "); -#line hidden -#line 78 - await testRunner.ThenAsync("the Add New Operator Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table81 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - 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)), table81, "When "); -#line hidden -#line 82 - await testRunner.AndAsync("click the Save Operator button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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 table82 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table82.AddRow(new string[] { - "Test Operator 1", - "Yes", - "Yes"}); - table82.AddRow(new string[] { - "Test Operator 2", - "Yes", - "No"}); - table82.AddRow(new string[] { - "Test Operator 3", - "No", - "Yes"}); - table82.AddRow(new string[] { - "Test Operator 4", - "Yes", - "Yes"}); -#line 84 - 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 "); -#line hidden -#line 91 - await testRunner.ThenAsync("the Edit Operator Screen is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table83 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - 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)), table83, "When "); -#line hidden -#line 95 - await testRunner.AndAsync("click the Save Operator button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#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 table84 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table84.AddRow(new string[] { - "Test Operator 1 update", - "No", - "No"}); - table84.AddRow(new string[] { - "Test Operator 2", - "Yes", - "No"}); - table84.AddRow(new string[] { - "Test Operator 3", - "No", - "Yes"}); - table84.AddRow(new string[] { - "Test Operator 4", - "Yes", - "Yes"}); -#line 97 - await testRunner.AndAsync("the following operator details are in the list", ((string)(null)), table84, "And "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/EstateManagementUI.IntegrationTests/nlog.config b/EstateManagementUI.IntegrationTests/nlog.config deleted file mode 100644 index b2c330e9..00000000 --- a/EstateManagementUI.IntegrationTests/nlog.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/EstateManagementUI.Testing/EstateManagementUI.Testing.csproj b/EstateManagementUI.Testing/EstateManagementUI.Testing.csproj deleted file mode 100644 index 12daa613..00000000 --- a/EstateManagementUI.Testing/EstateManagementUI.Testing.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - - net10.0 - enable - enable - None - false - true - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - diff --git a/EstateManagementUI.Testing/TestData.cs b/EstateManagementUI.Testing/TestData.cs deleted file mode 100644 index c2dd2147..00000000 --- a/EstateManagementUI.Testing/TestData.cs +++ /dev/null @@ -1,1419 +0,0 @@ -using Azure.Core; -using EstateManagementUI.BusinessLogic.Models; -using EstateManagementUI.ViewModels; -using EstateManagmentUI.BusinessLogic.Requests; -using EstateReportingAPI.DataTransferObjects; -using EstateReportingAPI.DataTrasferObjects; -using FileProcessor.DataTransferObjects.Responses; -using Microsoft.AspNetCore.Mvc.Rendering; -using SimpleResults; -using TransactionProcessor.DataTransferObjects.Responses.Contract; -using TransactionProcessor.DataTransferObjects.Responses.Estate; -using TransactionProcessor.DataTransferObjects.Responses.Merchant; -using TransactionProcessor.DataTransferObjects.Responses.Operator; -using FileImportLogList = FileProcessor.DataTransferObjects.Responses.FileImportLogList; -using FileLine = FileProcessor.DataTransferObjects.Responses.FileLine; -using FileLineProcessingResult = FileProcessor.DataTransferObjects.Responses.FileLineProcessingResult; -using LastSettlement = EstateReportingAPI.DataTransferObjects.LastSettlement; -using MerchantKpi = EstateReportingAPI.DataTransferObjects.MerchantKpi; -using SettlementSchedule = EstateManagementUI.BusinessLogic.Models.SettlementSchedule; -using TodaysSales = EstateReportingAPI.DataTransferObjects.TodaysSales; -using TodaysSalesCountByHour = EstateReportingAPI.DataTransferObjects.TodaysSalesCountByHour; -using TodaysSalesCountByHourModel = EstateManagementUI.BusinessLogic.Models.TodaysSalesCountByHourModel; -using TodaysSalesValueByHour = EstateReportingAPI.DataTransferObjects.TodaysSalesValueByHour; -using TodaysSalesValueByHourModel = EstateManagementUI.BusinessLogic.Models.TodaysSalesValueByHourModel; -using TodaysSettlement = EstateReportingAPI.DataTransferObjects.TodaysSettlement; - -namespace EstateManagementUI.Testing -{ - public static class TestData { - public static IReadOnlyDictionary DefaultAppSettings => - new Dictionary - { - ["AppSettings:ClientId"] = "clientId", - ["AppSettings:ClientSecret"] = "clientSecret", - ["AppSettings:BackEndClientId"] = "clientId", - ["AppSettings:BackEndClientSecret"] = "clientSecret", - ["AppSettings:UseConnectionStringConfig"] = "false", - ["EventStoreSettings:ConnectionString"] = "esdb://127.0.0.1:2113", - ["SecurityConfiguration:Authority"] = "https://127.0.0.1", - ["AppSettings:EstateManagementApi"] = "http://127.0.0.1", - ["AppSettings:SecurityService"] = "http://127.0.0.1", - ["AppSettings:ContractProductFeeCacheExpiryInHours"] = "", - ["AppSettings:ContractProductFeeCacheEnabled"] = "", - ["ConnectionStrings:HealthCheck"] = "HealthCheck", - ["ConnectionStrings:EstateReportingReadModel"] = "", - ["ConnectionStrings:TransactionProcessorReadModel"] = "" - }; - public static DateTime ComparisonDate = new DateTime(2024,1,1); - public static String AccessToken = "token1"; - public static CorrelationId CorrelationId = CorrelationIdHelper.New(); - public static Guid EstateId = Guid.Parse("BD6F1ED7-6290-4285-A200-E4F8D25F4CBE"); - public static Queries.GetEstateQuery GetEstateQuery => new(CorrelationIdHelper.New(), AccessToken, EstateId); - public static Queries.GetMerchantsQuery GetMerchantsQuery => new(CorrelationId,AccessToken, EstateId); - - public static Queries.GetMerchantQuery GetMerchantQuery => new(CorrelationId, AccessToken, EstateId, Merchant1Id); - public static Queries.GetOperatorsQuery GetOperatorsQuery => new(CorrelationId, AccessToken, EstateId); - public static Queries.GetOperatorQuery GetOperatorQuery => new(CorrelationId, AccessToken, EstateId, Operator1Id); - public static Queries.GetContractsQuery GetContractsQuery => new(CorrelationId, AccessToken, EstateId); - public static Queries.GetContractQuery GetContractQuery => new(CorrelationId, AccessToken, EstateId, Contract1Id); - - public static Queries.GetFileImportLogsListQuery GetFileImportLogsListQuery => - new Queries.GetFileImportLogsListQuery(CorrelationId, AccessToken, EstateId, Merchant1Id, FileImportLogQueryStartDate, - FileImportLogQueryEndDate); - - public static Queries.GetFileImportLogQuery GetFileImportLogQuery => - new Queries.GetFileImportLogQuery(CorrelationId, AccessToken, EstateId, Merchant1Id, FileImportLogId); - - public static Queries.GetFileDetailsQuery GetFileDetailsQuery => - new(CorrelationId, AccessToken, EstateId, FileImportLogFile1.FileId); - - public static Queries.GetComparisonDatesQuery GetComparisonDatesQuery => new(CorrelationId, AccessToken, EstateId); - public static Queries.GetTodaysSalesQuery GetTodaysSalesQuery => new(CorrelationId, AccessToken, EstateId, DateTime.Now); - public static Queries.GetTodaysSettlementQuery GetTodaysSettlementQuery => new(CorrelationId, AccessToken, EstateId, DateTime.Now); - public static Queries.GetTodaysSalesCountByHourQuery GetTodaysSalesCountByHourQuery => new(CorrelationId, AccessToken, EstateId, DateTime.Now); - public static Queries.GetTodaysSalesValueByHourQuery GetTodaysSalesValueByHourQuery => new(CorrelationId, AccessToken, EstateId, DateTime.Now); - - public static Queries.GetMerchantKpiQuery GetMerchantKpiQuery => new (CorrelationId, AccessToken, EstateId); - - public static Queries.GetTodaysFailedSalesQuery GetTodaysFailedSalesQuery => - new(CorrelationId, AccessToken, EstateId, "1009", DateTime.Now); - - public static Queries.GetTopProductDataQuery GetTopProductDataQuery => - new Queries.GetTopProductDataQuery(CorrelationId, AccessToken, EstateId, 1); - - public static Queries.GetBottomProductDataQuery GetBottomProductDataQuery => new(CorrelationId, AccessToken, EstateId, 1); - public static Queries.GetTopMerchantDataQuery GetTopMerchantDataQuery => new(CorrelationId, AccessToken, EstateId, 1); - public static Queries.GetBottomMerchantDataQuery GetBottomMerchantDataQuery => new(CorrelationId, AccessToken, EstateId, 1); - public static Queries.GetTopOperatorDataQuery GetTopOperatorDataQuery => new(CorrelationId, AccessToken, EstateId, 1); - public static Queries.GetBottomOperatorDataQuery GetBottomOperatorDataQuery => new(CorrelationId, AccessToken, EstateId, 1); - - public static Queries.GetLastSettlementQuery GetLastSettlementQuery => new(CorrelationId, AccessToken, EstateId); - - public static Queries.GetProductPerformanceQuery GetProductPerformanceQuery => new(CorrelationId, AccessToken, EstateId, DateTime.Now.AddDays(-30), DateTime.Now); - - public static Commands.AddMerchantCommand AddNewMerchantCommand => new(CorrelationId, AccessToken, EstateId, CreateMerchantModel(BusinessLogic.Models.SettlementSchedule.Immediate)); - - public static Commands.UpdateMerchantCommand UpdateMerchantCommand => new(CorrelationId, AccessToken, EstateId, Merchant1Id, new UpdateMerchantModel { - MerchantName = Merchant1Name, - SettlementSchedule = EstateManagementUI.BusinessLogic.Models.SettlementSchedule.Immediate - }); - - public static Commands.UpdateMerchantAddressCommand UpdateMerchantAddressCommand => new(CorrelationId, AccessToken, EstateId, Merchant1Id, new AddressModel - { - AddressLine1 = Merchant1AddressLine1, - AddressLine2 = Merchant1AddressLine2, - AddressLine3 = Merchant1AddressLine3, - AddressLine4 = Merchant1AddressLine4, - Country = Merchant1Country, - PostalCode = Merchant1PostalCode, - Region = Merchant1Region, - Town = Merchant1Town - }); - - public static Commands.UpdateMerchantContactCommand UpdateMerchantContactCommand => new(CorrelationId, AccessToken, EstateId, Merchant1Id, new ContactModel - { - ContactName = Merchant1ContactName, - ContactPhoneNumber = Merchant1ContactPhoneNumber, - ContactEmailAddress = Merchant1ContactEmailAddress - }); - - public static Commands.AssignContractToMerchantCommand AssignContractToMerchantCommand => new(CorrelationId, AccessToken, EstateId, Merchant1Id, new AssignContractToMerchantModel { - ContractId = Contract1Id - }); - - public static Commands.RemoveContractFromMerchantCommand RemoveContractFromMerchantCommand => new(CorrelationId, AccessToken, EstateId, Merchant1Id, Contract1Id); - - public static Commands.AssignDeviceToMerchantCommand AssignDeviceToMerchantCommand => new(CorrelationId, AccessToken, EstateId, Merchant1Id, AssignDeviceToMerchantModel); - - public static AssignOperatorToMerchantModel AssignOperatorToMerchantModel => new AssignOperatorToMerchantModel { OperatorId = Operator1Id }; - public static AssignOperatorToEstateModel AssignOperatorToEstateModel => new AssignOperatorToEstateModel { 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(CorrelationId, AccessToken, EstateId, Merchant1Id, new AssignOperatorToMerchantModel { - OperatorId = Operator1Id - }); - - public static Commands.RemoveOperatorFromMerchantCommand RemoveOperatorFromMerchantCommand => new(CorrelationId, AccessToken, EstateId, Merchant1Id, Operator1Id); - - public static Commands.AssignOperatorToEstateCommand AssignOperatorToEstateCommand => new(CorrelationId, AccessToken, EstateId, new AssignOperatorToEstateModel { - OperatorId = Operator1Id - }); - - public static Commands.RemoveOperatorFromEstateCommand RemoveOperatorFromEstateCommand => new(CorrelationId, AccessToken, EstateId, Operator1Id); - - public static Commands.CreateContractCommand CreateContractCommand => new(CorrelationId, AccessToken, EstateId, CreateContractModel); - public static Commands.CreateContractProductCommand CreateContractProductCommand => new(CorrelationId, AccessToken, EstateId, Contract1Id, CreateContractProductModel); - - public static Commands.CreateContractProductTransactionFeeCommand CreateContractProductTransactionFeeCommand => new(CorrelationId, AccessToken, EstateId, Contract1Id, Contract1Product1Id, CreateContractProductTransactionFeeModel); - - public static Commands.MakeDepositCommand MakeDepositCommand => new(CorrelationId, 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 - { - MerchantName = Merchant1Name, - SettlementSchedule = settlementSchedule, - Contact = new ContactModel - { - ContactName = TestData.Merchant1ContactName, - ContactPhoneNumber = TestData.Merchant1ContactPhoneNumber, - ContactEmailAddress = TestData.Merchant1ContactEmailAddress - }, - Address = new AddressModel - { - AddressLine4 = TestData.Merchant1AddressLine4, - AddressLine1 = TestData.Merchant1AddressLine1, - AddressLine2 = TestData.Merchant1AddressLine2, - AddressLine3 = TestData.Merchant1AddressLine3, - Country = TestData.Merchant1Country, - PostalCode = TestData.Merchant1PostalCode, - Region = TestData.Merchant1Region, - Town = TestData.Merchant1Town - } - }; - - public static UpdateMerchantModel UpdateMerchantModel(BusinessLogic.Models.SettlementSchedule settlementSchedule) => - new UpdateMerchantModel - { - MerchantName = Merchant1Name, - SettlementSchedule = settlementSchedule - }; - - public static AddressModel AddressModel => - new AddressModel - { - AddressLine1 = Merchant1AddressLine1, - AddressLine2 = Merchant1AddressLine2, - AddressLine3 = Merchant1AddressLine3, - AddressLine4 = Merchant1AddressLine4, - Country = Merchant1Country, - PostalCode = Merchant1PostalCode, - Region = Merchant1Region, - Town = Merchant1Town - }; - - public static ContactModel ContactModel => new ContactModel { ContactEmailAddress = Merchant1ContactEmailAddress, ContactName = Merchant1ContactName, ContactPhoneNumber = Merchant1ContactPhoneNumber }; - - public static Commands.AddNewOperatorCommand AddNewOperatorCommand => - new(CorrelationId, AccessToken, EstateId, Operator1Id, Operator1Name, RequireCustomMerchantNumber, - RequireCustomTerminalNumber); - - public static Commands.UpdateOperatorCommand UpdateOperatorCommand => - new(CorrelationId, AccessToken, EstateId, Operator1Id, Operator1Name, RequireCustomMerchantNumber, - RequireCustomTerminalNumber); - - public static String EstateName = "Test Estate 1"; - - public static String Operator1Name = "Operator 1"; - public static Guid Operator1Id = Guid.Parse("DECA8293-F045-41C5-A2F7-30F2792FD273"); - public static String Operator2Name = "Operator 2"; - public static Guid Operator2Id = Guid.Parse("4412915E-02C5-442B-981C-1710F8770FBC"); - - public static Boolean RequireCustomMerchantNumber = true; - - public static Boolean RequireCustomTerminalNumber = true; - - public static String EmailAddress = "estateuser1@testestate1.co.uk"; - - public static Guid SecurityUserId = Guid.Parse("6A3C1B74-F01E-4017-85D5-6E6082038AB8"); - - public static String Merchant1Reference = "Reference1"; - public static String Merchant1Name = "Test Merchant 1"; - public static Guid Merchant1Id = Guid.Parse("2F8431D9-8D04-4AE5-B66C-DB40DFADE581"); - public static TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule Merchant1SettlementSchedule = TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Immediate; - - public static String Merchant1AddressLine1 = "Address Line 1"; - - public static String Merchant1AddressLine2 = "Address Line 2"; - - public static String Merchant1AddressLine3 = "Address Line 3"; - - public static String Merchant1AddressLine4 = "Address Line 4"; - - public static String Merchant1ContactEmailAddress = "testcontact@merchant1.co.uk"; - - public static String Merchant1ContactName = "Mr Test Contact"; - - public static String Merchant1ContactPhoneNumber = "1234567890"; - - public static String Merchant1Country = "United Kingdom"; - - public static String Merchant1PostalCode = "TE571NG"; - - public static String Merchant1Region = "Test Region"; - - public static String Merchant1Town = "Test Town"; - - public static AddressResponse Merchant1Address = new() { - AddressLine1 = Merchant1AddressLine1, Town = Merchant1Town - }; - - public static Dictionary Merchant1Devices = new Dictionary { - { Guid.Parse("A5B6A7FD-1D45-4781-A9CC-0A09C206737E"), "Device 1" } - }; - - public static MerchantContractResponse Merchant1Contract = new() - { - ContractId = Contract1Id - }; - - public static MerchantOperatorResponse Merchant1Operator = new() - { - OperatorId = Operator1Id - }; - - public static ContactResponse Merchant1Contact = new() { ContactName = "Contact 1" }; - - public static String Merchant2Reference = "Reference2"; - public static String Merchant2Name = "Test Merchant 2"; - public static Guid Merchant2Id = Guid.Parse("8959608C-2448-48EA-AFB4-9D10FFFB6140"); - public static TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule Merchant2SettlementSchedule = TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Weekly; - - public static AddressResponse - Merchant2Address = new() { AddressLine1 = "Address Line 2", Town = "Test Town 2" }; - - public static ContactResponse Merchant2Contact = new() { ContactName = "Contact 2" }; - - public static String Merchant3Reference = "Reference3"; - public static String Merchant3Name = "Test Merchant 3"; - public static Guid Merchant3Id = Guid.Parse("877D7384-9A72-4A73-A275-9DB62BF32EDB"); - public static TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule Merchant3SettlementSchedule = TransactionProcessor.DataTransferObjects.Responses.Merchant.SettlementSchedule.Monthly; - - public static AddressResponse - Merchant3Address = new() { AddressLine1 = "Address Line 3", Town = "Test Town 3" }; - - public static DateTime FileImportLogQueryStartDate = DateTime.Now.AddDays(-1); - public static DateTime FileImportLogQueryEndDate = DateTime.Now; - - public static ContactResponse Merchant3Contact = new() { ContactName = "Contact 3" }; - - public static EstateResponse EstateResponse => - new EstateResponse { - EstateName = TestData.EstateName, - Operators = new List { - new EstateOperatorResponse { - OperatorId = Operator1Id, - Name = Operator1Name, - RequireCustomMerchantNumber = TestData.RequireCustomMerchantNumber, - RequireCustomTerminalNumber = TestData.RequireCustomTerminalNumber - } - }, - EstateId = TestData.EstateId, - SecurityUsers = new List { - new SecurityUserResponse { - EmailAddress = TestData.EmailAddress, SecurityUserId = TestData.SecurityUserId - } - } - }; - - - public static OperatorResponse OperatorResponse => - new OperatorResponse { - Name = Operator1Name, - OperatorId = Operator1Id, - RequireCustomMerchantNumber = false, - RequireCustomTerminalNumber = false - }; - - public static List OperatorResponses => - new List { - new OperatorResponse { - Name = Operator1Name, - OperatorId = Operator1Id, - RequireCustomMerchantNumber = false, - RequireCustomTerminalNumber = false - }, - new OperatorResponse { - Name = Operator2Name, - OperatorId = Operator2Id, - RequireCustomMerchantNumber = false, - RequireCustomTerminalNumber = false - } - }; - - public static List MerchantResponses => - new List { - new MerchantResponse { - SettlementSchedule = Merchant1SettlementSchedule, - MerchantReference = Merchant1Reference, - MerchantName = Merchant1Name, - MerchantId = Merchant1Id, - Addresses = [Merchant1Address], - Contacts = [Merchant1Contact] - }, - new MerchantResponse { - SettlementSchedule = Merchant2SettlementSchedule, - MerchantReference = Merchant2Reference, - MerchantName = Merchant2Name, - MerchantId = Merchant2Id, - Addresses = [Merchant2Address], - Contacts = [Merchant2Contact] - }, - new MerchantResponse { - SettlementSchedule = Merchant3SettlementSchedule, - MerchantReference = Merchant3Reference, - MerchantName = Merchant3Name, - MerchantId = Merchant3Id, - Addresses = [Merchant3Address], - Contacts = [Merchant3Contact] - } - }; - - public static MerchantResponse MerchantResponse => - new MerchantResponse { - SettlementSchedule = Merchant1SettlementSchedule, - MerchantReference = Merchant1Reference, - MerchantName = Merchant1Name, - MerchantId = Merchant1Id, - Addresses = [Merchant1Address], - Contacts = [Merchant1Contact], - Devices = Merchant1Devices, - Contracts = [Merchant1Contract], - Operators = [Merchant1Operator] - }; - - public static Guid Contract1Id = Guid.Parse("82ED1302-491D-48F4-8FC7-58A22EB1CF4C"); - public static String Contract1Description = "Test Contract 1"; - - public static String Contract1Product1Name = "Contract 1 Product 1"; - public static String Contract1Product1DisplayText = "Contract 1 Prod 1"; - public static Guid Contract1Product1Id = Guid.Parse("49E996AC-7068-42E5-950F-5E73E8909730"); - public static ProductType Contract1Product1ProductType = ProductType.MobileTopup; - public static Decimal? Contract1Product1Value = 100.00m; - - public static String Contract1Product2Name = "Contract 1 Product 2"; - public static String Contract1Product2DisplayText = "Contract 1 Prod 2"; - public static Guid Contract1Product2Id = Guid.Parse("71159369-A719-46E3-9D86-E681307EEFAF"); - public static ProductType Contract1Product2ProductType = ProductType.MobileTopup; - public static Decimal? Contract1Product2Value = 200.00m; - - public static String Contract1Product3Name = "Contract 1 Product 3"; - public static String Contract1Product3DisplayText = "Contract 1 Prod 3"; - public static Guid Contract1Product3Id = Guid.Parse("29A7B01D-825C-4CD2-A6CE-F18D1DE9087B"); - public static ProductType Contract1Product3ProductType = ProductType.MobileTopup; - public static Decimal? Contract1Product3Value = null; - - public static Guid Contract2Id = Guid.Parse("A3A9ED76-EB64-464D-A958-95A496FD63D5"); - public static String Contract2Description = "Test Contract 2"; - - public static Guid Contract3Id = Guid.Parse("9070D695-30F1-4554-B595-28019E3237C4"); - public static String Contract3Description = "Test Contract 3"; - - public static Decimal TransactionFee1Value = 0.5m; - public static String TransactionFee1Description = "Merchant Commission"; - public static FeeType TransactionFee1Type = FeeType.Merchant; - public static CalculationType TransactionFee1CalculationType = CalculationType.Fixed; - public static Guid TransactionFee1Id = Guid.Parse("61D0AF6D-1303-459F-87E2-4B686BB0585E"); - - public static TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProductTransactionFee ContractProductTransactionFee1 => - new TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProductTransactionFee { - Value = TransactionFee1Value, - Description = TransactionFee1Description, - FeeType = TransactionFee1Type, - CalculationType = TransactionFee1CalculationType, - TransactionFeeId = TransactionFee1Id, - }; - - public static TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProduct ContractProduct1 => - new TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProduct { - Name = Contract1Product1Name, - DisplayText = Contract1Product1DisplayText, - ProductId = Contract1Product1Id, - ProductType = Contract1Product1ProductType, - Value = Contract1Product1Value, - TransactionFees = new List { - ContractProductTransactionFee1 - } - }; - - public static TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProduct ContractProduct2 => - new TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProduct - { - Name = Contract1Product2Name, - DisplayText = Contract1Product2DisplayText, - ProductId = Contract1Product2Id, - ProductType = Contract1Product2ProductType, - Value = Contract1Product2Value - }; - - public static TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProduct ContractProduct3 => - new TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProduct - { - Name = Contract1Product3Name, - DisplayText = Contract1Product3DisplayText, - ProductId = Contract1Product3Id, - ProductType = Contract1Product3ProductType, - Value = Contract1Product3Value - }; - - - public static ContractResponse ContractResponse1 => - new ContractResponse { - OperatorId = Operator1Id, - OperatorName = Operator1Name, - ContractId = Contract1Id, - Description = Contract1Description, - Products = new List { ContractProduct1, ContractProduct2, ContractProduct3 } - }; - - public static List ContractResponses => - new List() { - ContractResponse1 - }; - - public static ContractResponse ContractResponseNullProducts => - new ContractResponse { - OperatorId = Operator2Id, - OperatorName = Operator2Name, - ContractId = Contract2Id, - Description = Contract2Description, - Products = null - }; - - public static ContractResponse ContractResponseEmptyProducts => - new ContractResponse { - OperatorId = Operator2Id, - OperatorName = Operator2Name, - ContractId = Contract2Id, - Description = Contract2Description, - Products = null - }; - - public static FileImportLogList FileImportLogList => - new FileImportLogList() { FileImportLogs = new List { FileImportLog1 } }; - - public static DateTime ImportLogDateTime = DateTime.Now; - public static Guid FileImportLogId = Guid.Parse("6D747595-C718-4CB0-B7BA-8FB470E5DB0E"); - public static Guid FileProfileId1 = Guid.Parse("55036A79-DFAA-471D-8EB0-4E3DFBF9685B"); - public static String FileProfileName1 = "File Profile 1"; - - public static FileImportLogFile FileImportLogFile1 = new FileImportLogFile { - FileImportLogId = FileImportLogId, - MerchantId = Merchant1Id, - FileId = Guid.Parse("90152CBE-1598-41BF-B0A0-B7A9A99DF9E4"), - FilePath = @"C:\Temp\File1.txt", - FileProfileId = FileProfileId1, - FileUploadedDateTime = DateTime.Now, - OriginalFileName = "originalFile1", - UserId = SecurityUserId - }; - - public static FileImportLogFile FileImportLogFile2 = new FileImportLogFile - { - FileImportLogId = FileImportLogId, - MerchantId = Merchant1Id, - FileId = Guid.Parse("31873942-4E19-4F53-A3EE-9EA19ECB4649"), - FilePath = @"C:\Temp\File2.txt", - FileProfileId = FileProfileId1, - FileUploadedDateTime = DateTime.Now, - OriginalFileName = "originalFile2", - UserId = SecurityUserId - }; - - public static FileImportLog FileImportLog1 => - new FileImportLog { - ImportLogDate = ImportLogDateTime.Date, - ImportLogDateTime = ImportLogDateTime, - FileCount = 0, - FileImportLogId = FileImportLogId, - Files = new List() { - FileImportLogFile1, - FileImportLogFile2 - }, - ImportLogTime = ImportLogDateTime.TimeOfDay - }; - - public static Guid FileId1 = Guid.Parse("90BEB4AA-2162-435E-816B-BEA12BAE0E30"); - public static String FileLocation1 = "C:\\Temp\\File1.txt"; - - public static FileDetails FileDetails1 => - new FileDetails { - EstateId = EstateId, - FileId = FileId1, - FileImportLogId = FileImportLogId, - FileLocation = FileLocation1, - FileProfileId = FileProfileId1, - FileProfileName = FileProfileName1, - MerchantId = Merchant1Id, - MerchantName = Merchant1Name, - ProcessingCompleted = true, - UserEmailAddress = EmailAddress, - UserId = SecurityUserId, - ProcessingSummary = - new FileProcessingSummary { - FailedLines = 1, - IgnoredLines = 2, - NotProcessedLines = 4, // Includes Unknown - RejectedLines = 4, - SuccessfullyProcessedLines = 5, - TotalLines = 16 - }, - FileLines = new List { - new FileLine { - LineNumber = 1, - ProcessingResult = FileLineProcessingResult.Failed, - RejectionReason = "Rejected", - TransactionId = Guid.Empty, - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 2, - ProcessingResult = FileLineProcessingResult.Ignored, - RejectionReason = "", - TransactionId = Guid.Empty, - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 3, - ProcessingResult = FileLineProcessingResult.Ignored, - RejectionReason = "", - TransactionId = Guid.Empty, - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 4, - ProcessingResult = FileLineProcessingResult.NotProcessed, - RejectionReason = "", - TransactionId = Guid.Empty, - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 5, - ProcessingResult = FileLineProcessingResult.NotProcessed, - RejectionReason = "", - TransactionId = Guid.Empty, - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 6, - ProcessingResult = FileLineProcessingResult.NotProcessed, - RejectionReason = "", - TransactionId = Guid.Empty, - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 7, - ProcessingResult = FileLineProcessingResult.Rejected, - RejectionReason = "", - TransactionId = Guid.Empty, - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 8, - ProcessingResult = FileLineProcessingResult.Rejected, - RejectionReason = "", - TransactionId = Guid.Empty, - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 9, - ProcessingResult = FileLineProcessingResult.Rejected, - RejectionReason = "", - TransactionId = Guid.Empty, - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 10, - ProcessingResult = FileLineProcessingResult.Rejected, - RejectionReason = "", - TransactionId = Guid.Empty, - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 11, - ProcessingResult = FileLineProcessingResult.Successful, - RejectionReason = "", - TransactionId = Guid.NewGuid(), - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 12, - ProcessingResult = FileLineProcessingResult.Successful, - RejectionReason = "", - TransactionId = Guid.NewGuid(), - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 13, - ProcessingResult = FileLineProcessingResult.Successful, - RejectionReason = "", - TransactionId = Guid.NewGuid(), - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 14, - ProcessingResult = FileLineProcessingResult.Successful, - RejectionReason = "", - TransactionId = Guid.NewGuid(), - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 15, - ProcessingResult = FileLineProcessingResult.Successful, - RejectionReason = "", - TransactionId = Guid.NewGuid(), - LineData = "1,2,3" - }, - new FileLine { - LineNumber = 16, - ProcessingResult = FileLineProcessingResult.Unknown, - RejectionReason = "", - TransactionId = Guid.NewGuid(), - LineData = "1,2,3" - }, - } - }; - - public static TodaysSettlement TodaysSettlement => new TodaysSettlement - { - ComparisonSettlementCount = 100, - ComparisonSettlementValue = 1000, - TodaysSettlementCount = 50, - TodaysSettlementValue = 500 - }; - - public static TodaysSales TodaysSales => new TodaysSales - { - ComparisonSalesCount = 100, - ComparisonSalesValue = 1000, - TodaysSalesCount = 50, - TodaysSalesValue = 500 - }; - - public static List ComparisonDates => new List { - new ComparisonDate { - Date = new DateTime(2024, 1, 1), Description = new DateTime(2024, 1, 1).ToString(), OrderValue = 0 - }, - new ComparisonDate { - Date = new DateTime(2024, 1, 2), Description = new DateTime(2024, 1, 2).ToString(), OrderValue = 0 - } - }; - - public static List TodaysSalesCountByHour => new List { - new TodaysSalesCountByHour { TodaysSalesCount = 100, ComparisonSalesCount = 85, Hour = 0 }, - new TodaysSalesCountByHour { TodaysSalesCount = 90, ComparisonSalesCount = 87, Hour = 1 } - }; - - public static List TodaysSalesValueByHour => new List { - new TodaysSalesValueByHour { TodaysSalesValue = 100, ComparisonSalesValue = 85, Hour = 0 }, - new TodaysSalesValueByHour { TodaysSalesValue = 90, ComparisonSalesValue = 87, Hour = 1 } - }; - - public static List TopBottomProductDataList => new List{ - new TopBottomProductData(){ - ProductName = "Product 1", - SalesValue = 100 - }, - new TopBottomProductData(){ - ProductName = "Product 2", - SalesValue = 200 - } - }; - - public static List TopBottomMerchantDataList => new List{ - new TopBottomMerchantData(){ - MerchantName = "Merchant 1", - SalesValue = 100 - }, - new TopBottomMerchantData(){ - MerchantName = "Merchant 2", - SalesValue = 200 - } - }; - - public static List TopBottomOperatorDataList => new List{ - new TopBottomOperatorData(){ - OperatorName = "Operator 1", - SalesValue = 100 - }, - new TopBottomOperatorData(){ - OperatorName = "Operator 2", - SalesValue = 200 - } - }; - - public static MerchantKpi MerchantKpi => new MerchantKpi() - { - MerchantsWithNoSaleInLast7Days = 1, - MerchantsWithNoSaleToday = 2, - MerchantsWithSaleInLastHour = 3 - }; - - public static LastSettlement LastSettlement => - new LastSettlement - { - SettlementDate = new DateTime(2024, 1, 1), - FeesValue = 100.00m, - SalesCount = 100, - SalesValue = 1000.00m - }; - - public static FileDetails FileDetails => new FileDetails - { - FileId = Guid.NewGuid(), - FileProfileId = Guid.NewGuid(), - FileProfileName = "Test Profile", - FileImportLogId = Guid.NewGuid(), - FileLocation = "Test Location", - ProcessingCompleted = true, - EstateId = Guid.NewGuid(), - UserId = Guid.NewGuid(), - UserEmailAddress = "test@example.com", - MerchantId = Guid.NewGuid(), - MerchantName = "Test Merchant", - ProcessingSummary = new FileProcessingSummary - { - FailedLines = 1, - IgnoredLines = 2, - NotProcessedLines = 3, - RejectedLines = 4, - SuccessfullyProcessedLines = 5, - TotalLines = 15 - }, - FileLines = new List - { - new FileLine - { - LineData = "Line 1 Data", - LineNumber = 1, - RejectionReason = "Reason 1", - TransactionId = Guid.NewGuid(), - ProcessingResult = FileLineProcessingResult.Successful - }, - new FileLine - { - LineData = "Line 2 Data", - LineNumber = 2, - RejectionReason = "Reason 2", - TransactionId = Guid.NewGuid(), - ProcessingResult = FileLineProcessingResult.Failed - }, - new FileLine - { - LineData = "Line 3 Data", - LineNumber = 3, - RejectionReason = "Reason 3", - TransactionId = Guid.NewGuid(), - ProcessingResult = FileLineProcessingResult.Ignored - }, - new FileLine - { - LineData = "Line 4 Data", - LineNumber = 4, - RejectionReason = "Reason 4", - TransactionId = Guid.NewGuid(), - ProcessingResult = FileLineProcessingResult.NotProcessed - }, - new FileLine - { - LineData = "Line 5 Data", - LineNumber = 5, - RejectionReason = "Reason 5", - TransactionId = Guid.NewGuid(), - ProcessingResult = FileLineProcessingResult.Rejected - }, - new FileLine - { - LineData = "Line 6 Data", - LineNumber = 6, - RejectionReason = "Reason 6", - TransactionId = Guid.NewGuid(), - ProcessingResult = FileLineProcessingResult.Unknown - } - } - }; - - public static List ComparisonDates1 => new List - { - new ComparisonDateModel { Date = DateTime.Parse("2023-01-01"), Description = "2023-01-01", OrderValue = 1 } - }; - - public static TodaysSalesModel TodaysSales1 => new TodaysSalesModel - { - TodaysSalesValue = 100, - ComparisonSalesValue = 80 - }; - - public static MerchantKpiModel MerchantKpi1 => new MerchantKpiModel - { - MerchantsWithNoSaleInLast7Days = 5, - MerchantsWithNoSaleToday = 3, - MerchantsWithSaleInLastHour = 2 - }; - - public static List BottomMerchants1 => new List - { - new TopBottomMerchantDataModel { MerchantName = "Merchant1", SalesValue = 50 }, - new TopBottomMerchantDataModel { MerchantName = "Merchant2", SalesValue = 30 } - }; - - public static List BottomOperators1 => new List - { - new TopBottomOperatorDataModel { OperatorName = "Operator1", SalesValue = 40 }, - new TopBottomOperatorDataModel { OperatorName = "Operator2", SalesValue = 20 } - }; - - public static List BottomProducts1 => new List - { - new TopBottomProductDataModel { ProductName = "Product1", SalesValue = 60 }, - new TopBottomProductDataModel { ProductName = "Product2", SalesValue = 25 } - }; - - public static TodaysSalesModel TodaysFailedSales1 => new TodaysSalesModel - { - TodaysSalesValue = 70, - ComparisonSalesValue = 50 - }; - - public static TodaysSettlementModel TodaysSettlement1 => new TodaysSettlementModel - { - TodaysSettlementValue = 1000, - ComparisonSettlementValue = 800 - }; - - public static LastSettlementModel LastSettlement1 => new LastSettlementModel - { - SettlementDate = DateTime.Parse("2023-01-01"), - SalesValue = 1500, - FeesValue = 100 - }; - - public static OperatorModel Operator => new OperatorModel - { - Name = "Test Operator", - RequireCustomMerchantNumber = true, - RequireCustomTerminalNumber = false - }; - - public static Result OperatorResult => Result.Success(Operator); - - public static List Operators => new List - { - new OperatorModel { OperatorId = Guid.NewGuid(), Name = "Operator1", RequireCustomMerchantNumber = true, RequireCustomTerminalNumber = false }, - new OperatorModel { OperatorId = Guid.NewGuid(), Name = "Operator2", RequireCustomMerchantNumber = false, RequireCustomTerminalNumber = true } - }; - - public static Result> OperatorsResult => Result.Success(Operators); - - public static List Merchants => new List - { - new MerchantModel { MerchantId = Guid.NewGuid(), MerchantName = "Merchant1", MerchantReference = "Reference1",Address = new AddressModel{AddressLine1 = "AddressLine1", Town = "Town1"}, Contact = new ContactModel{ContactName = "Contact1"}, SettlementSchedule = "Immediate"}, - new MerchantModel { MerchantId = Guid.NewGuid(), MerchantName = "Merchant2", MerchantReference = "Reference2",Address = new AddressModel{AddressLine1 = "AddressLine2", Town = "Town2"}, Contact = new ContactModel{ContactName = "Contact2"}, SettlementSchedule = "Monthly"} - }; - - public static Result> MerchantsResult => Result.Success(Merchants); - - public static MerchantModel Merchant => new MerchantModel - { - MerchantId = Guid.NewGuid(), - MerchantName = "Test Merchant", - MerchantReference = "Ref123", - SettlementSchedule = "Immediate", - Address = new AddressModel - { - AddressLine1 = "123 Main St", - AddressLine2 = "Suite 100", - Town = "Anytown", - Region = "Anystate", - Country = "USA", - PostalCode = "12345", - AddressId = Guid.NewGuid() - }, - Contact = new ContactModel - { - ContactName = "John Doe", - ContactEmailAddress = "john.doe@example.com", - ContactPhoneNumber = "555-1234", - ContactId = Guid.NewGuid() - }, - Operators = new List - { - new MerchantOperatorModel - { - OperatorId = Guid.NewGuid(), - Name = "Operator1", - MerchantNumber = "123456", - TerminalNumber = "7890", - IsDeleted = false - } - }, - Contracts = new List - { - new MerchantContractModel - { - ContractId = Guid.NewGuid(), - Name = "Contract1", - IsDeleted = false - } - }, - Devices = new Dictionary - { - { Guid.NewGuid(), "Device1" } - } - }; - - public static Result MerchantResult => Result.Success(Merchant); - - - public static List Contracts => new List - { - new ContractModel { ContractId = Guid.NewGuid(), Description = "Contract1" }, - new ContractModel { ContractId = Guid.NewGuid(), Description = "Contract2" } - }; - - public static Result> ContractsResult => Result.Success(Contracts); - - public static List FileImportLogs => new List - { - new FileImportLogModel - { - FileImportLogId = Guid.NewGuid(), - ImportLogDateTime = DateTime.Now, - ImportLogDate = DateTime.Now.Date, - ImportLogTime = DateTime.Now.TimeOfDay, - FileCount = 5 - }, - new FileImportLogModel - { - FileImportLogId = Guid.NewGuid(), - ImportLogDateTime = DateTime.Now.AddDays(-1), - ImportLogDate = DateTime.Now.AddDays(-1).Date, - ImportLogTime = DateTime.Now.AddDays(-1).TimeOfDay, - FileCount = 3 - } - }; - - public static Result> FileImportLogsResult => Result.Success(FileImportLogs); - - public static FileImportLogModel FileImportLog => new FileImportLogModel - { - FileImportLogId = Guid.Parse("C9EDAF44-63A7-4037-8E0F-4EC0707474EE"), - ImportLogDateTime = DateTime.Now, - ImportLogDate = DateTime.Now.Date, - ImportLogTime = DateTime.Now.TimeOfDay, - FileCount = 5, - Files = new List { - new FileImportLogFileModel { - OriginalFileName = "File1.txt", - FileUploadedDateTime = new DateTime(2024,12,25), - FileProfileId = Guid.Parse("B2A59ABF-293D-4A6B-B81B-7007503C3476"), - UserId = Guid.Parse("01A5BD19-0A11-4814-B27B-75A53E237CE6"), - }, - new FileImportLogFileModel { - OriginalFileName = "File2.txt", - FileUploadedDateTime = new DateTime(2024,12,26), - FileProfileId = Guid.Parse("B2A59ABF-293D-4A6B-B81B-7007503C3476"), - UserId = Guid.Parse("01A5BD19-0A11-4814-B27B-75A53E237CE6"), - }, - new FileImportLogFileModel { - OriginalFileName = "File3.txt", - FileUploadedDateTime = new DateTime(2024,12,27), - FileProfileId = Guid.Parse("B2A59ABF-293D-4A6B-B81B-7007503C3476"), - UserId = Guid.Parse("01A5BD19-0A11-4814-B27B-75A53E237CE6"), - }, - new FileImportLogFileModel { - OriginalFileName = "File4.txt", - FileUploadedDateTime = new DateTime(2024,12,28), - FileProfileId = Guid.Parse("B2A59ABF-293D-4A6B-B81B-7007503C3476"), - UserId = Guid.Parse("01A5BD19-0A11-4814-B27B-75A53E237CE6"), - }, - new FileImportLogFileModel { - OriginalFileName = "File5.txt", - FileUploadedDateTime = new DateTime(2024,12,29), - FileProfileId = Guid.Parse("B2A59ABF-293D-4A6B-B81B-7007503C3476"), - UserId = Guid.Parse("01A5BD19-0A11-4814-B27B-75A53E237CE6"), - } - } - }; - - public static Result FileImportLogResult => Result.Success(FileImportLog); - - public static EstateModel Estate => new EstateModel - { - EstateId = Guid.NewGuid(), - EstateName = "Test Estate", - Reference = "Ref123", - SecurityUsers = new List - { - new SecurityUserModel - { - SecurityUserId = Guid.NewGuid(), - EmailAddress = "user1@example.com" - }, - new SecurityUserModel - { - SecurityUserId = Guid.NewGuid(), - EmailAddress = "user2@example.com" - } - }, - Operators = new List { - new EstateOperatorModel { - Name = "Operator1" - }, - new EstateOperatorModel { - Name = "Operator2" - } - } - }; - - public static Result EstateResult => Result.Success(Estate); - - public static FileDetailsModel FileDetailsWith2Lines => new FileDetailsModel - { - FileId = Guid.NewGuid(), - FileLocation = "path/to/file", - MerchantName = "Test Merchant", - FileProfileName = "Test Profile", - UserEmailAddress = "user@example.com", - FileLines = new List - { - new FileLineModel - { - LineNumber = 1, - LineData = "data1", - ProcessingResult = BusinessLogic.Models.FileLineProcessingResult.Successful, - TransactionId = Guid.NewGuid(), - RejectionReason = "None" - }, - new FileLineModel - { - LineNumber = 2, - LineData = "data2", - ProcessingResult = BusinessLogic.Models.FileLineProcessingResult.Failed, - TransactionId = Guid.NewGuid(), - RejectionReason = "Error" - } - } - }; - - public static Result FileDetailsResult => Result.Success(FileDetailsWith2Lines); - - - public static EstateModel ViewEstate => new EstateModel - { - EstateId = Guid.Parse("D2ED8F42-BA29-47A6-B781-FE115CD145D0"), - EstateName = "Test Estate", - Reference = "Ref123" - }; - - public static Result ViewEstateResult => Result.Success(ViewEstate); - - - public static List ContractProducts => new List - { - new ContractProductModel { - ContractProductId = Guid.NewGuid(), ProductName = "Product1", ProductType = "Type1", - NumberOfFees = 2, DisplayText = "Product 1", Value = "100 KES" - }, - new ContractProductModel { - ContractProductId = Guid.NewGuid(), ProductName = "Product2", ProductType = "Type2", NumberOfFees = 3 - , DisplayText = "Product 2", Value = "200 KES" - } - }; - - public static ContractModel ContractsResultWithProducts => new ContractModel() { - ContractId = Guid.NewGuid(), Description = "Contract1", - ContractProducts = ContractProducts - }; - - public static ContractListModel ContractList => new ContractListModel - { - Contracts = new List - { - new SelectListItem { Text = "Contract1", Value = Guid.NewGuid().ToString() }, - new SelectListItem { Text = "Contract2", Value = Guid.NewGuid().ToString() } - }, - ContractId = Guid.NewGuid().ToString() - }; - - public static Guid ContractId => Guid.Parse("BA93C499-9921-468E-960E-03D1063E7FF8"); - public static Guid ContractProductId => Guid.Parse("55B77A81-A218-4874-88A4-EA86B3C8181D"); - - public static ContractModel GetContractModel() - { - return new ContractModel - { - ContractId = ContractId, - ContractProducts = new List - { - new ContractProductModel - { - ContractProductId = ContractProductId, - ProductName = "Product1", - ContractProductTransactionFees = new List - { - new ContractProductTransactionFeeModel - { - ContractProductTransactionFeeId = Guid.NewGuid(), - CalculationType = "Type1", - Description = "Description1", - Value = 10.0m, - FeeType = "FeeType1" - }, - new ContractProductTransactionFeeModel - { - ContractProductTransactionFeeId = Guid.NewGuid(), - CalculationType = "Type2", - Description = "Description2", - Value = 20.0m, - FeeType = "FeeType2" - } - } - } - } - }; - } - - public static List GetContracts() - { - return new List - { - new ContractModel - { - ContractId = Guid.NewGuid(), - OperatorName = "Operator1", - Description = "Description1", - NumberOfProducts = 2 - }, - new ContractModel - { - ContractId = Guid.NewGuid(), - OperatorName = "Operator2", - Description = "Description2", - NumberOfProducts = 3 - } - }; - } - - public static List GetOperatorModels() - { - return new List - { - new OperatorModel - { - OperatorId = Guid.NewGuid(), - Name = "Operator1" - }, - new OperatorModel - { - OperatorId = Guid.NewGuid(), - Name = "Operator2" - } - }; - } - - public static AssignOperatorToMerchantModel GetAssignOperatorToMerchantModel() - { - return new AssignOperatorToMerchantModel - { - OperatorId = Guid.NewGuid(), - MerchantNumber = "123456", - TerminalNumber = "7890" - }; - } - - public static List GetOperatorListModels() - { - return new List - { - new OperatorListModel - { - OperatorId = "64BA00F0-2DB1-4706-BB96-6A925BA25910", - Operators = new List - { - new SelectListItem { Value = "64BA00F0-2DB1-4706-BB96-6A925BA25910", Text = "Operator1" }, - new SelectListItem { Value = "1136657A-16A1-4416-A9A0-C8939A79E3FE", Text = "Operator2" } - } - } - }; - } - - public static List GetMerchants() - { - return new List - { - new MerchantModel - { - MerchantId = Guid.NewGuid(), - MerchantName = "Merchant1", - MerchantReference = "Reference1", - Address = new AddressModel - { - AddressLine1 = "Address Line 1", - Town = "Town1", - Region = "Region1", - Country = "Country1", - PostalCode = "PostalCode1" - }, - Contact = new ContactModel - { - ContactName = "Contact1", - ContactPhoneNumber = "1234567890", - ContactEmailAddress = "contact1@example.com" - }, - SettlementSchedule = "Immediate", - Operators = new List - { - new MerchantOperatorModel - { - OperatorId = Guid.NewGuid(), - Name = "Operator1", - MerchantNumber = "123456", - TerminalNumber = "7890", - IsDeleted = false - } - }, - Contracts = new List - { - new MerchantContractModel - { - ContractId = Guid.NewGuid(), - Name = "Contract1", - IsDeleted = false - } - }, - Devices = new Dictionary - { - { Guid.NewGuid(), "Device1" } - } - }, - new MerchantModel - { - MerchantId = Guid.NewGuid(), - MerchantName = "Merchant2", - MerchantReference = "Reference2", - Address = new AddressModel - { - AddressLine1 = "Address Line 2", - Town = "Town2", - Region = "Region2", - Country = "Country2", - PostalCode = "PostalCode2" - }, - Contact = new ContactModel - { - ContactName = "Contact2", - ContactPhoneNumber = "0987654321", - ContactEmailAddress = "contact2@example.com" - }, - SettlementSchedule = "Monthly", - Operators = new List - { - new MerchantOperatorModel - { - OperatorId = Guid.NewGuid(), - Name = "Operator2", - MerchantNumber = "654321", - TerminalNumber = "0987", - IsDeleted = false - } - }, - Contracts = new List - { - new MerchantContractModel - { - ContractId = Guid.NewGuid(), - Name = "Contract2", - IsDeleted = false - } - }, - Devices = new Dictionary - { - { Guid.NewGuid(), "Device2" } - } - } - }; - } - - public static List GetOperators() - { - return new List - { - new OperatorModel - { - OperatorId = Guid.NewGuid(), - Name = "Operator1", - RequireCustomMerchantNumber = true, - RequireCustomTerminalNumber = false - }, - new OperatorModel - { - OperatorId = Guid.NewGuid(), - Name = "Operator2", - RequireCustomMerchantNumber = false, - RequireCustomTerminalNumber = true - } - }; - } - - public static List GetComparisonDates() - { - return new List - { - new ComparisonDateModel - { - Date = new DateTime(2024, 1, 1), - Description = "2024-01-01", - OrderValue = 1 - }, - new ComparisonDateModel - { - Date = new DateTime(2024, 1, 2), - Description = "2024-01-02", - OrderValue = 2 - } - }; - } - - public static TodaysSalesModel GetTodaysSalesModel() - { - return new TodaysSalesModel - { - TodaysSalesValue = 1000m, - ComparisonSalesValue = 800m - }; - } - - public static TodaysSettlementModel GetTodaysSettlementModel() - { - return new TodaysSettlementModel - { - TodaysSettlementValue = 500m, - ComparisonSettlementValue = 400m - }; - } - - public static List GetTodaysSalesCountByHourModels() - { - return new List - { - new TodaysSalesCountByHourModel { Hour = 1, TodaysSalesCount = 10, ComparisonSalesCount = 8 }, - new TodaysSalesCountByHourModel { Hour = 2, TodaysSalesCount = 20, ComparisonSalesCount = 15 } - }; - } - - public static List GetTodaysSalesValueByHourModels() - { - return new List - { - new TodaysSalesValueByHourModel { Hour = 1, TodaysSalesValue = 100m, ComparisonSalesValue = 80m }, - new TodaysSalesValueByHourModel { Hour = 2, TodaysSalesValue = 200m, ComparisonSalesValue = 150m } - }; - } - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/AddContractDialogTests.cs b/EstateManagementUI.UITests/AddContractDialogTests.cs deleted file mode 100644 index fee1ab29..00000000 --- a/EstateManagementUI.UITests/AddContractDialogTests.cs +++ /dev/null @@ -1,97 +0,0 @@ -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 Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using SimpleResults; -using System.Security.Claims; - -namespace EstateManagementUI.UITests; - -public class AddContractDialogTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly AddContractDialog _addContractDialog; - - public AddContractDialogTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._addContractDialog = new AddContractDialog(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._addContractDialog.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_PopulatesContracts() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.Contracts); - - // Act - await this._addContractDialog.MountAsync(); - - // Assert - this._addContractDialog.Contract.ShouldNotBeNull(); - this._addContractDialog.Contract.Contracts.Count.ShouldBe(3); - } - - [Fact] - public async Task Save_AssignsContractToMerchant_WhenContractIdIsNotEmpty() - { - // Arrange - this._addContractDialog.MerchantId = Guid.NewGuid(); - this._addContractDialog.Contract = TestData.ContractList; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success()); - - // Act - await this._addContractDialog.Save(); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - var events = this._addContractDialog.GetDispatchedEvents(); - events.Count.ShouldBe(2); - events[0].ShouldBeOfType(); - events[1].ShouldBeOfType(); - } - - [Fact] - public async Task Save_ShowsErrorMessage_WhenAssignContractFails() - { - // Arrange - this._addContractDialog.MerchantId = Guid.NewGuid(); - this._addContractDialog.Contract = TestData.ContractList; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Failure(new List { "Error" })); - - // Act - await this._addContractDialog.Save(); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - var events = this._addContractDialog.GetDispatchedEvents(); - events.Count.ShouldBe(2); - events[0].ShouldBeOfType(); - events[1].ShouldBeOfType(); - } - - [Fact] - public async Task Close_DispatchesHideAddContractDialogEvent() - { - // Act - await this._addContractDialog.Close(); - - // Assert - var events = this._addContractDialog.GetDispatchedEvents(); - events.Count.ShouldBe(1); - events[0].ShouldBeOfType(); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/AddDeviceDialogTests.cs b/EstateManagementUI.UITests/AddDeviceDialogTests.cs deleted file mode 100644 index 154d3282..00000000 --- a/EstateManagementUI.UITests/AddDeviceDialogTests.cs +++ /dev/null @@ -1,95 +0,0 @@ -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); - var events = this._addDeviceDialog.GetDispatchedEvents(); - events.Count.ShouldBe(2); - events[0].ShouldBeOfType(); - 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); - - var events = this._addDeviceDialog.GetDispatchedEvents(); - events.Count.ShouldBe(2); - events[0].ShouldBeOfType(); - events[1].ShouldBeOfType(); - } - - [Fact] - public async Task Close_DispatchesHideAddContractDialogEvent() - { - // Act - await this._addDeviceDialog.Close(); - - // Assert - var events = this._addDeviceDialog.GetDispatchedEvents(); - events.Count.ShouldBe(1); - events[0].ShouldBeOfType(); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/AddOperatorDialogTests.cs b/EstateManagementUI.UITests/AddOperatorDialogTests.cs deleted file mode 100644 index b9f067ab..00000000 --- a/EstateManagementUI.UITests/AddOperatorDialogTests.cs +++ /dev/null @@ -1,99 +0,0 @@ -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); - var events = this._addOperatorDialog.GetDispatchedEvents(); - 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); - var events = this._addOperatorDialog.GetDispatchedEvents(); - 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 - var events = this._addOperatorDialog.GetDispatchedEvents(); - events.ShouldContain(e => e is MerchantPageEvents.HideAddOperatorDialog); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/ChartHelpersTests.cs b/EstateManagementUI.UITests/ChartHelpersTests.cs deleted file mode 100644 index 12b25693..00000000 --- a/EstateManagementUI.UITests/ChartHelpersTests.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Text; -using Shouldly; - -namespace EstateManagementUI.UITests; - -public class ChartHelpersTests -{ - [Fact] - public void ConvertChartOptionsToHtml_ValidChartOptions_ReturnsHtmlString() - { - // Arrange - string chartOptions = "
Chart Options
"; - - // Act - string result = ChartHelpers.ConvertChartOptionsToHtml(chartOptions); - - // Assert - result.ShouldBe(chartOptions); - } - - [Fact] - public void GetScriptForCharts_ValidInputs_ReturnsScriptString() - { - // Arrange - string chartId = "chart1"; - string chartOptions = "{ type: 'bar' }"; - - // Act - string result = ChartHelpers.GetScriptForCharts(chartId, chartOptions); - - // Assert - StringBuilder expectedScript = new StringBuilder(); - expectedScript.Append($"var options = {chartOptions};"); - expectedScript.Append($"var element = document.querySelector(\"#{chartId}\");"); - expectedScript.Append($"var {chartId} = new ApexCharts(element, options);"); - expectedScript.Append($"{chartId}.render();"); - - result.ShouldBe(expectedScript.ToString()); - } -} - -/* -public static class TestData -{ - public static List ComparisonDates => new List - { - new ComparisonDateModel { Date = DateTime.Parse("2023-01-01"), Description = "2023-01-01", OrderValue = 1 } - }; - - public static TodaysSalesModel TodaysSales => new TodaysSalesModel - { - TodaysSalesValue = 100, - ComparisonSalesValue = 80 - }; - - public static MerchantKpiModel MerchantKpi => new MerchantKpiModel - { - MerchantsWithNoSaleInLast7Days = 5, - MerchantsWithNoSaleToday = 3, - MerchantsWithSaleInLastHour = 2 - }; - - public static List BottomMerchants => new List - { - new TopBottomMerchantDataModel { MerchantName = "Merchant1", SalesValue = 50 }, - new TopBottomMerchantDataModel { MerchantName = "Merchant2", SalesValue = 30 } - }; - - public static List BottomOperators => new List - { - new TopBottomOperatorDataModel { OperatorName = "Operator1", SalesValue = 40 }, - new TopBottomOperatorDataModel { OperatorName = "Operator2", SalesValue = 20 } - }; - - public static List BottomProducts => new List - { - new TopBottomProductDataModel { ProductName = "Product1", SalesValue = 60 }, - new TopBottomProductDataModel { ProductName = "Product2", SalesValue = 25 } - }; - - public static TodaysSalesModel TodaysFailedSales => new TodaysSalesModel - { - TodaysSalesValue = 70, - ComparisonSalesValue = 50 - }; -}*/ \ No newline at end of file diff --git a/EstateManagementUI.UITests/ContractProductTransactionFeeListTests.cs b/EstateManagementUI.UITests/ContractProductTransactionFeeListTests.cs deleted file mode 100644 index 01a5cde5..00000000 --- a/EstateManagementUI.UITests/ContractProductTransactionFeeListTests.cs +++ /dev/null @@ -1,164 +0,0 @@ -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 deleted file mode 100644 index 57e9c61c..00000000 --- a/EstateManagementUI.UITests/ContractProductsListTests.cs +++ /dev/null @@ -1,199 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Contract.ContractProduct; -using EstateManagementUI.Testing; -using EstateManagementUI.ViewModels; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using System.Security.Claims; - -namespace EstateManagementUI.UITests; - -public class ContractProductsListTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly ContractProductsList _contractProductsList; - - public ContractProductsListTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._contractProductsList = new ContractProductsList(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._contractProductsList.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_PopulatesContractProducts() - { - // Arrange - this._contractProductsList.ContractId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.ContractsResultWithProducts); - - // Act - await this._contractProductsList.MountAsync(); - - // Assert - this._contractProductsList.ContractName.ShouldBe(TestData.ContractsResultWithProducts.Description); - this._contractProductsList.ContractProducts.ShouldNotBeNull(); - this._contractProductsList.ContractProducts.Count.ShouldBe(2); - this._contractProductsList.ContractProducts[0].ProductName.ShouldBe("Product1"); - this._contractProductsList.ContractProducts[1].ProductName.ShouldBe("Product2"); - } - - [Fact] - public async Task Sort_SortsContractProductsByDisplayText() - { - // Arrange - this._contractProductsList.ContractId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.ContractsResultWithProducts); - - // Act - await this._contractProductsList.Sort(ContractProductSorting.DisplayText); - - // Assert - this._contractProductsList.ContractProducts.ShouldNotBeNull(); - this._contractProductsList.ContractProducts.Count.ShouldBe(2); - this._contractProductsList.ContractProducts[0].DisplayText.ShouldBe("Product 2"); - this._contractProductsList.ContractProducts[1].DisplayText.ShouldBe("Product 1"); - - // Act - await this._contractProductsList.Sort(ContractProductSorting.DisplayText); - - this._contractProductsList.ContractProducts[0].DisplayText.ShouldBe("Product 1"); - this._contractProductsList.ContractProducts[1].DisplayText.ShouldBe("Product 2"); - } - - [Fact] - public async Task Sort_SortsContractProductsByNumberOfFees() - { - // Arrange - this._contractProductsList.ContractId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.ContractsResultWithProducts); - - // Act - await this._contractProductsList.Sort(ContractProductSorting.NumberOfFees); - - // Assert - this._contractProductsList.ContractProducts.ShouldNotBeNull(); - this._contractProductsList.ContractProducts.Count.ShouldBe(2); - this._contractProductsList.ContractProducts[0].NumberOfFees.ShouldBe(2); - this._contractProductsList.ContractProducts[1].NumberOfFees.ShouldBe(3); - - // Act - await this._contractProductsList.Sort(ContractProductSorting.NumberOfFees); - - this._contractProductsList.ContractProducts[0].NumberOfFees.ShouldBe(3); - this._contractProductsList.ContractProducts[1].NumberOfFees.ShouldBe(2); - } - - [Fact] - public async Task Sort_SortsContractProductsByProductName() - { - // Arrange - this._contractProductsList.ContractId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.ContractsResultWithProducts); - - // Act - await this._contractProductsList.Sort(ContractProductSorting.ProductName); - - // Assert - this._contractProductsList.ContractProducts.ShouldNotBeNull(); - this._contractProductsList.ContractProducts.Count.ShouldBe(2); - this._contractProductsList.ContractProducts[0].ProductName.ShouldBe("Product1"); - this._contractProductsList.ContractProducts[1].ProductName.ShouldBe("Product2"); - - // Act - await this._contractProductsList.Sort(ContractProductSorting.ProductName); - - this._contractProductsList.ContractProducts[0].ProductName.ShouldBe("Product2"); - this._contractProductsList.ContractProducts[1].ProductName.ShouldBe("Product1"); - } - - [Fact] - public async Task Sort_SortsContractProductsByProductType() - { - // Arrange - this._contractProductsList.ContractId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.ContractsResultWithProducts); - - // Act - await this._contractProductsList.Sort(ContractProductSorting.ProductType); - - // Assert - this._contractProductsList.ContractProducts.ShouldNotBeNull(); - this._contractProductsList.ContractProducts.Count.ShouldBe(2); - this._contractProductsList.ContractProducts[0].ProductType.ShouldBe("Type1"); - this._contractProductsList.ContractProducts[1].ProductType.ShouldBe("Type2"); - - // Act - await this._contractProductsList.Sort(ContractProductSorting.ProductType); - - this._contractProductsList.ContractProducts[0].ProductType.ShouldBe("Type2"); - this._contractProductsList.ContractProducts[1].ProductType.ShouldBe("Type1"); - } - - [Fact] - public async Task Sort_SortsContractProductsByValue() - { - // Arrange - this._contractProductsList.ContractId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.ContractsResultWithProducts); - - // Act - await this._contractProductsList.Sort(ContractProductSorting.Value); - - // Assert - this._contractProductsList.ContractProducts.ShouldNotBeNull(); - this._contractProductsList.ContractProducts.Count.ShouldBe(2); - this._contractProductsList.ContractProducts[0].Value.ShouldBe("100 KES"); - this._contractProductsList.ContractProducts[1].Value.ShouldBe("200 KES"); - - // Act - await this._contractProductsList.Sort(ContractProductSorting.Value); - - this._contractProductsList.ContractProducts[0].Value.ShouldBe("200 KES"); - this._contractProductsList.ContractProducts[1].Value.ShouldBe("100 KES"); - } - - [Fact] - public async Task ViewProductFees_NavigatesToProductFeesPage() - { - // Arrange - var contractProductId = Guid.NewGuid(); - this._contractProductsList.ContractId = Guid.NewGuid(); - this._contractProductsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - await this._contractProductsList.ViewProductFees(contractProductId); - - // Assert - this._contractProductsList.LocationUrl.ShouldNotBeNull(); - this._contractProductsList.LocationUrl.ShouldBe("/Contract/ContractProductTransactionFees"); - Guid payloadContractProductId = TestHelpers.GetPropertyValue(this._contractProductsList.Payload, "ContractProductId"); - payloadContractProductId.ShouldBe(contractProductId); - } - - [Fact] - public async Task NewContractProduct_NavigatesToNewContractProductPage() - { - // Arrange - this._contractProductsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - await this._contractProductsList.NewContractProduct(); - - // Assert - 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 deleted file mode 100644 index 3f9997c0..00000000 --- a/EstateManagementUI.UITests/ContractsListTests.cs +++ /dev/null @@ -1,161 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Contract.Contracts; -using EstateManagementUI.Testing; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using System.Security.Claims; - -namespace EstateManagementUI.UITests; - -public class ContractsListTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly ContractsList _contractsList; - - public ContractsListTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._contractsList = new ContractsList(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._contractsList.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_PopulatesContracts() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.ContractsResult); - - // Act - await this._contractsList.MountAsync(); - - // Assert - this._contractsList.Contracts.ShouldNotBeNull(); - this._contractsList.Contracts.Count.ShouldBe(2); - this._contractsList.Contracts[0].Description.ShouldBe("Contract1"); - this._contractsList.Contracts[1].Description.ShouldBe("Contract2"); - } - - [Fact] - public async Task Sort_ShouldSortContractsByDescription() - { - // Arrange - var contracts = TestData.GetContracts(); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(contracts); - - // Act - await _contractsList.Sort(ContractSorting.Description); - - // Assert - _contractsList.Contracts[0].Description.ShouldBe("Description2"); - _contractsList.Contracts[1].Description.ShouldBe("Description1"); - - // Act - await _contractsList.Sort(ContractSorting.Description); - - // Assert - _contractsList.Contracts[0].Description.ShouldBe("Description1"); - _contractsList.Contracts[1].Description.ShouldBe("Description2"); - } - - [Fact] - public async Task Sort_ShouldSortContractsByOperator() - { - // Arrange - var contracts = TestData.GetContracts(); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(contracts); - - // Act - await _contractsList.Sort(ContractSorting.Operator); - - // Assert - _contractsList.Contracts[0].OperatorName.ShouldBe("Operator1"); - _contractsList.Contracts[1].OperatorName.ShouldBe("Operator2"); - - // Act - await _contractsList.Sort(ContractSorting.Operator); - - // Assert - _contractsList.Contracts[0].OperatorName.ShouldBe("Operator2"); - _contractsList.Contracts[1].OperatorName.ShouldBe("Operator1"); - } - - [Fact] - public async Task Sort_ShouldSortContractsByNumberOfProducts() - { - // Arrange - var contracts = TestData.GetContracts(); - _mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(contracts); - - // Act - await _contractsList.Sort(ContractSorting.NumberOfProducts); - - // Assert - _contractsList.Contracts[0].NumberOfProducts.ShouldBe(2); - _contractsList.Contracts[1].NumberOfProducts.ShouldBe(3); - - // Act - await _contractsList.Sort(ContractSorting.NumberOfProducts); - - // Assert - _contractsList.Contracts[0].NumberOfProducts.ShouldBe(3); - _contractsList.Contracts[1].NumberOfProducts.ShouldBe(2); - } - - [Fact] - public async Task ViewProducts_ShouldNavigateToProductPage() - { - // Arrange - var contractId = Guid.NewGuid(); - this._contractsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - await _contractsList.ViewProducts(contractId); - - // Assert - _contractsList.LocationUrl.ShouldNotBeNull(); - _contractsList.LocationUrl.ShouldBe("/Contract/ContractProducts"); - var payloadContractId = TestHelpers.GetPropertyValue(_contractsList.Payload, "ContractId"); - payloadContractId.ShouldBe(contractId); - } - - [Fact] - public async Task View_ShouldNavigateToContractPage() - { - // Arrange - var contractId = Guid.NewGuid(); - this._contractsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - await _contractsList.View(contractId); - - // Assert - _contractsList.LocationUrl.ShouldNotBeNull(); - _contractsList.LocationUrl.ShouldBe("/Contract/ViewContract"); - var payloadContractId = TestHelpers.GetPropertyValue(_contractsList.Payload, "ContractId"); - payloadContractId.ShouldBe(contractId); - } - - [Fact] - public async Task NewContract_ShouldNavigateToNewContractPage() - { - // Arrange - this._contractsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - await _contractsList.NewContract(); - - // Assert - _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 deleted file mode 100644 index 47d9702c..00000000 --- a/EstateManagementUI.UITests/DashboardTests.cs +++ /dev/null @@ -1,217 +0,0 @@ -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 deleted file mode 100644 index dc20390e..00000000 --- a/EstateManagementUI.UITests/DataHelperFunctionsTests.cs +++ /dev/null @@ -1,190 +0,0 @@ -using EstateManagementUI.BusinessLogic.Models; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Moq; -using Shouldly; -using SimpleResults; - -namespace EstateManagementUI.UITests; - -public class DataHelperFunctionsTests -{ - private readonly Mock _mediatorMock = new(); - - [Fact] - public async Task GetComparisonDates_ValidInputs_ReturnsComparisonDateListModel() - { - // Arrange - string accessToken = "testAccessToken"; - Guid estateId = Guid.NewGuid(); - CorrelationId correlationId = CorrelationIdHelper.New(); - var comparisonDates = new List - { - new ComparisonDateModel { Date = DateTime.Now, Description = "2023-01-01", OrderValue = 1 }, - new ComparisonDateModel { Date = DateTime.Now.AddDays(1), Description = "2023-01-02", OrderValue = 2 } - }; - var result = Result.Success(comparisonDates); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(result); - - // Act - var response = await DataHelperFunctions.GetComparisonDates(correlationId, accessToken, estateId, this._mediatorMock.Object); - - // Assert - response.ShouldNotBeNull(); - response.Dates.ShouldNotBeEmpty(); - response.SelectedDate.ShouldBe(comparisonDates.First().Date); - } - - [Fact] - public async Task GetOperatorsOld_ValidInputs_ReturnsOperatorListModel() - { - // Arrange - string accessToken = "testAccessToken"; - Guid estateId = Guid.NewGuid(); - CorrelationId correlationId = CorrelationIdHelper.New(); - var operators = new List - { - new OperatorModel { OperatorId = Guid.NewGuid(), Name = "Operator1" }, - new OperatorModel { OperatorId = Guid.NewGuid(), Name = "Operator2" } - }; - var result = Result.Success(operators); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(result); - - // Act - var response = await DataHelperFunctions.GetOperatorsOld(correlationId, accessToken, estateId, this._mediatorMock.Object); - - // Assert - response.ShouldNotBeNull(); - response.Operators.ShouldNotBeEmpty(); - response.Operators.First().Text.ShouldBe("- Select an Operator -"); - } - - [Fact] - public async Task GetMerchants_ValidInputs_ReturnsMerchantListModel() - { - // Arrange - string accessToken = "testAccessToken"; - Guid estateId = Guid.NewGuid(); - CorrelationId correlationId = CorrelationIdHelper.New(); - var merchants = new List - { - new MerchantModel { MerchantId = Guid.NewGuid(), MerchantName = "Merchant1" }, - new MerchantModel { MerchantId = Guid.NewGuid(), MerchantName = "Merchant2" } - }; - var result = Result.Success(merchants); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(result); - - // Act - var response = await DataHelperFunctions.GetMerchants(correlationId, accessToken, estateId, this._mediatorMock.Object); - - // Assert - response.ShouldNotBeNull(); - response.Merchants.ShouldNotBeEmpty(); - response.Merchants.First().Text.ShouldBe("- Select a Merchant -"); - } - - [Fact] - public async Task GetContracts_ValidInputs_ReturnsContractListModel() - { - // Arrange - string accessToken = "testAccessToken"; - Guid estateId = Guid.NewGuid(); - CorrelationId correlationId = CorrelationIdHelper.New(); - var contracts = new List - { - new ContractModel { ContractId = Guid.NewGuid(), Description = "Contract1" }, - new ContractModel { ContractId = Guid.NewGuid(), Description = "Contract2" } - }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(contracts); - - // Act - var response = await DataHelperFunctions.GetContracts(correlationId, accessToken, estateId, this._mediatorMock.Object); - - // Assert - response.ShouldNotBeNull(); - 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(); - CorrelationId correlationId = CorrelationIdHelper.New(); - 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(correlationId, 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 deleted file mode 100644 index 79030ab2..00000000 --- a/EstateManagementUI.UITests/EditMerchantTests.cs +++ /dev/null @@ -1,153 +0,0 @@ -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 - var events = this._editMerchant.GetDispatchedEvents(); - events.ShouldContain(e => e is MerchantPageEvents.ShowAddOperatorDialog); - } - - [Fact] - public void AddContract_ShouldDispatchShowAddContractDialogEvent() { - // Act - this._editMerchant.AddContract(); - - // Assert - var events = this._editMerchant.GetDispatchedEvents(); - events.ShouldContain(e => e is MerchantPageEvents.ShowAddContractDialog); - } - - [Fact] - public void AddDevice_ShouldDispatchShowAddDeviceDialogEvent() - { - // Act - this._editMerchant.AddDevice(); - - // Assert - var events = this._editMerchant.GetDispatchedEvents(); - 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(); - - var events = this._makeDeposit.GetDispatchedEvents(); - 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(); - - var events = this._makeDeposit.GetDispatchedEvents(); - events.ShouldContain(e => e is ShowMessage); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/EstateManagementUI.UITests.csproj b/EstateManagementUI.UITests/EstateManagementUI.UITests.csproj deleted file mode 100644 index efd39681..00000000 --- a/EstateManagementUI.UITests/EstateManagementUI.UITests.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - net10.0 - enable - enable - None - false - true - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - diff --git a/EstateManagementUI.UITests/FileDetailsTests.cs b/EstateManagementUI.UITests/FileDetailsTests.cs deleted file mode 100644 index a0864f12..00000000 --- a/EstateManagementUI.UITests/FileDetailsTests.cs +++ /dev/null @@ -1,96 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.FileProcessing.FileDetails; -using EstateManagementUI.Testing; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using System.Security.Claims; - -namespace EstateManagementUI.UITests; - -public class FileDetailsTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly FileDetails _fileDetails; - private readonly Mock _httpContextAccessorMock; - - public FileDetailsTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._fileDetails = new FileDetails(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._fileDetails.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_LoadsFileDetails_WhenFileIdIsNotEmpty() - { - // Arrange - this._fileDetails.FileId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.FileDetailsResult); - - // Act - await this._fileDetails.MountAsync(); - - // Assert - this._fileDetails.FileName.ShouldBe("path/to/file"); - this._fileDetails.MerchantName.ShouldBe("Test Merchant"); - this._fileDetails.FileProfile.ShouldBe("Test Profile"); - this._fileDetails.UploadedBy.ShouldBe("user@example.com"); - this._fileDetails.FileLines.ShouldNotBeNull(); - this._fileDetails.FileLines.Count.ShouldBe(2); - } - - [Fact] - public async Task Sort_SortsFileLinesByLineNumber() - { - // Arrange - this._fileDetails.FileId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.FileDetailsResult); - - // Act - await this._fileDetails.Sort(FileDetailsSorting.LineNumber); - - // Assert - this._fileDetails.FileLines.ShouldNotBeNull(); - this._fileDetails.FileLines.Count.ShouldBe(2); - this._fileDetails.FileLines[0].LineNumber.ShouldBe(2); - this._fileDetails.FileLines[1].LineNumber.ShouldBe(1); - - // Act - await this._fileDetails.Sort(FileDetailsSorting.LineNumber); - - this._fileDetails.FileLines[0].LineNumber.ShouldBe(1); - this._fileDetails.FileLines[1].LineNumber.ShouldBe(2); - } - - [Fact] - public async Task Sort_SortsFileLinesByResult() - { - // Arrange - this._fileDetails.FileId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.FileDetailsResult); - - // Act - await this._fileDetails.Sort(FileDetailsSorting.Result); - - // Assert - this._fileDetails.FileLines.ShouldNotBeNull(); - this._fileDetails.FileLines.Count.ShouldBe(2); - this._fileDetails.FileLines[0].ProcessingResult.ShouldBe(ViewModels.FileLineProcessingResult.Successful); - this._fileDetails.FileLines[1].ProcessingResult.ShouldBe(ViewModels.FileLineProcessingResult.Failed); - - // Act - await this._fileDetails.Sort(FileDetailsSorting.Result); - - this._fileDetails.FileLines[0].ProcessingResult.ShouldBe(ViewModels.FileLineProcessingResult.Failed); - this._fileDetails.FileLines[1].ProcessingResult.ShouldBe(ViewModels.FileLineProcessingResult.Successful); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/FileImportLogListTests.cs b/EstateManagementUI.UITests/FileImportLogListTests.cs deleted file mode 100644 index ea757de3..00000000 --- a/EstateManagementUI.UITests/FileImportLogListTests.cs +++ /dev/null @@ -1,139 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.FileProcessing.FileImportLogs; -using EstateManagementUI.Testing; -using EstateManagementUI.ViewModels; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Routing; -using Moq; -using Shouldly; -using System.Security.Claims; -using Microsoft.AspNetCore.Routing; -using FileImportLogList = EstateManagementUI.Pages.FileProcessing.FileImportLogs.FileImportLogList; - -namespace EstateManagementUI.UITests; - -public class FileImportLogListTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly FileImportLogList _fileImportLogList; - - public FileImportLogListTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._fileImportLogList = new FileImportLogList(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._fileImportLogList.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_PopulatesMerchantsAndDates() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.MerchantsResult); - - // Act - await this._fileImportLogList.MountAsync(); - - // Assert - this._fileImportLogList.Merchant.ShouldNotBeNull(); - this._fileImportLogList.Merchant.Merchants.ShouldNotBeEmpty(); - this._fileImportLogList.StartDate.ShouldNotBeNull(); - this._fileImportLogList.EndDate.ShouldNotBeNull(); - } - - [Fact] - public async Task Query_PopulatesFileImportLogs_WhenMerchantIdIsNotEmpty() - { - // Arrange - this._fileImportLogList.Merchant = new MerchantListModel { MerchantId = Guid.NewGuid().ToString() }; - this._fileImportLogList.StartDate = new DateModel { SelectedDate = DateTime.Now }; - this._fileImportLogList.EndDate = new DateModel { SelectedDate = DateTime.Now }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.FileImportLogsResult); - - // Act - await this._fileImportLogList.Query(); - - // Assert - this._fileImportLogList.FileImportLogs.ShouldNotBeNull(); - this._fileImportLogList.FileImportLogs.Count.ShouldBe(2); - } - - [Fact] - public async Task Sort_SortsFileImportLogsByImportLogDate() - { - // Arrange - this._fileImportLogList.Merchant = new MerchantListModel { MerchantId = Guid.NewGuid().ToString() }; - this._fileImportLogList.StartDate = new DateModel { SelectedDate = DateTime.Now }; - this._fileImportLogList.EndDate = new DateModel { SelectedDate = DateTime.Now }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.FileImportLogsResult); - - // Act - await this._fileImportLogList.Sort(FileImportLogListSorting.ImportLogDate); - - // Assert - this._fileImportLogList.FileImportLogs.ShouldNotBeNull(); - this._fileImportLogList.FileImportLogs.Count.ShouldBe(2); - this._fileImportLogList.FileImportLogs[0].ImportLogDate.ShouldBe(TestData.FileImportLogs[0].ImportLogDate); - this._fileImportLogList.FileImportLogs[1].ImportLogDate.ShouldBe(TestData.FileImportLogs[1].ImportLogDate); - - // Act - await this._fileImportLogList.Sort(FileImportLogListSorting.ImportLogDate); - - this._fileImportLogList.FileImportLogs[0].ImportLogDate.ShouldBe(TestData.FileImportLogs[1].ImportLogDate); - this._fileImportLogList.FileImportLogs[1].ImportLogDate.ShouldBe(TestData.FileImportLogs[0].ImportLogDate); - } - - [Fact] - public async Task Sort_SortsFileImportLogsByNumberOfFiles() - { - // Arrange - this._fileImportLogList.Merchant = new MerchantListModel { MerchantId = Guid.NewGuid().ToString() }; - this._fileImportLogList.StartDate = new DateModel { SelectedDate = DateTime.Now }; - this._fileImportLogList.EndDate = new DateModel { SelectedDate = DateTime.Now }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.FileImportLogsResult); - - // Act - await this._fileImportLogList.Sort(FileImportLogListSorting.NumberOfFiles); - - // Assert - this._fileImportLogList.FileImportLogs.ShouldNotBeNull(); - this._fileImportLogList.FileImportLogs.Count.ShouldBe(2); - this._fileImportLogList.FileImportLogs[0].FileCount.ShouldBe(3); - this._fileImportLogList.FileImportLogs[1].FileCount.ShouldBe(5); - - // Act - await this._fileImportLogList.Sort(FileImportLogListSorting.NumberOfFiles); - - this._fileImportLogList.FileImportLogs[0].FileCount.ShouldBe(5); - this._fileImportLogList.FileImportLogs[1].FileCount.ShouldBe(3); - } - - [Fact] - public async Task ViewFiles_NavigatesToFileImportLogPage() - { - - - // Arrange - var fileImportLogId = Guid.NewGuid(); - this._fileImportLogList.Merchant = new MerchantListModel { MerchantId = Guid.NewGuid().ToString() }; - this._fileImportLogList.Url = TestHelper.GetTestUrlHelper(); - - // Act - await this._fileImportLogList.ViewFiles(fileImportLogId); - - // Assert - this._fileImportLogList.LocationUrl.ShouldNotBeNull(); - this._fileImportLogList.LocationUrl.ShouldBe("/FileProcessing/FileImportLog"); - Guid payloadFileImportLogId = TestHelpers.GetPropertyValue(this._fileImportLogList.Payload, "FileImportLogId"); - payloadFileImportLogId.ShouldBe(fileImportLogId); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/FileImportLogTests.cs b/EstateManagementUI.UITests/FileImportLogTests.cs deleted file mode 100644 index 2c180adc..00000000 --- a/EstateManagementUI.UITests/FileImportLogTests.cs +++ /dev/null @@ -1,168 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.FileProcessing.FileImportLog; -using EstateManagementUI.Testing; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using System.Security.Claims; - -namespace EstateManagementUI.UITests; - -public class FileImportLogTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly FileImportLog _fileImportLog; - - public FileImportLogTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._fileImportLog = new FileImportLog(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._fileImportLog.ViewContext = TestHelper.GetTestViewContext(); - } - - [Theory] - [InlineData(FileImportLogSorting.FileName, true)] - [InlineData(FileImportLogSorting.FileName, false)] - [InlineData(FileImportLogSorting.DateTimeUploaded, true)] - [InlineData(FileImportLogSorting.DateTimeUploaded, false)] - [InlineData(FileImportLogSorting.FileProfile, true)] - [InlineData(FileImportLogSorting.FileProfile, false)] - [InlineData(FileImportLogSorting.OriginalFileName, true)] - [InlineData(FileImportLogSorting.OriginalFileName, false)] - [InlineData(FileImportLogSorting.UserName, true)] - [InlineData(FileImportLogSorting.UserName, false)] - public async Task MountAsync_LoadsFileImportLog_WhenFileImportLogIdIsNotEmpty(FileImportLogSorting sortField, Boolean ascending) - { - // Arrange - this._fileImportLog.FileImportLogId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.FileImportLogResult); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.EstateResult); - this._fileImportLog.Sorting = (Column: sortField, Ascending: ascending); - // Act - await this._fileImportLog.MountAsync(); - - // Assert - this._fileImportLog.ImportLogDate.ShouldBe(TestData.FileImportLog.ImportLogDate); - this._fileImportLog.FileImportLogId.ShouldBe(TestData.FileImportLog.FileImportLogId); - this._fileImportLog.Files.Count.ShouldBe(5); - } - - [Fact] - public async Task ViewFileDetails_UrlSet() - { - Guid fileId = Guid.Parse("D726ED3C-93DE-4FC3-81F9-30CF330079BB"); - this._fileImportLog.Url = TestHelper.GetTestUrlHelper(); - - // Act - await this._fileImportLog.ViewFileDetails(fileId); - - // Assert - this._fileImportLog.LocationUrl.ShouldBe("/FileProcessing/FileDetails"); - Guid payloadFileId = TestHelpers.GetPropertyValue(this._fileImportLog.Payload, "FileId"); - payloadFileId.ShouldBe(fileId); - - } - - [Fact] - public async Task Sort_ByDateTimeUploaded() - { - this._fileImportLog.FileImportLogId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.FileImportLogResult); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.EstateResult); - - // Act - await this._fileImportLog.Sort(FileImportLogSorting.DateTimeUploaded); - - // Assert - this._fileImportLog.Files.Count.ShouldBe(5); - this._fileImportLog.Files[0].UploadDateTime.ShouldBe(DateTime.Parse("2024-12-25")); - this._fileImportLog.Files[1].UploadDateTime.ShouldBe(DateTime.Parse("2024-12-26")); - this._fileImportLog.Files[2].UploadDateTime.ShouldBe(DateTime.Parse("2024-12-27")); - this._fileImportLog.Files[3].UploadDateTime.ShouldBe(DateTime.Parse("2024-12-28")); - this._fileImportLog.Files[4].UploadDateTime.ShouldBe(DateTime.Parse("2024-12-29")); - - // Act - await this._fileImportLog.Sort(FileImportLogSorting.DateTimeUploaded); - - // Assert - this._fileImportLog.Files.Count.ShouldBe(5); - this._fileImportLog.Files[0].UploadDateTime.ShouldBe(DateTime.Parse("2024-12-29")); - this._fileImportLog.Files[1].UploadDateTime.ShouldBe(DateTime.Parse("2024-12-28")); - this._fileImportLog.Files[2].UploadDateTime.ShouldBe(DateTime.Parse("2024-12-27")); - this._fileImportLog.Files[3].UploadDateTime.ShouldBe(DateTime.Parse("2024-12-26")); - this._fileImportLog.Files[4].UploadDateTime.ShouldBe(DateTime.Parse("2024-12-25")); - } - - [Fact] - public async Task Sort_ByOriginalFileName() - { - this._fileImportLog.FileImportLogId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.FileImportLogResult); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.EstateResult); - - // Act - await this._fileImportLog.Sort(FileImportLogSorting.OriginalFileName); - - // Assert - this._fileImportLog.Files.Count.ShouldBe(5); - this._fileImportLog.Files[0].OriginalFileName.ShouldBe("File1.txt"); - this._fileImportLog.Files[1].OriginalFileName.ShouldBe("File2.txt"); - this._fileImportLog.Files[2].OriginalFileName.ShouldBe("File3.txt"); - this._fileImportLog.Files[3].OriginalFileName.ShouldBe("File4.txt"); - this._fileImportLog.Files[4].OriginalFileName.ShouldBe("File5.txt"); - - // Act - await this._fileImportLog.Sort(FileImportLogSorting.OriginalFileName); - - // Assert - this._fileImportLog.Files.Count.ShouldBe(5); - this._fileImportLog.Files[0].OriginalFileName.ShouldBe("File5.txt"); - this._fileImportLog.Files[1].OriginalFileName.ShouldBe("File4.txt"); - this._fileImportLog.Files[2].OriginalFileName.ShouldBe("File3.txt"); - this._fileImportLog.Files[3].OriginalFileName.ShouldBe("File2.txt"); - this._fileImportLog.Files[4].OriginalFileName.ShouldBe("File1.txt"); - } - - [Fact] - public async Task Sort_ByFileProfile() - { - this._fileImportLog.FileImportLogId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.FileImportLogResult); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.EstateResult); - - // Act - await this._fileImportLog.Sort(FileImportLogSorting.FileProfile); - - // Assert - this._fileImportLog.Files.Count.ShouldBe(5); - this._fileImportLog.Files[0].FileProfileName.ShouldBe("Safaricom Topup"); - this._fileImportLog.Files[1].FileProfileName.ShouldBe("Safaricom Topup"); - this._fileImportLog.Files[2].FileProfileName.ShouldBe("Safaricom Topup"); - this._fileImportLog.Files[3].FileProfileName.ShouldBe("Safaricom Topup"); - this._fileImportLog.Files[4].FileProfileName.ShouldBe("Safaricom Topup"); - - // Act - await this._fileImportLog.Sort(FileImportLogSorting.FileProfile); - - // Assert - this._fileImportLog.Files.Count.ShouldBe(5); - this._fileImportLog.Files[0].FileProfileName.ShouldBe("Safaricom Topup"); - this._fileImportLog.Files[1].FileProfileName.ShouldBe("Safaricom Topup"); - this._fileImportLog.Files[2].FileProfileName.ShouldBe("Safaricom Topup"); - this._fileImportLog.Files[3].FileProfileName.ShouldBe("Safaricom Topup"); - this._fileImportLog.Files[4].FileProfileName.ShouldBe("Safaricom Topup"); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/HelpersTests.cs b/EstateManagementUI.UITests/HelpersTests.cs deleted file mode 100644 index abc1d874..00000000 --- a/EstateManagementUI.UITests/HelpersTests.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System.Security.Claims; -using EstateManagementUI.Common; -using Shouldly; - -namespace EstateManagementUI.UITests; - -public class HelpersTests -{ - [Fact] - public void GetClaimValue_ValidClaim_ReturnsClaimValue() - { - // Arrange - var claims = new List - { - new Claim(Helpers.EstateIdClaimType, "12345") - }; - var claimsIdentity = new ClaimsIdentity(claims); - - // Act - var result = Helpers.GetClaimValue(claimsIdentity, Helpers.EstateIdClaimType); - - // Assert - result.ShouldBe("12345"); - } - - [Fact] - public void GetClaimValue_InvalidClaim_ThrowsInvalidOperationException() - { - // Arrange - var claims = new List(); - var claimsIdentity = new ClaimsIdentity(claims); - - // Act & Assert - Should.Throw(() => Helpers.GetClaimValue(claimsIdentity, Helpers.EstateIdClaimType)); - } - - [Fact] - public void GetSecurityServiceAddresses_ValidInputs_ReturnsCorrectAddresses() - { - // Arrange - string authority = "https://localhost:5000"; - string securityServiceLocalPort = "5001"; - string securityServicePort = "5002"; - - // Act - var (authorityAddress, issuerAddress) = Helpers.GetSecurityServiceAddresses(authority, securityServiceLocalPort, securityServicePort); - - // Assert - authorityAddress.ShouldBe("https://localhost:5001"); - issuerAddress.ShouldBe("https://localhost:5002"); - } - - [Fact] - public void SafeDivision_ValidInputs_ReturnsCorrectResult() - { - // Arrange - decimal numerator = 10; - decimal denominator = 2; - - // Act - var result = numerator.SafeDivision(denominator); - - // Assert - result.ShouldBe(5); - } - - [Fact] - public void SafeDivision_DivideByZero_ReturnsZero() - { - // Arrange - decimal numerator = 10; - decimal denominator = 0; - - // Act - var result = numerator.SafeDivision(denominator); - - // Assert - result.ShouldBe(0); - } - - [Theory] - [InlineData(-0.1, true, "info-box bg-success")] - [InlineData(0, true, "info-box bg-info")] - [InlineData(0.1, true, "info-box bg-warning")] - [InlineData(0.3, true, "info-box bg-danger")] - [InlineData(0.1, false, "info-box bg-success")] - [InlineData(0, false, "info-box bg-info")] - [InlineData(-0.1, false, "info-box bg-warning")] - [InlineData(-0.3, false, "info-box bg-danger")] - public async Task RenderKpiCardClass_ValidInputs_ReturnsCorrectClass(decimal variance, bool lessIsGood, string expectedClass) - { - // Act - var result = await Helpers.RenderKpiCardClass(variance, lessIsGood); - - // Assert - result.ShouldBe(expectedClass); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/MerchantDetailsTests.cs b/EstateManagementUI.UITests/MerchantDetailsTests.cs deleted file mode 100644 index 3e78a726..00000000 --- a/EstateManagementUI.UITests/MerchantDetailsTests.cs +++ /dev/null @@ -1,344 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Merchant.MerchantDetails; -using EstateManagementUI.Pages.Shared.Components; -using EstateManagementUI.Testing; -using EstateManagementUI.ViewModels; -using EstateManagmentUI.BusinessLogic.Requests; -using Hydro; -using MediatR; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc.Rendering; -using Moq; -using Shouldly; -using SimpleResults; -using System.Reflection; -using Merchant = EstateManagementUI.Pages.Merchant.MerchantDetails.Merchant; - -namespace EstateManagementUI.UITests; - -public class MerchantDetailsTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly Merchant _merchant; - - public MerchantDetailsTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._merchant = new Merchant(this._mediatorMock.Object, this._permissionsServiceMock.Object, "MerchantFunction"); - 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() - { - // Arrange - this._merchant.MerchantId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.MerchantResult); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.ContractsResult); - - // Act - await this._merchant.MountAsync(); - - // Assert - this._merchant.Name.ShouldBe("Test Merchant"); - this._merchant.Reference.ShouldBe("Ref123"); - this._merchant.Address.AddressLine1.ShouldBe("123 Main St"); - this._merchant.Contact.ContactName.ShouldBe("John Doe"); - this._merchant.Operators.ShouldNotBeNull(); - this._merchant.Operators.Count.ShouldBe(1); - this._merchant.Contracts.ShouldNotBeNull(); - this._merchant.Contracts.Count.ShouldBe(1); - this._merchant.Devices.ShouldNotBeNull(); - this._merchant.Devices.Count.ShouldBe(1); - } - - [Fact] - public async Task Save_AddsNewMerchant_WhenMerchantIdIsEmpty() - { - // Arrange - this._merchant.MerchantId = Guid.Empty; - this._merchant.Name = "New 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()); - - // Act - await this._merchant.Save(); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - } - - [Fact] - public async Task Save_CreateFails() - { - // Arrange - this._merchant.MerchantId = Guid.Empty; - this._merchant.Name = "New 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"})); - - // Act - await this._merchant.Save(); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - var events = this._merchant.GetDispatchedEvents(); - events.Count.ShouldBe(1); - events[0].ShouldBeOfType(typeof(ShowMessage)); - } - - [Fact] - public async Task Save_UpdatesMerchant_WhenMerchantIdIsNotEmpty() - { - // 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.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.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); - var events = this._merchant.GetDispatchedEvents(); - events.Count.ShouldBe(1); - 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); - var events = this._merchant.GetDispatchedEvents(); - events.Count.ShouldBe(1); - 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); - var events = this._merchant.GetDispatchedEvents(); - events.Count.ShouldBe(1); - events[0].ShouldBeOfType(); - } - - [Fact] - public async Task RemoveOperator_RemovesOperatorFromMerchant() - { - // Arrange - var merchantId = Guid.NewGuid(); - var operatorId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success()); - - // Act - await this._merchant.RemoveOperator(merchantId, operatorId); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - } - - [Fact] - public async Task RemoveContract_RemovesContractFromMerchant() - { - // Arrange - var merchantId = Guid.NewGuid(); - var contractId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success()); - - // Act - await this._merchant.RemoveContract(merchantId, contractId); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/MerchantTests.cs b/EstateManagementUI.UITests/MerchantTests.cs deleted file mode 100644 index 8cec33fd..00000000 --- a/EstateManagementUI.UITests/MerchantTests.cs +++ /dev/null @@ -1,227 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Merchant.MerchantDetails; -using EstateManagementUI.Testing; -using EstateManagementUI.ViewModels; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.ModelBinding; -using Microsoft.AspNetCore.Mvc.Rendering; -using Microsoft.AspNetCore.Mvc.Routing; -using Microsoft.AspNetCore.Mvc.ViewFeatures; -using Microsoft.Extensions.DependencyInjection; -using Moq; -using Shouldly; -using SimpleResults; -using System.Security.Claims; -using Microsoft.AspNetCore.Routing; -using Merchant = EstateManagementUI.Pages.Merchant.MerchantDetails.Merchant; - -namespace EstateManagementUI.UITests; - -public static class TestHelper { - public static IUrlHelper GetTestUrlHelper() { - Mock urlHelperMock = new Mock(); - - // Example: Mock Url.Action() to return some URL - urlHelperMock - .Setup(u => u.RouteUrl(It.IsAny())) - .Returns("/"); - urlHelperMock.Setup(u => u.ActionContext).Returns(new ActionContext - { - RouteData = new RouteData() - }); - - return urlHelperMock.Object; - } - public static ViewContext GetTestViewContext() { - var httpContext = GetTestHttpContext(); - var viewData = new ViewDataDictionary(new Microsoft.AspNetCore.Mvc.ModelBinding.EmptyModelMetadataProvider(), new ModelStateDictionary()); - var writer = new System.IO.StringWriter(); - - return new ViewContext - { - HttpContext = httpContext, - ViewData = viewData, - Writer = writer - }; - } - public static HttpContext GetTestHttpContext() { - // Arrange - var httpContext = new DefaultHttpContext(); - - // Mock the authentication service - var authenticationServiceMock = new Mock(); - - // Return an authentication ticket with the access token - var authTicket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(new[] - { - new Claim("access_token", "mock-access-token") - }, "Bearer")), - "Bearer" - ); - - authenticationServiceMock - .Setup(a => a.AuthenticateAsync(httpContext, It.IsAny())) - .ReturnsAsync(AuthenticateResult.Success(authTicket)); - - httpContext.RequestServices = new ServiceCollection() - .AddSingleton(authenticationServiceMock.Object) - .BuildServiceProvider(); - - var claims = new[] { new Claim("estateId", "45DD2B9C-C9B1-4CCA-89AC-CE0480FBC804") }; - var identity = new ClaimsIdentity(claims, "Bearer"); - var principal = new ClaimsPrincipal(identity); - httpContext.User = principal; - return httpContext; - } -} - -public class MerchantTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly Merchant _merchant; - - public MerchantTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._merchant = new Merchant(this._mediatorMock.Object, this._permissionsServiceMock.Object, "MerchantFunction"); - this._merchant.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_LoadsMerchant_WhenMerchantIdIsNotEmpty() - { - // Arrange - this._merchant.MerchantId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.MerchantResult); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.ContractsResult); - - // Act - await this._merchant.MountAsync(); - - // Assert - this._merchant.Name.ShouldBe("Test Merchant"); - this._merchant.Reference.ShouldBe("Ref123"); - this._merchant.Address.AddressLine1.ShouldBe("123 Main St"); - this._merchant.Contact.ContactName.ShouldBe("John Doe"); - this._merchant.Operators.ShouldNotBeNull(); - this._merchant.Operators.Count.ShouldBe(1); - this._merchant.Contracts.ShouldNotBeNull(); - this._merchant.Contracts.Count.ShouldBe(1); - this._merchant.Devices.ShouldNotBeNull(); - this._merchant.Devices.Count.ShouldBe(1); - } - - [Fact] - public async Task Save_AddsNewMerchant_WhenMerchantIdIsEmpty() - { - // Arrange - this._merchant.MerchantId = Guid.Empty; - this._merchant.Name = "New 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 = 1; - 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); - } - - [Fact] - public async Task Save_UpdatesMerchant_WhenMerchantIdIsNotEmpty() - { - // 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 = 1; - 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.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.Once); - } - - [Fact] - public async Task RemoveOperator_RemovesOperatorFromMerchant() - { - // Arrange - var merchantId = Guid.NewGuid(); - var operatorId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success()); - - // Act - await this._merchant.RemoveOperator(merchantId, operatorId); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - } - - [Fact] - public async Task RemoveContract_RemovesContractFromMerchant() - { - // Arrange - var merchantId = Guid.NewGuid(); - var contractId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success()); - - // Act - await this._merchant.RemoveContract(merchantId, contractId); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/MerchantsListTests.cs b/EstateManagementUI.UITests/MerchantsListTests.cs deleted file mode 100644 index 658283ac..00000000 --- a/EstateManagementUI.UITests/MerchantsListTests.cs +++ /dev/null @@ -1,246 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Merchant.MerchantsList; -using EstateManagementUI.Testing; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using System.Security.Claims; - -namespace EstateManagementUI.UITests; - -public class MerchantsListTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly MerchantsList _merchantsList; - - public MerchantsListTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._merchantsList = new MerchantsList(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._merchantsList.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_PopulatesMerchants() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.MerchantsResult); - - // Act - await this._merchantsList.MountAsync(); - - // Assert - this._merchantsList.Merchants.ShouldNotBeNull(); - this._merchantsList.Merchants.Count.ShouldBe(2); - this._merchantsList.Merchants[0].Name.ShouldBe("Merchant1"); - this._merchantsList.Merchants[1].Name.ShouldBe("Merchant2"); - } - - [Fact] - public void Add_NavigatesToNewMerchantPage() - { - this._merchantsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - this._merchantsList.Add(); - - // Assert - this._merchantsList.LocationUrl.ShouldNotBeNull(); - this._merchantsList.LocationUrl.ShouldBe("/Merchant/NewMerchant"); - } - - [Fact] - public async Task View_NavigatesToViewMerchantPage() - { - // Arrange - var merchantId = Guid.NewGuid(); - this._merchantsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - await this._merchantsList.View(merchantId); - - // Assert - this._merchantsList.LocationUrl.ShouldNotBeNull(); - this._merchantsList.LocationUrl.ShouldBe("/Merchant/ViewMerchant"); - Guid payloadMerchantId = TestHelpers.GetPropertyValue(this._merchantsList.Payload, "MerchantId"); - payloadMerchantId.ShouldBe(merchantId); - } - - [Fact] - public async Task Edit_NavigatesToEditMerchantPage() - { - // Arrange - var merchantId = Guid.NewGuid(); - this._merchantsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - await this._merchantsList.Edit(merchantId); - - // Assert - this._merchantsList.LocationUrl.ShouldNotBeNull(); - this._merchantsList.LocationUrl.ShouldBe("/Merchant/EditMerchant"); - 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() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.MerchantsResult); - - // Act - await this._merchantsList.Sort(MerchantSorting.Name); - - // Assert - this._merchantsList.Merchants.ShouldNotBeNull(); - this._merchantsList.Merchants.Count.ShouldBe(2); - this._merchantsList.Merchants[0].Name.ShouldBe("Merchant2"); - this._merchantsList.Merchants[1].Name.ShouldBe("Merchant1"); - - // Act - await this._merchantsList.Sort(MerchantSorting.Name); - - this._merchantsList.Merchants[0].Name.ShouldBe("Merchant1"); - this._merchantsList.Merchants[1].Name.ShouldBe("Merchant2"); - } - - [Fact] - public async Task Sort_SortsMerchantsByContact() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.MerchantsResult); - - // Act - await this._merchantsList.Sort(MerchantSorting.Contact); - - // Assert - this._merchantsList.Merchants.ShouldNotBeNull(); - this._merchantsList.Merchants.Count.ShouldBe(2); - this._merchantsList.Merchants[0].ContactName.ShouldBe("Contact1"); - this._merchantsList.Merchants[1].ContactName.ShouldBe("Contact2"); - - // Act - await this._merchantsList.Sort(MerchantSorting.Contact); - - this._merchantsList.Merchants[0].ContactName.ShouldBe("Contact2"); - this._merchantsList.Merchants[1].ContactName.ShouldBe("Contact1"); - } - - [Fact] - public async Task Sort_SortsMerchantsByAddressLine1() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.MerchantsResult); - - // Act - await this._merchantsList.Sort(MerchantSorting.AddressLine1); - - // Assert - this._merchantsList.Merchants.ShouldNotBeNull(); - this._merchantsList.Merchants.Count.ShouldBe(2); - this._merchantsList.Merchants[0].AddressLine1.ShouldBe("AddressLine1"); - this._merchantsList.Merchants[1].AddressLine1.ShouldBe("AddressLine2"); - - // Act - await this._merchantsList.Sort(MerchantSorting.AddressLine1); - - this._merchantsList.Merchants[0].AddressLine1.ShouldBe("AddressLine2"); - this._merchantsList.Merchants[1].AddressLine1.ShouldBe("AddressLine1"); - } - - [Fact] - public async Task Sort_SortsMerchantsByReference() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.MerchantsResult); - - // Act - await this._merchantsList.Sort(MerchantSorting.Reference); - - // Assert - this._merchantsList.Merchants.ShouldNotBeNull(); - this._merchantsList.Merchants.Count.ShouldBe(2); - this._merchantsList.Merchants[0].Reference.ShouldBe("Reference1"); - this._merchantsList.Merchants[1].Reference.ShouldBe("Reference2"); - - // Act - await this._merchantsList.Sort(MerchantSorting.Reference); - - this._merchantsList.Merchants[0].Reference.ShouldBe("Reference2"); - this._merchantsList.Merchants[1].Reference.ShouldBe("Reference1"); - } - - [Fact] - public async Task Sort_SortsMerchantsBySettlementSchedule() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.MerchantsResult); - - // Act - await this._merchantsList.Sort(MerchantSorting.SettlementSchedule); - - // Assert - this._merchantsList.Merchants.ShouldNotBeNull(); - this._merchantsList.Merchants.Count.ShouldBe(2); - this._merchantsList.Merchants[0].SettlementSchedule.ShouldBe("Immediate"); - this._merchantsList.Merchants[1].SettlementSchedule.ShouldBe("Monthly"); - - // Act - await this._merchantsList.Sort(MerchantSorting.SettlementSchedule); - - this._merchantsList.Merchants[0].SettlementSchedule.ShouldBe("Monthly"); - this._merchantsList.Merchants[1].SettlementSchedule.ShouldBe("Immediate"); - } - - [Fact] - public async Task Sort_SortsMerchantsByTown() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.MerchantsResult); - - // Act - await this._merchantsList.Sort(MerchantSorting.Town); - - // Assert - this._merchantsList.Merchants.ShouldNotBeNull(); - this._merchantsList.Merchants.Count.ShouldBe(2); - this._merchantsList.Merchants[0].Town.ShouldBe("Town1"); - this._merchantsList.Merchants[1].Town.ShouldBe("Town2"); - - // Act - await this._merchantsList.Sort(MerchantSorting.Town); - - this._merchantsList.Merchants[0].Town.ShouldBe("Town2"); - this._merchantsList.Merchants[1].Town.ShouldBe("Town1"); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/NavigationServiceTests.cs b/EstateManagementUI.UITests/NavigationServiceTests.cs deleted file mode 100644 index 32067565..00000000 --- a/EstateManagementUI.UITests/NavigationServiceTests.cs +++ /dev/null @@ -1,133 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Services; -using Microsoft.AspNetCore.Mvc.Rendering; -using Microsoft.AspNetCore.Routing; -using Moq; -using Shared.Logger; -using Shouldly; -using SimpleResults; - -namespace EstateManagementUI.UITests; - -public class NavigationServiceTests -{ - private readonly Mock PermissionsServiceMock; - private readonly NavigationService NavigationService; - - public NavigationServiceTests() { - Logger.Initialise(new NullLogger()); - this.PermissionsServiceMock = new Mock(); - this.NavigationService = new NavigationService(this.PermissionsServiceMock.Object); - } - - [Fact] - public void GetCurrentPageClass_PageStartsWithPrefix_ReturnsActiveClass() - { - // Arrange - var routeData = new RouteData(); - routeData.Values["page"] = "/Dashboard"; - var viewContext = new ViewContext { RouteData = routeData }; - - // Act - var result = this.NavigationService.GetCurrentPageClass(viewContext, "Dashboard"); - - // Assert - result.ShouldBe("btn btn-sm btn-neutral btn-active"); - } - - [Fact] - public void GetCurrentPageClass_PageDoesNotStartWithPrefix_ReturnsGhostClass() - { - // Arrange - var routeData = new RouteData(); - routeData.Values["page"] = "/Home"; - var viewContext = new ViewContext { RouteData = routeData }; - - // Act - var result = this.NavigationService.GetCurrentPageClass(viewContext, "Dashboard"); - - // Assert - result.ShouldBe("btn btn-sm btn-ghost"); - } - - [Fact] - public void GetCurrentPageClass_PageIsNull_ReturnsGhostClass() - { - // Arrange - var routeData = new RouteData(); - routeData.Values["page"] = null; - var viewContext = new ViewContext { RouteData = routeData }; - - // Act - var result = this.NavigationService.GetCurrentPageClass(viewContext, "Dashboard"); - - // Assert - result.ShouldBe("btn btn-sm btn-ghost"); - } - - [Fact] - public async Task RenderItem_PermissionGranted_ReturnsHtmlString() - { - // Arrange - string userName = "testUser"; - string title = "Dashboard"; - string name = "Dashboard"; - string id = "dashboardLink"; - string pageName = "Index"; - this.PermissionsServiceMock.Setup(p => p.DoIHavePermissions(userName, name)) - .ReturnsAsync(Result.Success()); - - // Act - var result = await this.NavigationService.RenderItem(userName, title, name, id, pageName); - - // Assert - result.ShouldContain("nav-link"); - result.ShouldContain("fa-solid fa-gauge-high"); - result.ShouldContain("Dashboard"); - } - - [Fact] - public async Task RenderItem_PermissionDenied_ReturnsEmptyString() - { - // Arrange - string userName = "testUser"; - string title = "Dashboard"; - string name = "Dashboard"; - string id = "dashboardLink"; - string pageName = "Index"; - this.PermissionsServiceMock.Setup(p => p.DoIHavePermissions(userName, name)) - .ReturnsAsync(Result.Failure("Permission denied")); - - // Act - var result = await this.NavigationService.RenderItem(userName, title, name, id, pageName); - - // Assert - result.ShouldBeEmpty(); - } - - [Theory] - [InlineData("Estate", "fa-solid fa-network-wired")] - [InlineData("Merchant", "fa-solid fa-store")] - [InlineData("Contract", "fa-solid fa-file-contract")] - [InlineData("Operator", "fa-solid fa-building-columns")] - [InlineData("Reporting", "fa-solid fa-chart-simple")] - [InlineData("File Processing", "fa-solid fa-file-csv")] - public async Task RenderItem_CorrectIconReturned(String name, String expectedIcon) - { - // Arrange - string userName = "testUser"; - string title = "Dashboard"; - string id = "dashboardLink"; - string pageName = "Index"; - this.PermissionsServiceMock.Setup(p => p.DoIHavePermissions(userName, name)) - .ReturnsAsync(Result.Success()); - - // Act - var result = await this.NavigationService.RenderItem(userName, title, name, id, pageName); - - // Assert - result.ShouldContain(expectedIcon); - } - - -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/OperatorListTests.cs b/EstateManagementUI.UITests/OperatorListTests.cs deleted file mode 100644 index 77ce561b..00000000 --- a/EstateManagementUI.UITests/OperatorListTests.cs +++ /dev/null @@ -1,44 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Estate.OperatorList; -using EstateManagementUI.Testing; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using System.Security.Claims; - -namespace EstateManagementUI.UITests; - -public class OperatorListTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly OperatorList _operatorList; - - public OperatorListTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._operatorList = new OperatorList(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._operatorList.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_PopulatesOperators() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.EstateResult); - - // Act - await this._operatorList.MountAsync(); - - // Assert - this._operatorList.Operators.ShouldNotBeNull(); - this._operatorList.Operators.Count.ShouldBe(2); - this._operatorList.Operators[0].Name.ShouldBe("Operator1"); - this._operatorList.Operators[1].Name.ShouldBe("Operator2"); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/OperatorTests.cs b/EstateManagementUI.UITests/OperatorTests.cs deleted file mode 100644 index 0dd3c3f7..00000000 --- a/EstateManagementUI.UITests/OperatorTests.cs +++ /dev/null @@ -1,144 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Operator; -using EstateManagementUI.Testing; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using SimpleResults; -using System.Security.Claims; -using Operator = EstateManagementUI.Pages.Operator.OperatorDialogs.Operator; -using ShowMessage = EstateManagementUI.Pages.Shared.Components.ShowMessage; - -namespace EstateManagementUI.UITests; - -public class OperatorTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly Operator _operator; - - public OperatorTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._operator = new Operator(this._mediatorMock.Object, this._permissionsServiceMock.Object, "OperatorFunction"); - this._operator.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_LoadsOperator_WhenOperatorIdIsNotEmpty() - { - // Arrange - this._operator.OperatorId = Guid.NewGuid(); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.OperatorResult); - - // Act - await this._operator.MountAsync(); - - // Assert - this._operator.Name.ShouldBe("Test Operator"); - this._operator.RequireCustomMerchantNumber.ShouldBeTrue(); - this._operator.RequireCustomTerminalNumber.ShouldBeFalse(); - } - - [Fact] - public async Task Close_SetsLocationUrl() - { - this._operator.Url = TestHelper.GetTestUrlHelper(); - - // Act - this._operator.Close(); - - // Assert - this._operator.LocationUrl.ShouldBe("/Operator/Index"); - this._operator.Payload.ShouldBeNull(); - } - - [Fact] - public async Task Save_AddsNewOperator_WhenOperatorIdIsEmpty() - { - // Arrange - this._operator.OperatorId = Guid.Empty; - this._operator.Name = "New Operator"; - this._operator.RequireCustomMerchantNumber = true; - this._operator.RequireCustomTerminalNumber = false; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success()); - - // Act - await this._operator.Save(); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - var events = this._operator.GetDispatchedEvents(); - events.Count.ShouldBe(1); - events[0].ShouldBeOfType(); - } - - [Fact] - public async Task Save_AddOperatorFailed_MessageShow() - { - // Arrange - this._operator.OperatorId = Guid.Empty; - this._operator.Name = "New Operator"; - this._operator.RequireCustomMerchantNumber = true; - this._operator.RequireCustomTerminalNumber = false; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Failure(new List(){"Failed"})); - - // Act - await this._operator.Save(); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - var events = this._operator.GetDispatchedEvents(); - events.Count.ShouldBe(1); - events[0].ShouldBeOfType(); - } - - [Fact] - public async Task Save_UpdatesOperator_WhenOperatorIdIsNotEmpty() - { - // Arrange - this._operator.OperatorId = Guid.NewGuid(); - this._operator.Name = "Updated Operator"; - this._operator.RequireCustomMerchantNumber = true; - this._operator.RequireCustomTerminalNumber = false; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success()); - - // Act - await this._operator.Save(); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - var events = this._operator.GetDispatchedEvents(); - events.Count.ShouldBe(1); - events[0].ShouldBeOfType(); - } - - [Fact] - public async Task Save_UpdateOperatorFailed_MessageShow() - { - // Arrange - this._operator.OperatorId = Guid.NewGuid(); - this._operator.Name = "Updated Operator"; - this._operator.RequireCustomMerchantNumber = true; - this._operator.RequireCustomTerminalNumber = false; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Failure(new List() { "Failed" })); - - // Act - await this._operator.Save(); - - // Assert - this._mediatorMock.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - var events = this._operator.GetDispatchedEvents(); - events.Count.ShouldBe(1); - events[0].ShouldBeOfType(); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/OperatorsListTests.cs b/EstateManagementUI.UITests/OperatorsListTests.cs deleted file mode 100644 index d9b1f996..00000000 --- a/EstateManagementUI.UITests/OperatorsListTests.cs +++ /dev/null @@ -1,159 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Operator.OperatorsList; -using EstateManagementUI.Testing; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using System.Security.Claims; - -namespace EstateManagementUI.UITests; - -public class OperatorsListTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly OperatorsList _operatorsList; - - public OperatorsListTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._operatorsList = new OperatorsList(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._operatorsList.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_PopulatesOperators() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.OperatorsResult); - - // Act - await this._operatorsList.MountAsync(); - - // Assert - this._operatorsList.Operators.ShouldNotBeNull(); - this._operatorsList.Operators.Count.ShouldBe(2); - this._operatorsList.Operators[0].Name.ShouldBe("Operator1"); - this._operatorsList.Operators[1].Name.ShouldBe("Operator2"); - } - - [Fact] - public void Add_NavigatesToNewOperatorPage() - { - this._operatorsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - this._operatorsList.Add(); - - // Assert - this._operatorsList.LocationUrl.ShouldNotBeNull(); - this._operatorsList.LocationUrl.ShouldBe("/Operator/NewOperator"); - } - - [Fact] - public async Task View_NavigatesToViewOperatorPage() - { - // Arrange - var operatorId = Guid.NewGuid(); - this._operatorsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - await this._operatorsList.View(operatorId); - - // Assert - this._operatorsList.LocationUrl.ShouldNotBeNull(); - this._operatorsList.LocationUrl.ShouldBe("/Operator/ViewOperator"); - Guid payloadOperatorId = TestHelpers.GetPropertyValue(this._operatorsList.Payload, "OperatorId"); - payloadOperatorId.ShouldBe(operatorId); - } - - [Fact] - public async Task Edit_NavigatesToEditOperatorPage() - { - // Arrange - var operatorId = Guid.NewGuid(); - this._operatorsList.Url = TestHelper.GetTestUrlHelper(); - - // Act - await this._operatorsList.Edit(operatorId); - - this._operatorsList.LocationUrl.ShouldNotBeNull(); - this._operatorsList.LocationUrl.ShouldBe("/Operator/EditOperator"); - Guid payloadOperatorId = TestHelpers.GetPropertyValue(this._operatorsList.Payload, "OperatorId"); - payloadOperatorId.ShouldBe(operatorId); - } - - [Fact] - public async Task Sort_SortsOperatorsByName() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.OperatorsResult); - - // Act - await this._operatorsList.Sort(OperatorSorting.Name); - - // Assert - this._operatorsList.Operators.ShouldNotBeNull(); - this._operatorsList.Operators.Count.ShouldBe(2); - this._operatorsList.Operators[0].Name.ShouldBe("Operator2"); - this._operatorsList.Operators[1].Name.ShouldBe("Operator1"); - - // Act - await this._operatorsList.Sort(OperatorSorting.Name); - - this._operatorsList.Operators[0].Name.ShouldBe("Operator1"); - this._operatorsList.Operators[1].Name.ShouldBe("Operator2"); - } - - [Fact] - public async Task Sort_SortsOperatorsByRequireCustomMerchantNumber() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.OperatorsResult); - - // Act - await this._operatorsList.Sort(OperatorSorting.RequireCustomMerchantNumber); - - // Assert - this._operatorsList.Operators.ShouldNotBeNull(); - this._operatorsList.Operators.Count.ShouldBe(2); - this._operatorsList.Operators[0].Name.ShouldBe("Operator2"); - this._operatorsList.Operators[1].Name.ShouldBe("Operator1"); - - // Act - await this._operatorsList.Sort(OperatorSorting.RequireCustomMerchantNumber); - - this._operatorsList.Operators[0].Name.ShouldBe("Operator1"); - this._operatorsList.Operators[1].Name.ShouldBe("Operator2"); - } - - [Fact] - public async Task Sort_SortsOperatorsByRequireCustomTerminalNumber() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.OperatorsResult); - - // Act - await this._operatorsList.Sort(OperatorSorting.RequireCustomTerminalNumber); - - // Assert - this._operatorsList.Operators.ShouldNotBeNull(); - this._operatorsList.Operators.Count.ShouldBe(2); - this._operatorsList.Operators[0].Name.ShouldBe("Operator1"); - this._operatorsList.Operators[1].Name.ShouldBe("Operator2"); - - // Act - await this._operatorsList.Sort(OperatorSorting.RequireCustomTerminalNumber); - - this._operatorsList.Operators[0].Name.ShouldBe("Operator2"); - this._operatorsList.Operators[1].Name.ShouldBe("Operator1"); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/ProfileDropdownTests.cs b/EstateManagementUI.UITests/ProfileDropdownTests.cs deleted file mode 100644 index 21196ad5..00000000 --- a/EstateManagementUI.UITests/ProfileDropdownTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System.Security.Claims; -using EstateManagementUI.Pages.Shared.Profile; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; - -namespace EstateManagementUI.UITests; - -public class ProfileDropdownTests -{ - private readonly Mock _httpContextAccessorMock; - private ProfileDropdown _profileDropdown; - private readonly Mock _serviceProviderMock; - private readonly Mock _authenticationServiceMock; - private readonly Mock httpContextMock; - public ProfileDropdownTests() - { - this._httpContextAccessorMock = new Mock(); - this._serviceProviderMock = new Mock(); - this._authenticationServiceMock = new Mock(); - this.httpContextMock = new Mock(); - this._serviceProviderMock.Setup(sp => sp.GetService(typeof(IAuthenticationService))) - .Returns(this._authenticationServiceMock.Object); - - this.httpContextMock.Setup(c => c.RequestServices) - .Returns(this._serviceProviderMock.Object); - ClaimsPrincipal principal = new(new ClaimsIdentity(new[] - { - new Claim("given_name", "Test"), - new Claim("family_name", "User"), - new Claim("registration_date", new DateTime(2024,12,27).ToString("yyyy-MM-dd HH:mm:ss.fff")) - })); - this.httpContextMock.Setup(c => c.User) - .Returns(principal); - - this._httpContextAccessorMock.Setup(x => x.HttpContext) - .Returns(this.httpContextMock.Object); - - this._profileDropdown = new ProfileDropdown(this._httpContextAccessorMock.Object); - } - - [Fact] - public async Task ProfileDropdown_SignOut_CallsSignOutAsync() - { - // Act - await this._profileDropdown.SignOut(); - - // Assert - this._authenticationServiceMock.Verify(a => a.SignOutAsync(It.IsAny(), "oidc", null), Times.Once); - this._authenticationServiceMock.Verify(a => a.SignOutAsync(It.IsAny(), "Cookies", null), Times.Once); - } - - [Fact] - public async Task ProfileDropdown_UserFullName_IsExpectedValue() - { - // Act - var userFullname = this._profileDropdown.UserFullName; - userFullname.ShouldBe("Test User"); - } - - [Fact(Skip = "Date form at issues")] - public async Task ProfileDropdown_RegistrationText_IsExpectedValue() - { - // Act - var registrationText = this._profileDropdown.RegistrationText; - registrationText.ShouldBe("Registered on 27/12/2024"); - } - - [Fact] - public async Task ProfileDropdown_NoRegistrationDate_IsExpectedValue() - { - ClaimsPrincipal principal = new(new ClaimsIdentity(new[] - { - new Claim("given_name", "Test"), - new Claim("family_name", "User"), - //new Claim("registration_date", null) - })); - this.httpContextMock.Setup(c => c.User) - .Returns(principal); - - this._httpContextAccessorMock.Setup(x => x.HttpContext) - .Returns(this.httpContextMock.Object); - - this._profileDropdown = new ProfileDropdown(this._httpContextAccessorMock.Object); - - // Act - var registrationText = this._profileDropdown.RegistrationText; - registrationText.ShouldBe("Registered on Unknown"); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/SettlementAnalysisTests.cs b/EstateManagementUI.UITests/SettlementAnalysisTests.cs deleted file mode 100644 index 9c18b332..00000000 --- a/EstateManagementUI.UITests/SettlementAnalysisTests.cs +++ /dev/null @@ -1,132 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Reporting.SettlementAnalysis; -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; - -namespace EstateManagementUI.UITests; - -public class SettlementAnalysisTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly SettlementAnalysis _settlementAnalysis; - - public SettlementAnalysisTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._settlementAnalysis = new SettlementAnalysis(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._settlementAnalysis.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_PopulatesComparisonDate() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.ComparisonDates1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysSettlement1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.LastSettlement1)); - // Act - await this._settlementAnalysis.MountAsync(); - - // Assert - this._settlementAnalysis.ComparisonDate.ShouldNotBeNull(); - this._settlementAnalysis.ComparisonDate.Dates.ShouldNotBeEmpty(); - this._settlementAnalysis.ComparisonDate.Dates[0].Text.ShouldBe("2023-01-01"); - } - - [Fact] - public async Task Query_PopulatesTodaysSettlement() - { - // Arrange - this._settlementAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysSettlement1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.LastSettlement1)); - - - // Act - await this._settlementAnalysis.Query(); - - // Assert - this._settlementAnalysis.TodaysSettlement.ShouldNotBeNull(); - this._settlementAnalysis.TodaysSettlement.TodaysSettlementValue.ShouldBe(1000); - this._settlementAnalysis.TodaysSettlement.ComparisonSettlementValue.ShouldBe(800); - - this._settlementAnalysis.LastSettlement.ShouldNotBeNull(); - this._settlementAnalysis.LastSettlement.SettlementDate.ShouldBe(DateTime.Parse("2023-01-01")); - this._settlementAnalysis.LastSettlement.SettlementSalesValue.ShouldBe(1500); - this._settlementAnalysis.LastSettlement.SettlementFeesValue.ShouldBe(100); - } - - [Fact] - public async Task Query_GetTodaysSettlementQueryFailed() - { - // Arrange - this._settlementAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - 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.LastSettlement1)); - - - // Act - await this._settlementAnalysis.Query(); - - // Assert - this._settlementAnalysis.TodaysSettlement.ShouldNotBeNull(); - this._settlementAnalysis.TodaysSettlement.TodaysSettlementValue.ShouldBe(0); - this._settlementAnalysis.TodaysSettlement.ComparisonSettlementValue.ShouldBe(0); - - this._settlementAnalysis.LastSettlement.ShouldNotBeNull(); - this._settlementAnalysis.LastSettlement.SettlementDate.ShouldBe(DateTime.Parse("2023-01-01")); - this._settlementAnalysis.LastSettlement.SettlementSalesValue.ShouldBe(1500); - this._settlementAnalysis.LastSettlement.SettlementFeesValue.ShouldBe(100); - } - - [Fact] - public async Task Query_GetLastSettlementQueryFailed() - { - // Arrange - this._settlementAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysSettlement1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Failure()); - - - // Act - await this._settlementAnalysis.Query(); - - // Assert - this._settlementAnalysis.TodaysSettlement.ShouldNotBeNull(); - this._settlementAnalysis.TodaysSettlement.TodaysSettlementValue.ShouldBe(1000); - this._settlementAnalysis.TodaysSettlement.ComparisonSettlementValue.ShouldBe(800); - - this._settlementAnalysis.LastSettlement.ShouldNotBeNull(); - this._settlementAnalysis.LastSettlement.SettlementDate.ShouldBe(DateTime.MinValue); - this._settlementAnalysis.LastSettlement.SettlementSalesValue.ShouldBe(0); - this._settlementAnalysis.LastSettlement.SettlementFeesValue.ShouldBe(0); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/TestHelpers.cs b/EstateManagementUI.UITests/TestHelpers.cs deleted file mode 100644 index e6344f66..00000000 --- a/EstateManagementUI.UITests/TestHelpers.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace EstateManagementUI.UITests; - -public static class TestHelpers { - public static T GetPropertyValue(object obj, string propertyName) - { - if (obj == null) - throw new ArgumentNullException(nameof(obj)); - - var type = obj.GetType(); - var property = type.GetProperty(propertyName); - - if (property == null) - throw new ArgumentException($"Property '{propertyName}' not found on type '{type.FullName}'."); - - var value = property.GetValue(obj); - - if (value == null) - throw new InvalidOperationException($"Property '{propertyName}' is null."); - - if (value is not T) - throw new InvalidCastException($"Property '{propertyName}' is not of type '{typeof(T).FullName}'."); - - return (T)value; - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/TransactionAnalysisTests.cs b/EstateManagementUI.UITests/TransactionAnalysisTests.cs deleted file mode 100644 index 14786686..00000000 --- a/EstateManagementUI.UITests/TransactionAnalysisTests.cs +++ /dev/null @@ -1,433 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Reporting.TransactionAnalysis; -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; - -namespace EstateManagementUI.UITests; - -public class TransactionAnalysisTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly TransactionAnalysis _transactionAnalysis; - - public TransactionAnalysisTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._transactionAnalysis = new TransactionAnalysis(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._transactionAnalysis.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_PopulatesComparisonDate() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.ComparisonDates1)); - this._transactionAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysSales1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.MerchantKpi1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomMerchants1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomOperators1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomProducts1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysFailedSales1)); - // Act - await this._transactionAnalysis.MountAsync(); - - // Assert - this._transactionAnalysis.ComparisonDate.ShouldNotBeNull(); - this._transactionAnalysis.ComparisonDate.Dates.ShouldNotBeEmpty(); - this._transactionAnalysis.ComparisonDate.Dates[0].Text.ShouldBe("2023-01-01"); - } - - [Fact] - public async Task Query_AllQueriesSuccessful() - { - // Arrange - this._transactionAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysSales1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.MerchantKpi1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomMerchants1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomOperators1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomProducts1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysFailedSales1)); - // Act - await this._transactionAnalysis.Query(); - - // Assert - this._transactionAnalysis.TodaysSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysSales.TodaysSalesValue.ShouldBe(100); - this._transactionAnalysis.TodaysSales.ComparisonSalesValue.ShouldBe(80); - - // Assert - this._transactionAnalysis.MerchantKpi.ShouldNotBeNull(); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleInLast7Days.ShouldBe(5); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleToday.ShouldBe(3); - this._transactionAnalysis.MerchantKpi.MerchantsWithSaleInLastHour.ShouldBe(2); - - this._transactionAnalysis.TopBottomMerchants.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomMerchants.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomMerchants[0].MerchantName.ShouldBe("Merchant1"); - this._transactionAnalysis.TopBottomMerchants[0].SalesValue.ShouldBe(50); - - this._transactionAnalysis.TopBottomOperators.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomOperators.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomOperators[0].OperatorName.ShouldBe("Operator1"); - this._transactionAnalysis.TopBottomOperators[0].SalesValue.ShouldBe(40); - - this._transactionAnalysis.TopBottomProducts.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomProducts.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomProducts[0].ProductName.ShouldBe("Product1"); - this._transactionAnalysis.TopBottomProducts[0].SalesValue.ShouldBe(60); - - this._transactionAnalysis.TodaysFailedSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysFailedSales.TodaysSalesValue.ShouldBe(70); - this._transactionAnalysis.TodaysFailedSales.ComparisonSalesValue.ShouldBe(50); - } - - [Fact] - public async Task Query_GetTodaysSalesQueryFailed() - { - // Arrange - this._transactionAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - 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.MerchantKpi1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomMerchants1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomOperators1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomProducts1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysFailedSales1)); - // Act - await this._transactionAnalysis.Query(); - - // Assert - this._transactionAnalysis.TodaysSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysSales.ComparisonLabel.ShouldBeNull(); - this._transactionAnalysis.TodaysSales.Variance.ShouldBe(0); - this._transactionAnalysis.TodaysSales.ComparisonSalesValue.ShouldBe(0); - this._transactionAnalysis.TodaysSales.TodaysSalesValue.ShouldBe(0); - - // Assert - this._transactionAnalysis.MerchantKpi.ShouldNotBeNull(); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleInLast7Days.ShouldBe(5); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleToday.ShouldBe(3); - this._transactionAnalysis.MerchantKpi.MerchantsWithSaleInLastHour.ShouldBe(2); - - this._transactionAnalysis.TopBottomMerchants.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomMerchants.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomMerchants[0].MerchantName.ShouldBe("Merchant1"); - this._transactionAnalysis.TopBottomMerchants[0].SalesValue.ShouldBe(50); - - this._transactionAnalysis.TopBottomOperators.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomOperators.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomOperators[0].OperatorName.ShouldBe("Operator1"); - this._transactionAnalysis.TopBottomOperators[0].SalesValue.ShouldBe(40); - - this._transactionAnalysis.TopBottomProducts.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomProducts.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomProducts[0].ProductName.ShouldBe("Product1"); - this._transactionAnalysis.TopBottomProducts[0].SalesValue.ShouldBe(60); - - this._transactionAnalysis.TodaysFailedSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysFailedSales.TodaysSalesValue.ShouldBe(70); - this._transactionAnalysis.TodaysFailedSales.ComparisonSalesValue.ShouldBe(50); - } - - [Fact] - public async Task Query_GetMerchantKpiQueryFailed() - { - // Arrange - this._transactionAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysSales1)); - 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.BottomMerchants1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomOperators1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomProducts1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysFailedSales1)); - // Act - await this._transactionAnalysis.Query(); - - // Assert - this._transactionAnalysis.TodaysSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysSales.TodaysSalesValue.ShouldBe(100); - this._transactionAnalysis.TodaysSales.ComparisonSalesValue.ShouldBe(80); - - // Assert - this._transactionAnalysis.MerchantKpi.ShouldNotBeNull(); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleInLast7Days.ShouldBe(0); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleToday.ShouldBe(0); - this._transactionAnalysis.MerchantKpi.MerchantsWithSaleInLastHour.ShouldBe(0); - - this._transactionAnalysis.TopBottomMerchants.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomMerchants.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomMerchants[0].MerchantName.ShouldBe("Merchant1"); - this._transactionAnalysis.TopBottomMerchants[0].SalesValue.ShouldBe(50); - - this._transactionAnalysis.TopBottomOperators.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomOperators.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomOperators[0].OperatorName.ShouldBe("Operator1"); - this._transactionAnalysis.TopBottomOperators[0].SalesValue.ShouldBe(40); - - this._transactionAnalysis.TopBottomProducts.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomProducts.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomProducts[0].ProductName.ShouldBe("Product1"); - this._transactionAnalysis.TopBottomProducts[0].SalesValue.ShouldBe(60); - - this._transactionAnalysis.TodaysFailedSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysFailedSales.TodaysSalesValue.ShouldBe(70); - this._transactionAnalysis.TodaysFailedSales.ComparisonSalesValue.ShouldBe(50); - } - - [Fact] - public async Task Query_GetBottomMerchantDataQueryFailed() - { - // Arrange - this._transactionAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysSales1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.MerchantKpi1)); - 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.BottomOperators1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomProducts1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysFailedSales1)); - // Act - await this._transactionAnalysis.Query(); - - // Assert - this._transactionAnalysis.TodaysSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysSales.TodaysSalesValue.ShouldBe(100); - this._transactionAnalysis.TodaysSales.ComparisonSalesValue.ShouldBe(80); - - // Assert - this._transactionAnalysis.MerchantKpi.ShouldNotBeNull(); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleInLast7Days.ShouldBe(5); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleToday.ShouldBe(3); - this._transactionAnalysis.MerchantKpi.MerchantsWithSaleInLastHour.ShouldBe(2); - - this._transactionAnalysis.TopBottomMerchants.ShouldBe(new List()); - - this._transactionAnalysis.TopBottomOperators.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomOperators.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomOperators[0].OperatorName.ShouldBe("Operator1"); - this._transactionAnalysis.TopBottomOperators[0].SalesValue.ShouldBe(40); - - this._transactionAnalysis.TopBottomProducts.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomProducts.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomProducts[0].ProductName.ShouldBe("Product1"); - this._transactionAnalysis.TopBottomProducts[0].SalesValue.ShouldBe(60); - - this._transactionAnalysis.TodaysFailedSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysFailedSales.TodaysSalesValue.ShouldBe(70); - this._transactionAnalysis.TodaysFailedSales.ComparisonSalesValue.ShouldBe(50); - } - - [Fact] - public async Task Query_GetBottomOperatorDataQueryFailed() - { - // Arrange - this._transactionAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysSales1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.MerchantKpi1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomMerchants1)); - 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.BottomProducts1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysFailedSales1)); - // Act - await this._transactionAnalysis.Query(); - - // Assert - this._transactionAnalysis.TodaysSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysSales.TodaysSalesValue.ShouldBe(100); - this._transactionAnalysis.TodaysSales.ComparisonSalesValue.ShouldBe(80); - - // Assert - this._transactionAnalysis.MerchantKpi.ShouldNotBeNull(); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleInLast7Days.ShouldBe(5); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleToday.ShouldBe(3); - this._transactionAnalysis.MerchantKpi.MerchantsWithSaleInLastHour.ShouldBe(2); - - this._transactionAnalysis.TopBottomMerchants.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomMerchants.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomMerchants[0].MerchantName.ShouldBe("Merchant1"); - this._transactionAnalysis.TopBottomMerchants[0].SalesValue.ShouldBe(50); - - this._transactionAnalysis.TopBottomOperators.ShouldBe(new List()); - - this._transactionAnalysis.TopBottomProducts.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomProducts.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomProducts[0].ProductName.ShouldBe("Product1"); - this._transactionAnalysis.TopBottomProducts[0].SalesValue.ShouldBe(60); - - this._transactionAnalysis.TodaysFailedSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysFailedSales.TodaysSalesValue.ShouldBe(70); - this._transactionAnalysis.TodaysFailedSales.ComparisonSalesValue.ShouldBe(50); - } - - [Fact] - public async Task Query_GetBottomProductDataQueryFailed() - { - // Arrange - this._transactionAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysSales1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.MerchantKpi1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomMerchants1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomOperators1)); - 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.TodaysFailedSales1)); - // Act - await this._transactionAnalysis.Query(); - - // Assert - this._transactionAnalysis.TodaysSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysSales.TodaysSalesValue.ShouldBe(100); - this._transactionAnalysis.TodaysSales.ComparisonSalesValue.ShouldBe(80); - - // Assert - this._transactionAnalysis.MerchantKpi.ShouldNotBeNull(); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleInLast7Days.ShouldBe(5); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleToday.ShouldBe(3); - this._transactionAnalysis.MerchantKpi.MerchantsWithSaleInLastHour.ShouldBe(2); - - this._transactionAnalysis.TopBottomMerchants.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomMerchants.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomMerchants[0].MerchantName.ShouldBe("Merchant1"); - this._transactionAnalysis.TopBottomMerchants[0].SalesValue.ShouldBe(50); - - this._transactionAnalysis.TopBottomOperators.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomOperators.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomOperators[0].OperatorName.ShouldBe("Operator1"); - this._transactionAnalysis.TopBottomOperators[0].SalesValue.ShouldBe(40); - - this._transactionAnalysis.TopBottomProducts.ShouldBe(new List()); - - this._transactionAnalysis.TodaysFailedSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysFailedSales.TodaysSalesValue.ShouldBe(70); - this._transactionAnalysis.TodaysFailedSales.ComparisonSalesValue.ShouldBe(50); - } - - [Fact] - public async Task Query_GetTodaysFailedSalesQueryFailed() - { - // Arrange - this._transactionAnalysis.ComparisonDate = new ComparisonDateListModel - { - SelectedDate = DateTime.Parse("2023-01-01") - }; - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.TodaysSales1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.MerchantKpi1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomMerchants1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomOperators1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.BottomProducts1)); - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Failure()); - // Act - await this._transactionAnalysis.Query(); - - // Assert - this._transactionAnalysis.TodaysSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysSales.TodaysSalesValue.ShouldBe(100); - this._transactionAnalysis.TodaysSales.ComparisonSalesValue.ShouldBe(80); - - // Assert - this._transactionAnalysis.MerchantKpi.ShouldNotBeNull(); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleInLast7Days.ShouldBe(5); - this._transactionAnalysis.MerchantKpi.MerchantsWithNoSaleToday.ShouldBe(3); - this._transactionAnalysis.MerchantKpi.MerchantsWithSaleInLastHour.ShouldBe(2); - - this._transactionAnalysis.TopBottomMerchants.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomMerchants.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomMerchants[0].MerchantName.ShouldBe("Merchant1"); - this._transactionAnalysis.TopBottomMerchants[0].SalesValue.ShouldBe(50); - - this._transactionAnalysis.TopBottomOperators.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomOperators.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomOperators[0].OperatorName.ShouldBe("Operator1"); - this._transactionAnalysis.TopBottomOperators[0].SalesValue.ShouldBe(40); - - this._transactionAnalysis.TopBottomProducts.ShouldNotBeNull(); - this._transactionAnalysis.TopBottomProducts.Count.ShouldBe(2); - this._transactionAnalysis.TopBottomProducts[0].ProductName.ShouldBe("Product1"); - this._transactionAnalysis.TopBottomProducts[0].SalesValue.ShouldBe(60); - - this._transactionAnalysis.TodaysFailedSales.ShouldNotBeNull(); - this._transactionAnalysis.TodaysFailedSales.ComparisonLabel.ShouldBeNull(); - this._transactionAnalysis.TodaysFailedSales.TodaysSalesValue.ShouldBe(0); - this._transactionAnalysis.TodaysFailedSales.ComparisonSalesValue.ShouldBe(0); - this._transactionAnalysis.TodaysFailedSales.Variance.ShouldBe(0); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/UsersListTests.cs b/EstateManagementUI.UITests/UsersListTests.cs deleted file mode 100644 index 49498aa3..00000000 --- a/EstateManagementUI.UITests/UsersListTests.cs +++ /dev/null @@ -1,44 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Estate.UsersList; -using EstateManagementUI.Testing; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using System.Security.Claims; - -namespace EstateManagementUI.UITests; - -public class UsersListTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly UsersList _usersList; - - public UsersListTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._usersList = new UsersList(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._usersList.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_PopulatesUsers() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.EstateResult); - - // Act - await this._usersList.MountAsync(); - - // Assert - this._usersList.Users.ShouldNotBeNull(); - this._usersList.Users.Count.ShouldBe(2); - this._usersList.Users[0].EmailAddress.ShouldBe("user1@example.com"); - this._usersList.Users[1].EmailAddress.ShouldBe("user2@example.com"); - } -} \ No newline at end of file diff --git a/EstateManagementUI.UITests/ViewEstateTests.cs b/EstateManagementUI.UITests/ViewEstateTests.cs deleted file mode 100644 index 4139d191..00000000 --- a/EstateManagementUI.UITests/ViewEstateTests.cs +++ /dev/null @@ -1,45 +0,0 @@ -using EstateManagementUI.BusinessLogic.PermissionService; -using EstateManagementUI.Pages.Estate.ViewEstate; -using EstateManagementUI.Testing; -using EstateManagmentUI.BusinessLogic.Requests; -using MediatR; -using Microsoft.AspNetCore.Http; -using Moq; -using Shouldly; -using System.Security.Claims; - -namespace EstateManagementUI.UITests; - -public class ViewEstateTests -{ - private readonly Mock _mediatorMock; - private readonly Mock _permissionsServiceMock; - private readonly ViewEstate _viewEstate; - - public ViewEstateTests() - { - this._mediatorMock = new Mock(); - this._permissionsServiceMock = new Mock(); - - this._viewEstate = new ViewEstate(this._mediatorMock.Object, this._permissionsServiceMock.Object); - this._viewEstate.ViewContext = TestHelper.GetTestViewContext(); - } - - [Fact] - public async Task MountAsync_LoadsEstate_WhenEstateIdIsNotEmpty() - { - // Arrange - this._mediatorMock.Setup(m => m.Send(It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.ViewEstateResult); - - // Act - await this._viewEstate.MountAsync(); - - // Assert - this._viewEstate.Estate.ShouldNotBeNull(); - this._viewEstate.Estate.Name.ShouldBe("Test Estate"); - this._viewEstate.Estate.Id.ShouldBe(TestData.ViewEstate.EstateId); - this._viewEstate.Estate.Reference.ShouldBe("Ref123"); - } - -} \ No newline at end of file diff --git a/EstateManagementUI.sln b/EstateManagementUI.sln index ca45dc0d..aaca300b 100644 --- a/EstateManagementUI.sln +++ b/EstateManagementUI.sln @@ -11,7 +11,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateManagementUI.BlazorSe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateManagementUI.BlazorServer.Tests", "EstateManagementUI.BlazorServer.Tests\EstateManagementUI.BlazorServer.Tests.csproj", "{55431CBE-C879-47B9-9607-A5822DE9B856}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateManagementUI.BlazorServer.Tests.Integration", "EstateManagementUI.BlazorServer.Tests.Integration\EstateManagementUI.BlazorServer.Tests.Integration.csproj", "{A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateManagementUI.DashboardTests", "EstateManagementUI.DashboardTests\EstateManagementUI.DashboardTests.csproj", "{9CA8F295-C096-2F98-FC78-73AFB562E5E1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -47,18 +47,18 @@ Global {55431CBE-C879-47B9-9607-A5822DE9B856}.Release|x64.Build.0 = Release|Any CPU {55431CBE-C879-47B9-9607-A5822DE9B856}.Release|x86.ActiveCfg = Release|Any CPU {55431CBE-C879-47B9-9607-A5822DE9B856}.Release|x86.Build.0 = Release|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Debug|x64.ActiveCfg = Debug|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Debug|x64.Build.0 = Debug|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Debug|x86.ActiveCfg = Debug|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Debug|x86.Build.0 = Debug|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Release|Any CPU.Build.0 = Release|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Release|x64.ActiveCfg = Release|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Release|x64.Build.0 = Release|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Release|x86.ActiveCfg = Release|Any CPU - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F}.Release|x86.Build.0 = Release|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|x64.ActiveCfg = Debug|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|x64.Build.0 = Debug|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|x86.ActiveCfg = Debug|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|x86.Build.0 = Debug|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|Any CPU.Build.0 = Release|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|x64.ActiveCfg = Release|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|x64.Build.0 = Release|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|x86.ActiveCfg = Release|Any CPU + {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -66,7 +66,7 @@ Global GlobalSection(NestedProjects) = preSolution {C52FE3F3-E999-4A12-A20B-0D5C6DA34AA9} = {05420FAB-1C50-4AAD-9E7C-2A86184019B7} {55431CBE-C879-47B9-9607-A5822DE9B856} = {E7671C23-F30C-471A-A9EF-AC85DC607B55} - {A7D3E9F1-8B2C-4D5E-9F6A-1C3E5B7D9A2F} = {E7671C23-F30C-471A-A9EF-AC85DC607B55} + {9CA8F295-C096-2F98-FC78-73AFB562E5E1} = {E7671C23-F30C-471A-A9EF-AC85DC607B55} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C5AE6DA4-B167-44E5-9B63-61C7E8D1BC9F} From 3af8226b0fd49618db8a1e30ecf49f3749d92e1b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:36:31 +0000 Subject: [PATCH 5/7] Rename project from EstateManagementUI.DashboardTests to EstateManagementUI.IntegrationTests Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- .../.gitignore | 0 .../Common/DashboardPageHelper.cs | 2 +- .../EstateManagementUI.IntegrationTests.csproj | 0 .../Features/Dashboard.feature | 0 .../Hooks/BrowserHooks.cs | 2 +- .../README.md | 4 ++-- .../Steps/DashboardSteps.cs | 4 ++-- .../appsettings.json | 0 8 files changed, 6 insertions(+), 6 deletions(-) rename {EstateManagementUI.DashboardTests => EstateManagementUI.IntegrationTests}/.gitignore (100%) rename {EstateManagementUI.DashboardTests => EstateManagementUI.IntegrationTests}/Common/DashboardPageHelper.cs (99%) rename EstateManagementUI.DashboardTests/EstateManagementUI.DashboardTests.csproj => EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj (100%) rename {EstateManagementUI.DashboardTests => EstateManagementUI.IntegrationTests}/Features/Dashboard.feature (100%) rename {EstateManagementUI.DashboardTests => EstateManagementUI.IntegrationTests}/Hooks/BrowserHooks.cs (98%) rename {EstateManagementUI.DashboardTests => EstateManagementUI.IntegrationTests}/README.md (98%) rename {EstateManagementUI.DashboardTests => EstateManagementUI.IntegrationTests}/Steps/DashboardSteps.cs (98%) rename {EstateManagementUI.DashboardTests => EstateManagementUI.IntegrationTests}/appsettings.json (100%) diff --git a/EstateManagementUI.DashboardTests/.gitignore b/EstateManagementUI.IntegrationTests/.gitignore similarity index 100% rename from EstateManagementUI.DashboardTests/.gitignore rename to EstateManagementUI.IntegrationTests/.gitignore diff --git a/EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs b/EstateManagementUI.IntegrationTests/Common/DashboardPageHelper.cs similarity index 99% rename from EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs rename to EstateManagementUI.IntegrationTests/Common/DashboardPageHelper.cs index e7c830a9..4e413d68 100644 --- a/EstateManagementUI.DashboardTests/Common/DashboardPageHelper.cs +++ b/EstateManagementUI.IntegrationTests/Common/DashboardPageHelper.cs @@ -1,7 +1,7 @@ using Microsoft.Playwright; using Shouldly; -namespace EstateManagementUI.DashboardTests.Common; +namespace EstateManagementUI.IntegrationTests.Common; /// /// Helper class for interacting with the Dashboard page using Playwright diff --git a/EstateManagementUI.DashboardTests/EstateManagementUI.DashboardTests.csproj b/EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj similarity index 100% rename from EstateManagementUI.DashboardTests/EstateManagementUI.DashboardTests.csproj rename to EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj diff --git a/EstateManagementUI.DashboardTests/Features/Dashboard.feature b/EstateManagementUI.IntegrationTests/Features/Dashboard.feature similarity index 100% rename from EstateManagementUI.DashboardTests/Features/Dashboard.feature rename to EstateManagementUI.IntegrationTests/Features/Dashboard.feature diff --git a/EstateManagementUI.DashboardTests/Hooks/BrowserHooks.cs b/EstateManagementUI.IntegrationTests/Hooks/BrowserHooks.cs similarity index 98% rename from EstateManagementUI.DashboardTests/Hooks/BrowserHooks.cs rename to EstateManagementUI.IntegrationTests/Hooks/BrowserHooks.cs index df8ea919..732d5a08 100644 --- a/EstateManagementUI.DashboardTests/Hooks/BrowserHooks.cs +++ b/EstateManagementUI.IntegrationTests/Hooks/BrowserHooks.cs @@ -1,7 +1,7 @@ using Microsoft.Playwright; using Reqnroll; -namespace EstateManagementUI.DashboardTests.Hooks; +namespace EstateManagementUI.IntegrationTests.Hooks; /// /// Hooks for managing browser lifecycle using Playwright diff --git a/EstateManagementUI.DashboardTests/README.md b/EstateManagementUI.IntegrationTests/README.md similarity index 98% rename from EstateManagementUI.DashboardTests/README.md rename to EstateManagementUI.IntegrationTests/README.md index 791334de..4c014be4 100644 --- a/EstateManagementUI.DashboardTests/README.md +++ b/EstateManagementUI.IntegrationTests/README.md @@ -5,7 +5,7 @@ This project contains integration tests for the Dashboard functionality of the E ## Project Structure ``` -EstateManagementUI.DashboardTests/ +EstateManagementUI.IntegrationTests/ ├── Features/ # Reqnroll feature files (Gherkin scenarios) │ └── Dashboard.feature # Dashboard test scenarios for all roles ├── Steps/ # Step definitions (links features to code) @@ -98,7 +98,7 @@ Set the following environment variables before running tests: ### Execute Tests ```bash -dotnet test EstateManagementUI.DashboardTests.csproj +dotnet test EstateManagementUI.IntegrationTests.csproj ``` ### Filter by Role diff --git a/EstateManagementUI.DashboardTests/Steps/DashboardSteps.cs b/EstateManagementUI.IntegrationTests/Steps/DashboardSteps.cs similarity index 98% rename from EstateManagementUI.DashboardTests/Steps/DashboardSteps.cs rename to EstateManagementUI.IntegrationTests/Steps/DashboardSteps.cs index fa7b4878..db148129 100644 --- a/EstateManagementUI.DashboardTests/Steps/DashboardSteps.cs +++ b/EstateManagementUI.IntegrationTests/Steps/DashboardSteps.cs @@ -1,8 +1,8 @@ using Microsoft.Playwright; using Reqnroll; -using EstateManagementUI.DashboardTests.Common; +using EstateManagementUI.IntegrationTests.Common; -namespace EstateManagementUI.DashboardTests.Steps; +namespace EstateManagementUI.IntegrationTests.Steps; /// /// Step definitions for Dashboard integration tests diff --git a/EstateManagementUI.DashboardTests/appsettings.json b/EstateManagementUI.IntegrationTests/appsettings.json similarity index 100% rename from EstateManagementUI.DashboardTests/appsettings.json rename to EstateManagementUI.IntegrationTests/appsettings.json From 729152127bc0e5e8ee78e080b51ce67be0dd31ce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:38:31 +0000 Subject: [PATCH 6/7] Fix grammar: change 'an Viewer' to 'a Viewer' in feature file Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- .../Features/Dashboard.feature | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/EstateManagementUI.IntegrationTests/Features/Dashboard.feature b/EstateManagementUI.IntegrationTests/Features/Dashboard.feature index c4ebbbe5..5ba01ab3 100644 --- a/EstateManagementUI.IntegrationTests/Features/Dashboard.feature +++ b/EstateManagementUI.IntegrationTests/Features/Dashboard.feature @@ -53,7 +53,7 @@ Scenario: Estate user sees recently created merchants @DashboardTests @ViewerRole Scenario: Viewer user sees full dashboard with merchant KPIs - Given the user is authenticated as an "Viewer" user + Given the user is authenticated as a "Viewer" user When the user navigates to the Dashboard Then the Dashboard page is displayed And the merchant KPI cards are displayed @@ -63,7 +63,7 @@ Scenario: Viewer user sees full dashboard with merchant KPIs @DashboardTests @ViewerRole Scenario: Viewer user sees sales data on dashboard - Given the user is authenticated as an "Viewer" user + Given the user is authenticated as a "Viewer" user When the user navigates to the Dashboard Then the Dashboard page is displayed And the Today's Sales card is displayed @@ -74,14 +74,14 @@ Scenario: Viewer user sees sales data on dashboard @DashboardTests @ViewerRole Scenario: Viewer user sees comparison date selector - Given the user is authenticated as an "Viewer" user + Given the user is authenticated as a "Viewer" user When the user navigates to the Dashboard Then the Dashboard page is displayed And the comparison date selector is displayed @DashboardTests @ViewerRole Scenario: Viewer user sees recently created merchants - Given the user is authenticated as an "Viewer" user + Given the user is authenticated as a "Viewer" user When the user navigates to the Dashboard Then the Dashboard page is displayed And the Recently Created Merchants section is displayed From 28aae19c74cf699b16774c03830325b6863c701e Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Mon, 12 Jan 2026 11:01:00 +0000 Subject: [PATCH 7/7] update solution --- EstateManagementUI.sln | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/EstateManagementUI.sln b/EstateManagementUI.sln index aaca300b..907e4f2a 100644 --- a/EstateManagementUI.sln +++ b/EstateManagementUI.sln @@ -11,7 +11,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateManagementUI.BlazorSe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateManagementUI.BlazorServer.Tests", "EstateManagementUI.BlazorServer.Tests\EstateManagementUI.BlazorServer.Tests.csproj", "{55431CBE-C879-47B9-9607-A5822DE9B856}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateManagementUI.DashboardTests", "EstateManagementUI.DashboardTests\EstateManagementUI.DashboardTests.csproj", "{9CA8F295-C096-2F98-FC78-73AFB562E5E1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EstateManagementUI.IntegrationTests", "EstateManagementUI.IntegrationTests\EstateManagementUI.IntegrationTests.csproj", "{93B9C973-7DA8-325D-D9FC-6E93A3A25B25}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -47,18 +47,18 @@ Global {55431CBE-C879-47B9-9607-A5822DE9B856}.Release|x64.Build.0 = Release|Any CPU {55431CBE-C879-47B9-9607-A5822DE9B856}.Release|x86.ActiveCfg = Release|Any CPU {55431CBE-C879-47B9-9607-A5822DE9B856}.Release|x86.Build.0 = Release|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|x64.ActiveCfg = Debug|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|x64.Build.0 = Debug|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|x86.ActiveCfg = Debug|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Debug|x86.Build.0 = Debug|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|Any CPU.Build.0 = Release|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|x64.ActiveCfg = Release|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|x64.Build.0 = Release|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|x86.ActiveCfg = Release|Any CPU - {9CA8F295-C096-2F98-FC78-73AFB562E5E1}.Release|x86.Build.0 = Release|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Debug|x64.ActiveCfg = Debug|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Debug|x64.Build.0 = Debug|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Debug|x86.ActiveCfg = Debug|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Debug|x86.Build.0 = Debug|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Release|Any CPU.Build.0 = Release|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Release|x64.ActiveCfg = Release|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Release|x64.Build.0 = Release|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Release|x86.ActiveCfg = Release|Any CPU + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -66,7 +66,7 @@ Global GlobalSection(NestedProjects) = preSolution {C52FE3F3-E999-4A12-A20B-0D5C6DA34AA9} = {05420FAB-1C50-4AAD-9E7C-2A86184019B7} {55431CBE-C879-47B9-9607-A5822DE9B856} = {E7671C23-F30C-471A-A9EF-AC85DC607B55} - {9CA8F295-C096-2F98-FC78-73AFB562E5E1} = {E7671C23-F30C-471A-A9EF-AC85DC607B55} + {93B9C973-7DA8-325D-D9FC-6E93A3A25B25} = {E7671C23-F30C-471A-A9EF-AC85DC607B55} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C5AE6DA4-B167-44E5-9B63-61C7E8D1BC9F}