diff --git a/.codacy.yml b/.codacy.yml new file mode 100644 index 000000000..a5756883b --- /dev/null +++ b/.codacy.yml @@ -0,0 +1,5 @@ +--- +exclude_paths: + - "TransactionProcessor.Mobile.BusinessLogic.Tests/**" + - "TransactionProcessor.Mobile.UITests/**" + - "TransactionProcessor.Mobile.UiTestBackend/**" diff --git a/.deepsource.toml b/.deepsource.toml deleted file mode 100644 index c3730ebfb..000000000 --- a/.deepsource.toml +++ /dev/null @@ -1,17 +0,0 @@ -version = 1 - -[[analyzers]] -name = "csharp" -enabled = true - -[[analyzers]] -name = "docker" -enabled = true - -[[analyzers]] -name = "javascript" -enabled = true - -[[analyzers]] -name = "sql" -enabled = true diff --git a/Directory.Packages.props b/Directory.Packages.props index 375cf5f3e..7bc942bf1 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,8 +5,8 @@ - - + + @@ -24,15 +24,15 @@ - + - - - - + + + + @@ -41,10 +41,10 @@ - - - - + + + + diff --git a/TestCategoryLister/Program.cs b/TestCategoryLister/Program.cs deleted file mode 100644 index 6643a10cb..000000000 --- a/TestCategoryLister/Program.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using NUnit.Framework; - -class Program -{ - static void Main(string[] args) - { - if (args.Length != 1) - { - Console.WriteLine("Usage: dotnet run "); - return; - } - - var path = args[0]; - var asm = Assembly.LoadFrom(path); - - foreach (var type in asm.GetTypes()) - { - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)) - { - // Must be an [NUnit.Framework.Test] method - var testAttr = method.GetCustomAttribute(); - if (testAttr is null) - continue; - - // Collect [Category] from method and class - var methodCategories = method.GetCustomAttributes().Select(a => a.Name); - var classCategories = type.GetCustomAttributes().Select(a => a.Name); - - var allCategories = methodCategories.Concat(classCategories).Distinct().ToList(); - - Console.WriteLine($"{type.FullName}.{method.Name} - Categories: {(allCategories.Count == 0 ? "None" : string.Join(", ", allCategories))}"); - } - } - } -} \ No newline at end of file diff --git a/TestCategoryLister/TestCategoryLister.csproj b/TestCategoryLister/TestCategoryLister.csproj deleted file mode 100644 index 72df9878a..000000000 --- a/TestCategoryLister/TestCategoryLister.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - Exe - net10.0 - - - - - \ No newline at end of file diff --git a/TransactionProcessor.Mobile.sln b/TransactionProcessor.Mobile.sln index 64936e2a8..5134d8701 100644 --- a/TransactionProcessor.Mobile.sln +++ b/TransactionProcessor.Mobile.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.14.36203.30 +# Visual Studio Version 18 +VisualStudioVersion = 18.9.12120.119 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransactionProcessor.Mobile", "TransactionProcessor.Mobile\TransactionProcessor.Mobile.csproj", "{6BE81803-4FDB-4900-8ED4-971A6AD4140D}" EndProject @@ -17,8 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransactionProcessor.Mobile EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransactionProcessor.Mobile.UiTestBackend", "TransactionProcessor.Mobile.UiTestBackend\TransactionProcessor.Mobile.UiTestBackend.csproj", "{B7AB20D4-69B2-4C8A-9E4A-00D47C4869F4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestCategoryLister", "TestCategoryLister\TestCategoryLister.csproj", "{A9557544-11B0-4718-A52D-8D513C9DD619}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -47,10 +45,6 @@ Global {B7AB20D4-69B2-4C8A-9E4A-00D47C4869F4}.Debug|Any CPU.Build.0 = Debug|Any CPU {B7AB20D4-69B2-4C8A-9E4A-00D47C4869F4}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7AB20D4-69B2-4C8A-9E4A-00D47C4869F4}.Release|Any CPU.Build.0 = Release|Any CPU - {A9557544-11B0-4718-A52D-8D513C9DD619}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A9557544-11B0-4718-A52D-8D513C9DD619}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A9557544-11B0-4718-A52D-8D513C9DD619}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A9557544-11B0-4718-A52D-8D513C9DD619}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -61,7 +55,6 @@ Global {327D1FDB-E953-4501-9DED-193EF75148E1} = {7AB22349-8BB9-41D3-A40F-268DFC30FD0C} {E892CDC5-7DDF-4A0A-B8DB-AAC2DE758E56} = {7AB22349-8BB9-41D3-A40F-268DFC30FD0C} {B7AB20D4-69B2-4C8A-9E4A-00D47C4869F4} = {7AB22349-8BB9-41D3-A40F-268DFC30FD0C} - {A9557544-11B0-4718-A52D-8D513C9DD619} = {7AB22349-8BB9-41D3-A40F-268DFC30FD0C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4A92260C-922A-4553-A4DE-94C3BE3BA20F} diff --git a/archive/.github/release-drafter.yml b/archive/.github/release-drafter.yml deleted file mode 100644 index 62aef7361..000000000 --- a/archive/.github/release-drafter.yml +++ /dev/null @@ -1,13 +0,0 @@ -categories: - - title: '🚀 Features' - labels: - - 'feature' - - title: '🐛 Bug Fixes' - labels: - - 'bug' - - title: '🧰 Maintenance' - label: 'maintenance' -change-template: '- $TITLE @$AUTHOR (#$NUMBER)' -template: | - ## Changes - $CHANGES diff --git a/archive/.github/workflows/android_e2e_tests.yml b/archive/.github/workflows/android_e2e_tests.yml deleted file mode 100644 index 6b37ca648..000000000 --- a/archive/.github/workflows/android_e2e_tests.yml +++ /dev/null @@ -1,177 +0,0 @@ -name: Build and Run Android End to End Tests - -on: - pull_request: - branches: - - main - -jobs: - end_to_end_tests: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '8.0.x' - - - name: Set up JDK - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Enable KVM group perms - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - - name: Install KVM and Android SDK (x86) - run: | - # Set up environment variables - export ANDROID_SDK_ROOT=$HOME/android-sdk - export ANDROID_HOME=$ANDROID_SDK_ROOT - export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH - - # Create necessary directories - mkdir -p $ANDROID_SDK_ROOT/cmdline-tools - - # Download and install command-line tools - wget -q https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip - unzip -q commandlinetools-linux-*.zip -d $ANDROID_SDK_ROOT/cmdline-tools - mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest - chmod +x $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager - - # Accept licenses and install required components - yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses - # Install Android API level 34 and necessary system images - $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "platform-tools" "emulator" "platforms;android-34" "system-images;android-34;google_apis;x86_64" - - # Export paths for future steps - echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV - echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV - echo "PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH" >> $GITHUB_ENV - - - name: Cache Emulator System Image (x86) - uses: actions/cache@v3 - with: - path: ~/.android/avd - key: android-emulator-x86-${{ runner.os }}-android-34 - - - name: Create Android Emulator (x86) - run: | - echo "no" | avdmanager create avd -n test_emulator -k "system-images;android-34;google_apis;x86_64" --device "pixel_4" - - - name: List AVDs - run: avdmanager list avd - - - name: Start Emulator - run: | - echo "Starting emulator..." - - export ANDROID_AVD_HOME=$HOME/.config/.android/avd - - nohup $ANDROID_HOME/emulator/emulator -avd test_emulator -no-window -no-audio -no-snapshot -gpu swiftshader_indirect -verbose > emulator.log 2>&1 & - - echo "Waiting for emulator process to start..." - sleep 10 # Allow time for initialization - - echo "Checking if emulator process is running..." - ps aux | grep emulator - - echo "Checking ADB devices..." - adb devices - - - name: Restart ADB - run: | - adb kill-server - adb start-server - adb devices - - - name: Wait for Emulator to Boot (Timeout 10 min with Debug) - run: | - # Start waiting for the emulator - echo "Waiting for emulator to boot..." - - # Check the list of devices connected (debugging) - adb wait-for-device - - # Wait for emulator boot completion - timeout 600 bash -c ' - while true; do - # Show the current list of devices (debugging) - adb devices - - # Check if the emulator is booting by checking the boot status - BOOT_COMPLETED=$(adb shell getprop sys.boot_completed 2>/dev/null) - echo "Boot status: $BOOT_COMPLETED" - - # If boot is completed, break the loop - if [ "$BOOT_COMPLETED" == "1" ]; then - echo "Emulator boot completed!" - break - fi - - # If boot is not completed, keep waiting - echo "Emulator still booting, waiting..." - sleep 5 - done - ' - - - name: Install Android Build Tools - run: | - echo "Installing Android Build Tools..." - sdkmanager "build-tools;34.0.0" # Updated to use Android 34 build tools - sdkmanager --update - - - name: Install MAUI workloads - run: | - dotnet workload install maui-android - - - name: Install Appium and Drivers - run: | - sudo npm install -g appium - appium driver install uiautomator2 - - - name: Start Appium Server - run: | - nohup appium --log appium.log & - - - name: Set up Docker (Ubuntu) - if: runner.os == 'Linux' - run: | - # Check Docker version to ensure it's installed properly - docker --version - docker info - - # Allow current user to access Docker without sudo (optional, for convenience) - sudo usermod -aG docker $USER - - # Restart Docker service to apply changes - sudo systemctl restart docker - - - name: Restore MAUI App for Android - run: dotnet restore TransactionMobile.Maui.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - - - name: Build Code - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-android -c Release --no-restore - - - name: Run Android Navigation Tests - run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRTest)&(Category=Android)" --no-restore - - - name: Upload Logs on Failure - if: failure() # Runs only if a previous step fails - uses: actions/upload-artifact@v4 - with: - name: android-e2e_tests - path: /home/txnproc/trace/ - - - name: Upload Appium Logs on Failure - if: failure() - uses: actions/upload-artifact@v4 - with: - name: android-e2e_tests_appium - path: appium.log \ No newline at end of file diff --git a/archive/.github/workflows/android_navigation_tests.yml b/archive/.github/workflows/android_navigation_tests.yml deleted file mode 100644 index 15879cd05..000000000 --- a/archive/.github/workflows/android_navigation_tests.yml +++ /dev/null @@ -1,307 +0,0 @@ -name: Build and Run Android Navigation Tests - -on: - pull_request: - branches: - - main - -jobs: - software_navigation_tests: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '8.0.x' - - - name: Set up JDK - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Enable KVM group perms - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - - name: Install KVM and Android SDK (x86) - run: | - # Set up environment variables - export ANDROID_SDK_ROOT=$HOME/android-sdk - export ANDROID_HOME=$ANDROID_SDK_ROOT - export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH - - # Create necessary directories - mkdir -p $ANDROID_SDK_ROOT/cmdline-tools - - # Download and install command-line tools - wget -q https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip - unzip -q commandlinetools-linux-*.zip -d $ANDROID_SDK_ROOT/cmdline-tools - mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest - chmod +x $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager - - # Accept licenses and install required components - yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses - # Install Android API level 34 and necessary system images - $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "platform-tools" "emulator" "platforms;android-34" "system-images;android-34;google_apis;x86_64" - - # Export paths for future steps - echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV - echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV - echo "PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH" >> $GITHUB_ENV - - - name: Cache Emulator System Image (x86) - uses: actions/cache@v3 - with: - path: ~/.android/avd - key: android-emulator-x86-${{ runner.os }}-android-34 - - - name: Create Android Emulator (x86) - run: | - echo "no" | avdmanager create avd -n test_emulator -k "system-images;android-34;google_apis;x86_64" --device "pixel_4" - - - name: List AVDs - run: avdmanager list avd - - - name: Start Emulator - run: | - echo "Starting emulator..." - - export ANDROID_AVD_HOME=$HOME/.config/.android/avd - - nohup $ANDROID_HOME/emulator/emulator -avd test_emulator -no-window -no-audio -no-snapshot -gpu swiftshader_indirect -verbose > emulator.log 2>&1 & - - echo "Waiting for emulator process to start..." - sleep 10 # Allow time for initialization - - echo "Checking if emulator process is running..." - ps aux | grep emulator - - echo "Checking ADB devices..." - adb devices - - - name: Restart ADB - run: | - adb kill-server - adb start-server - adb devices - - - name: Wait for Emulator to Boot (Timeout 10 min with Debug) - run: | - # Start waiting for the emulator - echo "Waiting for emulator to boot..." - - # Check the list of devices connected (debugging) - adb wait-for-device - - # Wait for emulator boot completion - timeout 600 bash -c ' - while true; do - # Show the current list of devices (debugging) - adb devices - - # Check if the emulator is booting by checking the boot status - BOOT_COMPLETED=$(adb shell getprop sys.boot_completed 2>/dev/null) - echo "Boot status: $BOOT_COMPLETED" - - # If boot is completed, break the loop - if [ "$BOOT_COMPLETED" == "1" ]; then - echo "Emulator boot completed!" - break - fi - - # If boot is not completed, keep waiting - echo "Emulator still booting, waiting..." - sleep 5 - done - ' - - - name: Install Android Build Tools - run: | - echo "Installing Android Build Tools..." - sdkmanager "build-tools;34.0.0" # Updated to use Android 34 build tools - sdkmanager --update - - - name: Install MAUI workloads - run: | - dotnet workload install maui-android - - - name: Install Appium and Drivers - run: | - sudo npm install -g appium - appium driver install uiautomator2 - - - name: Start Appium Server - run: | - nohup appium --log appium.log & - - - name: Restore MAUI App for Android - run: dotnet restore TransactionMobile.Maui.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - - - name: Build Code - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-android -c Release --no-restore - - - name: Run Android Navigation Tests - run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRNavTest)&(Category=Android)" --no-restore - - - name: Upload Appium Logs on Failure - if: failure() - uses: actions/upload-artifact@v4 - with: - name: android-software_navigation_tests_appium - path: appium.log - - hardware_navigation_tests: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '8.0.x' - - - name: Set up JDK - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Enable KVM group perms - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - - name: Install KVM and Android SDK (x86) - run: | - # Set up environment variables - export ANDROID_SDK_ROOT=$HOME/android-sdk - export ANDROID_HOME=$ANDROID_SDK_ROOT - export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH - - # Create necessary directories - mkdir -p $ANDROID_SDK_ROOT/cmdline-tools - - # Download and install command-line tools - wget -q https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip - unzip -q commandlinetools-linux-*.zip -d $ANDROID_SDK_ROOT/cmdline-tools - mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest - chmod +x $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager - - # Accept licenses and install required components - yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses - # Install Android API level 34 and necessary system images - $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "platform-tools" "emulator" "platforms;android-34" "system-images;android-34;google_apis;x86_64" - - # Export paths for future steps - echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV - echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV - echo "PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH" >> $GITHUB_ENV - - - name: Cache Emulator System Image (x86) - uses: actions/cache@v3 - with: - path: ~/.android/avd - key: android-emulator-x86-${{ runner.os }}-android-34 - - - name: Create Android Emulator (x86) - run: | - echo "no" | avdmanager create avd -n test_emulator -k "system-images;android-34;google_apis;x86_64" --device "pixel_4" - - - name: List AVDs - run: avdmanager list avd - - - name: Start Emulator - run: | - echo "Starting emulator..." - - export ANDROID_AVD_HOME=$HOME/.config/.android/avd - - nohup $ANDROID_HOME/emulator/emulator -avd test_emulator -no-window -no-audio -no-snapshot -gpu swiftshader_indirect -verbose > emulator.log 2>&1 & - - echo "Waiting for emulator process to start..." - sleep 10 # Allow time for initialization - - echo "Checking if emulator process is running..." - ps aux | grep emulator - - echo "Checking ADB devices..." - adb devices - - - name: Restart ADB - run: | - adb kill-server - adb start-server - adb devices - - - name: Wait for Emulator to Boot (Timeout 10 min with Debug) - run: | - # Start waiting for the emulator - echo "Waiting for emulator to boot..." - - # Check the list of devices connected (debugging) - adb wait-for-device - - # Wait for emulator boot completion - timeout 600 bash -c ' - while true; do - # Show the current list of devices (debugging) - adb devices - - # Check if the emulator is booting by checking the boot status - BOOT_COMPLETED=$(adb shell getprop sys.boot_completed 2>/dev/null) - echo "Boot status: $BOOT_COMPLETED" - - # If boot is completed, break the loop - if [ "$BOOT_COMPLETED" == "1" ]; then - echo "Emulator boot completed!" - break - fi - - # If boot is not completed, keep waiting - echo "Emulator still booting, waiting..." - sleep 5 - done - ' - - - name: Install Android Build Tools - run: | - echo "Installing Android Build Tools..." - sdkmanager "build-tools;34.0.0" # Updated to use Android 34 build tools - sdkmanager --update - - - name: Install MAUI workloads - run: | - dotnet workload install maui-android - - - name: Install Appium and Drivers - run: | - sudo npm install -g appium - appium driver install uiautomator2 - - - name: Start Appium Server - run: | - nohup appium --log appium.log & - - - name: Restore MAUI App for Android - run: dotnet restore TransactionMobile.Maui.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - - - name: Build Code - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-android -c Release --no-restore - - - name: Run Android Navigation Tests - run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRHWNavTest)&(Category=Android)" --no-restore - - - name: Upload Appium Logs on Failure - if: failure() - uses: actions/upload-artifact@v4 - with: - name: android-hardware_navigation_tests_appium - path: appium.log \ No newline at end of file diff --git a/archive/.github/workflows/archive/pullrequest_endtoend.yml b/archive/.github/workflows/archive/pullrequest_endtoend.yml deleted file mode 100644 index cea34a567..000000000 --- a/archive/.github/workflows/archive/pullrequest_endtoend.yml +++ /dev/null @@ -1,206 +0,0 @@ -name: Build & Test Pull Requests UI Tests - -on: - pull_request: - branches: - - main - -jobs: - end-to-end-tests: - runs-on: ${{ matrix.os }} - strategy: - matrix: - platform: [android] #, ios, windows] - include: - - platform: android - os: ubuntu-latest - - platform: ios - os: macos-latest - - platform: windows - os: windows-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - ############################## - # Setup .NET and Dependencies - ############################## - - name: Set up .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 8.0.x - - - name: Install MAUI Workloads for Android - if: matrix.platform == 'android' - run: dotnet workload install android --ignore-failed-sources - - - name: Install MAUI Workloads for iOS - if: matrix.platform == 'ios' - run: dotnet workload install maui --ignore-failed-sources - - - name: Install MAUI Workloads for Windows - if: matrix.platform == 'windows' - run: dotnet workload install maui --ignore-failed-sources - - ########################### - # 🐳 Start Backend System (Docker) - ########################### - - name: Install Docker Desktop (macOS only) - if: runner.os == 'macOS' - run: | - brew install docker - # Install Docker daemon (Docker CLI can work with a running daemon) - brew install --cask colima # Colima is a lightweight Docker alternative - colima start # Start Colima which runs the Docker daemon - # Wait for Docker to initialize - sleep 30 # Wait for Docker to be ready - docker info || (echo "Docker is not running" && exit 1) - - - name: Set up Docker (Ubuntu) - if: runner.os == 'Linux' - run: | - #sudo apt-get purge -y containerd.io - - # Update package information and install Docker - #sudo apt-get update - #sudo apt-get install -y docker.io - - # Enable Docker service to start on boot (in case it's required) - #sudo systemctl enable --now docker - - # Check Docker version to ensure it's installed properly - docker --version - docker info - - # Allow current user to access Docker without sudo (optional, for convenience) - sudo usermod -aG docker $USER - - # Restart Docker service to apply changes - sudo systemctl restart docker - - ########################### - # 🛠 Install Appium & Drivers - ########################### - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - - name: Install Appium and Drivers - run: | - npm install -g appium - appium driver install uiautomator2 - appium driver install xcuitest - appium driver install windows - - - name: Start Appium Server - run: | - nohup appium --log appium.log & - - ############################## - # 🟢 Android: Start Emulator - ############################## - - name: Install Android SDK & Start Emulator (Linux) - if: matrix.platform == 'android' - run: | - # Install dependencies - sudo apt-get update - sudo apt-get install -y unzip wget libglu1-mesa - - # Set up Android SDK directory - export ANDROID_HOME=$HOME/android-sdk - export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$PATH - mkdir -p $ANDROID_HOME/cmdline-tools - - # Download and install Android command-line tools - wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O cmdline-tools.zip - unzip -q cmdline-tools.zip -d $ANDROID_HOME/cmdline-tools - rm cmdline-tools.zip - mv $ANDROID_HOME/cmdline-tools/cmdline-tools $ANDROID_HOME/cmdline-tools/latest - - # Accept licenses - yes | sdkmanager --licenses || true - - # Install required Android SDK packages - sdkmanager --sdk_root=$ANDROID_HOME --install "platform-tools" "emulator" "system-images;android-31;google_apis;x86_64" - - # Verify installation - sdkmanager --list | grep "system-images;android-31;google_apis;x86_64" - - # Create and start emulator - echo "no" | avdmanager create avd -n testEmulator -k "system-images;android-31;google_apis;x86_64" --device "pixel_4" - - echo "⏳ Pausing for 10 seconds to ensure AVD registration..." - sleep 30 - - # Start the emulator in the background - nohup emulator -avd testEmulator -no-window -no-audio -gpu swiftshader_indirect -no-snapshot -no-boot-anim & - - # Wait up to 5 minutes (300 seconds) for the emulator to be ready - timeout=300 - while [[ $timeout -gt 0 ]]; do - boot_status=$(adb shell getprop sys.boot_completed 2>&1) - echo "Waiting for emulator... Boot status: $boot_status" - if [[ "$boot_status" == "1" ]]; then - echo "✅ Emulator booted successfully!" - exit 0 - fi - sleep 5 - ((timeout -= 5)) - done - - echo "❌ Emulator failed to boot within timeout!" - exit 1 - - - ############################## - # 🍏 iOS: Start Simulator - ############################## - - name: Start iOS Simulator - if: matrix.platform == 'ios' - run: | - open -a Simulator & - xcrun simctl list - xcrun simctl boot "iPhone 14" - xcrun simctl list devices - - ############################## - # 🔨 Build .NET MAUI App - ############################## - - name: Build MAUI App for Android - if: matrix.platform == 'android' - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-android -c Release --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - - - name: Build MAUI App for iOS - if: matrix.platform == 'ios' - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-ios -c Release --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - - - name: Build MAUI App for Windows - if: matrix.platform == 'windows' - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-windows -c Release --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - - ############################## - # 🚀 Run Appium UI Tests - ############################## - - name: Run Appium Tests (Android) - if: matrix.platform == 'android' - run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter (Category=PRTest)&(Category=Android) - - - name: Run Appium Tests (iOS) - if: matrix.platform == 'ios' - run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter (Category=PRTest)&(Category=iOS) - - - name: Run Appium Tests (Windows) - if: matrix.platform == 'windows' - run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "Category=PRTest&Category=Windows" - - ############################## - # 📤 Upload Logs if Tests Fail - ############################## - - name: Upload logs if tests fail - if: failure() - uses: actions/upload-artifact@v4 - with: - name: appium-logs-${{ matrix.test-type }} - path: artifacts/appium-logs-${{ matrix.test-type }}.log diff --git a/archive/.github/workflows/archive/pullrequest_navigationtests.yml b/archive/.github/workflows/archive/pullrequest_navigationtests.yml deleted file mode 100644 index c6c21b80c..000000000 --- a/archive/.github/workflows/archive/pullrequest_navigationtests.yml +++ /dev/null @@ -1,132 +0,0 @@ -# name: Build & Test Pull Requests UI Tests - -# on: -# pull_request: -# branches: -# - main - -# jobs: -# end-to-end-tests: -# runs-on: ${{ matrix.os }} -# strategy: -# matrix: -# platform: [android, ios, windows] -# include: -# - platform: android -# os: ubuntu-latest -# - platform: ios -# os: macos-latest -# - platform: windows -# os: windows-latest - -# steps: -# - name: Checkout repository -# uses: actions/checkout@v4 - -# ############################## -# # Setup .NET and Dependencies -# ############################## -# - name: Set up .NET -# uses: actions/setup-dotnet@v3 -# with: -# dotnet-version: 8.0.x - -# - name: Install MAUI Workloads -# run: dotnet workload install maui - -# ########################### -# # 🛠 Install Appium & Drivers -# ########################### -# - name: Install Node.js -# uses: actions/setup-node@v3 -# with: -# node-version: 18 - -# - name: Install Appium and Drivers -# run: | -# npm install -g appium -# appium driver install uiautomator2 -# appium driver install xcuitest -# appium driver install windows - -# - name: Start Appium Server -# run: | -# nohup appium --log appium.log & - -# ############################## -# # 🟢 Android: Start Emulator -# ############################## -# - name: Install Android SDK & Emulator -# if: matrix.platform == 'android' -# run: | -# sudo apt update -# sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils -# sudo usermod -aG libvirt $USER -# sudo usermod -aG kvm $USER -# sdkmanager --install "system-images;android-31;default;x86_64" -# echo "no" | avdmanager create avd -n testEmulator -k "system-images;android-31;default;x86_64" --device "pixel_4" -# nohup emulator -avd testEmulator -no-window -no-audio -gpu swiftshader_indirect & - -# - name: Wait for Emulator to Boot -# if: matrix.platform == 'android' -# run: | -# adb wait-for-device -# adb shell settings put global window_animation_scale 0 -# adb shell settings put global transition_animation_scale 0 -# adb shell settings put global animator_duration_scale 0 -# adb devices - -# ############################## -# # 🍏 iOS: Start Simulator -# ############################## -# - name: Start iOS Simulator -# if: matrix.platform == 'ios' -# run: | -# open -a Simulator & -# xcrun simctl list -# xcrun simctl boot "iPhone 14" -# xcrun simctl list devices - -# ############################## -# # 🔨 Build .NET MAUI App -# ############################## -# - name: Build MAUI App for Android -# if: matrix.platform == 'android' -# run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-android -c Release --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - -# - name: Build MAUI App for iOS -# if: matrix.platform == 'ios' -# run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-ios -c Release --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - -# - name: Build MAUI App for Windows -# if: matrix.platform == 'windows' -# run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-windows -c Release --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - -# ############################## -# # 🚀 Run Appium UI Tests -# ############################## -# - name: Run Appium Navigation Tests (Android) -# if: matrix.platform == 'android' -# run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter (Category=PRNavTest)&(Category=Android) - -# - name: Run Appium Navigation Hardware Tests (Android) -# if: matrix.platform == 'android' -# run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter (Category=PRHWNavTest)&(Category=Android) - -# - name: Run Appium Tests (iOS) -# if: matrix.platform == 'ios' -# run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter (Category=PRNavTest)&(Category=iOS) - -# - name: Run Appium Tests (Windows) -# if: matrix.platform == 'windows' -# run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "Category=PRNavTest&Category=Windows" - -# ############################## -# # 📤 Upload Logs if Tests Fail -# ############################## -# - name: Upload logs if tests fail -# if: failure() -# uses: actions/upload-artifact@v3 -# with: -# name: appium-logs-${{ matrix.test-type }} -# path: artifacts/appium-logs-${{ matrix.test-type }}.log diff --git a/archive/.github/workflows/archive/pullrequest_unittests.yml b/archive/.github/workflows/archive/pullrequest_unittests.yml deleted file mode 100644 index b94b0cc61..000000000 --- a/archive/.github/workflows/archive/pullrequest_unittests.yml +++ /dev/null @@ -1,33 +0,0 @@ -# name: Build & Test Pull Requests Unit Tests - -# on: -# pull_request: -# branches: -# - main - -# env: -# DOTNET_NOLOGO: true # Disable the .NET logo -# DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience -# DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry - -# jobs: -# unit-tests : -# runs-on: ubuntu-latest -# name: Android Build - Unit Tests -# steps: -# - name: Checkout -# uses: actions/checkout@v3 - -# - name: Install MAUI Workloads -# run: | -# dotnet workload install android --ignore-failed-sources -# dotnet workload install maui --ignore-failed-sources - -# - name: Restore Dependencies -# run: dotnet restore TransactionMobile.Maui.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - -# - name: Build Code -# run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -c Release -f net8.0-android --no-restore - -# - name: Run Unit Tests -# run: dotnet test TransactionMobile.Maui.BusinessLogic.Tests/TransactionMobile.Maui.BusinessLogic.Tests.csproj \ No newline at end of file diff --git a/archive/.github/workflows/createrelease.yml b/archive/.github/workflows/createrelease.yml deleted file mode 100644 index 0ac884651..000000000 --- a/archive/.github/workflows/createrelease.yml +++ /dev/null @@ -1,199 +0,0 @@ -name: Release - -on: - release: - types: [published] - -env: - DOTNET_NOLOGO: true # Disable the .NET logo - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience - DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - -jobs: - release_android: - runs-on: windows-2022 - name: "Android Release" - env: - ASPNETCORE_ENVIRONMENT: "Production" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Keystore File - run: | - echo "${{secrets.KEYSTORE_FILE }}" > transactionprocessing.keystore.asc - gpg -d --passphrase "${{ secrets.KEYSTORE_PASSWORD_GPG }}" --batch transactionprocessing.keystore.asc > transactionprocessing.keystore - - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - shell: bash - - - name: Setup .NET 8 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 8.0.x - - - name: Install MAUI Workload - run: dotnet workload install maui --ignore-failed-sources - - - name: Restore Dependencies - run: dotnet restore TransactionMobile.Maui.sln - - - name: Set Application Version - uses: TransactionProcessing/actions@1.0.1 - with: - filepath: 'TransactionMobile.Maui/TransactionMobile.Maui.csproj' - versionnumber: ${{ steps.get_version.outputs.VERSION }} - isWindows: false - - - name: Build Android - run: dotnet publish TransactionMobile.Maui/TransactionMobile.Maui.csproj -c Release -f net8.0-android --no-restore /p:AndroidSigningKeyStore=transactionprocessing.keystore /p:AndroidSigningKeyPass="${{ secrets.KEYSTORE_PASSWORD }}" - - - name: Upload Android Artifact - uses: actions/upload-artifact@v3 - with: - name: android-ci-build - path: TransactionMobile.Maui/bin/Release/net8.0-android/com.transactionprocessing.pos-Signed.apk - - - name: Upload Artifact to App Center - uses: Coxxs/AppCenter-Github-Action@v1 - with: - appName: "Transaction-Processing/POS-Android" - token: ${{secrets.APPCENTER_ANDROID_TOKEN}} - group: Merchants - file: TransactionMobile.Maui/bin/Release/net8.0-android/com.transactionprocessing.pos-Signed.apk - notifyTesters: true - debug: false - gitReleaseNotes: true - - release_windows: - runs-on: windows-2022 - name: "Windows Release" - env: - ASPNETCORE_ENVIRONMENT: "Production" - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - shell: bash - - - name: Setup .NET 8 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 8.0.x - - - name: Install MAUI Workload - run: dotnet workload install maui --ignore-failed-sources - - - name: Restore Dependencies - run: dotnet restore TransactionMobile.Maui.sln - - - name: Set Application Version - uses: TransactionProcessing/actions@1.0.1 - with: - filepath: 'TransactionMobile.Maui/TransactionMobile.Maui.csproj' - versionnumber: ${{ steps.get_version.outputs.VERSION }} - isWindows: true - - - name: Build Windows - run: dotnet publish TransactionMobile.Maui/TransactionMobile.Maui.csproj -c Release -f net8.0-windows10.0.19041.0 --no-restore - - - name: Upload Windows Artifact - uses: actions/upload-artifact@v3 - with: - name: windows-ci-build - path: TransactionMobile.Maui/bin/Release/net8.0-windows10.0.19041.0/win10-x64/AppPackages/TransactionMobile*/TransactionMobile*.msix - - - name: Upload Artifact to App Center - uses: Coxxs/AppCenter-Github-Action@v1 - with: - appName: "Transaction-Processing/POS-Windows" - token: ${{secrets.APPCENTER_WINDOWS_TOKEN}} - group: Merchants - file: "TransactionMobile.Maui/bin/Release/net8.0-windows10.0.19041.0/win10-x64/AppPackages/TransactionMobile.Maui_${{ steps.get_version.outputs.VERSION }}.0_Test/TransactionMobile.Maui_${{ steps.get_version.outputs.VERSION }}.0_x64.msix" - notifyTesters: true - debug: false - gitReleaseNotes: true - - release-mac: - runs-on: macos-11 - name: MacCatalyst Release - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - - name: Setup .NET 8 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 8.0.x - - - name: Install MAUI Workload - run: dotnet workload install maui --ignore-failed-sources - - - name: Restore Dependencies - run: dotnet restore TransactionMobile.Maui.sln - - - name: Set Application Version - uses: TransactionProcessing/actions@1.0.1 - with: - filepath: 'TransactionMobile.Maui/TransactionMobile.Maui.csproj' - versionnumber: ${{ steps.get_version.outputs.VERSION }} - isWindows: false - - - name: Build MacCatalyst - run: dotnet publish TransactionMobile.Maui/TransactionMobile.Maui.csproj -c Release -f net8.0-maccatalyst --no-restore - - - name: Upload MacCatalyst Artifact - uses: actions/upload-artifact@v3 - with: - name: macos-ci-build - path: TransactionMobile.Maui/bin/Release/net8.0-maccatalyst/maccatalyst-x64/publish/*.pkg - - release-ios: - runs-on: macos-11 - name: iOS Release - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - - name: Setup .NET 8 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 8.0.x - - - name: Install MAUI Workload - run: dotnet workload install maui --ignore-failed-sources - - - name: Restore Dependencies - run: dotnet restore TransactionMobile.Maui.sln - - - name: Set Application Version - uses: TransactionProcessing/actions@1.0.1 - with: - filepath: 'TransactionMobile.Maui/TransactionMobile.Maui.csproj' - versionnumber: ${{ steps.get_version.outputs.VERSION }} - isWindows: false - - - name: Build iOS - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -c Release -f net8.0-ios --no-restore /p:buildForSimulator=True /p:packageApp=True /p:ArchiveOnBuild=False - - - name: Upload MacCatalyst Artifact - uses: actions/upload-artifact@v3 - with: - name: iOS-ci-build - path: TransactionMobile.Maui/bin/Release/net8.0-ios/iossimulator-x64/**/*.app diff --git a/archive/.github/workflows/ios_e2e_tests.yml b/archive/.github/workflows/ios_e2e_tests.yml deleted file mode 100644 index 69b78ecd9..000000000 --- a/archive/.github/workflows/ios_e2e_tests.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Build and Run iOS End To End Tests - -on: - pull_request: - branches: - - main - -jobs: - e2e_tests: - runs-on: macos-14 - env: - PLATFORM_VERSION: "17.2" - DEVICE_NAME: "iPhone 15" - APP_PATH: "./MyTestApp.app" - - steps: - - name: 🧾 Checkout repo - uses: actions/checkout@v4 - - - name: 🔧 Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: 🔧 Set up .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '8.0.x' - - - name: 📦 Install Appium + XCUITest driver - run: | - npm install -g appium - appium driver install xcuitest - - - name: 🧹 Clean DerivedData and WDA cache - run: | - rm -rf ~/Library/Developer/Xcode/DerivedData - rm -rf ~/.appium/node_modules/appium-webdriveragent/Build - - - name: 🧪 Start Appium Server - run: | - nohup appium --log appium.log & - - - name: 📱 Create iOS Simulator (if needed) - run: | - SIMULATOR_NAME="ci-sim-$RANDOM" - xcrun simctl create "$SIMULATOR_NAME" "$DEVICE_NAME" "com.apple.CoreSimulator.SimRuntime.iOS-${PLATFORM_VERSION//./-}" - echo "SIMULATOR_NAME=$SIMULATOR_NAME" >> $GITHUB_ENV - - - name: 🚀 Boot simulator - run: | - xcrun simctl boot "$SIMULATOR_NAME" - xcrun simctl list | grep Booted - - - name: Install MAUI Workloads - run: | - dotnet workload install ios --ignore-failed-sources - dotnet workload install maui --ignore-failed-sources - - - name: Restore MAUI App for iOS - run: dotnet restore TransactionMobile.Maui.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - - - name: Build Code - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-ios -c Release --no-restore - - - name: Run iOS Navigation Tests - run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=iOSPRTest)&(Category=iOS)" --no-restore - - - name: Upload Appium Logs on Failure - if: failure() - uses: actions/upload-artifact@v4 - with: - name: ios-software_navigation_tests_appium - path: appium.log - - \ No newline at end of file diff --git a/archive/.github/workflows/ios_navigation_tests.yml b/archive/.github/workflows/ios_navigation_tests.yml deleted file mode 100644 index 5eebf5f6e..000000000 --- a/archive/.github/workflows/ios_navigation_tests.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Build and Run iOS Navigation Tests - -on: - pull_request: - branches: - - main - -jobs: - software_navigation_tests: - runs-on: macos-14 - env: - PLATFORM_VERSION: "17.2" - DEVICE_NAME: "iPhone 15" - APP_PATH: "./MyTestApp.app" - - steps: - - name: 🧾 Checkout repo - uses: actions/checkout@v4 - - - name: 🔧 Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: 🔧 Set up .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '8.0.x' - - - name: 📦 Install Appium + XCUITest driver - run: | - npm install -g appium - appium driver install xcuitest - - - name: 🧹 Clean DerivedData and WDA cache - run: | - rm -rf ~/Library/Developer/Xcode/DerivedData - rm -rf ~/.appium/node_modules/appium-webdriveragent/Build - - - name: 🧪 Start Appium Server - run: | - nohup appium --log appium.log & - - - name: 📱 Create iOS Simulator (if needed) - run: | - SIMULATOR_NAME="ci-sim-$RANDOM" - xcrun simctl create "$SIMULATOR_NAME" "$DEVICE_NAME" "com.apple.CoreSimulator.SimRuntime.iOS-${PLATFORM_VERSION//./-}" - echo "SIMULATOR_NAME=$SIMULATOR_NAME" >> $GITHUB_ENV - - - name: 🚀 Boot simulator - run: | - xcrun simctl boot "$SIMULATOR_NAME" - xcrun simctl list | grep Booted - - - name: Install MAUI Workloads - run: | - dotnet workload install ios --ignore-failed-sources - dotnet workload install maui --ignore-failed-sources - - - name: Restore MAUI App for iOS - run: dotnet restore TransactionMobile.Maui.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - - - name: Build Code - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-ios -c Release --no-restore - - - name: Run iOS Navigation Tests - run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRNavTest)&(Category=iOS)" --no-restore - - - name: Upload Appium Logs on Failure - if: failure() - uses: actions/upload-artifact@v4 - with: - name: ios-software_navigation_tests_appium - path: appium.log - - \ No newline at end of file diff --git a/archive/.github/workflows/prlinked.yml b/archive/.github/workflows/prlinked.yml deleted file mode 100644 index 84037c86c..000000000 --- a/archive/.github/workflows/prlinked.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Move Linked Issues - -on: - pull_request: - types: - - opened - - synchronize - - reopened - -jobs: - get-date: - runs-on: ubuntu-latest - outputs: - project_name_prefix: ${{ steps.format_date.outputs.formatted_date }} - steps: - - name: Get PR creation date - id: format_date - run: | - # Extract the month and year from the PR creation date - PR_DATE="${{ github.event.pull_request.created_at }}" - FORMATTED_DATE=$(date -d "$PR_DATE" "+%B %Y") # Format to Month Year - - # Debugging: print out the formatted date - echo "Formatted Date: ${FORMATTED_DATE} Sprint" - - # Set output using the Environment File method - echo "formatted_date=${FORMATTED_DATE} Sprint" >> $GITHUB_OUTPUT # Set the output for later jobs - - debug-date: - needs: get-date - runs-on: ubuntu-latest - steps: - - name: Debug the outputs - run: | - echo "PR Number: ${{ github.event.pull_request.number }}" - echo "Project Column Name: Review" - echo "Project Name Prefix (from get-date job output): ${{ needs.get-date.outputs.project_name_prefix }}" # Access the output correctly - - move-issues: - needs: get-date - uses: TransactionProcessing/org-ci-workflows/.github/workflows/move-linked-issue.yml@main - with: - pr_number: ${{ github.event.pull_request.number }} - project_column_name: "Review" - project_name_prefix: ${{ needs.get-date.outputs.project_name_prefix }} # Access the output from get-date job - secrets: - gh_token: ${{ secrets.GH_TOKEN }} diff --git a/archive/.github/workflows/release-management.yml b/archive/.github/workflows/release-management.yml deleted file mode 100644 index bb787fe66..000000000 --- a/archive/.github/workflows/release-management.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Release Management - -on: - push: - # branches to consider in the event; optional, defaults to all - branches: - - main - -jobs: - update_draft_release: - runs-on: ubuntu-latest - steps: - # Drafts your next Release notes as Pull Requests are merged into "master" - - uses: toolmantim/release-drafter@v5.12.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/archive/.github/workflows/repository_maintenance.yml b/archive/.github/workflows/repository_maintenance.yml deleted file mode 100644 index dda1d4901..000000000 --- a/archive/.github/workflows/repository_maintenance.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Maintenance Tasks - -on: - repository_dispatch: - workflow_dispatch: - schedule: - - cron: '0 0 * * *' # This schedule runs the workflow at midnight every day - -jobs: - cleanup-stale-branches: - runs-on: ubuntu-latest - steps: - - name: Cleanup Stale Branches - uses: cbrgm/cleanup-stale-branches-action@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - repository: ${{ github.repository }} - last-commit-age-days: 60 - dry-run: false - rate-limit: true diff --git a/archive/.github/workflows/unit_tests.yml b/archive/.github/workflows/unit_tests.yml deleted file mode 100644 index 7165b3348..000000000 --- a/archive/.github/workflows/unit_tests.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Build and Run Unit Tests - -on: - pull_request: - branches: - - main - -jobs: - unit_tests: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '8.0.x' - - - name: Install KVM and Android SDK (x86) - run: | - # Set up environment variables - export ANDROID_SDK_ROOT=$HOME/android-sdk - export ANDROID_HOME=$ANDROID_SDK_ROOT - export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH - - # Create necessary directories - mkdir -p $ANDROID_SDK_ROOT/cmdline-tools - - # Download and install command-line tools - wget -q https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip - unzip -q commandlinetools-linux-*.zip -d $ANDROID_SDK_ROOT/cmdline-tools - mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest - chmod +x $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager - - # Accept licenses and install required components - yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses - # Install Android API level 34 and necessary system images - $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "platform-tools" "emulator" "platforms;android-34" "system-images;android-34;google_apis;x86_64" - - # Export paths for future steps - echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV - echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV - echo "PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH" >> $GITHUB_ENV - - - name: Install Android Build Tools - run: | - echo "Installing Android Build Tools..." - sdkmanager "build-tools;34.0.0" # Updated to use Android 34 build tools - sdkmanager --update - - - name: Install MAUI workloads - run: | - dotnet workload install maui-android - - - name: Build Code - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json -f net8.0-android -c Release #--no-restore - - - name: Run unit tests - run: dotnet test TransactionMobile.Maui.BusinessLogic.Tests/TransactionMobile.Maui.BusinessLogic.Tests.csproj --configuration Release diff --git a/archive/.github/workflows/windows_e2e_tests.yml b/archive/.github/workflows/windows_e2e_tests.yml deleted file mode 100644 index d4c192b8c..000000000 --- a/archive/.github/workflows/windows_e2e_tests.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Build and Run Windows End to End Tests - -on: - pull_request: - branches: - - main - -jobs: - end_to_end_tests: - runs-on: windows-2022 - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Build Windows SQL Server - run: | - cd SQLDocker - docker build -t mssqlserver:2022-ltsc2022 --build-arg SQL_VERSION=2022 --build-arg WIN_VERSION=ltsc2022 . - - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.1 - with: - vs-prerelease: true - - - name: Set up .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '8.0.x' - - - name: Install MAUI workloads - run: | - dotnet workload install maui - - - name: Install Appium and Drivers - run: | - npm install -g appium --unsafe-perm=true --allow-root - appium driver install --source=npm appium-windows-driver - - - name: Start Appium Server - run: | - nohup appium --log appium.log & - - - name: Restore MAUI App for Android - run: dotnet restore TransactionMobile.Maui.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - - - name: Build Code - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-android -c Release --no-restore - - - name: Decrypt PFX File - run: | - echo "${{ secrets.WINDOWSSIGNINGCERT }}" > cert.pfx.asc - certutil -decode cert.pfx.asc cert.pfx - - - name: Add Cert to Store - run: certutil -user -q -p ${{ secrets.WINDOWSSIGNINGCERTPWD }} -importpfx cert.pfx NoRoot - - - name: Publish App - run: | - dotnet publish TransactionMobile.Maui/TransactionMobile.Maui.csproj -c Release -f net8.0-windows10.0.19041.0 /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="${{ secrets.WINDOWSSIGNINGCERTTHUMBPRINT }}" - - - name: Install App - shell: powershell - run: | - Import-Module Appx - .\TransactionMobile.Maui/bin/Release/net8.0-windows10.0.19041.0/win10-x64/AppPackages/TransactionMobile.Maui_1.0.0.0_Test/Install.ps1 -Force - - - name: Run Windows End To End Tests - env: - IsCI: true - run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRTest)&(Category=Windows)" --no-restore - - - name: Upload Logs on Failure - if: failure() # Runs only if a previous step fails - uses: actions/upload-artifact@v4 - with: - name: windows-e2e_tests - path: C:\\Users\\runneradmin\\txnproc - - - name: Upload Appium Logs on Failure - if: failure() - uses: actions/upload-artifact@v4 - with: - name: windows-e2e_tests_appium - path: appium.log diff --git a/archive/.github/workflows/windows_navigation_tests.yml b/archive/.github/workflows/windows_navigation_tests.yml deleted file mode 100644 index 90f804306..000000000 --- a/archive/.github/workflows/windows_navigation_tests.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Build and Run Windows Navigation Tests - -on: - pull_request: - branches: - - main - -jobs: - software_navigation_tests: - runs-on: windows-2022 - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.1 - with: - vs-prerelease: true - - - name: Set up .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '8.0.x' - - - name: Install MAUI workloads - run: | - dotnet workload install maui - - - name: Install Appium and Drivers - run: | - npm install -g appium --unsafe-perm=true --allow-root - appium driver install --source=npm appium-windows-driver - - - name: Start Appium Server - run: | - nohup appium --log appium.log & - - - name: Restore MAUI App for Android - run: dotnet restore TransactionMobile.Maui.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json - - - name: Build Code - run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.0-android -c Release --no-restore - - - name: Decrypt PFX File - run: | - echo "${{ secrets.WINDOWSSIGNINGCERT }}" > cert.pfx.asc - certutil -decode cert.pfx.asc cert.pfx - - - name: Add Cert to Store - run: certutil -user -q -p ${{ secrets.WINDOWSSIGNINGCERTPWD }} -importpfx cert.pfx NoRoot - - - name: Publish App - run: | - dotnet publish TransactionMobile.Maui/TransactionMobile.Maui.csproj -c Release -f net8.0-windows10.0.19041.0 /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="${{ secrets.WINDOWSSIGNINGCERTTHUMBPRINT }}" - - - name: Install App - shell: powershell - run: | - Import-Module Appx - .\TransactionMobile.Maui/bin/Release/net8.0-windows10.0.19041.0/win10-x64/AppPackages/TransactionMobile.Maui_1.0.0.0_Test/Install.ps1 -Force - - - name: Run Windows Navigation Tests - run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRNavTest)&(Category=Windows)" --no-restore - - - name: Upload Appium Logs on Failure - if: failure() - uses: actions/upload-artifact@v4 - with: - name: windows-software_navigation_tests_appium - path: appium.log - - \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/CommonTests/ExtensionsTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/CommonTests/ExtensionsTests.cs deleted file mode 100644 index e5b51d393..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/CommonTests/ExtensionsTests.cs +++ /dev/null @@ -1,591 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.Common -{ - using BusinessLogic.Common; - using Database; - using Models; - using Requests; - using Shouldly; - using SimpleResults; - using TransactionProcessorACL.DataTransferObjects; - using TransactionProcessorACL.DataTransferObjects.Responses; - using ViewModels.Transactions; - using Xunit; - - public class ExtensionsTests{ - [Theory] - [InlineData(true)] - [InlineData(false)] - public void LogonTransactionRequest_ToTransactionRecord_IsTranslated(Boolean inTrainingMode){ - LogonTransactionRequest request = LogonTransactionRequest.Create(TestData.TransactionDateTime); - TransactionRecord transactionRecord = request.ToTransactionRecord(inTrainingMode); - transactionRecord.TransactionDateTime.ShouldBe(request.TransactionDateTime); - transactionRecord.TransactionType.ShouldBe(1); - transactionRecord.IsTrainingMode.ShouldBe(inTrainingMode); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public void PerformMobileTopupRequest_ToTransactionRecord_IsTranslated(Boolean inTrainingMode){ - PerformMobileTopupRequest request = PerformMobileTopupRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.CustomerAccountNumber, - TestData.Operator1Product_100KES.Value, - TestData.CustomerEmailAddress); - - TransactionRecord transactionRecord = request.ToTransactionRecord(inTrainingMode); - transactionRecord.TransactionDateTime.ShouldBe(request.TransactionDateTime); - transactionRecord.TransactionType.ShouldBe(2); - transactionRecord.IsTrainingMode.ShouldBe(inTrainingMode); - transactionRecord.Amount.ShouldBe(request.TopupAmount); - transactionRecord.ProductId.ShouldBe(request.ProductId); - transactionRecord.ContractId.ShouldBe(request.ContractId); - transactionRecord.CustomerAccountNumber.ShouldBe(request.CustomerAccountNumber); - transactionRecord.CustomerEmailAddress.ShouldBe(request.CustomerEmailAddress); - transactionRecord.OperatorId.ShouldBe(request.OperatorId); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public void PerformVoucherIssueRequest_ToTransactionRecord_IsTranslated(Boolean inTrainingMode){ - PerformVoucherIssueRequest request = PerformVoucherIssueRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.RecipientMobileNumber, - TestData.RecipientEmailAddress, - TestData.Operator3Product_200KES.Value, - TestData.CustomerEmailAddress); - - TransactionRecord transactionRecord = request.ToTransactionRecord(inTrainingMode); - transactionRecord.TransactionDateTime.ShouldBe(request.TransactionDateTime); - transactionRecord.TransactionType.ShouldBe(2); - transactionRecord.IsTrainingMode.ShouldBe(inTrainingMode); - transactionRecord.Amount.ShouldBe(request.VoucherAmount); - transactionRecord.ProductId.ShouldBe(request.ProductId); - transactionRecord.ContractId.ShouldBe(request.ContractId); - transactionRecord.RecipientEmailAddress.ShouldBe(request.RecipientEmailAddress); - transactionRecord.RecipientMobileNumber.ShouldBe(request.RecipientMobileNumber); - transactionRecord.CustomerEmailAddress.ShouldBe(request.CustomerEmailAddress); - transactionRecord.OperatorId.ShouldBe(request.OperatorId); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public void PerformBillPaymentGetAccountRequest_ToTransactionRecord_IsTranslated(Boolean inTrainingMode){ - PerformBillPaymentGetAccountRequest request = PerformBillPaymentGetAccountRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.CustomerAccountNumber); - - TransactionRecord transactionRecord = request.ToTransactionRecord(inTrainingMode); - transactionRecord.TransactionDateTime.ShouldBe(request.TransactionDateTime); - transactionRecord.TransactionType.ShouldBe(2); - transactionRecord.IsTrainingMode.ShouldBe(inTrainingMode); - transactionRecord.ProductId.ShouldBe(request.ProductId); - transactionRecord.ContractId.ShouldBe(request.ContractId); - transactionRecord.CustomerAccountNumber.ShouldBe(request.CustomerAccountNumber); - transactionRecord.OperatorId.ShouldBe(request.OperatorId); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public void PerformBillPaymentMakePostPaymentRequest_ToTransactionRecord_IsTranslated(Boolean inTrainingMode){ - PerformBillPaymentMakePostPaymentRequest request = PerformBillPaymentMakePostPaymentRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.CustomerAccountNumber, - TestData.CustomerAccountName, - TestData.CustomerMobileNumber, - TestData.PaymentAmount); - - TransactionRecord transactionRecord = request.ToTransactionRecord(inTrainingMode); - transactionRecord.TransactionDateTime.ShouldBe(request.TransactionDateTime); - transactionRecord.TransactionType.ShouldBe(2); - transactionRecord.IsTrainingMode.ShouldBe(inTrainingMode); - transactionRecord.ProductId.ShouldBe(request.ProductId); - transactionRecord.ContractId.ShouldBe(request.ContractId); - transactionRecord.CustomerAccountNumber.ShouldBe(request.CustomerAccountNumber); - transactionRecord.OperatorId.ShouldBe(request.OperatorId); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public void PerformBillPaymentMakePrePaymentRequest_ToTransactionRecord_IsTranslated(Boolean inTrainingMode){ - PerformBillPaymentMakePostPaymentRequest request = PerformBillPaymentMakePostPaymentRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.CustomerAccountNumber, - TestData.CustomerAccountName, - TestData.CustomerMobileNumber, - TestData.PaymentAmount); - - TransactionRecord transactionRecord = request.ToTransactionRecord(inTrainingMode); - transactionRecord.TransactionDateTime.ShouldBe(request.TransactionDateTime); - transactionRecord.TransactionType.ShouldBe(2); - transactionRecord.IsTrainingMode.ShouldBe(inTrainingMode); - transactionRecord.ProductId.ShouldBe(request.ProductId); - transactionRecord.ContractId.ShouldBe(request.ContractId); - transactionRecord.CustomerAccountNumber.ShouldBe(request.CustomerAccountNumber); - transactionRecord.OperatorId.ShouldBe(request.OperatorId); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public void PerformBillPaymentGetMeterRequest_ToTransactionRecord_IsTranslated(Boolean inTrainingMode){ - PerformBillPaymentGetMeterRequest request = PerformBillPaymentGetMeterRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.CustomerAccountNumber); - - TransactionRecord transactionRecord = request.ToTransactionRecord(inTrainingMode); - transactionRecord.TransactionDateTime.ShouldBe(request.TransactionDateTime); - transactionRecord.TransactionType.ShouldBe(2); - transactionRecord.IsTrainingMode.ShouldBe(inTrainingMode); - transactionRecord.ProductId.ShouldBe(request.ProductId); - transactionRecord.ContractId.ShouldBe(request.ContractId); - transactionRecord.CustomerAccountNumber.ShouldBe(request.MeterNumber); - transactionRecord.OperatorId.ShouldBe(request.OperatorId); - } - - [Fact] - public void TransactionRecord_UpdateFrom_PerformLogonResponseModel_IsUpdated(){ - TransactionRecord transactionRecord = new TransactionRecord(); - - transactionRecord.IsSuccessful.ShouldBeFalse(); - - Result result = Result.Success(TestData.PerformLogonResponseModel); - - TransactionRecord updatedRecord = transactionRecord.UpdateFrom(result); - updatedRecord.IsSuccessful.ShouldBe(result.Data.IsSuccessful); - updatedRecord.ResponseMessage.ShouldBe(result.Data.ResponseMessage); - updatedRecord.EstateId.ShouldBe(result.Data.EstateId); - updatedRecord.MerchantId.ShouldBe(result.Data.MerchantId); - } - - [Fact] - public void TransactionRecord_UpdateFrom_PerformMobileTopupResponseModel_IsUpdated(){ - TransactionRecord transactionRecord = new TransactionRecord(); - - transactionRecord.IsSuccessful.ShouldBeFalse(); - - Result result = Result.Success(new PerformMobileTopupResponseModel{ - ResponseCode = "0000" - }); - - TransactionRecord updatedRecord = transactionRecord.UpdateFrom(result); - updatedRecord.IsSuccessful.ShouldBe(result.Data.IsSuccessful); - } - - [Fact] - public void TransactionRecord_UpdateFrom_PerformVoucherIssueResponseModel_IsUpdated(){ - TransactionRecord transactionRecord = new TransactionRecord(); - - transactionRecord.IsSuccessful.ShouldBeFalse(); - - Result result = Result.Success(new PerformVoucherIssueResponseModel{ - ResponseCode = "0000" - }); - - TransactionRecord updatedRecord = transactionRecord.UpdateFrom(result); - updatedRecord.IsSuccessful.ShouldBe(result.Data.IsSuccessful); - } - - [Fact] - public void TransactionRecord_UpdateFrom_PerformBillPaymentMakePaymentResponseModel_IsUpdated(){ - TransactionRecord transactionRecord = new TransactionRecord(); - - transactionRecord.IsSuccessful.ShouldBeFalse(); - - Result result = Result.Success(new PerformBillPaymentMakePaymentResponseModel{ - ResponseCode = "0000" - }); - - TransactionRecord updatedRecord = transactionRecord.UpdateFrom(result); - updatedRecord.IsSuccessful.ShouldBe(result.Data.IsSuccessful); - } - - [Fact] - public void TransactionRecord_UpdateFrom_PerformBillPaymentGetAccountResponseModel_IsUpdated(){ - TransactionRecord transactionRecord = new TransactionRecord(); - - transactionRecord.IsSuccessful.ShouldBeFalse(); - - Result result = Result.Success(new PerformBillPaymentGetAccountResponseModel{ - BillDetails = new BillDetails() - }); - - TransactionRecord updatedRecord = transactionRecord.UpdateFrom(result); - updatedRecord.IsSuccessful.ShouldBe(result.Data.IsSuccessful); - } - - [Fact] - public void TransactionRecord_UpdateFrom_PerformBillPaymentGetMeterResponseModel_IsUpdated(){ - TransactionRecord transactionRecord = new TransactionRecord(); - - transactionRecord.IsSuccessful.ShouldBeFalse(); - - Result result = Result.Success(new PerformBillPaymentGetMeterResponseModel{ - MeterDetails = new MeterDetails() - }); - - TransactionRecord updatedRecord = transactionRecord.UpdateFrom(result); - updatedRecord.IsSuccessful.ShouldBe(result.Data.IsSuccessful); - } - - [Fact] - public void PerformLogonRequestModel_ToLogonTransactionRequest_LogonTransactionRequestMessageIsCreated(){ - PerformLogonRequestModel model = new PerformLogonRequestModel{ - TransactionDateTime = TestData.TransactionDateTime, - DeviceIdentifier = TestData.DeviceIdentifier, - ApplicationVersion = TestData.ApplicationVersion, - TransactionNumber = TestData.TransactionNumber - }; - LogonTransactionRequestMessage request = model.ToLogonTransactionRequest(); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(model.TransactionDateTime); - request.DeviceIdentifier.ShouldBe(model.DeviceIdentifier); - request.ApplicationVersion.ShouldBe(model.ApplicationVersion); - request.TransactionNumber.ShouldBe(model.TransactionNumber); - } - - [Fact] - public void PerformReconciliationRequestModel_ToReconciliationRequest_ReconciliationRequestMessageIsCreated(){ - PerformReconciliationRequestModel model = new PerformReconciliationRequestModel{ - TransactionDateTime = TestData.TransactionDateTime, - DeviceIdentifier = TestData.DeviceIdentifier, - ApplicationVersion = TestData.ApplicationVersion, - OperatorTotals = new List{ - new OperatorTotalModel{ - ContractId = TestData.OperatorId1ContractId, - OperatorId = TestData.OperatorId1, - TransactionCount = 10, - TransactionValue = 100.00m - } - }, - TransactionCount = 10, - TransactionValue = 100.00m - }; - ReconciliationRequestMessage request = model.ToReconciliationRequest(); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(model.TransactionDateTime); - request.DeviceIdentifier.ShouldBe(model.DeviceIdentifier); - request.ApplicationVersion.ShouldBe(model.ApplicationVersion); - request.TransactionCount.ShouldBe(model.TransactionCount); - request.TransactionValue.ShouldBe(model.TransactionValue); - request.OperatorTotals.Single().TransactionValue.ShouldBe(model.OperatorTotals.Single().TransactionValue); - request.OperatorTotals.Single().TransactionCount.ShouldBe(model.OperatorTotals.Single().TransactionCount); - request.OperatorTotals.Single().ContractId.ShouldBe(model.OperatorTotals.Single().ContractId); - request.OperatorTotals.Single().OperatorId.ShouldBe(model.OperatorTotals.Single().OperatorId); - } - - [Fact] - public void PerformVoucherIssueRequestModel_ToSaleTransactionRequest_SaleTransactionRequestMessageIsCreated(){ - PerformVoucherIssueRequestModel model = new PerformVoucherIssueRequestModel{ - TransactionDateTime = TestData.TransactionDateTime, - DeviceIdentifier = TestData.DeviceIdentifier, - ApplicationVersion = TestData.ApplicationVersion, - TransactionNumber = TestData.TransactionNumber, - OperatorId = TestData.OperatorId1, - CustomerEmailAddress = TestData.CustomerEmailAddress, - RecipientEmailAddress = TestData.RecipientEmailAddress, - VoucherAmount = TestData.PaymentAmount, - ContractId = TestData.Operator1ProductDetails.ContractId, - ProductId = TestData.Operator1ProductDetails.ProductId, - RecipientMobileNumber = TestData.RecipientMobileNumber - }; - var request = model.ToSaleTransactionRequest(); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(model.TransactionDateTime); - request.DeviceIdentifier.ShouldBe(model.DeviceIdentifier); - request.ApplicationVersion.ShouldBe(model.ApplicationVersion); - request.TransactionNumber.ShouldBe(model.TransactionNumber); - request.OperatorId.ShouldBe(model.OperatorId); - request.CustomerEmailAddress.ShouldBe(model.CustomerEmailAddress); - request.ContractId.ShouldBe(model.ContractId); - request.ProductId.ShouldBe(model.ProductId); - request.AdditionalRequestMetaData.ContainsKey("Amount").ShouldBeTrue(); - request.AdditionalRequestMetaData["Amount"].ShouldBe(model.VoucherAmount.ToString()); - request.AdditionalRequestMetaData.ContainsKey("RecipientEmail").ShouldBeTrue(); - request.AdditionalRequestMetaData["RecipientEmail"].ShouldBe(model.RecipientEmailAddress); - request.AdditionalRequestMetaData.ContainsKey("RecipientMobile").ShouldBeTrue(); - request.AdditionalRequestMetaData["RecipientMobile"].ShouldBe(model.RecipientMobileNumber); - } - - [Fact] - public void PerformMobileTopupRequestModel_ToSaleTransactionRequest_SaleTransactionRequestMessageIsCreated(){ - PerformMobileTopupRequestModel model = new PerformMobileTopupRequestModel{ - TransactionDateTime = TestData.TransactionDateTime, - DeviceIdentifier = TestData.DeviceIdentifier, - ApplicationVersion = TestData.ApplicationVersion, - TransactionNumber = TestData.TransactionNumber, - OperatorId = TestData.OperatorId1, - CustomerEmailAddress = TestData.CustomerEmailAddress, - TopupAmount = TestData.PaymentAmount, - ContractId = TestData.Operator1ProductDetails.ContractId, - ProductId = TestData.Operator1ProductDetails.ProductId - }; - var request = model.ToSaleTransactionRequest(); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(model.TransactionDateTime); - request.DeviceIdentifier.ShouldBe(model.DeviceIdentifier); - request.ApplicationVersion.ShouldBe(model.ApplicationVersion); - request.TransactionNumber.ShouldBe(model.TransactionNumber); - request.OperatorId.ShouldBe(model.OperatorId); - request.CustomerEmailAddress.ShouldBe(model.CustomerEmailAddress); - request.ContractId.ShouldBe(model.ContractId); - request.ProductId.ShouldBe(model.ProductId); - request.AdditionalRequestMetaData.ContainsKey("Amount").ShouldBeTrue(); - request.AdditionalRequestMetaData["Amount"].ShouldBe(model.TopupAmount.ToString()); - } - - [Fact] - public void PerformBillPaymentGetAccountModel_ToSaleTransactionRequest_SaleTransactionRequestMessageIsCreated(){ - PerformBillPaymentGetAccountModel model = new PerformBillPaymentGetAccountModel{ - TransactionDateTime = TestData.TransactionDateTime, - DeviceIdentifier = TestData.DeviceIdentifier, - ApplicationVersion = TestData.ApplicationVersion, - TransactionNumber = TestData.TransactionNumber, - OperatorId = TestData.OperatorId1, - ContractId = TestData.Operator1ProductDetails.ContractId, - ProductId = TestData.Operator1ProductDetails.ProductId, - CustomerAccountNumber = TestData.CustomerAccountNumber, - }; - var request = model.ToSaleTransactionRequest(); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(model.TransactionDateTime); - request.DeviceIdentifier.ShouldBe(model.DeviceIdentifier); - request.ApplicationVersion.ShouldBe(model.ApplicationVersion); - request.TransactionNumber.ShouldBe(model.TransactionNumber); - request.OperatorId.ShouldBe(model.OperatorId); - request.ContractId.ShouldBe(model.ContractId); - request.ProductId.ShouldBe(model.ProductId); - request.AdditionalRequestMetaData.ContainsKey("CustomerAccountNumber").ShouldBeTrue(); - request.AdditionalRequestMetaData["CustomerAccountNumber"].ShouldBe(model.CustomerAccountNumber); - request.AdditionalRequestMetaData.ContainsKey("PataPawaPostPaidMessageType").ShouldBeTrue(); - request.AdditionalRequestMetaData["PataPawaPostPaidMessageType"].ShouldBe("VerifyAccount"); - } - - [Fact] - public void PerformBillPaymentGetMeterModel_ToSaleTransactionRequest_SaleTransactionRequestMessageIsCreated(){ - PerformBillPaymentGetMeterModel model = new PerformBillPaymentGetMeterModel{ - TransactionDateTime = TestData.TransactionDateTime, - DeviceIdentifier = TestData.DeviceIdentifier, - ApplicationVersion = TestData.ApplicationVersion, - TransactionNumber = TestData.TransactionNumber, - OperatorId = TestData.OperatorId1, - ContractId = TestData.Operator1ProductDetails.ContractId, - ProductId = TestData.Operator1ProductDetails.ProductId, - MeterNumber = TestData.MeterNumber, - }; - var request = model.ToSaleTransactionRequest(); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(model.TransactionDateTime); - request.DeviceIdentifier.ShouldBe(model.DeviceIdentifier); - request.ApplicationVersion.ShouldBe(model.ApplicationVersion); - request.TransactionNumber.ShouldBe(model.TransactionNumber); - request.OperatorId.ShouldBe(model.OperatorId); - request.ContractId.ShouldBe(model.ContractId); - request.ProductId.ShouldBe(model.ProductId); - request.AdditionalRequestMetaData.ContainsKey("MeterNumber").ShouldBeTrue(); - request.AdditionalRequestMetaData["MeterNumber"].ShouldBe(model.MeterNumber); - request.AdditionalRequestMetaData.ContainsKey("PataPawaPrePayMessageType").ShouldBeTrue(); - request.AdditionalRequestMetaData["PataPawaPrePayMessageType"].ShouldBe("meter"); - } - - [Fact] - public void PerformBillPaymentMakePaymentModel_PrePayment_ToSaleTransactionRequest_SaleTransactionRequestMessageIsCreated(){ - PerformBillPaymentMakePaymentModel model = new PerformBillPaymentMakePaymentModel{ - TransactionDateTime = TestData.TransactionDateTime, - DeviceIdentifier = TestData.DeviceIdentifier, - ApplicationVersion = TestData.ApplicationVersion, - TransactionNumber = TestData.TransactionNumber, - OperatorId = TestData.OperatorId1, - ContractId = TestData.Operator1ProductDetails.ContractId, - ProductId = TestData.Operator1ProductDetails.ProductId, - PaymentAmount = TestData.PaymentAmount, - CustomerAccountNumber = TestData.CustomerAccountNumber, - CustomerAccountName = TestData.CustomerAccountName, - CustomerMobileNumber = TestData.CustomerMobileNumber, - }; - var request = model.ToSaleTransactionRequest(); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(model.TransactionDateTime); - request.DeviceIdentifier.ShouldBe(model.DeviceIdentifier); - request.ApplicationVersion.ShouldBe(model.ApplicationVersion); - request.TransactionNumber.ShouldBe(model.TransactionNumber); - request.OperatorId.ShouldBe(model.OperatorId); - request.ContractId.ShouldBe(model.ContractId); - request.ProductId.ShouldBe(model.ProductId); - - request.AdditionalRequestMetaData.ContainsKey("MeterNumber").ShouldBeTrue(); - request.AdditionalRequestMetaData["MeterNumber"].ShouldBe(model.CustomerAccountNumber); - request.AdditionalRequestMetaData.ContainsKey("CustomerName").ShouldBeTrue(); - request.AdditionalRequestMetaData["CustomerName"].ShouldBe(model.CustomerAccountName); - request.AdditionalRequestMetaData.ContainsKey("MeterNumber").ShouldBeTrue(); - request.AdditionalRequestMetaData["MeterNumber"].ShouldBe(model.CustomerAccountNumber); - request.AdditionalRequestMetaData.ContainsKey("Amount").ShouldBeTrue(); - request.AdditionalRequestMetaData["Amount"].ShouldBe(model.PaymentAmount.ToString()); - request.AdditionalRequestMetaData.ContainsKey("PataPawaPrePayMessageType").ShouldBeTrue(); - request.AdditionalRequestMetaData["PataPawaPrePayMessageType"].ShouldBe("vend"); - } - - [Fact] - public void PerformBillPaymentMakePaymentModel_PostPayment_ToSaleTransactionRequest_SaleTransactionRequestMessageIsCreated(){ - PerformBillPaymentMakePaymentModel model = new PerformBillPaymentMakePaymentModel{ - TransactionDateTime = TestData.TransactionDateTime, - DeviceIdentifier = TestData.DeviceIdentifier, - ApplicationVersion = TestData.ApplicationVersion, - TransactionNumber = TestData.TransactionNumber, - OperatorId = TestData.OperatorId1, - ContractId = TestData.Operator1ProductDetails.ContractId, - ProductId = TestData.Operator1ProductDetails.ProductId, - PaymentAmount = TestData.PaymentAmount, - CustomerAccountNumber = TestData.CustomerAccountNumber, - CustomerAccountName = TestData.CustomerAccountName, - CustomerMobileNumber = TestData.CustomerMobileNumber, - PostPayment = true - }; - var request = model.ToSaleTransactionRequest(); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(model.TransactionDateTime); - request.DeviceIdentifier.ShouldBe(model.DeviceIdentifier); - request.ApplicationVersion.ShouldBe(model.ApplicationVersion); - request.TransactionNumber.ShouldBe(model.TransactionNumber); - request.OperatorId.ShouldBe(model.OperatorId); - request.ContractId.ShouldBe(model.ContractId); - request.ProductId.ShouldBe(model.ProductId); - - request.AdditionalRequestMetaData.ContainsKey("CustomerAccountNumber").ShouldBeTrue(); - request.AdditionalRequestMetaData["CustomerAccountNumber"].ShouldBe(model.CustomerAccountNumber); - request.AdditionalRequestMetaData.ContainsKey("CustomerName").ShouldBeTrue(); - request.AdditionalRequestMetaData["CustomerName"].ShouldBe(model.CustomerAccountName); - request.AdditionalRequestMetaData.ContainsKey("MobileNumber").ShouldBeTrue(); - request.AdditionalRequestMetaData["MobileNumber"].ShouldBe(model.CustomerMobileNumber); - request.AdditionalRequestMetaData.ContainsKey("Amount").ShouldBeTrue(); - request.AdditionalRequestMetaData["Amount"].ShouldBe(model.PaymentAmount.ToString()); - request.AdditionalRequestMetaData.ContainsKey("PataPawaPostPaidMessageType").ShouldBeTrue(); - request.AdditionalRequestMetaData["PataPawaPostPaidMessageType"].ShouldBe("ProcessBill"); - } - - [Theory] - [InlineData("CustomerAccountNumber")] - [InlineData("customeraccountnumber")] - [InlineData("CUSTOMERACCOUNTNUMBER")] - public void ExtractFieldFromMetadata_ExtractField_FieldIsExtracted(String fieldToExtract){ - Dictionary testMetaData = new Dictionary{ - { "CustomerAccountNumber", TestData.CustomerAccountNumber } - }; - - String extractedValue = testMetaData.ExtractFieldFromMetadata(fieldToExtract); - extractedValue.ShouldBe(TestData.CustomerAccountNumber); - } - - [Fact] - public void ExtractFieldFromMetadata_ExtractField_KeyNotFound_DefaultValueReturned() - { - Dictionary testMetaData = new Dictionary{ - { "CustomerAccountNumber", TestData.CustomerAccountNumber } - }; - - String extractedValue = testMetaData.ExtractFieldFromMetadata("TestValue"); - extractedValue.ShouldBeNull(); - } - - [Fact] - public void ExtractFieldFromMetadata_ExtractField_DictionaryValueNull_DefaultValueReturned() - { - Dictionary testMetaData = new Dictionary{ - { "CustomerAccountNumber", null } - }; - - String extractedValue = testMetaData.ExtractFieldFromMetadata("CustomerAccountNumber"); - extractedValue.ShouldBeNull(); - } - - [Fact] - public void MetaData_ToBillDetails_BillDetailsReturned(){ - Dictionary testMetaData = new Dictionary{ - { "customerAccountName", TestData.BillDetails.AccountName }, - { "customerAccountNumber", TestData.BillDetails.AccountNumber }, - { "customerBillBalance", TestData.BillDetails.Balance }, - { "customerBillDueDate", TestData.BillDetails.DueDate } - }; - BillDetails billDetails = testMetaData.ToBillDetails(); - - billDetails.AccountName.ShouldBe(TestData.BillDetails.AccountName); - billDetails.AccountNumber.ShouldBe(TestData.BillDetails.AccountNumber); - billDetails.Balance.ShouldBe(TestData.BillDetails.Balance); - billDetails.DueDate.ShouldBe(TestData.BillDetails.DueDate); - } - - [Fact] - public void MetaData_ToMeterDetails_MeterDetailsReturned() - { - Dictionary testMetaData = new Dictionary{ - { "pataPawaPrePaidCustomerName", TestData.MeterDetails.CustomerName } - }; - MeterDetails meterDetails = testMetaData.ToMeterDetails(TestData.MeterNumber); - - meterDetails.CustomerName.ShouldBe(TestData.MeterDetails.CustomerName); - meterDetails.MeterNumber.ShouldBe(TestData.MeterNumber); - } - - [Theory] - [InlineData("0000", true)] - [InlineData("0001", false)] - public void SaleTransactionResponseMessage_IsSuccessfulTransaction_ExpectedValueReturned(String responseCode, Boolean expectedValue){ - SaleTransactionResponseMessage responseMessage = new SaleTransactionResponseMessage{ - ResponseCode = responseCode - }; - responseMessage.IsSuccessfulTransaction().ShouldBe(expectedValue); - } - - [Theory] - [InlineData("0000", true)] - [InlineData("0001", false)] - public void ReconciliationResponseMessage_IsSuccessfulTransaction_ExpectedValueReturned(String responseCode, Boolean expectedValue) - { - ReconciliationResponseMessage responseMessage = new ReconciliationResponseMessage - { - ResponseCode = responseCode - }; - responseMessage.IsSuccessfulReconciliation().ShouldBe(expectedValue); - } - } - - public class ResultExtensionsTests{ - [Fact] - public void FailureExtended_FailureResultReturned(){ - var result = ResultExtensions.FailureExtended("Message", new Exception("ExceptionsMessage")); - result.IsFailed.ShouldBeTrue(); - result.Message.ShouldBe("Message"); - result.Errors.Single().ShouldBe("ExceptionsMessage"); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/LoginRequestHandlerTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/LoginRequestHandlerTests.cs deleted file mode 100644 index cec5db99e..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/LoginRequestHandlerTests.cs +++ /dev/null @@ -1,97 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.RequestHandlerTests; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Common; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using Xunit; - -public class LoginRequestHandlerTests -{ - private Mock AuthenticationService = null; - private Mock ConfigurationService = null; - private LoginRequestHandler LoginRequestHandler = null; - private readonly Mock ApplicationCache; - private Func AuthenticationServiceResolver; - private Func ConfigurationServiceResolver; - - public LoginRequestHandlerTests() { - this.AuthenticationService = new Mock(); - this.ConfigurationService= new Mock(); - this.ApplicationCache = new Mock(); - this.AuthenticationServiceResolver = _ => - { - return this.AuthenticationService.Object; - }; - this.ConfigurationServiceResolver = _ => - { - return this.ConfigurationService.Object; - }; - - - this.LoginRequestHandler = new LoginRequestHandler(this.AuthenticationServiceResolver, this.ConfigurationServiceResolver,this.ApplicationCache.Object); - } - - [Fact] - public async Task LoginRequestHandler_Handle_LoginRequest_IsHandled() - { - this.AuthenticationService.Setup(a => a.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.AccessToken)); - this.ConfigurationService.Setup(c => c.GetConfiguration(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new Configuration())); - - LoginRequest request = LoginRequest.Create(TestData.UserName,TestData.Password); - - Result result = await this.LoginRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.AccessToken.ShouldBe(TestData.Token); - result.Data.ExpiryInMinutes.ShouldBe(TestData.TokenExpiryInMinutes); - result.Data.RefreshToken.ShouldBe(TestData.RefreshToken); - } - - [Fact] - public async Task LoginRequestHandler_Handle_RefreshTokenRequest_IsHandled() - { - Mock authenticationService = new Mock(); - Func authenticationServiceResolver = new Func((param) => - { - return authenticationService.Object; - }); - Mock configurationService = new Mock(); - Func configurationServiceResolver = new Func((param) => - { - return configurationService.Object; - }); - this.AuthenticationService.Setup(a => a.RefreshAccessToken(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.AccessToken)); - this.ConfigurationService.Setup(c => c.GetConfiguration(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new Configuration())); - - RefreshTokenRequest request = RefreshTokenRequest.Create(TestData.RefreshToken); - - Result result = await this.LoginRequestHandler .Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.AccessToken.ShouldBe(TestData.Token); - result.Data.ExpiryInMinutes.ShouldBe(TestData.TokenExpiryInMinutes); - result.Data.RefreshToken.ShouldBe(TestData.RefreshToken); - } - - [Fact] - public async Task LoginRequestHandler_Handle_GetConfigurationRequest_IsHandled() - { - this.AuthenticationService.Setup(a => a.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.AccessToken)); - this.ConfigurationService.Setup(c => c.GetConfiguration(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new Configuration())); - - GetConfigurationRequest request = GetConfigurationRequest.Create(TestData.DeviceIdentifier); - - Result result = await this.LoginRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.ShouldNotBeNull(); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/MerchantRequestHandlerTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/MerchantRequestHandlerTests.cs deleted file mode 100644 index 63678a8d0..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/MerchantRequestHandlerTests.cs +++ /dev/null @@ -1,147 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.RequestHandlerTests; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Common; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using Xunit; - -public class MerchantRequestHandlerTests -{ - #region Fields - - private readonly Mock ApplicationCache; - - private readonly MerchantRequestHandler MerchantRequestHandler; - - private readonly Mock MerchantService; - - private Func MerchantServiceResolver; - #endregion - - #region Constructors - - public MerchantRequestHandlerTests() { - this.MerchantService = new Mock(); - this.ApplicationCache = new Mock(); - this.MerchantService = new Mock(); - this.MerchantServiceResolver = (param) => { - return this.MerchantService.Object; - }; - this.MerchantRequestHandler = new MerchantRequestHandler(this.MerchantServiceResolver, this.ApplicationCache.Object); - } - - #endregion - - #region Methods - - [Fact] - public async Task MerchantRequestHandler_GetContractProductsRequest_Handle_IsHandled() { - this.MerchantService.Setup(m => m.GetContractProducts(It.IsAny())) - .ReturnsAsync(Result.Success(TestData.ContractProductList)); - - GetContractProductsRequest request = GetContractProductsRequest.Create(); - - Result> result = await this.MerchantRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.Count.ShouldBe(TestData.ContractProductList.Count); - } - - [Fact] - public async Task MerchantRequestHandler_GetContractProductsRequest_Handle_CacheIsNull_IsHandled(){ - List products = null; - this.ApplicationCache.Setup(a => a.GetContractProducts()).Returns(products); - - this.MerchantService.Setup(m => m.GetContractProducts(It.IsAny())) - .ReturnsAsync(Result.Success(TestData.ContractProductList)); - - GetContractProductsRequest request = GetContractProductsRequest.Create(); - - Result> result = await this.MerchantRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.Count.ShouldBe(TestData.ContractProductList.Count); - } - - [Fact] - public async Task MerchantRequestHandler_GetContractProductsRequest_Handle_GetContractProductsFailed_IsHandled() - { - List products = new List(); - this.ApplicationCache.Setup(a => a.GetContractProducts()).Returns(products); - - this.MerchantService.Setup(m => m.GetContractProducts(It.IsAny())) - .ReturnsAsync(Result.Failure("failed")); - - GetContractProductsRequest request = GetContractProductsRequest.Create(); - - Result> result = await this.MerchantRequestHandler.Handle(request, CancellationToken.None); - - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task MerchantRequestHandler_GetContractProductsRequest_Handle_FilterByType_IsHandled() - { - this.MerchantService.Setup(m => m.GetContractProducts(It.IsAny())) - .ReturnsAsync(Result.Success(TestData.ContractProductList)); - - GetContractProductsRequest request = GetContractProductsRequest.Create(ProductType.Voucher); - - Result> result = await this.MerchantRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.Count.ShouldBe(1); - } - - [Fact] - public async Task MerchantRequestHandler_GetContractProductsRequest_Handle_CacheIsEmpty_IsHandled() - { - List products = new List(); - this.ApplicationCache.Setup(a => a.GetContractProducts()).Returns(products); - - this.MerchantService.Setup(m => m.GetContractProducts(It.IsAny())) - .ReturnsAsync(Result.Success(TestData.ContractProductList)); - - GetContractProductsRequest request = GetContractProductsRequest.Create(); - - Result> result = await this.MerchantRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.Count.ShouldBe(TestData.ContractProductList.Count); - } - - [Fact] - public async Task MerchantRequestHandler_GetMerchantBalanceRequest_Handle_IsHandled() { - this.MerchantService.Setup(m => m.GetMerchantBalance(It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantBalance)); - - GetMerchantBalanceRequest request = GetMerchantBalanceRequest.Create(); - - Result result = await this.MerchantRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.ShouldBe(TestData.MerchantBalance); - } - - [Fact] - public async Task MerchantRequestHandler_GetMerchantDetailsRequest_Handle_IsHandled() - { - this.MerchantService.Setup(m => m.GetMerchantDetails(It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantDetailsModel)); - - GetMerchantDetailsRequest request = GetMerchantDetailsRequest.Create(); - - Result result = await this.MerchantRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/SupportRequestHandlerTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/SupportRequestHandlerTests.cs deleted file mode 100644 index 1a9dfccbd..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/SupportRequestHandlerTests.cs +++ /dev/null @@ -1,154 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.RequestHandlerTests; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Database; -using Microsoft.Data.Sqlite; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using Xunit; - -public class SupportRequestHandlerTests -{ - - [Fact] - public async Task SupportRequestHandlerTests_UploadLogsRequest_NoLogs_Handle_IsHandled() - { - Mock configurationService = new Mock(); - Func configurationServiceResolver = new Func((param) => - { - return configurationService.Object; - }); - - Mock databaseContext = new Mock(); - databaseContext.Setup(d => d.GetLogMessages(It.IsAny(), It.IsAny())).ReturnsAsync(new List()); - Mock applicationCache = new Mock(); - - SupportRequestHandler handler = new SupportRequestHandler(configurationServiceResolver, databaseContext.Object, applicationCache.Object); - - UploadLogsRequest request = UploadLogsRequest.Create(TestData.DeviceIdentifier); - - Boolean response = await handler.Handle(request, CancellationToken.None); - - response.ShouldBeTrue(); - } - - [Fact] - public async Task SupportRequestHandlerTests_UploadLogsRequest_LogsToUpload_Only10Messages_Handle_IsHandled() - { - Mock configurationService = new Mock(); - Func configurationServiceResolver = new Func((param) => - { - return configurationService.Object; - }); - Mock databaseContext = new Mock(); - databaseContext.SetupSequence(d => d.GetLogMessages(It.IsAny(), It.IsAny())).ReturnsAsync(new List() - { - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()} - }).ReturnsAsync(new List()); - - Mock applicationCache = new Mock(); - - SupportRequestHandler handler = new SupportRequestHandler(configurationServiceResolver, databaseContext.Object, applicationCache.Object); - - UploadLogsRequest request = UploadLogsRequest.Create(TestData.DeviceIdentifier); - - Boolean response = await handler.Handle(request, CancellationToken.None); - - response.ShouldBeTrue(); - databaseContext.Verify(d => d.RemoveUploadedMessages(It.IsAny>()), Times.Once); - } - - [Fact] - public async Task SupportRequestHandlerTests_UploadLogsRequest_LogsToUpload_15Messages_Handle_IsHandled() - { - Mock configurationService = new Mock(); - Func configurationServiceResolver = new Func((param) => - { - return configurationService.Object; - }); - Mock databaseContext = new Mock(); - databaseContext.SetupSequence(d => d.GetLogMessages(It.IsAny(), It.IsAny())).ReturnsAsync(new List() - { - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - }).ReturnsAsync(new List() - { - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - new Database.LogMessage{LogLevel = LogLevel.Debug.ToString()}, - }).ReturnsAsync(new List()); - - Mock applicationCache = new Mock(); - - SupportRequestHandler handler = new SupportRequestHandler(configurationServiceResolver, databaseContext.Object, applicationCache.Object); - - UploadLogsRequest request = UploadLogsRequest.Create(TestData.DeviceIdentifier); - - Boolean response = await handler.Handle(request, CancellationToken.None); - - response.ShouldBeTrue(); - databaseContext.Verify(d => d.RemoveUploadedMessages(It.IsAny>()), Times.Exactly(2)); - } - - [Theory] - [InlineData(true, 4)] - [InlineData(false, 3)] - public async Task SupportRequestHandlerTests_ViewLogsRequest_Handle_IsHandled(Boolean isTrainingMode, Int32 expectedNumberMessages) - { - Mock configurationService = new Mock(); - Func configurationServiceResolver = new Func((param) => - { - return configurationService.Object; - }); - Func logLevelFunc = new Func(() => - { - return Database.LogLevel.Debug; - }); - IDatabaseContext databaseContext = new DatabaseContext(":memory:", logLevelFunc); - await databaseContext.InitialiseDatabase(); - - List logMessages = new List(); - logMessages.Add(new LogMessage { LogLevel = LogLevel.Debug.ToString() }); - logMessages.Add(new LogMessage { LogLevel = LogLevel.Debug.ToString() }); - logMessages.Add(new LogMessage { LogLevel = LogLevel.Debug.ToString() }); - logMessages.Add(new LogMessage { LogLevel = LogLevel.Debug.ToString(), IsTrainingMode = true }); - logMessages.Add(new LogMessage { LogLevel = LogLevel.Debug.ToString(), IsTrainingMode = true }); - logMessages.Add(new LogMessage { LogLevel = LogLevel.Debug.ToString(), IsTrainingMode = true }); - logMessages.Add(new LogMessage { LogLevel = LogLevel.Debug.ToString(), IsTrainingMode = true }); - await databaseContext.InsertLogMessages(logMessages); - - Mock applicationCache = new Mock(); - applicationCache.Setup(s => s.GetUseTrainingMode()).Returns(isTrainingMode); - SupportRequestHandler handler = new SupportRequestHandler(configurationServiceResolver, databaseContext, applicationCache.Object); - - ViewLogsRequest request = ViewLogsRequest.Create(); - List? result = await handler.Handle(request, CancellationToken.None); - - result.Count.ShouldBe(expectedNumberMessages); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/TransactionRequestHandlerTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/TransactionRequestHandlerTests.cs deleted file mode 100644 index 96590fc91..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestHandlerTests/TransactionRequestHandlerTests.cs +++ /dev/null @@ -1,373 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.RequestHandlerTests; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Common; -using Database; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using TransactionProcessorACL.DataTransferObjects.Responses; -using UIServices; -using Xunit; - -public class TransactionRequestHandlerTests -{ - private Mock TransactionService; - - private Mock DatabaseContext; - - private Mock ApplicationCache; - - private Mock ApplicationInfoService; - - private Mock DeviceService; - - private TransactionRequestHandler TransactionRequestHandler; - - private Func TransactionServiceResolver; - - public TransactionRequestHandlerTests() { - this.TransactionService = new Mock(); - this.DatabaseContext = new Mock(); - this.ApplicationCache = new Mock(); - this.ApplicationInfoService = new Mock(); - this.DeviceService = new Mock(); - this.TransactionServiceResolver = _ => - { - return this.TransactionService.Object; - }; - - - this.TransactionRequestHandler = new TransactionRequestHandler(this.TransactionServiceResolver, - this.DatabaseContext.Object, - this.ApplicationCache.Object, - this.ApplicationInfoService.Object, - this.DeviceService.Object); - - } - - [Fact] - public async Task TransactionRequestHandler_LogonTransactionRequest_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformLogon(It.IsAny(), It.IsAny())).ReturnsAsync( - Result.Success(TestData.PerformLogonResponseModel)); - - LogonTransactionRequest request = LogonTransactionRequest.Create(TestData.TransactionDateTime); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionRequestHandler_LogonTransactionRequest_Handle_LogonFailed_IsHandled() - { - this.TransactionService.Setup(t => t.PerformLogon(It.IsAny(), It.IsAny())).ReturnsAsync( - Result.Success(TestData.PerformLogonResponseFailedModel)); - - LogonTransactionRequest request = LogonTransactionRequest.Create(TestData.TransactionDateTime); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeFalse(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformMobileTopupRequest_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformMobileTopup(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformMobileTopupResponseModel - { - ResponseCode = "0000" - })); - - PerformMobileTopupRequest request = PerformMobileTopupRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.CustomerAccountNumber, - TestData.Operator1Product_100KES.Value, - TestData.CustomerEmailAddress); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformMobileTopupRequest_Handle_TopupFailed_IsHandled() - { - this.TransactionService.Setup(t => t.PerformMobileTopup(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformMobileTopupResponseModel - { - ResponseCode = "1000" - })); - - PerformMobileTopupRequest request = PerformMobileTopupRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.CustomerAccountNumber, - TestData.Operator1Product_100KES.Value, - TestData.CustomerEmailAddress); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeFalse(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformVoucherIssueRequest_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformVoucherIssue(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformVoucherIssueResponseModel - { - ResponseCode = "0000" - })); - - PerformVoucherIssueRequest request = PerformVoucherIssueRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.RecipientMobileNumber, - TestData.RecipientEmailAddress, - TestData.Operator3Product_200KES.Value, - TestData.CustomerEmailAddress); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformVoucherIssueRequest_Handle_VoucherIssueFailed_IsHandled() - { - this.TransactionService.Setup(t => t.PerformVoucherIssue(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformVoucherIssueResponseModel - { - ResponseCode = "1000" - })); - - PerformVoucherIssueRequest request = PerformVoucherIssueRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.RecipientMobileNumber, - TestData.RecipientEmailAddress, - TestData.Operator3Product_200KES.Value, - TestData.CustomerEmailAddress); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeFalse(); - result.IsSuccess.ShouldBeFalse(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformBillPaymentGetAccountRequest_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformBillPaymentGetAccount(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.PerformBillPaymentGetAccountResponseModel)); - - PerformBillPaymentGetAccountRequest request = PerformBillPaymentGetAccountRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.CustomerAccountNumber); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeTrue(); - result.Data.BillDetails.ShouldNotBeNull(); - - } - - [Fact] - public async Task TransactionRequestHandler_PerformBillPaymentGetAccountRequest_GetAccountFailed_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformBillPaymentGetAccount(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.PerformBillPaymentGetAccountResponseModelFailed)); - - PerformBillPaymentGetAccountRequest request = PerformBillPaymentGetAccountRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.CustomerAccountNumber); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeFalse(); - result.Data.BillDetails.ShouldBeNull(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformBillPaymentGetMeterRequest_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformBillPaymentGetMeter(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.PerformBillPaymentGetMeterResponseModel)); - - PerformBillPaymentGetMeterRequest request = PerformBillPaymentGetMeterRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.CustomerAccountNumber); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeTrue(); - result.Data.MeterDetails.ShouldNotBeNull(); - - } - - [Fact] - public async Task TransactionRequestHandler_PerformBillPaymentGetMeterRequest_GetMeterFailed_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformBillPaymentGetMeter(It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.PerformBillPaymentGetMeterResponseModelFailed)); - - PerformBillPaymentGetMeterRequest request = PerformBillPaymentGetMeterRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.CustomerAccountNumber); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeFalse(); - result.Data.MeterDetails.ShouldBeNull(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformBillPaymentMakePostPaymentRequest_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformBillPaymentMakePayment(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformBillPaymentMakePaymentResponseModel - { - ResponseCode = "0000" - })); - - PerformBillPaymentMakePostPaymentRequest request = PerformBillPaymentMakePostPaymentRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.CustomerAccountNumber, - TestData.CustomerAccountName, - TestData.CustomerMobileNumber, - TestData.PaymentAmount); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformBillPaymentMakePrePaymentRequest_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformBillPaymentMakePayment(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformBillPaymentMakePaymentResponseModel - { - ResponseCode = "0000" - })); - - PerformBillPaymentMakePrePaymentRequest request = PerformBillPaymentMakePrePaymentRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.MeterNumber, - TestData.CustomerAccountName, - TestData.PaymentAmount); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformBillPaymentMakePostPaymentRequest_PaymentFailed_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformBillPaymentMakePayment(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformBillPaymentMakePaymentResponseModel - { - ResponseCode = "0001" - })); - - PerformBillPaymentMakePostPaymentRequest request = PerformBillPaymentMakePostPaymentRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.CustomerAccountNumber, - TestData.CustomerAccountName, - TestData.CustomerMobileNumber, - TestData.PaymentAmount); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformBillPaymentMakePrePaymentRequest_PaymentFailed_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformBillPaymentMakePayment(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformBillPaymentMakePaymentResponseModel - { - ResponseCode = "0001" - })); - - PerformBillPaymentMakePrePaymentRequest request = PerformBillPaymentMakePrePaymentRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.MeterNumber, - TestData.CustomerAccountName, - TestData.PaymentAmount); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformReconciliationRequest_NoTransactions_Handle_IsHandled() - { - this.TransactionService.Setup(t => t.PerformReconciliation(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformReconciliationResponseModel - { - ResponseCode = "0000" - })); - this.DatabaseContext.Setup(d => d.GetTransactions(It.IsAny())).ReturnsAsync(new List()); - - PerformReconciliationRequest request = PerformReconciliationRequest.Create(TestData.TransactionDateTime, - TestData.DeviceIdentifier, - TestData.ApplicationVersion); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionRequestHandler_PerformReconciliationRequest_TransactionsStored_Handle_IsHandled() { - this.TransactionService.Setup(t => t.PerformReconciliation(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformReconciliationResponseModel - { - ResponseCode = "0000" - })); - - this.DatabaseContext.Setup(d => d.GetTransactions(It.IsAny())).ReturnsAsync(TestData.StoredTransactions); - - PerformReconciliationRequest request = PerformReconciliationRequest.Create(TestData.TransactionDateTime, TestData.DeviceIdentifier, TestData.ApplicationVersion); - - Result result = await this.TransactionRequestHandler.Handle(request, CancellationToken.None); - - result.IsSuccess.ShouldBeTrue(); - result.Data.IsSuccessful.ShouldBeTrue(); - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestTests/RequestTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestTests/RequestTests.cs deleted file mode 100644 index 2bcf39105..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/RequestTests/RequestTests.cs +++ /dev/null @@ -1,214 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.RequestTests; - -using Requests; -using Shouldly; -using Xunit; - -public class RequestTests -{ - [Fact] - public void GetContractProductsRequest_Create_IsCreated() - { - GetContractProductsRequest request = GetContractProductsRequest.Create(); - - request.ShouldNotBeNull(); - request.ProductType.ShouldBeNull(); - } - - [Theory] - [InlineData(Models.ProductType.BillPayment)] - [InlineData(Models.ProductType.MobileWallet)] - [InlineData(Models.ProductType.MobileTopup)] - [InlineData(Models.ProductType.Voucher)] - public void GetContractProductsRequest_Create_WithProductType_IsCreated(Models.ProductType productType) - { - GetContractProductsRequest request = GetContractProductsRequest.Create(productType); - - request.ShouldNotBeNull(); - request.ProductType.ShouldBe(productType); - } - - [Fact] - public void GetMerchantBalanceRequest_Create_IsCreated() - { - GetMerchantBalanceRequest request = GetMerchantBalanceRequest.Create(); - - request.ShouldNotBeNull(); - } - - [Fact] - public void LoginRequest_Create_IsCreated() - { - LoginRequest request = LoginRequest.Create(TestData.UserName, - TestData.Password); - - request.ShouldNotBeNull(); - request.UserName.ShouldBe(TestData.UserName); - request.Password.ShouldBe(TestData.Password); - } - - [Fact] - public void RefreshTokenRequest_Create_IsCreated() - { - RefreshTokenRequest request = RefreshTokenRequest.Create(TestData.RefreshToken); - - request.ShouldNotBeNull(); - request.RefreshToken.ShouldBe(TestData.RefreshToken); - } - - [Fact] - public void LogonTransactionRequest_Create_IsCreated() - { - LogonTransactionRequest request = LogonTransactionRequest.Create(TestData.TransactionDateTime); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(TestData.TransactionDateTime); - } - - [Fact] - public void PerformMobileTopupRequest_Create_IsCreated() - { - PerformMobileTopupRequest request = PerformMobileTopupRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId1ContractId, - TestData.Operator1Product_100KES.ProductId, - TestData.OperatorId1, - TestData.CustomerAccountNumber, - TestData.Operator1Product_100KES.Value, - TestData.CustomerEmailAddress); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(TestData.TransactionDateTime); - request.ContractId.ShouldBe(TestData.OperatorId1ContractId); - request.ProductId.ShouldBe(TestData.Operator1Product_100KES.ProductId); - request.OperatorId.ShouldBe(TestData.OperatorId1); - request.CustomerAccountNumber.ShouldBe(TestData.CustomerAccountNumber); - request.TopupAmount.ShouldBe(TestData.Operator1Product_100KES.Value); - request.CustomerEmailAddress.ShouldBe(TestData.CustomerEmailAddress); - } - - [Fact] - public void PerformVoucherIssueRequest_Create_IsCreated() - { - PerformVoucherIssueRequest request = PerformVoucherIssueRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.RecipientMobileNumber, - TestData.RecipientEmailAddress, - TestData.Operator3Product_200KES.Value, - TestData.CustomerEmailAddress); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(TestData.TransactionDateTime); - request.ContractId.ShouldBe(TestData.OperatorId3ContractId); - request.ProductId.ShouldBe(TestData.Operator3Product_200KES.ProductId); - request.OperatorId.ShouldBe(TestData.OperatorId3); - request.RecipientMobileNumber.ShouldBe(TestData.RecipientMobileNumber); - request.RecipientEmailAddress.ShouldBe(TestData.RecipientEmailAddress); - request.VoucherAmount.ShouldBe(TestData.Operator3Product_200KES.Value); - request.CustomerEmailAddress.ShouldBe(TestData.CustomerEmailAddress); - } - - [Fact] - public void PerformBillPaymentMakePostPaymentRequest_Create_IsCreated() { - PerformBillPaymentMakePostPaymentRequest request = PerformBillPaymentMakePostPaymentRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.CustomerAccountNumber, - TestData.CustomerAccountName, - TestData.CustomerMobileNumber, - TestData.PaymentAmount); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(TestData.TransactionDateTime); - request.ContractId.ShouldBe(TestData.OperatorId3ContractId); - request.ProductId.ShouldBe(TestData.Operator3Product_200KES.ProductId); - request.OperatorId.ShouldBe(TestData.OperatorId3); - request.CustomerAccountNumber.ShouldBe(TestData.CustomerAccountNumber); - request.CustomerAccountName.ShouldBe(TestData.CustomerAccountName); - request.CustomerMobileNumber.ShouldBe(TestData.CustomerMobileNumber); - request.PaymentAmount.ShouldBe(TestData.PaymentAmount); - } - - [Fact] - public void PerformBillPaymentMakePaymentRequest_Create_IsCreated() - { - PerformBillPaymentMakePrePaymentRequest request = PerformBillPaymentMakePrePaymentRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.MeterNumber, - TestData.CustomerAccountName, - TestData.PaymentAmount); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(TestData.TransactionDateTime); - request.ContractId.ShouldBe(TestData.OperatorId3ContractId); - request.ProductId.ShouldBe(TestData.Operator3Product_200KES.ProductId); - request.OperatorId.ShouldBe(TestData.OperatorId3); - request.MeterNumber.ShouldBe(TestData.MeterNumber); - request.CustomerAccountName.ShouldBe(TestData.CustomerAccountName); - request.PaymentAmount.ShouldBe(TestData.PaymentAmount); - } - - [Fact] - public void PerformBillPaymentGetAccountRequest_Create_IsCreated() { - PerformBillPaymentGetAccountRequest request = PerformBillPaymentGetAccountRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.CustomerAccountNumber); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(TestData.TransactionDateTime); - request.ContractId.ShouldBe(TestData.OperatorId3ContractId); - request.ProductId.ShouldBe(TestData.Operator3Product_200KES.ProductId); - request.OperatorId.ShouldBe(TestData.OperatorId3); - request.CustomerAccountNumber.ShouldBe(TestData.CustomerAccountNumber); - } - - [Fact] - public void PerformReconciliationRequest_Create_IsCreated() - { - PerformReconciliationRequest request = PerformReconciliationRequest.Create(TestData.TransactionDateTime,TestData.DeviceIdentifier, - TestData.ApplicationVersion); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(TestData.TransactionDateTime); - request.DeviceIdentifier.ShouldBe(TestData.DeviceIdentifier); - request.ApplicationVersion.ShouldBe(TestData.ApplicationVersion); - } - - [Fact] - public void UploadLogsRequest_Create_IsCreated() - { - UploadLogsRequest request = UploadLogsRequest.Create(TestData.DeviceIdentifier); - - request.ShouldNotBeNull(); - request.DeviceIdentifier.ShouldBe(TestData.DeviceIdentifier); - } - - [Fact] - public void PerformBillPaymentGetMeterRequest_Create_IsCreated(){ - PerformBillPaymentGetMeterRequest request = PerformBillPaymentGetMeterRequest.Create(TestData.TransactionDateTime, - TestData.OperatorId3ContractId, - TestData.Operator3Product_200KES.ProductId, - TestData.OperatorId3, - TestData.CustomerAccountNumber); - - request.ShouldNotBeNull(); - request.TransactionDateTime.ShouldBe(TestData.TransactionDateTime); - request.ContractId.ShouldBe(TestData.OperatorId3ContractId); - request.ProductId.ShouldBe(TestData.Operator3Product_200KES.ProductId); - request.OperatorId.ShouldBe(TestData.OperatorId3); - request.MeterNumber.ShouldBe(TestData.CustomerAccountNumber); - - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/AuthenticationServiceTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/AuthenticationServiceTests.cs deleted file mode 100644 index 032cce9d8..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/AuthenticationServiceTests.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ServicesTests -{ - using System.Threading; - using Logging; - using Models; - using Moq; - using SecurityService.Client; - using SecurityService.DataTransferObjects.Responses; - using Services; - using Shouldly; - using SimpleResults; - using Xunit; - - public class AuthenticationServiceTests{ - private readonly IAuthenticationService AuthenticationService; - - private readonly Mock SecurityServiceClient; - - private readonly Mock ApplicationCache; - public AuthenticationServiceTests(){ - Logger.Initialise(new NullLogger()); - this.SecurityServiceClient = new Mock(); - this.ApplicationCache = new Mock(); - this.AuthenticationService = new AuthenticationService(this.SecurityServiceClient.Object, - this.ApplicationCache.Object); - - // Standard cache mocking - this.ApplicationCache.Setup(a => a.GetConfiguration()).Returns(new Configuration()); - - } - - [Fact] - public async Task AuthenticationService_GetToken_TokenReturned(){ - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TokenResponse.Create(TestData.Token, TestData.RefreshToken, TestData.TokenExpiryInMinutes)); - - Result token = await this.AuthenticationService.GetToken(TestData.UserName, TestData.Password, CancellationToken.None); - token.IsSuccess.ShouldBeTrue(); - token.Data.AccessToken.ShouldBe(TestData.Token); - token.Data.RefreshToken.ShouldBe(TestData.RefreshToken); - token.Data.ExpiryInMinutes.ShouldBe(TestData.TokenExpiryInMinutes); - } - - [Fact] - public async Task AuthenticationService_GetToken_SecurityClientFailed_TokenNotReturned() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - Result token = await this.AuthenticationService.GetToken(TestData.UserName, TestData.Password, CancellationToken.None); - token.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task AuthenticationService_GetToken_SecurityClientThrowsException_TokenNotReturned() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result token = await this.AuthenticationService.GetToken(TestData.UserName, TestData.Password, CancellationToken.None); - token.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task AuthenticationService_RefreshAccessToken_TokenReturned() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TokenResponse.Create(TestData.Token, TestData.RefreshToken, TestData.TokenExpiryInMinutes)); - - Result token = await this.AuthenticationService.RefreshAccessToken(TestData.RefreshToken, CancellationToken.None); - token.IsSuccess.ShouldBeTrue(); - token.Data.AccessToken.ShouldBe(TestData.Token); - token.Data.RefreshToken.ShouldBe(TestData.RefreshToken); - token.Data.ExpiryInMinutes.ShouldBe(TestData.TokenExpiryInMinutes); - } - - [Fact] - public async Task AuthenticationService_RefreshAccessToken_SecurityClientFailed_TokenNotReturned() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - - Result token = await this.AuthenticationService.RefreshAccessToken(TestData.RefreshToken, CancellationToken.None); - - token.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task AuthenticationService_RefreshAccessToken_SecurityClientThrowsException_TokenNotReturned() - { - this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); - - Result token = await this.AuthenticationService.RefreshAccessToken(TestData.RefreshToken, CancellationToken.None); - - token.IsFailed.ShouldBeTrue(); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/ConfigurationServiceTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/ConfigurationServiceTests.cs deleted file mode 100644 index 17d36968a..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/ConfigurationServiceTests.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ServicesTests -{ - using System.Net; - using System.Net.Http; - using System.Threading; - using Logging; - using Models; - using Newtonsoft.Json; - using RichardSzalay.MockHttp; - using Services; - using Services.DataTransferObjects; - using Shouldly; - using Xunit; - - public class ConfigurationServiceTests{ - private MockHttpMessageHandler MockHttpMessageHandler; - - private Func BaseAddressResolver; - - private IConfigurationService ConfigurationService; - public ConfigurationServiceTests(){ - this.MockHttpMessageHandler = new MockHttpMessageHandler(); - this.BaseAddressResolver = (s) => $"http://localhost"; - this.ConfigurationService = new ConfigurationService(this.BaseAddressResolver, this.MockHttpMessageHandler.ToHttpClient()); - } - - [Theory] - [InlineData(LoggingLevel.Debug, LogLevel.Debug)] - [InlineData(LoggingLevel.Error, LogLevel.Error)] - [InlineData(LoggingLevel.Fatal, LogLevel.Fatal)] - [InlineData(LoggingLevel.Information, LogLevel.Info)] - [InlineData(LoggingLevel.Trace, LogLevel.Trace)] - [InlineData(LoggingLevel.Warning, LogLevel.Warn)] - [InlineData((LoggingLevel)99, LogLevel.Info)] - - public async Task ConfigurationService_GetConfiguration_ResultSuccess_And_ConfigReturned(LoggingLevel configLoggingLevel, LogLevel expectedLogLevel) - { - - ConfigurationResponse expectedConfiguration = new ConfigurationResponse - { - ClientId = "clientId", - ClientSecret = Guid.NewGuid().ToString(), - EnableAutoUpdates = false, - HostAddresses = new List{ - new HostAddress{ - ServiceType = ServiceType.TransactionProcessor, - Uri = "http://localhost:5001" - }, - new HostAddress{ - ServiceType = ServiceType.Security, - Uri = "http://localhost:5001" - }, - new HostAddress{ - ServiceType = ServiceType.TransactionProcessorAcl, - Uri = "http://localhost:5003" - } - }, - ApplicationCentreConfiguration = new ApplicationCentreConfiguration{ - AndroidKey = "Android", - MacosKey = "MacOS", - WindowsKey = "Windows", - IosKey = "iOS", - ApplicationId = "ApplicationId" - }, - DeviceIdentifier = TestData.DeviceIdentifier, - LogLevel = configLoggingLevel, - Id = Guid.NewGuid().ToString(), - }; - Logger.Initialise(new NullLogger()); - - this.MockHttpMessageHandler.When($"http://localhost/api/transactionmobileconfiguration/{TestData.DeviceIdentifier}") - .Respond("application/json", JsonConvert.SerializeObject(expectedConfiguration)); // Respond with JSON - - var configurationResult = await ConfigurationService.GetConfiguration(TestData.DeviceIdentifier, CancellationToken.None); - configurationResult.IsSuccess.ShouldBeTrue(); - configurationResult.Data.ShouldNotBeNull(); - configurationResult.Data.ClientSecret.ShouldBe(expectedConfiguration.ClientSecret); - configurationResult.Data.ClientId.ShouldBe(expectedConfiguration.ClientId); - configurationResult.Data.EnableAutoUpdates.ShouldBe(expectedConfiguration.EnableAutoUpdates); - configurationResult.Data.TransactionProcessorUri.ShouldBe(expectedConfiguration.HostAddresses.Single(s => s.ServiceType == ServiceType.TransactionProcessor).Uri); - configurationResult.Data.SecurityServiceUri.ShouldBe(expectedConfiguration.HostAddresses.Single(s => s.ServiceType == ServiceType.Security).Uri); - configurationResult.Data.TransactionProcessorAclUri.ShouldBe(expectedConfiguration.HostAddresses.Single(s => s.ServiceType == ServiceType.TransactionProcessorAcl).Uri); - configurationResult.Data.LogLevel.ShouldBe(expectedLogLevel); - configurationResult.Data.AppCenterConfig.AndroidKey.ShouldBe(expectedConfiguration.ApplicationCentreConfiguration.AndroidKey); - configurationResult.Data.AppCenterConfig.MacOSKey.ShouldBe(expectedConfiguration.ApplicationCentreConfiguration.MacosKey); - configurationResult.Data.AppCenterConfig.WindowsKey.ShouldBe(expectedConfiguration.ApplicationCentreConfiguration.WindowsKey); - configurationResult.Data.AppCenterConfig.iOSKey.ShouldBe(expectedConfiguration.ApplicationCentreConfiguration.IosKey); - } - - [Fact] - public async Task ConfigurationService_GetConfiguration_FailedHttpCall_ResultFailed() - { - Logger.Initialise(new NullLogger()); - - this.MockHttpMessageHandler.When($"http://localhost/api/transactionmobileconfiguration/{TestData.DeviceIdentifier}") - .Respond(req => new HttpResponseMessage(HttpStatusCode.BadRequest)); - - var configurationResult = await ConfigurationService.GetConfiguration(TestData.DeviceIdentifier, CancellationToken.None); - configurationResult.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ConfigurationService_GetConfiguration_FailedHttpCall_NotFound_ResultFailed() - { - Logger.Initialise(new NullLogger()); - - this.MockHttpMessageHandler.When($"http://localhost/api/transactionmobileconfiguration/{TestData.DeviceIdentifier}") - .Respond(req => new HttpResponseMessage(HttpStatusCode.NotFound)); - - var configurationResult = await ConfigurationService.GetConfiguration(TestData.DeviceIdentifier, CancellationToken.None); - configurationResult.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task ConfigurationService_PostDiagnosticLogs_ResultSuccess() - { - Logger.Initialise(new NullLogger()); - - this.MockHttpMessageHandler.When($"http://localhost/transactionmobilelogging/{TestData.DeviceIdentifier}") - .Respond(req => new HttpResponseMessage(HttpStatusCode.OK)); - - Should.NotThrow(async () => { - await ConfigurationService.PostDiagnosticLogs(TestData.DeviceIdentifier, null, CancellationToken.None); - }); - } - - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/MerchantServiceTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/MerchantServiceTests.cs deleted file mode 100644 index 4e7822cd2..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/MerchantServiceTests.cs +++ /dev/null @@ -1,192 +0,0 @@ -using Newtonsoft.Json; -using System.Net; -using TransactionMobile.Maui.BusinessLogic.UIServices; -using TransactionProcessorACL.DataTransferObjects.Responses; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ServicesTests; - -using Logging; -using Models; -using Moq; -using RichardSzalay.MockHttp; -using Services; -using Shouldly; -using SimpleResults; -using System; -using System.Collections.Generic; -using System.Diagnostics.Contracts; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -public class MerchantServiceTests{ - - private MockHttpMessageHandler MockHttpMessageHandler; - - private Func BaseAddressResolver; - - private readonly Mock ApplicationCache; - private readonly Mock ApplicationInfoService; - - private readonly IMerchantService MerchantService; - - public MerchantServiceTests(){ - Logger.Initialise(new NullLogger()); - this.MockHttpMessageHandler = new MockHttpMessageHandler(); - this.BaseAddressResolver = (s) => $"http://localhost"; - this.ApplicationCache = new Mock(); - this.ApplicationInfoService = new Mock(); - this.ApplicationInfoService.Setup(a => a.VersionString).Returns("1.0.0"); - this.MerchantService = new MerchantService(this.BaseAddressResolver, this.MockHttpMessageHandler.ToHttpClient(),this.ApplicationCache.Object, - this.ApplicationInfoService.Object); - - // Standard cache mocking here - this.ApplicationCache.Setup(a => a.GetAccessToken()).Returns(TestData.AccessToken); - } - - [Fact] - public async Task MerchantService_GetContractProducts_ContractProductsAreReturned(){ - - List contracts = new List(); - contracts.Add(new ContractResponse{ - ContractId = TestData.OperatorId1ContractId, - EstateId = TestData.EstateId, - Products = new List{ - new ContractProduct{ - ProductId = TestData.Operator1Product_100KES.ProductId, - DisplayText = TestData.Operator1Product_100KES.ProductDisplayText, - Name = TestData.Operator1Product_100KES.ProductDisplayText, - ProductType = TransactionProcessorACL.DataTransferObjects.Responses.ProductType.MobileTopup, - Value = TestData.Operator1Product_100KES.Value, - }, - new ContractProduct{ - ProductId = TestData.Operator1Product_200KES.ProductId, - DisplayText = TestData.Operator1Product_200KES.ProductDisplayText, - Name = TestData.Operator1Product_200KES.ProductDisplayText, - ProductType = TransactionProcessorACL.DataTransferObjects.Responses.ProductType.MobileTopup, - Value = TestData.Operator1Product_200KES.Value, - } - - } - }); - - - this.MockHttpMessageHandler.When($"http://localhost/api/merchants/contracts?application_version=1.0.0") - .Respond("application/json", JsonConvert.SerializeObject(Result.Success(contracts))); // Respond with JSON - - var result = await this.MerchantService.GetContractProducts(CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - result.Data.Count.ShouldBe(2); - } - - - [Fact] - public async Task MerchantService_GetContractProducts_HttpCallFailed_FailureReturned(){ - this.MockHttpMessageHandler.When($"http://localhost/api/merchants/contracts?application_version=1.0.0") - .Respond(HttpStatusCode.InternalServerError); - - Result> result = await this.MerchantService.GetContractProducts(CancellationToken.None); - result.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task MerchantService_GetMerchantDetails_MerchantDetailsReturned(){ - MerchantResponse merchantResponse = new MerchantResponse{ - MerchantName = TestData.MerchantName, - NextStatementDate = TestData.NextStatementDate, - SettlementSchedule = SettlementSchedule.Immediate, - Contacts = new List{ - new ContactResponse{ - ContactEmailAddress = TestData.ContactEmailAddress, - ContactName = TestData.ContactName, - ContactPhoneNumber = TestData.ContactMobileNumber - } - }, - Addresses = new List{ - new AddressResponse{ - AddressLine1 = TestData.AddressLine1, - AddressLine2 = TestData.AddressLine2, - AddressLine3 = TestData.AddressLine3, - AddressLine4 = TestData.AddressLine4, - PostalCode = TestData.PostalCode, - Region = TestData.Region, - Town = TestData.Town, - - } - } - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/merchants?application_version=1.0.0") - .Respond("application/json", JsonConvert.SerializeObject(Result.Success(merchantResponse))); // Respond with JSON - - Result merchantDetails = await this.MerchantService.GetMerchantDetails(CancellationToken.None); - merchantDetails.IsSuccess.ShouldBeTrue(); - merchantDetails.Data.Address.AddressLine1.ShouldBe(merchantResponse.Addresses.First().AddressLine1); - merchantDetails.Data.Address.AddressLine2.ShouldBe(merchantResponse.Addresses.First().AddressLine2); - merchantDetails.Data.Address.AddressLine3.ShouldBe(merchantResponse.Addresses.First().AddressLine3); - merchantDetails.Data.Address.AddressLine4.ShouldBe(merchantResponse.Addresses.First().AddressLine4); - merchantDetails.Data.Address.PostalCode.ShouldBe(merchantResponse.Addresses.First().PostalCode); - merchantDetails.Data.Address.Region.ShouldBe(merchantResponse.Addresses.First().Region); - merchantDetails.Data.Address.Town.ShouldBe(merchantResponse.Addresses.First().Town); - merchantDetails.Data.Contact.Name.ShouldBe(merchantResponse.Contacts.First().ContactName); - merchantDetails.Data.Contact.EmailAddress.ShouldBe(merchantResponse.Contacts.First().ContactEmailAddress); - merchantDetails.Data.Contact.MobileNumber.ShouldBe(merchantResponse.Contacts.First().ContactPhoneNumber); - merchantDetails.Data.MerchantName.ShouldBe(merchantResponse.MerchantName); - merchantDetails.Data.NextStatementDate.ShouldBe(merchantResponse.NextStatementDate); - merchantDetails.Data.SettlementSchedule.ShouldBe(merchantResponse.SettlementSchedule.ToString()); - } - - [Fact] - public async Task MerchantService_GetMerchantDetails_ResultFailed_FailedResultIsReturned() - { - this.MockHttpMessageHandler.When($"http://localhost/api/merchants?application_version=1.0.0") - .Respond(HttpStatusCode.BadRequest); - - Result merchantDetails = await this.MerchantService.GetMerchantDetails(CancellationToken.None); - merchantDetails.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task MerchantService_GetMerchantDetails_ExceptionThrown_FailedResultReturned(){ - this.MockHttpMessageHandler.When($"http://localhost/api/merchants?application_version=1.0.0") - .Respond(HttpStatusCode.InternalServerError); - - Result merchantDetails = await this.MerchantService.GetMerchantDetails(CancellationToken.None); - merchantDetails.IsSuccess.ShouldBeFalse(); - } - - [Theory] - [InlineData("Description", "OperatorName", Models.ProductType.BillPayment, "OperatorName")] - [InlineData("Description", "OperatorName", Models.ProductType.MobileTopup, "OperatorName")] - [InlineData("Description", "OperatorName", Models.ProductType.Voucher, "Description")] - public void GetOperatorName_CorrectNameReturned(String contractDescription, String operatorName, Models.ProductType productType, String expectedName){ - ContractResponse contractResponse = new ContractResponse{ - Description = contractDescription, - OperatorName = operatorName - }; - String result = Services.MerchantService.GetOperatorName(contractResponse, productType); - result.ShouldBe(expectedName); - } - - [Theory] - [InlineData("Safaricom", Models.ProductType.MobileTopup)] - [InlineData("Voucher", Models.ProductType.Voucher)] - [InlineData("PataPawa PostPay", Models.ProductType.BillPayment)] - [InlineData("PataPawa PrePay", Models.ProductType.BillPayment)] - public void GetProductType_CorrectProductTypeReturned(String operatorName, Models.ProductType expectedProductType){ - Models.ProductType result = Services.MerchantService.GetProductType(operatorName); - result.ShouldBe(expectedProductType); - } - - [Theory] - [InlineData("Safaricom", Models.ProductSubType.MobileTopup)] - [InlineData("Voucher", Models.ProductSubType.Voucher)] - [InlineData("PataPawa PostPay", Models.ProductSubType.BillPaymentPostPay)] - [InlineData("PataPawa PrePay", Models.ProductSubType.BillPaymentPrePay)] - public void GetProductSubType_CorrectProductSubTypeReturned(String operatorName, Models.ProductSubType expectedProductSubType) - { - Models.ProductSubType result = Services.MerchantService.GetProductSubType(operatorName); - result.ShouldBe(expectedProductSubType); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/TransactionServiceTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/TransactionServiceTests.cs deleted file mode 100644 index 41b5d3a02..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ServicesTests/TransactionServiceTests.cs +++ /dev/null @@ -1,516 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ServicesTests -{ - using System.Net; - using System.Net.Http; - using System.Threading; - using Logging; - using Models; - using Moq; - using Newtonsoft.Json; - using RichardSzalay.MockHttp; - using Services; - using Shouldly; - using SimpleResults; - using TransactionProcessorACL.DataTransferObjects.Responses; - using Xunit; - - public class TransactionServiceTests{ - - private MockHttpMessageHandler MockHttpMessageHandler; - - private Func BaseAddressResolver; - - private ITransactionService TransactionService; - - private Mock ApplicationCache; - - public TransactionServiceTests(){ - this.MockHttpMessageHandler = new MockHttpMessageHandler(); - this.BaseAddressResolver = (s) => $"http://localhost"; - this.ApplicationCache = new Mock(); - this.TransactionService = new TransactionService(this.BaseAddressResolver, this.MockHttpMessageHandler.ToHttpClient(), this.ApplicationCache.Object); - this.ApplicationCache.Setup(s => s.GetAccessToken()).Returns(new TokenResponseModel(){ - AccessToken = "token" - }); - Logger.Initialise(new Logging.NullLogger()); - } - - [Fact] - public async Task TransactionService_PerformLogon_LogonPerformed(){ - - PerformLogonRequestModel requestModel = new PerformLogonRequestModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber - }; - - LogonTransactionResponseMessage expectedResponse = new LogonTransactionResponseMessage{ - ResponseMessage = TestData.ResponseMessage_Success, - EstateId = TestData.EstateId, - MerchantId = TestData.MerchantId, - ResponseCode = TestData.ResponseCode_Success, - TransactionId = TestData.TransactionId, - AdditionalResponseMetaData = new Dictionary() - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond("application/json", JsonConvert.SerializeObject(Result.Success(expectedResponse))); // Respond with JSON - - Result performLogonResult = await this.TransactionService.PerformLogon(requestModel, CancellationToken.None); - - performLogonResult.IsSuccess.ShouldBeTrue(); - performLogonResult.Data.ShouldNotBeNull(); - performLogonResult.Data.EstateId.ShouldBe(expectedResponse.EstateId); - performLogonResult.Data.MerchantId.ShouldBe(expectedResponse.MerchantId); - performLogonResult.Data.ResponseCode.ShouldBe(expectedResponse.ResponseCode); - performLogonResult.Data.ResponseMessage.ShouldBe(expectedResponse.ResponseMessage); - performLogonResult.Data.IsSuccessful.ShouldBeTrue(); - } - - [Theory] - [InlineData(HttpStatusCode.BadRequest)] - [InlineData(HttpStatusCode.HttpVersionNotSupported)] - public async Task TransactionService_PerformLogon_LogonFailed(HttpStatusCode statusCode){ - - PerformLogonRequestModel requestModel = new PerformLogonRequestModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond(req => new HttpResponseMessage(statusCode)); - - Result performLogonResult = await this.TransactionService.PerformLogon(requestModel, CancellationToken.None); - - performLogonResult.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionService_PerformMobileTopup_MobileTopupPerformed(){ - - PerformMobileTopupRequestModel requestModel = new PerformMobileTopupRequestModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - CustomerAccountNumber = TestData.CustomerAccountNumber, - CustomerEmailAddress = TestData.CustomerEmailAddress, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - TopupAmount = TestData.PaymentAmount - }; - - SaleTransactionResponseMessage expectedResponse = new SaleTransactionResponseMessage{ - ResponseMessage = TestData.ResponseMessage_Success, - EstateId = TestData.EstateId, - MerchantId = TestData.MerchantId, - ResponseCode = TestData.ResponseCode_Success, - TransactionId = TestData.TransactionId, - AdditionalResponseMetaData = new Dictionary() - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond("application/json", JsonConvert.SerializeObject(Result.Success(expectedResponse))); // Respond with JSON - - Result performMobileTopupResult = await this.TransactionService.PerformMobileTopup(requestModel, CancellationToken.None); - - performMobileTopupResult.IsSuccess.ShouldBeTrue(); - performMobileTopupResult.Data.ShouldNotBeNull(); - performMobileTopupResult.Data.EstateId.ShouldBe(expectedResponse.EstateId); - performMobileTopupResult.Data.MerchantId.ShouldBe(expectedResponse.MerchantId); - performMobileTopupResult.Data.ResponseCode.ShouldBe(expectedResponse.ResponseCode); - performMobileTopupResult.Data.ResponseMessage.ShouldBe(expectedResponse.ResponseMessage); - performMobileTopupResult.Data.IsSuccessful.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionService_PerformVoucherIssue_MobileTopupFailed(){ - - PerformMobileTopupRequestModel requestModel = new PerformMobileTopupRequestModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - CustomerAccountNumber = TestData.CustomerAccountNumber, - CustomerEmailAddress = TestData.CustomerEmailAddress, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - TopupAmount = TestData.PaymentAmount - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond(req => new HttpResponseMessage(HttpStatusCode.BadRequest)); - - Result performMobileTopupResult = await this.TransactionService.PerformMobileTopup(requestModel, CancellationToken.None); - - performMobileTopupResult.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionService_PerformVoucherIssue_VoucherIssuePerformed(){ - PerformVoucherIssueRequestModel requestModel = new PerformVoucherIssueRequestModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - CustomerEmailAddress = TestData.CustomerEmailAddress, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - RecipientEmailAddress = TestData.RecipientEmailAddress, - RecipientMobileNumber = TestData.RecipientMobileNumber, - VoucherAmount = TestData.PaymentAmount - }; - - SaleTransactionResponseMessage expectedResponse = new SaleTransactionResponseMessage{ - ResponseMessage = TestData.ResponseMessage_Success, - EstateId = TestData.EstateId, - MerchantId = TestData.MerchantId, - ResponseCode = TestData.ResponseCode_Success, - TransactionId = TestData.TransactionId, - AdditionalResponseMetaData = new Dictionary() - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond("application/json", JsonConvert.SerializeObject(Result.Success(expectedResponse))); // Respond with JSON - - Result performVoucherIssueResult = await this.TransactionService.PerformVoucherIssue(requestModel, CancellationToken.None); - - performVoucherIssueResult.IsSuccess.ShouldBeTrue(); - performVoucherIssueResult.Data.ShouldNotBeNull(); - performVoucherIssueResult.Data.EstateId.ShouldBe(expectedResponse.EstateId); - performVoucherIssueResult.Data.MerchantId.ShouldBe(expectedResponse.MerchantId); - performVoucherIssueResult.Data.ResponseCode.ShouldBe(expectedResponse.ResponseCode); - performVoucherIssueResult.Data.ResponseMessage.ShouldBe(expectedResponse.ResponseMessage); - performVoucherIssueResult.Data.IsSuccessful.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionService_PerformVoucherIssue_VoucherIssueFailed(){ - - PerformVoucherIssueRequestModel requestModel = new PerformVoucherIssueRequestModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - CustomerEmailAddress = TestData.CustomerEmailAddress, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - RecipientEmailAddress = TestData.RecipientEmailAddress, - RecipientMobileNumber = TestData.RecipientMobileNumber, - VoucherAmount = TestData.PaymentAmount - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond(req => new HttpResponseMessage(HttpStatusCode.BadRequest)); - - Result performVoucherIssueResult = await this.TransactionService.PerformVoucherIssue(requestModel, CancellationToken.None); - - performVoucherIssueResult.IsFailed.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionService_PerformBillPaymentGetAccount_GetAccountPerformed() { - PerformBillPaymentGetAccountModel requestModel = new PerformBillPaymentGetAccountModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - CustomerAccountNumber = TestData.CustomerAccountNumber, - }; - - SaleTransactionResponseMessage expectedResponse = new SaleTransactionResponseMessage{ - ResponseMessage = TestData.ResponseMessage_Success, - EstateId = TestData.EstateId, - MerchantId = TestData.MerchantId, - ResponseCode = TestData.ResponseCode_Success, - TransactionId = TestData.TransactionId, - AdditionalResponseMetaData = new Dictionary(){ - { "customerAccountName", TestData.BillDetails.AccountName }, - { "customerAccountNumber", TestData.BillDetails.AccountNumber }, - { "customerBillBalance", TestData.BillDetails.Balance }, - { "customerBillDueDate", TestData.BillDetails.DueDate } - } - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond("application/json", JsonConvert.SerializeObject(Result.Success(expectedResponse))); // Respond with JSON - - Result performBillPaymentGetAccountResult = await this.TransactionService.PerformBillPaymentGetAccount(requestModel, CancellationToken.None); - performBillPaymentGetAccountResult.ShouldNotBeNull(); - performBillPaymentGetAccountResult.IsSuccess.ShouldBeTrue(); - performBillPaymentGetAccountResult.Data.ShouldNotBeNull(); - performBillPaymentGetAccountResult.Data.IsSuccessful.ShouldBeTrue(); - performBillPaymentGetAccountResult.Data.BillDetails.ShouldNotBeNull(); - performBillPaymentGetAccountResult.Data.BillDetails.AccountName.ShouldBe(TestData.BillDetails.AccountName); - performBillPaymentGetAccountResult.Data.BillDetails.AccountNumber.ShouldBe(TestData.BillDetails.AccountNumber); - performBillPaymentGetAccountResult.Data.BillDetails.Balance.ShouldBe(TestData.BillDetails.Balance); - performBillPaymentGetAccountResult.Data.BillDetails.DueDate.ShouldBe(TestData.BillDetails.DueDate); - } - - [Fact] - public async Task TransactionService_PerformBillPaymentGetAccount_GetAccountFailed(){ - - PerformBillPaymentGetAccountModel requestModel = new PerformBillPaymentGetAccountModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - CustomerAccountNumber = TestData.CustomerAccountNumber, - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond(req => new HttpResponseMessage(HttpStatusCode.BadRequest)); - - Result performBillPaymentGetAccountResult = await this.TransactionService.PerformBillPaymentGetAccount(requestModel, CancellationToken.None); - - performBillPaymentGetAccountResult.IsFailed.ShouldBeTrue(); - } - - - [Fact] - public async Task TransactionService_PerformBillPaymentGetMeter_GetMeterPerformed(){ - PerformBillPaymentGetMeterModel requestModel = new PerformBillPaymentGetMeterModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - MeterNumber = TestData.MeterNumber - }; - - SaleTransactionResponseMessage expectedResponse = new SaleTransactionResponseMessage{ - ResponseMessage = TestData.ResponseMessage_Success, - EstateId = TestData.EstateId, - MerchantId = TestData.MerchantId, - ResponseCode = TestData.ResponseCode_Success, - TransactionId = TestData.TransactionId, - AdditionalResponseMetaData = new Dictionary(){ - { "pataPawaPrePaidCustomerName", TestData.BillDetails.AccountName } - } - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond("application/json", JsonConvert.SerializeObject(Result.Success(expectedResponse))); // Respond with JSON - - Result performBillPaymentGetMeterResult = await this.TransactionService.PerformBillPaymentGetMeter(requestModel, CancellationToken.None); - - performBillPaymentGetMeterResult.IsSuccess.ShouldBeTrue(); - performBillPaymentGetMeterResult.Data.ShouldNotBeNull(); - performBillPaymentGetMeterResult.Data.IsSuccessful.ShouldBeTrue(); - performBillPaymentGetMeterResult.Data.MeterDetails.ShouldNotBeNull(); - performBillPaymentGetMeterResult.Data.MeterDetails.CustomerName.ShouldBe(TestData.MeterDetails.CustomerName); - performBillPaymentGetMeterResult.Data.MeterDetails.MeterNumber.ShouldBe(TestData.MeterDetails.MeterNumber); - } - - [Fact] - public async Task TransactionService_PerformBillPaymentGetMeter_NoAdditionalResponseMetaData_GetMeterPerformed(){ - PerformBillPaymentGetMeterModel requestModel = new PerformBillPaymentGetMeterModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - MeterNumber = TestData.MeterNumber - }; - - SaleTransactionResponseMessage expectedResponse = new SaleTransactionResponseMessage{ - ResponseMessage = TestData.ResponseMessage_Success, - EstateId = TestData.EstateId, - MerchantId = TestData.MerchantId, - ResponseCode = TestData.ResponseCode_Success, - TransactionId = TestData.TransactionId, - AdditionalResponseMetaData = null - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond("application/json", JsonConvert.SerializeObject(Result.Success(expectedResponse))); // Respond with JSON - - Result performBillPaymentGetMeterResult = await this.TransactionService.PerformBillPaymentGetMeter(requestModel, CancellationToken.None); - - performBillPaymentGetMeterResult.IsSuccess.ShouldBeTrue(); - performBillPaymentGetMeterResult.Data.ShouldNotBeNull(); - performBillPaymentGetMeterResult.Data.IsSuccessful.ShouldBeFalse(); - performBillPaymentGetMeterResult.Data.MeterDetails.ShouldBeNull(); - } - - [Fact] - public async Task TransactionService_PerformBillPaymentGetMeter_GetMeterFailed(){ - PerformBillPaymentGetMeterModel requestModel = new PerformBillPaymentGetMeterModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - MeterNumber = TestData.MeterNumber - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond(req => new HttpResponseMessage(HttpStatusCode.BadRequest)); - - Result performBillPaymentGetMeterResult = await this.TransactionService.PerformBillPaymentGetMeter(requestModel, CancellationToken.None); - - performBillPaymentGetMeterResult.IsFailed.ShouldBeTrue(); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task TransactionService_PerformBillPaymentMakePayment_MakePaymentPerformed(Boolean isPostPayment){ - PerformBillPaymentMakePaymentModel requestModel = new PerformBillPaymentMakePaymentModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - CustomerAccountName = TestData.CustomerAccountName, - PaymentAmount = TestData.PaymentAmount, - CustomerAccountNumber = TestData.CustomerAccountNumber, - CustomerMobileNumber = TestData.CustomerMobileNumber, - PostPayment = isPostPayment - }; - - SaleTransactionResponseMessage expectedResponse = new SaleTransactionResponseMessage{ - ResponseMessage = TestData.ResponseMessage_Success, - EstateId = TestData.EstateId, - MerchantId = TestData.MerchantId, - ResponseCode = TestData.ResponseCode_Success, - TransactionId = TestData.TransactionId - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond("application/json", JsonConvert.SerializeObject(Result.Success(expectedResponse))); // Respond with JSON - - Result performBillPaymentGetMeterResult = await this.TransactionService.PerformBillPaymentMakePayment(requestModel, CancellationToken.None); - - performBillPaymentGetMeterResult.IsSuccess.ShouldBeTrue(); - performBillPaymentGetMeterResult.Data.ShouldNotBeNull(); - performBillPaymentGetMeterResult.Data.IsSuccessful.ShouldBeTrue(); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task TransactionService_PerformBillPaymentMakePayment_MakePaymentFailed(Boolean isPostPayment){ - PerformBillPaymentMakePaymentModel requestModel = new PerformBillPaymentMakePaymentModel{ - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - TransactionNumber = TestData.TransactionNumber, - ContractId = TestData.Operator1ProductDetails.ContractId, - OperatorId = TestData.OperatorId1, - ProductId = TestData.Operator1ProductDetails.ProductId, - CustomerAccountName = TestData.CustomerAccountName, - PaymentAmount = TestData.PaymentAmount, - CustomerAccountNumber = TestData.CustomerAccountNumber, - CustomerMobileNumber = TestData.CustomerMobileNumber, - PostPayment = isPostPayment - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond(req => new HttpResponseMessage(HttpStatusCode.BadRequest)); - - Result performBillPaymentGetMeterResult = await this.TransactionService.PerformBillPaymentMakePayment(requestModel, CancellationToken.None); - - performBillPaymentGetMeterResult.IsSuccess.ShouldBeFalse(); - } - - [Fact] - public async Task TransactionService_PerformReconciliation_ReconciliationPerformed() - { - PerformReconciliationRequestModel requestModel = new PerformReconciliationRequestModel - { - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - OperatorTotals = new List(){ - new OperatorTotalModel{ - TransactionCount = TestData.TransactionCount, - TransactionValue = TestData.TransactionValue, - ContractId = TestData.OperatorId1ContractId, - OperatorId = TestData.OperatorId1 - } - }, - TransactionCount = TestData.TransactionCount, - TransactionValue = TestData.TransactionValue - }; - - SaleTransactionResponseMessage expectedResponse = new SaleTransactionResponseMessage - { - ResponseMessage = TestData.ResponseMessage_Success, - EstateId = TestData.EstateId, - MerchantId = TestData.MerchantId, - ResponseCode = TestData.ResponseCode_Success, - TransactionId = TestData.TransactionId, - AdditionalResponseMetaData = null - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions") - .Respond("application/json", JsonConvert.SerializeObject(Result.Success(expectedResponse))); // Respond with JSON - - Result performReconciliationResult = await this.TransactionService.PerformReconciliation(requestModel, CancellationToken.None); - - performReconciliationResult.IsSuccess.ShouldBeTrue(); - performReconciliationResult.Data.ShouldNotBeNull(); - performReconciliationResult.Data.EstateId.ShouldBe(expectedResponse.EstateId); - performReconciliationResult.Data.MerchantId.ShouldBe(expectedResponse.MerchantId); - performReconciliationResult.Data.ResponseCode.ShouldBe(expectedResponse.ResponseCode); - performReconciliationResult.Data.ResponseMessage.ShouldBe(expectedResponse.ResponseMessage); - performReconciliationResult.Data.IsSuccessful.ShouldBeTrue(); - } - - [Fact] - public async Task TransactionService_PerformReconciliation_ReconciliationFailed() - { - PerformReconciliationRequestModel requestModel = new PerformReconciliationRequestModel - { - ApplicationVersion = TestData.ApplicationVersion, - DeviceIdentifier = TestData.DeviceIdentifier, - TransactionDateTime = TestData.TransactionDateTime, - OperatorTotals = new List(){ - new OperatorTotalModel{ - TransactionCount = TestData.TransactionCount, - TransactionValue = TestData.TransactionValue, - ContractId = TestData.OperatorId1ContractId, - OperatorId = TestData.OperatorId1 - } - }, - TransactionCount = TestData.TransactionCount, - TransactionValue = TestData.TransactionValue - }; - - this.MockHttpMessageHandler.When($"http://localhost/api/transactions").Respond(req => new HttpResponseMessage(HttpStatusCode.BadRequest)); - - Result performReconciliationResult = await this.TransactionService.PerformReconciliation(requestModel, CancellationToken.None); - - performReconciliationResult.IsFailed.ShouldBeTrue(); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/TestData.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/TestData.cs deleted file mode 100644 index 5ef8eb033..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/TestData.cs +++ /dev/null @@ -1,348 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests -{ - using Database; - using Microsoft.Win32.SafeHandles; - using Models; - using ViewModels.Transactions; - - public static class TestData - { - public static TokenResponseModel AccessToken => - new TokenResponseModel - { - ExpiryInMinutes = TestData.TokenExpiryInMinutes, - AccessToken = TestData.Token, - RefreshToken = TestData.RefreshToken - }; - - public static Configuration Configuration = new Configuration(); - public static Configuration NullConfiguration = null; - - public static TokenResponseModel NullAccessToken => null; - - public static String Token = "Token"; - - public static String RefreshToken = "RefreshToken"; - public static Int32 TokenExpiryInMinutes = 5; - public static Guid EstateId = Guid.Parse("21D339F4-C97F-4C30-A212-11CA01E2D508"); - public static Guid MerchantId = Guid.Parse("E8B4B839-434A-43A2-B373-D8813F63F615"); - - public static String OperatorIdentifier1 = "Safaricom"; - public static String OperatorIdentifier2 = "Safaricom1"; - public static String OperatorIdentifier3 = "Voucher"; - - public static String OperatorName1 = "Safaricom"; - public static String OperatorName2 = "Safaricom1"; - public static String OperatorName3 = "Voucher"; - - public static Guid OperatorId1 = Guid.Parse("2CA5F4C7-34EC-425B-BB53-7EEDF48D9967"); - public static Guid OperatorId2 = Guid.Parse("1CA5F4C7-34EC-425B-BB53-7EEDF48D9968"); - public static Guid OperatorId3 = Guid.Parse("17FA0431-4DCB-43CF-97B7-2CEDC74E4796"); - - public static Guid OperatorId1ContractId = Guid.Parse("D57DAC9B-4039-4120-B5A8-F7FDF1D3A3C2"); - public static Guid OperatorId2ContractId = Guid.Parse("2471F981-DDA8-4B87-91F4-DD5DCB984FC1"); - public static Guid OperatorId3ContractId = Guid.Parse("(0BCACE74-CBF1-4F2C-AC1C-733BF1F53133)"); - - public static ProductDetails Operator1ProductDetails => - new ProductDetails() { - ProductId = Operator1Product_100KES.ProductId, - ContractId = Operator1Product_100KES.ContractId, - OperatorId = Operator1Product_100KES.OperatorId, - }; - - public static ContractProductModel Operator1Product_BillPayment_PostPayment = new ContractProductModel - { - ContractId = OperatorId1ContractId, - IsFixedValue = true, - OperatorId = OperatorId1, - OperatorIdentfier = OperatorIdentifier1, - OperatorName = OperatorName1, - ProductDisplayText = "Custom", - ProductId = Guid.Parse("48D96AE5-A829-498B-8C0D-D7107610EBDC"), - ProductType = ProductType.BillPayment, - ProductSubType = ProductSubType.BillPaymentPostPay - }; - - public static ContractProductModel Operator1Product_BillPayment_PrePayment = new ContractProductModel - { - ContractId = OperatorId1ContractId, - IsFixedValue = true, - OperatorId = OperatorId1, - OperatorIdentfier = OperatorIdentifier1, - OperatorName = OperatorName1, - ProductDisplayText = "Custom", - ProductId = Guid.Parse("48D96AE5-A829-498B-8C0D-D7107610EBDC"), - ProductType = ProductType.BillPayment, - ProductSubType = ProductSubType.BillPaymentPrePay - }; - - public static ContractProductModel Operator1Product_100KES = new ContractProductModel - { - ContractId = OperatorId1ContractId, - IsFixedValue = true, - OperatorId = OperatorId1, - OperatorIdentfier = OperatorIdentifier1, - OperatorName = OperatorName1, - ProductDisplayText = "100 KES", - ProductId = Guid.Parse("48D96AE5-A829-498B-8C0D-D7107610EBDC"), - ProductType = ProductType.MobileTopup, - Value = 100 - }; - - public static ContractProductModel Operator1Product_200KES = new ContractProductModel - { - ContractId = OperatorId1ContractId, - IsFixedValue = true, - OperatorId = OperatorId1, - OperatorIdentfier = OperatorIdentifier1, - OperatorName = OperatorName1, - ProductDisplayText = "200 KES", - ProductId = Guid.Parse("63821A48-D35E-451D-9E88-C8DCB548E7ED"), - ProductType = ProductType.MobileTopup, - Value = 200 - }; - - public static ContractProductModel Operator1Product_Custom = new ContractProductModel - { - ContractId = OperatorId1ContractId, - IsFixedValue = false, - OperatorId = OperatorId1, - OperatorIdentfier = OperatorIdentifier1, - OperatorName = OperatorName1, - ProductDisplayText = "Custom", - ProductId = Guid.Parse("63821A48-D35E-451D-9E88-C8DCB548E7ED"), - ProductType = ProductType.MobileTopup - }; - - public static ContractProductModel Operator2Product_Custom = new ContractProductModel - { - ContractId = OperatorId2ContractId, - IsFixedValue = false, - OperatorId = TestData.OperatorId2, - OperatorIdentfier = OperatorIdentifier2, - OperatorName = OperatorName2, - ProductDisplayText = "Custom", - ProductId = Guid.Parse("63821A48-D35E-451D-9E88-C8DCB548E7ED"), - ProductType = ProductType.MobileTopup - }; - - public static ContractProductModel Operator3Product_200KES = new ContractProductModel - { - ContractId = OperatorId3ContractId, - IsFixedValue = false, - OperatorId = TestData.OperatorId3, - OperatorIdentfier = OperatorIdentifier3, - OperatorName = OperatorName3, - ProductDisplayText = "100 KES", - ProductId = Guid.Parse("3270DC5F-1BB3-4ECF-BA06-AFB42B651483"), - ProductType = ProductType.Voucher, - Value = 200 - }; - - public static List ContractProductList = new List - { - Operator1Product_100KES, - Operator1Product_200KES, - Operator1Product_Custom, - Operator2Product_Custom, - TestData.Operator3Product_200KES - }; - - public static List ContractProductListEmpty = new List(); - - public static ContractOperatorModel ContractOperatorModel = new ContractOperatorModel - { - OperatorIdentfier = TestData.OperatorIdentifier1, - OperatorId = TestData.OperatorId1, - OperatorName = TestData.OperatorName1 - }; - - public static String UserName = "testusername"; - public static String Password = "testpassword"; - - public static DateTime TransactionDateTime = new DateTime(2022, 2, 14); - - public static String TransactionNumber = "1"; - - public static String DeviceIdentifier = "1ABCD11"; - - public static String ApplicationVersion = "1.0.0"; - - public static String CustomerAccountNumber = "0123456"; - public static String CustomerEmailAddress = "1@2.com"; - - public static String RecipientMobileNumber = "0123456"; - - public static String RecipientEmailAddress = "1@2.com"; - - public static Decimal MerchantBalance = 199.99m; - - public static List StoredTransactions => - new List{ - new TransactionRecord{ - Amount = TestData.Operator1Product_100KES.Value, - ContractId = TestData.Operator1Product_100KES.ContractId, - IsSuccessful = true, - OperatorId = TestData.Operator1Product_100KES.OperatorId, - }, - new TransactionRecord{ - Amount = TestData.Operator1Product_100KES.Value, - ContractId = TestData.Operator1Product_100KES.ContractId, - IsSuccessful = true, - OperatorId = TestData.Operator1Product_100KES.OperatorId, - }, - new TransactionRecord{ - Amount = TestData.Operator1Product_100KES.Value, - ContractId = TestData.Operator1Product_100KES.ContractId, - IsSuccessful = true, - OperatorId = TestData.Operator1Product_100KES.OperatorId, - }, - new TransactionRecord{ - Amount = TestData.Operator3Product_200KES.Value, - ContractId = TestData.Operator3Product_200KES.ContractId, - IsSuccessful = true, - OperatorId = TestData.Operator3Product_200KES.OperatorId, - } - }; - - public static String ResponseCode_Success = "0000"; - public static String ResponseMessage_Success = "SUCCESS"; - public static String ResponseCode_Failed = "1000"; - public static String ResponseMessage_Failed = "Failed"; - - - - public static PerformLogonResponseModel PerformLogonResponseModel => - new PerformLogonResponseModel - { - EstateId = TestData.EstateId, - MerchantId = TestData.MerchantId, - ResponseCode = ResponseCode_Success, - ResponseMessage = ResponseMessage_Success - }; - - public static PerformLogonResponseModel PerformLogonResponseFailedModel => - new PerformLogonResponseModel - { - EstateId = TestData.EstateId, - MerchantId = TestData.MerchantId, - ResponseCode = ResponseCode_Failed, - ResponseMessage = ResponseMessage_Failed - }; - - - public static PerformBillPaymentGetAccountResponseModel PerformBillPaymentGetAccountResponseModel => - new PerformBillPaymentGetAccountResponseModel { - BillDetails = TestData.BillDetails - }; - - public static PerformBillPaymentGetMeterResponseModel PerformBillPaymentGetMeterResponseModel => - new PerformBillPaymentGetMeterResponseModel - { - MeterDetails = TestData.MeterDetails - }; - - public static PerformBillPaymentGetAccountResponseModel PerformBillPaymentGetAccountResponseModelFailed => - new PerformBillPaymentGetAccountResponseModel - { - BillDetails = null - }; - - public static PerformBillPaymentGetMeterResponseModel PerformBillPaymentGetMeterResponseModelFailed => - new PerformBillPaymentGetMeterResponseModel - { - MeterDetails = null - }; - - public static MerchantDetailsModel MerchantDetailsModel => new MerchantDetailsModel { - MerchantName = TestData.MerchantName, - Contact = new ContactModel { - Name = TestData.ContactName, - EmailAddress = TestData.ContactEmailAddress, - MobileNumber = TestData.ContactMobileNumber - }, - Address = new AddressModel { - AddressLine2 = TestData.AddressLine2, - Town = TestData.Town, - AddressLine4 = TestData.AddressLine4, - PostalCode = TestData.PostalCode, - Region = TestData.Region, - AddressLine3 = TestData.AddressLine3, - AddressLine1 = TestData.AddressLine1 - }, - AvailableBalance = TestData.AvailableBalance, - Balance = TestData.Balance, - LastStatementDate = TestData.LastStatementDate, - NextStatementDate = TestData.NextStatementDate, - SettlementSchedule = TestData.SettlementSchedule - }; - - public static Decimal Balance = 100.00m; - - public static Decimal AvailableBalance = 99.00m; - - public static String MerchantName = "Test Merchant"; - - public static DateTime NextStatementDate = new DateTime(2022, 09, 01); - public static DateTime LastStatementDate = new DateTime(2022, 08, 01); - - public static String SettlementSchedule = "Monthly"; - - // Address - public static String AddressLine1 = "Address Line 1"; - public static String AddressLine2 = "Address Line 2"; - public static String AddressLine3 = "Address Line 3"; - public static String AddressLine4 = "Address Line 4"; - public static String PostalCode = "TE57 1NG"; - public static String Region = "Region"; - public static String Town = "Town"; - - // Contact - public static String ContactEmailAddress = "testcontact@myemail.com"; - - public static String ContactName = "Mr Test Contact"; - - public static String ContactMobileNumber = "077777777"; - - public static String MeterNumber = "123456"; - - public static String CustomerAccountName = "Mr Test Customer"; - - public static String AccountBalance = "100 KES"; - - public static String AccountDueDate = "20/09/2022"; - - public static String CustomerMobileNumber = "077777777"; - - public static Decimal PaymentAmount = 50.00m; - - public static Guid TransactionId = Guid.Parse("66F9743A-A682-4A73-9A80-441A3C9BCFDC"); - - public static BillDetails BillDetails => - new BillDetails { - AccountNumber = TestData.CustomerAccountNumber, - AccountName = TestData.CustomerAccountName, - Balance = TestData.AccountBalance, - DueDate = TestData.AccountDueDate - }; - - public static MeterDetails MeterDetails => - new MeterDetails - { - MeterNumber = TestData.MeterNumber, - CustomerName = TestData.CustomerAccountName - }; - - public static Int32 TransactionCount = 1; - - public static Decimal TransactionValue = 100.00m; - - } -} - \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/TransactionMobile.Maui.BusinessLogic.Tests.csproj b/archive/TransactionMobile.Maui.BusinessLogic.Tests/TransactionMobile.Maui.BusinessLogic.Tests.csproj deleted file mode 100644 index 90703d307..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/TransactionMobile.Maui.BusinessLogic.Tests.csproj +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - net8.0; - None - - - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/ExtendedBaseViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/ExtendedBaseViewModelTests.cs deleted file mode 100644 index 908f62d76..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/ExtendedBaseViewModelTests.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests -{ - using System.Threading; - using Maui.UIServices; - using Moq; - using Services; - using Shouldly; - using SimpleResults; - using UIServices; - using ViewModels; - using Xunit; - - public class ExtendedBaseViewModelTests{ - private Mock ApplicationCache = null; - - private Mock DialogService = null; - - private Mock NavigationService = null; - private Mock NavigationParameterService = null; - - private Mock DeviceService = null; - - private ExtendedBaseViewModel ViewModel = null; - public ExtendedBaseViewModelTests(){ - this.ApplicationCache = new Mock(); - this.DialogService = new Mock(); - this.NavigationService = new Mock(); - this.DeviceService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ViewModel = new ExtendedBaseViewModel(this.ApplicationCache.Object, - this.DialogService.Object, - this.NavigationService.Object, - this.DeviceService.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public async Task ExtendedBaseViewModel_HandleResult_ResultIsNull_ErrorThrown(){ - Result result = null; - ApplicationException exception= Should.Throw(() => { - this.ViewModel.HandleResult(result); - }); - exception.Message.ShouldBe("Result from function call was null"); - } - - [Fact] - public async Task ExtendedBaseViewModel_HandleResult_ResultIsAndError_ErrorThrown(){ - Result result = Result.Failure("Error has been returned"); - - ApplicationException exception = Should.Throw(() => { - this.ViewModel.HandleResult(result); - }); - exception.Message.ShouldBe("Error has been returned"); - } - - [Theory] - [InlineData(Orientation.Landscape)] - [InlineData(Orientation.Portrait)] - public async Task ExtendedBaseViewModel_Initialise_OrientationIsSet(Orientation orientation){ - var viewModel = new ExtendedBaseViewModel(this.ApplicationCache.Object, - this.DialogService.Object, - this.NavigationService.Object, - this.DeviceService.Object, - this.NavigationParameterService.Object, - orientation); - await this.ViewModel.Initialise(CancellationToken.None); - this.DeviceService.Verify(v => v.SetOrientation(It.IsAny()), Times.Once); - viewModel.Orientation.ShouldBe(orientation); - } - - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/HomePageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/HomePageViewModelTests.cs deleted file mode 100644 index 23ac37f3d..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/HomePageViewModelTests.cs +++ /dev/null @@ -1,69 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests; - -using System; -using Logging; -using Maui.UIServices; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using Services; -using UIServices; -using ViewModels; -using Xunit; -using NullLogger = Logging.NullLogger; - -[Collection("ViewModelTests")] -public class HomePageViewModelTests -{ - private Mock navigationService; - private Mock navigationParameterService; - - private Mock applicationCache; - - private Mock dialogService; - - private HomePageViewModel viewModel; - - private readonly Mock DeviceService; - - public HomePageViewModelTests() { - this.navigationService = new Mock(); - applicationCache = new Mock(); - dialogService = new Mock(); - this.DeviceService = new Mock(); - this.navigationParameterService = new Mock(); - viewModel = new HomePageViewModel(applicationCache.Object, - dialogService.Object, - this.DeviceService.Object, - navigationService.Object, - navigationParameterService.Object); - Logger.Initialise(new NullLogger()); - } - - [Fact] - public void HomePageViewModel_BackButtonCommand_Execute_UserSelectsToLogout_LoginPageDisplayed() - { - dialogService.Setup(d => d.ShowDialog(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(true); - - viewModel.BackButtonCommand.Execute(null); - - navigationService.Verify(n => n.GoToLoginPage(), Times.Once); - dialogService.Verify(d => d.ShowDialog(It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny()), Times.Once); - } - - [Fact] - public void HomePageViewModel_BackButtonCommand_Execute_UserSelectsNotToLogout_LoginPageDisplayed() - { - dialogService.Setup(d => d.ShowDialog(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(false); - - viewModel.BackButtonCommand.Execute(null); - - navigationService.VerifyNoOtherCalls(); - dialogService.Verify(d => d.ShowDialog(It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny()), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/LoginPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/LoginPageViewModelTests.cs deleted file mode 100644 index 1e9516c82..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/LoginPageViewModelTests.cs +++ /dev/null @@ -1,208 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests; - -using System; -using System.Collections.Generic; -using System.Threading; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Caching.Memory; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Shouldly; -using SimpleResults; -using TransactionMobile.Maui.BusinessLogic.Services; -using TransactionMobile.Maui.Database; -using UIServices; -using ViewModels; -using Xunit; -using NullLogger = Microsoft.Extensions.Logging.Abstractions.NullLogger; - -[Collection("ViewModelTests")] -public class LoginPageViewModelTests -{ - private LoginPageViewModel ViewModel; - - private readonly Mock Mediator; - - private readonly Mock NavigationService; - private Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DeviceService; - - private readonly Mock ApplicationInfoService; - - private readonly Mock DialogService; - public LoginPageViewModelTests() { - this.Mediator = new Mock(); - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DeviceService = new Mock(); - this.ApplicationInfoService = new Mock(); - this.DialogService = new Mock(); - - this.ViewModel = new LoginPageViewModel(this.Mediator.Object, this.NavigationService.Object, this.ApplicationCache.Object, - this.DeviceService.Object, this.ApplicationInfoService.Object, - this.DialogService.Object, this.NavigationParameterService.Object); - Logger.Initialise(new Logging.NullLogger()); - } - - [Fact] - public void LoginPageViewModel_LoginCommand_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new Configuration())); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.AccessToken)); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.PerformLogonResponseModel)); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantBalance)); - - this.ViewModel.LoginCommand.Execute(null); - - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.NavigationService.Verify(n => n.GoToHome(), Times.Once); - } - - [Theory] - [InlineData(null)] - [InlineData("")] - [InlineData("http://localhost")] - public void LoginPageViewModel_LoginCommand_Execute_ConfigUrlSet_IsExecuted(String configUrl) - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new Configuration())); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.AccessToken)); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.PerformLogonResponseModel)); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantBalance)); - this.ViewModel.ConfigHostUrl = configUrl; - this.ViewModel.LoginCommand.Execute(null); - - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.NavigationService.Verify(n => n.GoToHome(), Times.Once); - if (String.IsNullOrEmpty(configUrl) == false){ - this.ApplicationCache.Verify(v => v.SetConfigHostUrl(It.IsAny(), It.IsAny()), Times.Once); - } - - } - - [Fact] - public void LoginPageViewModel_LoginCommand_Execute_ErrorGettingConfig_WarningToastIsShown() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure("Error")); - - this.ViewModel.LoginCommand.Execute(null); - - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Never); - this.NavigationService.Verify(n => n.GoToHome(), Times.Never); - - this.DialogService.Verify(n => n.ShowWarningToast(It.IsAny(), - null, - "OK", - null, - CancellationToken.None), Times.Once); - } - - [Fact] - public void LoginPageViewModel_LoginCommand_Execute_ErrorGettingToken_WarningToastIsShown() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new Configuration())); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure("Error")); - - this.ViewModel.LoginCommand.Execute(null); - - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Never); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Never); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Never); - this.NavigationService.Verify(n => n.GoToHome(), Times.Never); - - this.DialogService.Verify(n => n.ShowWarningToast(It.IsAny(), - null, - "OK", - null, - CancellationToken.None), Times.Once); - } - - [Fact] - public void LoginPageViewModel_LoginCommand_Execute_ErrorDuringLogonTransaction_WarningToastIsShown() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new Configuration())); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.AccessToken)); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure("")); - - this.ViewModel.LoginCommand.Execute(null); - - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Never); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Never); - this.NavigationService.Verify(n => n.GoToHome(), Times.Never); - - this.DialogService.Verify(n => n.ShowWarningToast(It.IsAny(), - null, - "OK", - null, - CancellationToken.None), Times.Once); - } - - [Fact] - public void LoginPageViewModel_LoginCommand_Execute_ErrorDuringGetContractProducts_WarningToastIsShown() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new Configuration())); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.AccessToken)); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.PerformLogonResponseModel)); - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure("")); - - this.ViewModel.LoginCommand.Execute(null); - - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Never); - this.NavigationService.Verify(n => n.GoToHome(), Times.Never); - - this.DialogService.Verify(n => n.ShowWarningToast(It.IsAny(), - null, - "OK", - null, - CancellationToken.None), Times.Once); - } - - [Fact] - public void LoginPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - this.NavigationService.Verify(n => n.QuitApplication(), Times.Once); - } - - [Fact] - public void LoginPageViewModel_PropertyTests_ValuesAreAsExpected(){ - this.DeviceService.Setup(d => d.GetIdentifier()).Returns("testidentifier"); - - this.ViewModel.Password = TestData.Password; - this.ViewModel.UserName = TestData.UserName; - this.ViewModel.UseTrainingMode = true; - this.ViewModel.ConfigHostUrl = "http://localhost"; - - this.ViewModel.UserName.ShouldBe(TestData.UserName); - this.ViewModel.Password.ShouldBe(TestData.Password); - this.ViewModel.ConfigHostUrl.ShouldBe("http://localhost"); - this.ViewModel.UseTrainingMode.ShouldBeTrue(); - this.ViewModel.DeviceIdentifier.ShouldBe("testidentifier"); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountAddressPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountAddressPageViewModelTests.cs deleted file mode 100644 index b6cf1a093..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountAddressPageViewModelTests.cs +++ /dev/null @@ -1,71 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.MyAccount; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using Services; -using Shouldly; -using UIServices; -using ViewModels; -using ViewModels.MyAccount; -using Xunit; - -[Collection("ViewModelTests")] -public class MyAccountAddressPageViewModelTests -{ - private readonly Mock NavigationService; - private Mock NavigationParameterService; - private readonly Mock ApplicationCache; - private readonly Mock DialogService; - private readonly Mock Mediator; - private readonly MyAccountAddressPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public MyAccountAddressPageViewModelTests() - { - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogService = new Mock(); - this.Mediator = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new MyAccountAddressPageViewModel(this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogService.Object, - this.DeviceService.Object, - this.Mediator.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public async Task MyAccountAddressPageViewModel_Initialise_IsInitialised() - { - this.ApplicationCache.Setup(a => a.GetMerchantDetails()).Returns(TestData.MerchantDetailsModel); - - await this.ViewModel.Initialise(CancellationToken.None); - - this.ApplicationCache.Verify(a => a.GetMerchantDetails(), Times.Once); - this.ViewModel.Address.ShouldNotBeNull(); - this.ViewModel.Address.AddressLine1.ShouldBe(TestData.AddressLine1); - this.ViewModel.Address.AddressLine2.ShouldBe(TestData.AddressLine2); - this.ViewModel.Address.AddressLine3.ShouldBe(TestData.AddressLine3); - this.ViewModel.Address.AddressLine4.ShouldBe(TestData.AddressLine4); - this.ViewModel.Address.Region.ShouldBe(TestData.Region); - this.ViewModel.Address.Town.ShouldBe(TestData.Town); - this.ViewModel.Address.PostalCode.ShouldBe(TestData.PostalCode); - } - - [Fact] - public async Task MyAccountAddressPageViewModel_BackButtonCommand_PreviousPageIsShown() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountContactPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountContactPageViewModelTests.cs deleted file mode 100644 index 797b712a0..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountContactPageViewModelTests.cs +++ /dev/null @@ -1,65 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.MyAccount; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using Services; -using Shouldly; -using UIServices; -using ViewModels; -using ViewModels.MyAccount; -using Xunit; - -[Collection("ViewModelTests")] -public class MyAccountContactPageViewModelTests -{ - private readonly Mock NavigationService; - private readonly Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogService; - - private readonly MyAccountContactPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public MyAccountContactPageViewModelTests() { - this.NavigationService = new Mock(); - this.ApplicationCache = new Mock(); - this.NavigationParameterService = new Mock(); - this.DialogService = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new MyAccountContactPageViewModel(this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogService.Object, this.DeviceService.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public async Task MyAccountContactPageViewModel_Initialise_IsInitialised() - { - this.ApplicationCache.Setup(a => a.GetMerchantDetails()).Returns(TestData.MerchantDetailsModel); - - await this.ViewModel.Initialise(CancellationToken.None); - - this.ApplicationCache.Verify(a => a.GetMerchantDetails(), Times.Once); - this.ViewModel.Contact.ShouldNotBeNull(); - this.ViewModel.Contact.EmailAddress.ShouldBe(TestData.ContactEmailAddress); - this.ViewModel.Contact.Name.ShouldBe(TestData.ContactName); - this.ViewModel.Contact.MobileNumber.ShouldBe(TestData.ContactMobileNumber); - } - - [Fact] - public async Task MyAccountContactPageViewModel_BackButtonCommand_PreviousPageIsShown() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountDetailsPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountDetailsPageViewModelTests.cs deleted file mode 100644 index c9dcc3ec4..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountDetailsPageViewModelTests.cs +++ /dev/null @@ -1,67 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.MyAccount; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using Services; -using Shouldly; -using UIServices; -using ViewModels; -using ViewModels.MyAccount; -using Xunit; - -[Collection("ViewModelTests")] -public class MyAccountDetailsPageViewModelTests -{ - private readonly Mock NavigationService; - private Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogService; - - private readonly MyAccountDetailsPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public MyAccountDetailsPageViewModelTests() - { - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogService = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new MyAccountDetailsPageViewModel(this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogService.Object, - this.DeviceService.Object, this.NavigationParameterService.Object); - } - - [Fact] - public async Task MyAccountDetailsPageViewModel_Initialise_IsInitialised() - { - this.ApplicationCache.Setup(a => a.GetMerchantDetails()).Returns(TestData.MerchantDetailsModel); - - await this.ViewModel.Initialise(CancellationToken.None); - - this.ApplicationCache.Verify(a => a.GetMerchantDetails(), Times.Once); - this.ViewModel.Balance.ShouldBe(TestData.Balance); - this.ViewModel.AvailableBalance.ShouldBe(TestData.AvailableBalance); - this.ViewModel.MerchantName.ShouldBe(TestData.MerchantName); - this.ViewModel.LastStatementDate.ShouldBe(TestData.LastStatementDate); - this.ViewModel.NextStatementDate.ShouldBe(TestData.NextStatementDate); - this.ViewModel.SettlementSchedule.ShouldBe(TestData.SettlementSchedule); - } - - [Fact] - public async Task MyAccountDetailsPageViewModel_BackButtonCommand_PreviousPageIsShown() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountPageViewModelTests.cs deleted file mode 100644 index fa685948a..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/MyAccount/MyAccountPageViewModelTests.cs +++ /dev/null @@ -1,131 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.MyAccount; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using BusinessLogic.Common; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.Logging.Abstractions; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using UIServices; -using ViewModels; -using ViewModels.MyAccount; -using Xunit; - -[Collection("ViewModelTests")] -public class MyAccountPageViewModelTests -{ - #region Methods - - private readonly Mock NavigationService; - private readonly Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogService; - - private readonly Mock Mediator; - - private readonly MyAccountPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public MyAccountPageViewModelTests() { - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogService = new Mock(); - this.DeviceService = new Mock(); - this.Mediator = new Mock(); - this.ViewModel = new MyAccountPageViewModel(this.NavigationService.Object, this.ApplicationCache.Object, - this.DialogService.Object, this.DeviceService.Object, - this.Mediator.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public async Task MyAccountPageViewModel_Initialise_IsInitialised() { - - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success( TestData.MerchantDetailsModel)); - - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.MerchantName.ShouldBe(TestData.MerchantDetailsModel.MerchantName); - this.ViewModel.LastLogin.ShouldBe(DateTime.Now, TimeSpan.FromSeconds(30)); - this.ApplicationCache.Verify(a => a.SetMerchantDetails(It.IsAny(), It.IsAny()), Times.Once); - } - - [Fact] - public void MyAccountPageViewModel_OptionSelectedCommand_AccountInfo_Execute_IsExecuted() { - this.ViewModel.OptionSelectedCommand.Execute(this.CreateItemSelected(MyAccountPageViewModel.AccountOptions.AccountInfo)); - - this.NavigationService.Verify(n => n.GoToMyAccountDetails(), Times.Once); - } - - [Fact] - public void MyAccountPageViewModel_OptionSelectedCommand_Addresses_Execute_IsExecuted() { - this.ViewModel.OptionSelectedCommand.Execute(this.CreateItemSelected(MyAccountPageViewModel.AccountOptions.Addresses)); - - this.NavigationService.Verify(n => n.GoToMyAccountAddresses(), Times.Once); - } - - [Fact] - public void MyAccountPageViewModel_OptionSelectedCommand_Contacts_Execute_IsExecuted() { - this.ViewModel.OptionSelectedCommand.Execute(this.CreateItemSelected(MyAccountPageViewModel.AccountOptions.Contacts)); - - this.NavigationService.Verify(n => n.GoToMyAccountContacts(), Times.Once); - } - - [Fact] - public void MyAccountPageViewModel_OptionSelectedCommand_Logout_Execute_IsExecuted() { - this.ViewModel.OptionSelectedCommand.Execute(this.CreateItemSelected(MyAccountPageViewModel.AccountOptions.Logout)); - - this.NavigationService.Verify(n => n.GoToLoginPage(), Times.Once); - } - - [Fact] - public void MyAccountPageViewModel_OptionSelectedCommand_Unsupported_Execute_IsExecuted() - { - this.ViewModel.OptionSelectedCommand.Execute(this.CreateItemSelected((MyAccountPageViewModel.AccountOptions)99)); - - this.NavigationService.Verify(n => n.GoToMyAccountDetails(), Times.Never); - } - - [Fact] - public void MyAccountPageViewModel_GetMyAccountOptions_OptionsReturned(){ - this.ViewModel.MyAccountOptions = new List{ - new ListViewItem{ - Title = "Test" - } - }; - List options = this.ViewModel.MyAccountOptions; - options.Count.ShouldBe(1); - } - - [Fact] - public async Task MyAccountPageViewModel_BackButtonCommand_HomePageIsShown() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n=> n.GoToHome(),Times.Once); - } - - private ItemSelected CreateItemSelected(MyAccountPageViewModel.AccountOptions selectedOption) { - ItemSelected i = new ItemSelected(); - i.SelectedItemIndex = (Int32)selectedOption; - return i; - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Reports/ReportsPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Reports/ReportsPageViewModelTests.cs deleted file mode 100644 index 02cb4c035..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Reports/ReportsPageViewModelTests.cs +++ /dev/null @@ -1,200 +0,0 @@ -using Moq; -using System; -using System.Threading.Tasks; -using Xunit; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Reports -{ - using System.Threading; - using BusinessLogic.Common; - using LiveChartsCore.Measure; - using Maui.UIServices; - using MediatR; - using Models; - using Services; - using Shouldly; - using UIServices; - using ViewModels.Reports; - - public class ReportsPageViewModelTests - { - private readonly Mock NavigationService; - private readonly Mock NavigationParameterService; - private readonly Mock ApplicationCache; - private readonly Mock DialogService; - private readonly Mock DeviceService; - private readonly Mock Mediator; - - private readonly ReportsPageViewModel ViewModel; - - public ReportsPageViewModelTests(){ - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogService = new Mock(); - this.DeviceService = new Mock(); - this.Mediator = new Mock(); - - this.ViewModel = new ReportsPageViewModel(this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogService.Object, - this.DeviceService.Object, - this.Mediator.Object, - this.NavigationParameterService.Object); - } - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(99)] - - public async Task ReportsPageViewModel_OptionSelectedCommand_Execute_IsExecuted(Int32 selectedIndex){ - ListViewItem li = new ListViewItem{ - Title = "Test" - }; - ItemSelected itemSelected = new ItemSelected{ - SelectedItem = li, - SelectedItemIndex = selectedIndex, - }; - this.ViewModel.OptionSelectedCommand.Execute(itemSelected); - - switch(selectedIndex){ - case 0: - this.NavigationService.Verify(v => v.GoToReportsSalesAnalysis(), Times.Once); - break; - case 1: - this.NavigationService.Verify(v => v.GoToReportsBalanceAnalysis(), Times.Once); - break; - default: - this.NavigationService.Verify(v => v.GoToReportsSalesAnalysis(), Times.Never); - this.NavigationService.Verify(v => v.GoToReportsBalanceAnalysis(), Times.Never); - break; - } - } - - [Fact] - public async Task ReportsPageViewModel_Initialise_IsInitialised() - { - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.ReportsMenuOptions.Count.ShouldBe(2); - } - - [Fact] - public async Task ReportsPageViewModel_BackButtonCommand_HomePageIsShown() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoToHome(), Times.Once); - } - } - - public class ReportsSalesAnalysisPageViewModelTests{ - private readonly ReportsSalesAnalysisPageViewModel ViewModel; - private readonly Mock NavigationService; - private readonly Mock NavigationParameterService; - private readonly Mock ApplicationCache; - private readonly Mock DialogService; - private readonly Mock DeviceService; - private readonly Mock Mediator; - - public ReportsSalesAnalysisPageViewModelTests(){ - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogService = new Mock(); - this.DeviceService = new Mock(); - this.Mediator = new Mock(); - - this.ViewModel = new ReportsSalesAnalysisPageViewModel(this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogService.Object, - this.DeviceService.Object, - this.Mediator.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public async Task ReportsSalesAnalysisPageViewModel_Initialise_Execute_IsExecuted(){ - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.ComparisonDates.Count.ShouldBe(3); - } - - [Fact] - public async Task ReportsSalesAnalysisPageViewModel_ComparisonDatePickerSelectedIndexChangedCommand_HomePageIsShown(){ - ComparisonDate comparisonDate = new ComparisonDate(DateTime.Now.AddDays(-1), "Yesterday"); - this.ViewModel.SelectedItem = comparisonDate; - this.ViewModel.ComparisonDatePickerSelectedIndexChangedCommand.Execute(comparisonDate); - - // Nothing to actually verify yet here - this.ViewModel.SalesAnalysisList.Count.ShouldBe(2); - } - - [Fact] - public async Task ReportsSalesAnalysisPageViewModel_BackButtonCommand_HomePageIsShown() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } - } - - public class ReportsBalanceAnalysisPageViewModelTests - { - private ReportsBalanceAnalysisPageViewModel ViewModel; - private Mock NavigationService; - private Mock NavigationParameterService; - private Mock ApplicationCache; - private Mock DialogService; - private readonly Mock DeviceService; - private Mock Mediator; - - public ReportsBalanceAnalysisPageViewModelTests() - { - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogService = new Mock(); - this.DeviceService = new Mock(); - this.Mediator = new Mock(); - - this.ViewModel = new ReportsBalanceAnalysisPageViewModel(this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogService.Object, - this.DeviceService.Object, - this.Mediator.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public async Task ReportsBalanceAnalysisPageViewModel_Initialise_Execute_IsExecuted() - { - await ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.XAxes.ShouldNotBeNull(); - this.ViewModel.YAxes.ShouldNotBeNull(); - this.ViewModel.TooltipFindingStrategy.ShouldBe(TooltipFindingStrategy.CompareOnlyX); - this.ViewModel.TooltipPosition.ShouldBe(TooltipPosition.Top); - this.ViewModel.Series.ShouldNotBeNull(); - } - - //[Fact] - //public async Task ReportsSalesAnalysisPageViewModel_ComparisonDatePickerSelectedIndexChangedCommand_HomePageIsShown() - //{ - // ComparisonDate comparisonDate = new ComparisonDate(DateTime.Now.AddDays(-1), "Yesterday"); - // this.viewModel.SelectedItem = comparisonDate; - // viewModel.ComparisonDatePickerSelectedIndexChangedCommand.Execute(comparisonDate); - - // // Nothing to actually verify yet here - // this.viewModel.SalesAnalysisList.Count.ShouldBe(2); - //} - - [Fact] - public async Task ReportsBalanceAnalysisPageViewModel_BackButtonCommand_HomePageIsShown() - { - ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Support/SupportPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Support/SupportPageViewModelTests.cs deleted file mode 100644 index 4125f132e..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Support/SupportPageViewModelTests.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Support -{ - using Maui.UIServices; - using MediatR; - using Moq; - using UIServices; - using Xunit; - using TransactionMobile.Maui.BusinessLogic.ViewModels.Support; - using TransactionMobile.Maui.Database; - using System.Collections.Generic; - using System.Threading; - using Logging; - using Microsoft.Extensions.Logging.Abstractions; - using Requests; - using Services; - using ViewModels; - using System.Linq; - using System.Text; - using Castle.Components.DictionaryAdapter; - using Shouldly; - - [Collection("ViewModelTests")] - public class SupportPageViewModelTests - { - private readonly Mock NavigationService; - - private readonly Mock NavigationParameterService; - - private readonly Mock DatabaseContext; - - private readonly Mock Mediator; - - private readonly Mock DeviceService; - - private readonly Mock ApplicationInfoService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogService; - - private readonly SupportPageViewModel ViewModel; - public SupportPageViewModelTests() { - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.DatabaseContext = new Mock(); - this.Mediator = new Mock(); - this.DeviceService = new Mock(); - this.ApplicationInfoService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogService = new Mock(); - this.ViewModel = new SupportPageViewModel(this.DeviceService.Object, - this.ApplicationInfoService.Object, - this.DatabaseContext.Object, - this.Mediator.Object, - this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogService.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public void SupportPageViewModel_UploadLogsCommand_Execute_IsExecuted() - { - this.ViewModel.UploadLogsCommand.Execute(null); - - this.Mediator.Verify(m => m.Send(It.IsAny(),It.IsAny()),Times.Once); - } - - [Fact] - public void SupportPageViewModel_ViewLogsCommand_Execute_IsExecuted() - { - this.ViewModel.ViewLogsCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoToViewLogsPage(), Times.Once); - } - - [Fact] - public void SupportPageViewModel_Platform_ValueIsReturned(){ - this.DeviceService.Setup(d => d.GetPlatform()).Returns("Platform"); - this.DeviceService.Setup(d => d.GetManufacturer()).Returns("Manufacturer"); - this.DeviceService.Setup(d => d.GetModel()).Returns("Model"); - - String platform = this.ViewModel.Platform; - - StringBuilder expectedPlatform = new(); - expectedPlatform.Append("Platform: ").AppendLine("Platform"); - expectedPlatform.Append("Manufacturer: ").AppendLine("Manufacturer"); - expectedPlatform.Append("Device: ").AppendLine("Model"); - - platform.ShouldBe(expectedPlatform.ToString()); - } - - [Fact] - public void SupportPageViewModel_NumberTransactionsStored_ValueIsReturned() - { - this.DatabaseContext.Setup(d => d.GetTransactions(It.IsAny())).ReturnsAsync(new List{ - new TransactionRecord() - - }); - String numberTransactionsStored = this.ViewModel.NumberTransactionsStored; - - String expectedNumberTransactionsStored = $"Transactions Stored: 1"; - - numberTransactionsStored.ShouldBe(expectedNumberTransactionsStored); - } - - [Fact] - public void SupportPageViewModel_ApplicationName_ValueIsReturned() - { - this.ApplicationInfoService.Setup(d => d.ApplicationName).Returns("ApplicationName"); - this.ApplicationInfoService.Setup(d => d.VersionString).Returns("VersionString"); - - String applicationName = this.ViewModel.ApplicationName; - - String expectedApplicationName = $"ApplicationName vVersionString"; - - applicationName.ShouldBe(expectedApplicationName); - } - - [Fact] - public void SupportPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoToHome(), Times.Once); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Support/ViewLogsPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Support/ViewLogsPageViewModelTests.cs deleted file mode 100644 index bb1e51adc..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Support/ViewLogsPageViewModelTests.cs +++ /dev/null @@ -1,70 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Support; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging.Abstractions; -using Models; -using Moq; -using Requests; -using Services; -using Shouldly; -using UIServices; -using ViewModels; -using ViewModels.Support; -using Xunit; - -[Collection("ViewModelTests")] -public class ViewLogsPageViewModelTests -{ - private readonly Mock NavigationService; - - private readonly Mock NavigationParameterService; - - private readonly Mock Mediator; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogService; - - private readonly ViewLogsPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public ViewLogsPageViewModelTests() { - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.Mediator = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogService = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new ViewLogsPageViewModel(this.Mediator.Object, - this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogService.Object, - this.DeviceService.Object, this.NavigationParameterService.Object); - } - - [Fact] - public async Task SupportPageViewModel_UploadLogsCommand_Execute_IsExecuted(){ - - this.Mediator.Setup(m => m.Send>(It.IsAny(), It.IsAny())).ReturnsAsync(new List(){ - new LogMessage() - }); - - await this.ViewModel.LoadLogMessages(); - this.ViewModel.LogMessages.Count.ShouldBe(1); - } - - [Fact] - public void ViewLogsPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Admin/AdminPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Admin/AdminPageViewModelTests.cs deleted file mode 100644 index 03480eb20..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Admin/AdminPageViewModelTests.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.Admin -{ - using Logging; - using Maui.UIServices; - using MediatR; - using Microsoft.Extensions.Caching.Memory; - using Moq; - using UIServices; - using ViewModels.Admin; - using ViewModels.Transactions; - using Xunit; - using TransactionMobile.Maui.BusinessLogic.Services; - - [Collection("ViewModelTests")] - public class AdminPageViewModelTests - { - private readonly Mock NavigationService; - private readonly Mock NavigationParameterService; - - private readonly Mock Mediator; - - private readonly Mock DeviceService; - - private readonly Mock ApplicationInfoService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogService; - - private readonly AdminPageViewModel ViewModel; - public AdminPageViewModelTests() { - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.Mediator = new Mock(); - this.DeviceService = new Mock(); - this.ApplicationInfoService = new Mock(); - this.DialogService = new Mock(); - this.ApplicationCache = new Mock(); - this.ViewModel = new AdminPageViewModel(this.Mediator.Object, - this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogService.Object, - this.DeviceService.Object, - this.ApplicationInfoService.Object, this.NavigationParameterService.Object); - } - - [Fact] - public void AdminPageViewModel_AdminCommand_Execute_IsExecuted() - { - this.ViewModel.ReconciliationCommand.Execute(null); - this.NavigationService.Verify(n => n.GoToHome(), Times.Once); - } - - [Fact] - public void AdminPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentFailedPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentFailedPageViewModelTests.cs deleted file mode 100644 index 114b797b2..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentFailedPageViewModelTests.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.BillPayment; - -using Logging; -using Maui.UIServices; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using ViewModels; -using ViewModels.Transactions; -using Xunit; -using NullLogger = Logging.NullLogger; - -[Collection("ViewModelTests")] -public class BillPaymentFailedPageViewModelTests -{ - private readonly Mock NavigationService; - private readonly BillPaymentFailedPageViewModel ViewModel; - public BillPaymentFailedPageViewModelTests() { - this.NavigationService = new Mock(); - this.ViewModel = new BillPaymentFailedPageViewModel(this.NavigationService.Object); - Logger.Initialise(new NullLogger()); - } - - [Fact] - public void BillPaymentFailedPageViewModel_CancelledCommand_Execute_IsExecuted() - { - this.ViewModel.CancelledCommand.Execute(null); - this.NavigationService.Verify(n => n.PopToRoot(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentGetAccountPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentGetAccountPageViewModelTests.cs deleted file mode 100644 index 33744c39f..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentGetAccountPageViewModelTests.cs +++ /dev/null @@ -1,107 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.BillPayment; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; -using NullLogger = Logging.NullLogger; - -[Collection("ViewModelTests")] -public class BillPaymentGetAccountPageViewModelTests -{ - private readonly Mock Mediator; - - private readonly Mock NavigationService; - - private readonly Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogSevice; - - private readonly BillPaymentGetAccountPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public BillPaymentGetAccountPageViewModelTests() { - this.Mediator = new Mock(); - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new BillPaymentGetAccountPageViewModel(this.NavigationService.Object, this.ApplicationCache.Object, - this.DialogSevice.Object, this.DeviceService.Object, this.Mediator.Object, - this.NavigationParameterService.Object); - - Logger.Initialise(new NullLogger()); - } - - [Fact] - public async Task BillPaymentGetAccountPageViewModel_ApplyQueryAttributes_QueryAttributesApplied() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { { nameof(ProductDetails), TestData.Operator1ProductDetails }, }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.ProductDetails.OperatorId.ShouldBe(TestData.Operator1ProductDetails.OperatorId); - this.ViewModel.ProductDetails.ProductId.ShouldBe(TestData.Operator1ProductDetails.ProductId); - this.ViewModel.ProductDetails.ContractId.ShouldBe(TestData.Operator1ProductDetails.ContractId); - } - - [Fact] - public async Task BillPaymentGetAccountPageViewModel_GetAccountCommand_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.PerformBillPaymentGetAccountResponseModel)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { { nameof(ProductDetails), TestData.Operator1ProductDetails }, }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.CustomerAccountNumber = TestData.CustomerAccountNumber; - - this.ViewModel.GetAccountCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoToBillPaymentPayBillPage(It.IsAny(), It.IsAny()), Times.Once); - } - - [Fact] - public async Task BillPaymentGetAccountPageViewModel_GetAccountCommand_Failed_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.PerformBillPaymentGetAccountResponseModelFailed)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { { nameof(ProductDetails), TestData.Operator1ProductDetails }, }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.CustomerAccountNumber = TestData.CustomerAccountNumber; - - this.ViewModel.GetAccountCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoToBillPaymentFailedPage(), Times.Once); - } - - - [Fact] - public async Task BillPaymentSelectProductPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentGetMeterPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentGetMeterPageViewModelTests.cs deleted file mode 100644 index 33f151c5a..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentGetMeterPageViewModelTests.cs +++ /dev/null @@ -1,107 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.BillPayment; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using Moq; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using UIServices; -using ViewModels.Transactions; -using Xunit; - -public class BillPaymentGetMeterPageViewModelTests -{ - private readonly Mock Mediator; - - private readonly Mock NavigationService; - - private Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogSevice; - - private readonly BillPaymentGetMeterPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public BillPaymentGetMeterPageViewModelTests() - { - this.Mediator = new Mock(); - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new BillPaymentGetMeterPageViewModel(this.NavigationService.Object, this.ApplicationCache.Object, - this.DialogSevice.Object, this.DeviceService.Object, this.Mediator.Object, - this.NavigationParameterService.Object); - - Logger.Initialise(new NullLogger()); - } - - [Fact] - public async Task BillPaymentGetAccountPageViewModel_ApplyQueryAttributes_QueryAttributesApplied() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.ProductDetails.OperatorId.ShouldBe(TestData.Operator1ProductDetails.OperatorId); - this.ViewModel.ProductDetails.ProductId.ShouldBe(TestData.Operator1ProductDetails.ProductId); - this.ViewModel.ProductDetails.ContractId.ShouldBe(TestData.Operator1ProductDetails.ContractId); - } - - [Fact] - public async Task BillPaymentGetAccountPageViewModel_GetMeterCommand_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.PerformBillPaymentGetMeterResponseModel)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.MeterNumber = TestData.MeterNumber; - - this.ViewModel.GetMeterCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoToBillPaymentPayBillPage(It.IsAny(), It.IsAny()), Times.Once); - } - - [Fact] - public async Task BillPaymentGetAccountPageViewModel_GetMeterCommand_Failed_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.PerformBillPaymentGetMeterResponseModelFailed)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.MeterNumber = TestData.MeterNumber; - - this.ViewModel.GetMeterCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoToBillPaymentFailedPage(), Times.Once); - } - - - [Fact] - public async Task BillPaymentSelectProductPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentPayBillPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentPayBillPageViewModelTests.cs deleted file mode 100644 index a00768bb2..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentPayBillPageViewModelTests.cs +++ /dev/null @@ -1,215 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.BillPayment; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using TransactionProcessorACL.DataTransferObjects.Responses; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class BillPaymentPayBillPageViewModelTests -{ - private readonly Mock Mediator; - - private readonly Mock NavigationService; - - private Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogSevice; - - private readonly BillPaymentPayBillPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public BillPaymentPayBillPageViewModelTests() { - this.Mediator = new Mock(); - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new BillPaymentPayBillPageViewModel(this.NavigationService.Object, this.ApplicationCache.Object, - this.DialogSevice.Object, this.Mediator.Object, this.DeviceService.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public async Task BillPaymentPayBillPageViewModel_ApplyQueryAttributes_PostPay_QueryAttributesApplied() - { - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(BillDetails), TestData.BillDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.ProductDetails.OperatorId.ShouldBe(TestData.Operator1ProductDetails.OperatorId); - this.ViewModel.ProductDetails.ProductId.ShouldBe(TestData.Operator1ProductDetails.ProductId); - this.ViewModel.ProductDetails.ContractId.ShouldBe(TestData.Operator1ProductDetails.ContractId); - this.ViewModel.BillDetails.AccountName.ShouldBe(TestData.BillDetails.AccountName); - this.ViewModel.BillDetails.AccountNumber.ShouldBe(TestData.BillDetails.AccountNumber); - this.ViewModel.BillDetails.Balance.ShouldBe(TestData.BillDetails.Balance); - this.ViewModel.BillDetails.DueDate.ShouldBe(TestData.BillDetails.DueDate); - } - - [Fact] - public async Task BillPaymentPayBillPageViewModel_ApplyQueryAttributes_PrePay_QueryAttributesApplied() - { - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(MeterDetails), TestData.MeterDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.ProductDetails.OperatorId.ShouldBe(TestData.Operator1ProductDetails.OperatorId); - this.ViewModel.ProductDetails.ProductId.ShouldBe(TestData.Operator1ProductDetails.ProductId); - this.ViewModel.ProductDetails.ContractId.ShouldBe(TestData.Operator1ProductDetails.ContractId); - this.ViewModel.MeterDetails.MeterNumber.ShouldBe(TestData.MeterDetails.MeterNumber); - this.ViewModel.MeterDetails.CustomerName.ShouldBe(TestData.MeterDetails.CustomerName); - } - - [Fact] - public async Task BillPaymentPayBillPageViewModel_CustomerMobileNumberEntryCompleted_Execute_IsExecuted() - { - bool isCompletedCalled = false; - this.ViewModel.OnCustomerMobileNumberEntryCompleted = () => - { - isCompletedCalled = true; - }; - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(BillDetails), TestData.BillDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.CustomerMobileNumberEntryCompletedCommand.Execute(null); - isCompletedCalled.ShouldBeTrue(); - } - - [Fact] - public async Task BillPaymentPayBillPageViewModel_PaymentAmountEntryCompleted_Execute_IsExecuted() - { - bool isCompletedCalled = false; - this.ViewModel.OnPaymentAmountEntryCompleted = () => - { - isCompletedCalled = true; - }; - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(BillDetails), TestData.BillDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.PaymentAmountEntryCompletedCommand.Execute(null); - isCompletedCalled.ShouldBeTrue(); - } - - [Fact] - public async Task BillPaymentPayBillPageViewModel_MakeBillPaymentCommand_Execute_SuccessfulPostPayPayment_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformBillPaymentMakePaymentResponseModel() - { - ResponseCode = "0000" - })); - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(BillDetails), TestData.BillDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.MakeBillPaymentCommand.Execute(null); - this.Mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - this.NavigationService.Verify(v => v.GoToBillPaymentSuccessPage(), Times.Once); - } - - [Fact] - public async Task BillPaymentPayBillPageViewModel_MakeBillPaymentCommand_Execute_SuccessfulPrePayPayment_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformBillPaymentMakePaymentResponseModel() - { - ResponseCode = "0000" - })); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(MeterDetails), TestData.MeterDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.MakeBillPaymentCommand.Execute(null); - this.Mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - this.NavigationService.Verify(v => v.GoToBillPaymentSuccessPage(), Times.Once); - } - - [Fact] - public async Task BillPaymentPayBillPageViewModel_MakeBillPaymentCommand_Execute_FailedPostPayPayment_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformBillPaymentMakePaymentResponseModel() { - ResponseCode = "1010" - })); - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(BillDetails), TestData.BillDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.MakeBillPaymentCommand.Execute(null); - this.Mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - this.NavigationService.Verify(v => v.GoToBillPaymentFailedPage(), Times.Once); - } - - [Fact] - public async Task BillPaymentPayBillPageViewModel_MakeBillPaymentCommand_Execute_FailedPrePayPayment_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformBillPaymentMakePaymentResponseModel() - { - ResponseCode = "1010" - })); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(MeterDetails), TestData.MeterDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.MakeBillPaymentCommand.Execute(null); - this.Mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - this.NavigationService.Verify(v => v.GoToBillPaymentFailedPage(), Times.Once); - } - - [Fact] - public void BillPaymentPayBillPageViewModel_SetProperties_ValuesExpected(){ - this.ViewModel.PaymentAmount = TestData.PaymentAmount; - this.ViewModel.CustomerMobileNumber = TestData.CustomerMobileNumber; - this.ViewModel.IsPostPayVisible = true; - this.ViewModel.IsPrePayVisible = true; - this.ViewModel.PaymentAmount.ShouldBe(TestData.PaymentAmount); - this.ViewModel.CustomerMobileNumber.ShouldBe(TestData.CustomerMobileNumber); - this.ViewModel.IsPostPayVisible.ShouldBeTrue(); - this.ViewModel.IsPrePayVisible.ShouldBeTrue(); - - } - - [Fact] - public void MobileTopupPerformTopupPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - this.NavigationService.Verify(v => v.GoBack(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentSelectOperatorPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentSelectOperatorPageViewModelTests.cs deleted file mode 100644 index b2e047f89..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentSelectOperatorPageViewModelTests.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.BillPayment -{ - using System; - using System.Collections.Generic; - using System.Threading; - using BusinessLogic.Common; - using Common; - using Logging; - using Maui.UIServices; - using MediatR; - using Models; - using Moq; - using RequestHandlers; - using Requests; - using Services; - using Shouldly; - using SimpleResults; - using UIServices; - using ViewModels.Transactions; - using Xunit; - - [Collection("ViewModelTests")] - public class BillPaymentSelectOperatorPageViewModelTests - { - private readonly Mock Mediator; - - private readonly Mock NavigationService; - - private readonly Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogSevice; - - private readonly BillPaymentSelectOperatorPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public BillPaymentSelectOperatorPageViewModelTests() { - this.Mediator = new Mock(); - this.NavigationParameterService = new Mock(); - this.NavigationService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new BillPaymentSelectOperatorPageViewModel(this.Mediator.Object, - this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogSevice.Object, - this.DeviceService.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public async Task BillPaymentSelectOperatorPageViewModel_Initialise_IsInitialised() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - await this.ViewModel.Initialise(CancellationToken.None); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - - this.ViewModel.Operators.Count.ShouldBe(3); - } - - [Fact] - public async Task BillPaymentSelectOperatorPageViewModel_OperatorSelectedCommand_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.Operators.Count.ShouldBe(3); - - ItemSelected selectedContractOperator = new ItemSelected - { - SelectedItemIndex = 1, - SelectedItem = TestData.ContractOperatorModel - }; - - this.ViewModel.OperatorSelectedCommand.Execute(selectedContractOperator); - - this.NavigationService.Verify(n => n.GoToBillPaymentSelectProductPage(It.IsAny()), Times.Once); - } - - [Fact] - public async Task BillPaymentSelectOperatorPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - ItemSelected selectedContractOperator = new ItemSelected - { - SelectedItemIndex = 1, - SelectedItem = TestData.ContractOperatorModel - }; - - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentSelectProductPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentSelectProductPageViewModelTests.cs deleted file mode 100644 index 374219511..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentSelectProductPageViewModelTests.cs +++ /dev/null @@ -1,133 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.BillPayment; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using BusinessLogic.Common; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using UIServices; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class BillPaymentSelectProductPageViewModelTests -{ - #region Methods - - private readonly Mock Mediator; - - private readonly Mock NavigationService; - - private readonly Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogSevice; - - private readonly BillPaymentSelectProductPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public BillPaymentSelectProductPageViewModelTests() - { - this.Mediator = new Mock(); - - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new BillPaymentSelectProductPageViewModel(this.Mediator.Object, - this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogSevice.Object, - this.DeviceService.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public async Task BillPaymentSelectProductPageViewModel_ApplyQueryAttributes_QueryAttributesApplied() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { { nameof(ProductDetails), TestData.Operator1ProductDetails }, }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.ProductDetails.OperatorId.ShouldBe(TestData.OperatorId1); - } - - [Fact] - public async Task BillPaymentSelectProductPageViewModel_Initialise_IsInitialised() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { { nameof(ProductDetails), TestData.Operator1ProductDetails }, }); - await this.ViewModel.Initialise(CancellationToken.None); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - - this.ViewModel.Products.Count.ShouldBe(3); - } - - [Fact] - public async Task BillPaymentSelectProductPageViewModel_ProductSelectedCommand_PostPay_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { { nameof(ProductDetails), TestData.Operator1ProductDetails }, }); - await this.ViewModel.Initialise(CancellationToken.None); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - - this.ViewModel.Products.Count.ShouldBe(3); - - ItemSelected selectedContractProduct = new ItemSelected - { - SelectedItemIndex = 1, - SelectedItem = TestData.Operator1Product_BillPayment_PostPayment, - }; - - this.ViewModel.ProductSelectedCommand.Execute(selectedContractProduct); - - this.NavigationService.Verify(n => n.GoToBillPaymentGetAccountPage(It.IsAny()), Times.Once); - } - - [Fact] - public async Task BillPaymentSelectProductPageViewModel_ProductSelectedCommand_PrePay_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { { nameof(ProductDetails), TestData.Operator1ProductDetails }, }); - await this.ViewModel.Initialise(CancellationToken.None); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - - this.ViewModel.Products.Count.ShouldBe(3); - - ItemSelected selectedContractProduct = new ItemSelected - { - SelectedItemIndex = 1, - SelectedItem = TestData.Operator1Product_BillPayment_PrePayment, - }; - - this.ViewModel.ProductSelectedCommand.Execute(selectedContractProduct); - - this.NavigationService.Verify(n => n.GoToBillPaymentGetMeterPage(It.IsAny()), Times.Once); - } - - [Fact] - public async Task BillPaymentSelectProductPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentSuccessPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentSuccessPageViewModelTests.cs deleted file mode 100644 index cbfff3ff9..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/BillPayment/BillPaymentSuccessPageViewModelTests.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.BillPayment; - -using Logging; -using Maui.UIServices; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using ViewModels; -using ViewModels.Transactions; -using Xunit; -using NullLogger = Logging.NullLogger; - -[Collection("ViewModelTests")] -public class BillPaymentSuccessPageViewModelTests -{ - private readonly Mock NavigationService; - private readonly BillPaymentSuccessPageViewModel ViewModel; - public BillPaymentSuccessPageViewModelTests() - { - this.NavigationService = new Mock(); - this.ViewModel = new BillPaymentSuccessPageViewModel(this.NavigationService.Object); - Logger.Initialise(new NullLogger()); - } - - [Fact] - public void BillPaymentSuccessPageViewModel_CompletedCommand_Execute_IsExecuted() - { - this.ViewModel.CompletedCommand.Execute(null); - this.NavigationService.Verify(n => n.PopToRoot(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupFailedPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupFailedPageViewModelTests.cs deleted file mode 100644 index 33eef9906..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupFailedPageViewModelTests.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.MobileTopup; - -using Logging; -using Maui.UIServices; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using Services; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; -using NullLogger = Logging.NullLogger; - -[Collection("ViewModelTests")] -public class MobileTopupFailedPageViewModelTests -{ - private readonly Mock NavigationService; - - private readonly MobileTopupFailedPageViewModel ViewModel; - public MobileTopupFailedPageViewModelTests() - { - this.NavigationService = new Mock(); - - this.ViewModel = new MobileTopupFailedPageViewModel(this.NavigationService.Object); - Logger.Initialise(new NullLogger()); - } - - [Fact] - public void MobileTopupFailedPageViewModel_CancelledCommand_Execute_IsExecuted() - { - this.ViewModel.CancelledCommand.Execute(null); - this.NavigationService.Verify(n => n.PopToRoot(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupPerformTopupPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupPerformTopupPageViewModelTests.cs deleted file mode 100644 index 347d50c56..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupPerformTopupPageViewModelTests.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.MobileTopup; - -using System; -using System.Collections.Generic; -using System.Threading; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging.Abstractions; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using TransactionProcessorACL.DataTransferObjects.Responses; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class MobileTopupPerformTopupPageViewModelTests -{ - private readonly Mock Mediator; - - private readonly Mock NavigationService; - private readonly Mock NavigationParameterService; - private readonly Mock ApplicationCache; - private readonly Mock DialogSevice; - private readonly MobileTopupPerformTopupPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public MobileTopupPerformTopupPageViewModelTests() { - - this.Mediator = new Mock(); - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new MobileTopupPerformTopupPageViewModel(this.Mediator.Object, - this.NavigationService.Object, - this.ApplicationCache.Object, - this.DialogSevice.Object, - this.DeviceService.Object, - this.NavigationParameterService.Object); - } - [Fact] - public async Task MobileTopupPerformTopupPageViewModel_ApplyQueryAttributes_QueryAttributesApplied() - { - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.TopupAmount), TestData.Operator1Product_100KES.Value} - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.ProductDetails.ContractId.ShouldBe(TestData.OperatorId1ContractId); - this.ViewModel.ProductDetails.ProductId.ShouldBe(TestData.Operator1Product_100KES.ProductId); - this.ViewModel.ProductDetails.OperatorId.ShouldBe(TestData.OperatorId1); - this.ViewModel.TopupAmount.ShouldBe(TestData.Operator1Product_100KES.Value); - } - - [Fact] - public async Task MobileTopupPerformTopupPageViewModel_CustomerEmailAddressEntryCompletedCommand_Execute_IsExecuted() - { - bool isCompletedCalled = false; - this.ViewModel.OnCustomerEmailAddressEntryCompleted = () => - { - isCompletedCalled = true; - }; - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.TopupAmount), TestData.Operator1Product_100KES.Value} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.CustomerEmailAddressEntryCompletedCommand.Execute(null); - isCompletedCalled.ShouldBeTrue(); - } - - [Fact] - public async Task MobileTopupPerformTopupPageViewModel_CustomerMobileNumberEntryCompletedCommand_Execute_IsExecuted() - { - Boolean isCompletedCalled = false; - this.ViewModel.OnCustomerMobileNumberEntryCompleted = () => - { - isCompletedCalled = true; - }; - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.TopupAmount), TestData.Operator1Product_100KES.Value} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.CustomerMobileNumberEntryCompletedCommand.Execute(null); - isCompletedCalled.ShouldBeTrue(); - } - - [Fact] - public async Task MobileTopupPerformTopupPageViewModel_TopupAmountEntryCompletedCommand_Execute_IsExecuted() - { - Boolean isCompletedCalled = false; - this.ViewModel.OnTopupAmountEntryCompleted = () => - { - isCompletedCalled = true; - }; - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.TopupAmount), TestData.Operator1Product_100KES.Value} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.TopupAmountEntryCompletedCommand.Execute(null); - isCompletedCalled.ShouldBeTrue(); - } - - [Fact] - public async Task MobileTopupPerformTopupPageViewModel_PerformTopupCommand_Execute_SuccessfulTopup_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformMobileTopupResponseModel() { - ResponseCode = "0000" - })); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.TopupAmount), TestData.Operator1Product_100KES.Value} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.PerformTopupCommand.Execute(null); - this.Mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - this.NavigationService.Verify(v => v.GoToMobileTopupSuccessPage(), Times.Once); - } - - [Fact] - public async Task MobileTopupPerformTopupPageViewModel_PerformTopupCommand_Execute_FailedTopup_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformMobileTopupResponseModel() - { - ResponseCode = "0001" - })); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.TopupAmount), TestData.Operator1Product_100KES.Value} - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.PerformTopupCommand.Execute(null); - this.Mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - this.NavigationService.Verify(v => v.GoToMobileTopupFailedPage(), Times.Once); - } - - [Fact] - public void MobileTopupPerformTopupPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - this.NavigationService.Verify(v => v.GoBack(), Times.Once); - } - - [Fact] - public void MobileTopupPerformTopupPageViewModel_Properties_ReturnExpectedValues(){ - this.ViewModel.CustomerEmailAddress = TestData.CustomerEmailAddress; - this.ViewModel.CustomerMobileNumber= TestData.CustomerMobileNumber; - - this.ViewModel.CustomerEmailAddress.ShouldBe(TestData.CustomerEmailAddress); - this.ViewModel.CustomerMobileNumber.ShouldBe(TestData.CustomerMobileNumber); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupSelectOperatorPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupSelectOperatorPageViewModelTests.cs deleted file mode 100644 index 51b276862..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupSelectOperatorPageViewModelTests.cs +++ /dev/null @@ -1,96 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.MobileTopup; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using BusinessLogic.Common; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging.Abstractions; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class MobileTopupSelectOperatorPageViewModelTests -{ - private readonly Mock Mediator; - - private readonly Mock NavigationService; - - private readonly Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogSevice; - - private readonly MobileTopupSelectOperatorPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public MobileTopupSelectOperatorPageViewModelTests() { - this.Mediator = new Mock(); - - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new MobileTopupSelectOperatorPageViewModel(this.Mediator.Object, this.NavigationService.Object, this.DialogSevice.Object, this.ApplicationCache.Object, this.DeviceService.Object, - this.NavigationParameterService.Object); - - - } - - [Fact] - public async Task MobileTopupSelectOperatorPageViewModel_Initialise_IsInitialised() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - await this.ViewModel.Initialise(CancellationToken.None); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - - this.ViewModel.Operators.Count.ShouldBe(3); - } - - [Fact] - public async Task MobileTopupSelectOperatorPageViewModel_OperatorSelectedCommand_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.Operators.Count.ShouldBe(3); - - ItemSelected selectedContractOperator = new ItemSelected - { - SelectedItemIndex = 1, - SelectedItem = TestData.ContractOperatorModel - }; - - this.ViewModel.OperatorSelectedCommand.Execute(selectedContractOperator); - - this.NavigationService.Verify(n => n.GoToMobileTopupSelectProductPage(It.IsAny()), Times.Once); - } - - [Fact] - public async Task MobileTopupSelectOperatorPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupSelectProductPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupSelectProductPageViewModelTests.cs deleted file mode 100644 index 8da046506..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupSelectProductPageViewModelTests.cs +++ /dev/null @@ -1,111 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.MobileTopup; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using BusinessLogic.Common; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using UIServices; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class MobileTopupSelectProductPageViewModelTests -{ - #region Methods - - private readonly Mock Mediator; - - private readonly Mock NavigationService; - private Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogSevice; - - private readonly MobileTopupSelectProductPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public MobileTopupSelectProductPageViewModelTests() { - this.Mediator = new Mock(); - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new MobileTopupSelectProductPageViewModel(this.Mediator.Object, this.NavigationService.Object, this.ApplicationCache.Object, this.DialogSevice.Object, this.DeviceService.Object, - this.NavigationParameterService.Object); - } - - [Fact] - public async Task MobileTopupSelectProductPageViewModel_ApplyQueryAttributes_QueryAttributesApplied() { - - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.ProductDetails.OperatorId.ShouldBe(TestData.OperatorId1); - } - - [Fact] - public async Task MobileTopupSelectProductPageViewModel_Initialise_IsInitialised() { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - - this.ViewModel.Products.Count.ShouldBe(3); - } - - [Fact] - public async Task MobileTopupSelectProductPageViewModel_ProductSelectedCommand_Execute_IsExecuted() { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - - this.ViewModel.Products.Count.ShouldBe(3); - - ItemSelected selectedContractProduct = new ItemSelected { - SelectedItemIndex = 1, - SelectedItem = TestData.Operator1Product_100KES - }; - - this.ViewModel.ProductSelectedCommand.Execute(selectedContractProduct); - - this.NavigationService.Verify(n => n.GoToMobileTopupPerformTopupPage(It.IsAny(),It.IsAny()), Times.Once); - } - - [Fact] - public async Task MobileTopupSelectProductPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupSuccessPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupSuccessPageViewModelTests.cs deleted file mode 100644 index 8a58bd20f..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/MobileTopup/MobileTopupSuccessPageViewModelTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.MobileTopup; - -using Logging; -using Maui.UIServices; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using Services; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class MobileTopupSuccessPageViewModelTests -{ - private readonly Mock NavigationService; - - private readonly MobileTopupSuccessPageViewModel ViewModel; - - public MobileTopupSuccessPageViewModelTests() { - this.NavigationService = new Mock(); - - this.ViewModel = new MobileTopupSuccessPageViewModel(this.NavigationService.Object); - } - - [Fact] - public void MobileTopupSuccessPageViewModel_CompletedCommand_Execute_IsExecuted() - { - this.ViewModel.CompletedCommand.Execute(null); - this.NavigationService.Verify(n => n.PopToRoot(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/TransactionsPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/TransactionsPageViewModelTests.cs deleted file mode 100644 index 6d5762ade..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/TransactionsPageViewModelTests.cs +++ /dev/null @@ -1,77 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions; - -using System; -using Logging; -using Maui.UIServices; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using Services; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class TransactionsPageViewModelTests -{ - private readonly Mock ApplicationCache; - private readonly Mock NavigationService; - private Mock NavigationParameterService; - private readonly TransactionsPageViewModel ViewModel; - private readonly Mock DialogSevice; - - private readonly Mock DeviceService; - - public TransactionsPageViewModelTests() { - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new TransactionsPageViewModel(this.NavigationService.Object, this.ApplicationCache.Object, this.DialogSevice.Object, this.DeviceService.Object, - this.NavigationParameterService.Object); - - } - - [Fact] - public void TransactionsPageViewModel_AdminCommand_Execute_IsExecuted() - { - this.ViewModel.AdminCommand.Execute(null); - this.NavigationService.Verify(n => n.GoToAdminPage(), Times.Once); - } - - [Fact] - public void TransactionsPageViewModel_BillPaymentCommand_Execute_IsExecuted() - { - this.ViewModel.BillPaymentCommand.Execute(null); - this.NavigationService.Verify(n => n.GoToBillPaymentSelectOperatorPage(), Times.Once); - } - - [Fact] - public void TransactionsPageViewModel_MobileTopupCommand_Execute_IsExecuted() - { - this.ViewModel.MobileTopupCommand.Execute(null); - this.NavigationService.Verify(n => n.GoToMobileTopupSelectOperatorPage(), Times.Once); - } - - [Fact] - public void TransactionsPageViewModel_MobileWalletCommand_Execute_IsExecuted() - { - this.ViewModel.MobileWalletCommand.Execute(null); - this.NavigationService.Verify(n => n.GoToHome(), Times.Once); - } - - [Fact] - public void TransactionsPageViewModel_VoucherCommand_Execute_IsExecuted() - { - this.ViewModel.VoucherCommand.Execute(null); - this.NavigationService.Verify(n => n.GoToVoucherSelectOperatorPage(), Times.Once); - } - - [Fact] - public void TransactionsPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - this.NavigationService.Verify(n => n.GoToHome(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherIssueFailedPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherIssueFailedPageViewModelTests.cs deleted file mode 100644 index 27d6dfa98..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherIssueFailedPageViewModelTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.Voucher; - -using Logging; -using Maui.UIServices; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using Services; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; -using NullLogger = Logging.NullLogger; - -[Collection("ViewModelTests")] -public class VoucherIssueFailedPageViewModelTests -{ - private readonly Mock NavigationService; - - private readonly VoucherIssueFailedPageViewModel ViewModel; - - public VoucherIssueFailedPageViewModelTests() { - NavigationService = new Mock(); - - this.ViewModel = new VoucherIssueFailedPageViewModel(this.NavigationService.Object); - Logger.Initialise(new NullLogger()); - } - - [Fact] - public void VoucherIssueFailedPageViewModel_CancelledCommand_Execute_IsExecuted() - { - this.ViewModel.CancelledCommand.Execute(null); - this.NavigationService.Verify(n => n.PopToRoot(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherIssueSelectProductPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherIssueSelectProductPageViewModelTests.cs deleted file mode 100644 index 99423e213..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherIssueSelectProductPageViewModelTests.cs +++ /dev/null @@ -1,113 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.Voucher; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using BusinessLogic.Common; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging.Abstractions; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class VoucherIssueSelectProductPageViewModelTests -{ - #region Methods - - private readonly Mock Mediator; - - private readonly Mock NavigationService; - private Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogSevice; - private readonly VoucherSelectProductPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public VoucherIssueSelectProductPageViewModelTests() { - - this.Mediator = new Mock(); - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new VoucherSelectProductPageViewModel(this.Mediator.Object, this.NavigationService.Object, - this.ApplicationCache.Object, this.DialogSevice.Object, - this.DeviceService.Object, this.NavigationParameterService.Object); - - } - - [Fact] - public async Task VoucherIssueSelectProductPageViewModel_ApplyQueryAttributes_QueryAttributesApplied() { - - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.ViewModel.ProductDetails.OperatorId.ShouldBe(TestData.OperatorId1); - } - - [Fact] - public async Task VoucherIssueSelectProductPageViewModel_Initialise_IsInitialised() { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - - this.ViewModel.Products.Count.ShouldBe(3); - } - - [Fact] - public async Task VoucherIssueSelectProductPageViewModel_ProductSelectedCommand_Execute_IsExecuted() { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails} - }); - await this.ViewModel.Initialise(CancellationToken.None); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - - this.ViewModel.Products.Count.ShouldBe(3); - - ItemSelected selectedContractProduct = new ItemSelected { - SelectedItemIndex = 1, - SelectedItem = TestData.Operator1Product_100KES - }; - - this.ViewModel.ProductSelectedCommand.Execute(selectedContractProduct); - - this.NavigationService.Verify(n => n.GoToVoucherIssueVoucherPage(It.IsAny(),It.IsAny()), Times.Once); - } - - [Fact] - public async Task VoucherIssueSelectProductPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(n => n.GoBack(), Times.Once); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherIssueSuccessPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherIssueSuccessPageViewModelTests.cs deleted file mode 100644 index 3f2d5f042..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherIssueSuccessPageViewModelTests.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.Voucher; - -using Logging; -using Maui.UIServices; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using Services; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class VoucherIssueSuccessPageViewModelTests -{ - private readonly Mock NavigationService; - private readonly VoucherIssueSuccessPageViewModel ViewModel; - - public VoucherIssueSuccessPageViewModelTests() - { - NavigationService = new Mock(); - this.ViewModel = new VoucherIssueSuccessPageViewModel(this.NavigationService.Object); - } - - [Fact] - public void VoucherIssueSuccessPageViewModel_CompletedCommand_Execute_IsExecuted() - { - this.ViewModel.CompletedCommand.Execute(null); - this.NavigationService.Verify(n => n.PopToRoot(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherPerformIssuePageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherPerformIssuePageViewModelTests.cs deleted file mode 100644 index 93f26f7ed..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherPerformIssuePageViewModelTests.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.Voucher; - -using System; -using System.Collections.Generic; -using System.Threading; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging.Abstractions; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using TransactionProcessorACL.DataTransferObjects.Responses; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class VoucherPerformIssuePageViewModelTests -{ - private readonly Mock Mediator; - - private readonly Mock NavigationService; - - private readonly Mock NavigationParameterService; - - private readonly Mock ApplicationCache; - - private readonly Mock DialogService; - private readonly VoucherPerformIssuePageViewModel ViewModel; - - private readonly Mock DeviceService; - - public VoucherPerformIssuePageViewModelTests() { - this.Mediator = new Mock(); - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogService = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new VoucherPerformIssuePageViewModel(this.NavigationService.Object, this.ApplicationCache.Object, - this.DialogService.Object, this.DeviceService.Object, this.Mediator.Object, this.NavigationParameterService.Object); - } - - [Fact] - public async Task VoucherPerformIssuePageViewModel_ApplyQueryAttributes_QueryAttributesApplied() - { - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.VoucherAmount), TestData.Operator1Product_100KES.Value} - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.ProductDetails.ContractId.ShouldBe(TestData.OperatorId1ContractId); - this.ViewModel.ProductDetails.ProductId.ShouldBe(TestData.Operator1Product_100KES.ProductId); - this.ViewModel.ProductDetails.OperatorId.ShouldBe(TestData.OperatorId1); - this.ViewModel.VoucherAmount.ShouldBe(TestData.Operator1Product_100KES.Value); - } - - [Fact] - public void VoucherPerformIssuePageViewModel_CustomerEmailAddressEntryCompletedCommand_Execute_IsExecuted() - { - bool isCompletedCalled = false; - this.ViewModel.OnCustomerEmailAddressEntryCompleted = () => - { - isCompletedCalled = true; - }; - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.VoucherAmount), TestData.Operator1Product_100KES.Value} - }); - this.ViewModel.CustomerEmailAddressEntryCompletedCommand.Execute(null); - isCompletedCalled.ShouldBeTrue(); - } - - [Fact] - public void VoucherPerformIssuePageViewModel_RecipientMobileNumberEntryCompletedCommand_Execute_IsExecuted() - { - bool isCompletedCalled = false; - this.ViewModel.OnRecipientMobileNumberEntryCompleted = () => - { - isCompletedCalled = true; - }; - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.VoucherAmount), TestData.Operator1Product_100KES.Value} - }); - this.ViewModel.RecipientMobileNumberEntryCompletedCommand.Execute(null); - isCompletedCalled.ShouldBeTrue(); - } - - [Fact] - public void VoucherPerformIssuePageViewModel_RecipientEmailAddressEntryCompleted_Execute_IsExecuted() - { - bool isCompletedCalled = false; - this.ViewModel.OnRecipientEmailAddressEntryCompleted = () => - { - isCompletedCalled = true; - }; - - // TODO: Move to the mock - //this.ViewModel.ApplyQueryAttributes(new Dictionary - // { - // {nameof(ProductDetails), TestData.Operator1ProductDetails}, - // {nameof(this.ViewModel.VoucherAmount), TestData.Operator1Product_100KES.Value} - // }); - this.ViewModel.RecipientEmailAddressEntryCompletedCommand.Execute(null); - isCompletedCalled.ShouldBeTrue(); - } - - [Fact] - public async Task VoucherPerformIssuePageViewModel_VoucherAmountEntryCompletedCommand_Execute_IsExecuted() - { - bool isCompletedCalled = false; - this.ViewModel.OnVoucherAmountEntryCompleted = () => - { - isCompletedCalled = true; - }; - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.VoucherAmount), TestData.Operator1Product_100KES.Value} - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.VoucherAmountEntryCompletedCommand.Execute(null); - isCompletedCalled.ShouldBeTrue(); - } - - [Fact] - public async Task VoucherPerformIssuePageViewModel_IssueVoucherCommand_Execute_SuccessfulVoucher_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformVoucherIssueResponseModel() { - ResponseCode = "0000" - })); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.VoucherAmount), TestData.Operator1Product_100KES.Value} - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.IssueVoucherCommand.Execute(null); - this.Mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - this.NavigationService.Verify(v => v.GoToVoucherIssueSuccessPage(), Times.Once); - } - - [Fact] - public async Task VoucherPerformIssuePageViewModel_IssueVoucherCommand_Execute_FailedVoucher_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new PerformVoucherIssueResponseModel() - { - ResponseCode = "1010" - })); - - this.NavigationParameterService.Setup(n => n.GetParameters()).Returns(new Dictionary { - {nameof(ProductDetails), TestData.Operator1ProductDetails}, - {nameof(this.ViewModel.VoucherAmount), TestData.Operator1Product_100KES.Value} - }); - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.IssueVoucherCommand.Execute(null); - this.Mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Once); - this.NavigationService.Verify(v => v.GoToVoucherIssueFailedPage(), Times.Once); - } - - [Fact] - public void VoucherPerformIssuePageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(v => v.GoBack(), Times.Once); - } - - [Fact] - public void VoucherPerformIssuePageViewModel_Properties_ReturnExpectedValues() - { - this.ViewModel.CustomerEmailAddress = TestData.CustomerEmailAddress; - this.ViewModel.RecipientEmailAddress = TestData.RecipientEmailAddress; - this.ViewModel.RecipientMobileNumber= TestData.RecipientMobileNumber; - - this.ViewModel.CustomerEmailAddress.ShouldBe(TestData.CustomerEmailAddress); - this.ViewModel.RecipientEmailAddress.ShouldBe(TestData.RecipientEmailAddress); - this.ViewModel.RecipientMobileNumber.ShouldBe(TestData.RecipientMobileNumber); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherSelectOperatorPageViewModelTests.cs b/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherSelectOperatorPageViewModelTests.cs deleted file mode 100644 index c36b75556..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic.Tests/ViewModelTests/Transactions/Voucher/VoucherSelectOperatorPageViewModelTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Tests.ViewModelTests.Transactions.Voucher; - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using BusinessLogic.Common; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Microsoft.Extensions.Logging.Abstractions; -using Models; -using Moq; -using RequestHandlers; -using Requests; -using Services; -using Shouldly; -using SimpleResults; -using UIServices; -using ViewModels; -using ViewModels.Transactions; -using Xunit; - -[Collection("ViewModelTests")] -public class VoucherSelectOperatorPageViewModelTests -{ - private readonly Mock Mediator; - - private readonly Mock NavigationService; - private Mock NavigationParameterService; - private readonly Mock ApplicationCache; - - private readonly Mock DialogSevice; - - private readonly VoucherSelectOperatorPageViewModel ViewModel; - - private readonly Mock DeviceService; - - public VoucherSelectOperatorPageViewModelTests() { - this.Mediator = new Mock(); - this.NavigationService = new Mock(); - this.NavigationParameterService = new Mock(); - this.ApplicationCache = new Mock(); - this.DialogSevice = new Mock(); - this.DeviceService = new Mock(); - this.ViewModel = new VoucherSelectOperatorPageViewModel(this.Mediator.Object, this.NavigationService.Object, this.ApplicationCache.Object, - this.DialogSevice.Object, this.DeviceService.Object, - this.NavigationParameterService.Object); - - } - [Fact] - public async Task VoucherSelectOperatorPageViewModel_Initialise_IsInitialised() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - - await this.ViewModel.Initialise(CancellationToken.None); - this.Mediator.Verify(x => x.Send(It.IsAny(), It.IsAny()), Times.Once); - - this.ViewModel.Operators.Count.ShouldBe(3); - } - - [Fact] - public async Task VoucherSelectOperatorPageViewModel_OperatorSelectedCommand_Execute_IsExecuted() - { - this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.ContractProductList)); - - await this.ViewModel.Initialise(CancellationToken.None); - - this.ViewModel.Operators.Count.ShouldBe(3); - - ItemSelected selectedContractOperator = new ItemSelected - { - SelectedItemIndex = 1, - SelectedItem = TestData.ContractOperatorModel - }; - - this.ViewModel.OperatorSelectedCommand.Execute(selectedContractOperator); - - this.NavigationService.Verify(n => n.GoToVoucherSelectProductPage(It.IsAny()), Times.Once); - } - - [Fact] - public void VoucherSelectOperatorPageViewModel_BackButtonCommand_Execute_IsExecuted() - { - this.ViewModel.BackButtonCommand.Execute(null); - - this.NavigationService.Verify(v => v.GoBack(), Times.Once); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Common/Extensions.cs b/archive/TransactionMobile.Maui.BusinessLogic/Common/Extensions.cs deleted file mode 100644 index e6e37b540..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Common/Extensions.cs +++ /dev/null @@ -1,393 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Common; - -using Database; -using Models; -using RequestHandlers; -using Requests; -using SimpleResults; -using TransactionProcessorACL.DataTransferObjects; -using TransactionProcessorACL.DataTransferObjects.Responses; -using ViewModels.Transactions; - -public static class Extensions -{ - public static TransactionRecord ToTransactionRecord(this LogonTransactionRequest request, - Boolean isTrainingMode) { - TransactionRecord transactionRecord = new TransactionRecord { - TransactionDateTime = request.TransactionDateTime, - TransactionType = 1, - IsTrainingMode = isTrainingMode - }; - - return transactionRecord; - } - - public static TransactionRecord ToTransactionRecord(this PerformMobileTopupRequest request, - Boolean isTrainingMode) { - TransactionRecord transactionRecord = new TransactionRecord { - TransactionDateTime = request.TransactionDateTime, - TransactionType = 2, - Amount = request.TopupAmount, - ProductId = request.ProductId, - ContractId = request.ContractId, - CustomerAccountNumber = request.CustomerAccountNumber, - CustomerEmailAddress = request.CustomerEmailAddress, - OperatorId = request.OperatorId, - IsTrainingMode = isTrainingMode - }; - - return transactionRecord; - } - - public static TransactionRecord ToTransactionRecord(this PerformVoucherIssueRequest request, Boolean isTrainingMode) { - TransactionRecord transactionRecord = new TransactionRecord { - TransactionDateTime = request.TransactionDateTime, - TransactionType = 2, - Amount = request.VoucherAmount, - ProductId = request.ProductId, - ContractId = request.ContractId, - RecipientEmailAddress = request.RecipientEmailAddress, - RecipientMobileNumber = request.RecipientMobileNumber, - CustomerEmailAddress = request.CustomerEmailAddress, - OperatorId = request.OperatorId, - IsTrainingMode = isTrainingMode - }; - - return transactionRecord; - } - - public static TransactionRecord ToTransactionRecord(this PerformBillPaymentGetAccountRequest request, Boolean isTrainingMode) { - TransactionRecord transactionRecord = new TransactionRecord - { - TransactionDateTime = request.TransactionDateTime, - TransactionType = 2, - Amount = 0, - ProductId = request.ProductId, - ContractId = request.ContractId, - OperatorId = request.OperatorId, -CustomerAccountNumber = request.CustomerAccountNumber, - IsTrainingMode = isTrainingMode - }; - return transactionRecord; - } - - public static TransactionRecord ToTransactionRecord(this PerformBillPaymentMakePostPaymentRequest request, Boolean isTrainingMode) { - TransactionRecord transactionRecord = new TransactionRecord - { - TransactionDateTime = request.TransactionDateTime, - TransactionType = 2, - Amount = 0, - ProductId = request.ProductId, - ContractId = request.ContractId, - OperatorId = request.OperatorId, - CustomerAccountNumber = request.CustomerAccountNumber, - IsTrainingMode = isTrainingMode - }; - return transactionRecord; - } - - public static TransactionRecord ToTransactionRecord(this PerformBillPaymentMakePrePaymentRequest request, Boolean isTrainingMode) - { - TransactionRecord transactionRecord = new TransactionRecord - { - TransactionDateTime = request.TransactionDateTime, - TransactionType = 2, - Amount = 0, - ProductId = request.ProductId, - ContractId = request.ContractId, - OperatorId = request.OperatorId, - CustomerAccountNumber = request.MeterNumber, - IsTrainingMode = isTrainingMode - }; - return transactionRecord; - } - - public static TransactionRecord ToTransactionRecord(this PerformBillPaymentGetMeterRequest request, Boolean isTrainingMode) - { - TransactionRecord transactionRecord = new TransactionRecord - { - TransactionDateTime = request.TransactionDateTime, - TransactionType = 2, - Amount = 0, - ProductId = request.ProductId, - ContractId = request.ContractId, - OperatorId = request.OperatorId, - CustomerAccountNumber = request.MeterNumber, - IsTrainingMode = isTrainingMode - }; - return transactionRecord; - } - - - public static TransactionRecord UpdateFrom(this TransactionRecord transactionRecord, - Result result) { - transactionRecord.IsSuccessful = result.Data.IsSuccessful; - transactionRecord.ResponseMessage = result.Data.ResponseMessage; - transactionRecord.EstateId = result.Data.EstateId; - transactionRecord.MerchantId = result.Data.MerchantId; - - return transactionRecord; - } - - public static TransactionRecord UpdateFrom(this TransactionRecord transactionRecord, - Result result) - { - transactionRecord.IsSuccessful = result.Data.IsSuccessful; - - return transactionRecord; - } - - public static TransactionRecord UpdateFrom(this TransactionRecord transactionRecord, - Result result) - { - transactionRecord.IsSuccessful = result.Data.IsSuccessful; - - return transactionRecord; - } - - public static TransactionRecord UpdateFrom(this TransactionRecord transactionRecord, - Result result) - { - transactionRecord.IsSuccessful = result.Data.IsSuccessful; - - return transactionRecord; - } - - public static TransactionRecord UpdateFrom(this TransactionRecord transactionRecord, - Result result) - { - transactionRecord.IsSuccessful = result.Data.IsSuccessful; - - return transactionRecord; - } - - public static TransactionRecord UpdateFrom(this TransactionRecord transactionRecord, - Result result) - { - transactionRecord.IsSuccessful = result.Data.IsSuccessful; - - return transactionRecord; - } - - public static LogonTransactionRequestMessage ToLogonTransactionRequest(this PerformLogonRequestModel model) - { - LogonTransactionRequestMessage logonTransactionRequest = new LogonTransactionRequestMessage - { - ApplicationVersion = model.ApplicationVersion, - DeviceIdentifier = model.DeviceIdentifier, - TransactionDateTime = model.TransactionDateTime, - TransactionNumber = model.TransactionNumber - }; - - return logonTransactionRequest; - } - - public static ReconciliationRequestMessage ToReconciliationRequest(this PerformReconciliationRequestModel model) - { - ReconciliationRequestMessage reconciliationRequest = new ReconciliationRequestMessage - { - ApplicationVersion = model.ApplicationVersion, - TransactionDateTime = model.TransactionDateTime, - DeviceIdentifier = model.DeviceIdentifier, - TransactionCount = model.TransactionCount, - TransactionValue = model.TransactionValue, - OperatorTotals = new List() - }; - foreach (OperatorTotalModel modelOperatorTotal in model.OperatorTotals) - { - reconciliationRequest.OperatorTotals.Add(new OperatorTotalRequest - { - OperatorId = modelOperatorTotal.OperatorId, - TransactionValue = modelOperatorTotal.TransactionValue, - ContractId = modelOperatorTotal.ContractId, - TransactionCount = modelOperatorTotal.TransactionCount - }); - } - - return reconciliationRequest; - } - - public static SaleTransactionRequestMessage ToSaleTransactionRequest(this PerformVoucherIssueRequestModel model) - { - SaleTransactionRequestMessage saleTransactionRequest = new SaleTransactionRequestMessage - { - ProductId = model.ProductId, - OperatorId = model.OperatorId, - ApplicationVersion = model.ApplicationVersion, - DeviceIdentifier = model.DeviceIdentifier, - ContractId = model.ContractId, - TransactionDateTime = model.TransactionDateTime, - CustomerEmailAddress = model.CustomerEmailAddress, - TransactionNumber = model.TransactionNumber - }; - - // Add the additional request data - saleTransactionRequest.AdditionalRequestMetaData = new Dictionary { - {"Amount", model.VoucherAmount.ToString()}, - {"RecipientEmail", model.RecipientEmailAddress}, - {"RecipientMobile", model.RecipientMobileNumber} - }; - - return saleTransactionRequest; - } - - public static SaleTransactionRequestMessage ToSaleTransactionRequest(this PerformMobileTopupRequestModel model) - { - SaleTransactionRequestMessage saleTransactionRequest = new SaleTransactionRequestMessage - { - ProductId = model.ProductId, - OperatorId = model.OperatorId, - ApplicationVersion = model.ApplicationVersion, - DeviceIdentifier = model.DeviceIdentifier, - ContractId = model.ContractId, - TransactionDateTime = model.TransactionDateTime, - CustomerEmailAddress = model.CustomerEmailAddress, - TransactionNumber = model.TransactionNumber - }; - - // Add the additional request data - saleTransactionRequest.AdditionalRequestMetaData = new Dictionary { - {"Amount", model.TopupAmount.ToString()}, - {"CustomerAccountNumber", model.CustomerAccountNumber} - }; - - return saleTransactionRequest; - } - - public static SaleTransactionRequestMessage ToSaleTransactionRequest(this PerformBillPaymentGetAccountModel model) { - SaleTransactionRequestMessage saleTransactionRequest = new SaleTransactionRequestMessage - { - ProductId = model.ProductId, - OperatorId = model.OperatorId, - ApplicationVersion = model.ApplicationVersion, - DeviceIdentifier = model.DeviceIdentifier, - ContractId = model.ContractId, - TransactionDateTime = model.TransactionDateTime, - TransactionNumber = model.TransactionNumber - }; - // Add the additional request data - saleTransactionRequest.AdditionalRequestMetaData = new Dictionary { - {"CustomerAccountNumber", model.CustomerAccountNumber}, - {"PataPawaPostPaidMessageType", "VerifyAccount"} - }; - - return saleTransactionRequest; - } - - public static SaleTransactionRequestMessage ToSaleTransactionRequest(this PerformBillPaymentMakePaymentModel model) - { - SaleTransactionRequestMessage saleTransactionRequest = new SaleTransactionRequestMessage - { - ProductId = model.ProductId, - OperatorId = model.OperatorId, - ApplicationVersion = model.ApplicationVersion, - DeviceIdentifier = model.DeviceIdentifier, - ContractId = model.ContractId, - TransactionDateTime = model.TransactionDateTime, - TransactionNumber = model.TransactionNumber - }; - if (model.PostPayment){ - // Add the additional request data - saleTransactionRequest.AdditionalRequestMetaData = new Dictionary{ - { "CustomerAccountNumber", model.CustomerAccountNumber }, - { "CustomerName", model.CustomerAccountName }, - { "MobileNumber", model.CustomerMobileNumber }, - { "Amount", model.PaymentAmount.ToString() }, - { "PataPawaPostPaidMessageType", "ProcessBill" } - }; - } - else{ - saleTransactionRequest.AdditionalRequestMetaData = new Dictionary{ - { "MeterNumber", model.CustomerAccountNumber }, - { "CustomerName", model.CustomerAccountName }, - { "PataPawaPrePayMessageType", "vend" }, - { "Amount", model.PaymentAmount.ToString() }, - }; - } - - return saleTransactionRequest; - } - - public static SaleTransactionRequestMessage ToSaleTransactionRequest(this PerformBillPaymentGetMeterModel model) - { - SaleTransactionRequestMessage saleTransactionRequest = new SaleTransactionRequestMessage - { - ProductId = model.ProductId, - OperatorId = model.OperatorId, - ApplicationVersion = model.ApplicationVersion, - DeviceIdentifier = model.DeviceIdentifier, - ContractId = model.ContractId, - TransactionDateTime = model.TransactionDateTime, - TransactionNumber = model.TransactionNumber - }; - // Add the additional request data - saleTransactionRequest.AdditionalRequestMetaData = new Dictionary { - {"MeterNumber", model.MeterNumber.ToString()}, - {"PataPawaPrePayMessageType", "meter"} - }; - - return saleTransactionRequest; - } - - public static T ExtractFieldFromMetadata(this Dictionary additionalTransactionMetadata, - String fieldName) - { - // Create a case insensitive version of the dictionary - Dictionary caseInsensitiveDictionary = new Dictionary(StringComparer.InvariantCultureIgnoreCase); - foreach (KeyValuePair keyValuePair in additionalTransactionMetadata) - { - caseInsensitiveDictionary.Add(keyValuePair.Key, keyValuePair.Value); - } - - if (caseInsensitiveDictionary.ContainsKey(fieldName)) - { - String fieldData = caseInsensitiveDictionary[fieldName]; - Type t = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T); - Object safeValue = (fieldData == null) ? null : Convert.ChangeType(fieldData, t); - return (T)safeValue; - } - - return default(T); - } - - public static BillDetails ToBillDetails(this Dictionary additionalTransactionMetadata) - { - BillDetails billDetails = new BillDetails(); - - billDetails.AccountName = additionalTransactionMetadata.ExtractFieldFromMetadata("customerAccountName"); - billDetails.AccountNumber = additionalTransactionMetadata.ExtractFieldFromMetadata("customerAccountNumber"); - billDetails.Balance = additionalTransactionMetadata.ExtractFieldFromMetadata("customerBillBalance"); - billDetails.DueDate = additionalTransactionMetadata.ExtractFieldFromMetadata("customerBillDueDate"); - - return billDetails; - } - - public static MeterDetails ToMeterDetails(this Dictionary additionalTransactionMetadata, String meterNumber) - { - MeterDetails meterDetails = new MeterDetails(); - - meterDetails.MeterNumber = meterNumber; - meterDetails.CustomerName = additionalTransactionMetadata.ExtractFieldFromMetadata("pataPawaPrePaidCustomerName"); ; - - return meterDetails; - } - - public static Boolean IsSuccessfulTransaction(this SaleTransactionResponseMessage transactionResponse) { - return transactionResponse.ResponseCode == "0000"; - } - - public static Boolean IsSuccessfulReconciliation(this ReconciliationResponseMessage reconciliationResponse) { - return reconciliationResponse.ResponseCode == "0000"; - } -} - -public static class ResultExtensions -{ - public static Result FailureExtended(string message, Exception exception) - { - return Result.Failure(message, - new List{ - exception.Message - }); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Common/IdGenerationService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Common/IdGenerationService.cs deleted file mode 100644 index b62522421..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Common/IdGenerationService.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Common -{ - using System.Security.Cryptography; - using Newtonsoft.Json; - - /*public class IdGenerationService - { - internal delegate Guid GenerateUniqueIdFromObject(Object payload); - - internal delegate Guid GenerateUniqueIdFromString(String payload); - - - private static readonly JsonSerialiser JsonSerialiser = new(() => new JsonSerializerSettings - { - Formatting = Formatting.None - }); - - private static readonly GenerateUniqueIdFromObject GenerateUniqueId = - data => IdGenerationService.GenerateGuidFromString(IdGenerationService.JsonSerialiser.Serialise(data)); - - private static readonly GenerateUniqueIdFromString GenerateGuidFromString = uniqueKey => { - using SHA256 sha256Hash = SHA256.Create(); - //Generate hash from the key - Byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(uniqueKey)); - - Byte[] j = bytes.Skip(Math.Max(0, bytes.Count() - 16)).ToArray(); //Take last 16 - - //Create our Guid. - return new Guid(j); - }; - - public static Guid GenerateGuid(Object o) => IdGenerationService.GenerateUniqueId(o); - }*/ -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Common/ItemSelected.cs b/archive/TransactionMobile.Maui.BusinessLogic/Common/ItemSelected.cs deleted file mode 100644 index 7a996e141..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Common/ItemSelected.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Common; - -public class ItemSelected -{ - public T SelectedItem; - public Int32 SelectedItemIndex; -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Database/DatabaseContext.cs b/archive/TransactionMobile.Maui.BusinessLogic/Database/DatabaseContext.cs deleted file mode 100644 index 32d1b9c60..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Database/DatabaseContext.cs +++ /dev/null @@ -1,92 +0,0 @@ -namespace TransactionMobile.Maui.Database -{ - using SQLite; - using System.Diagnostics.CodeAnalysis; - - [ExcludeFromCodeCoverage] - public class DatabaseContext : IDatabaseContext - { - #region Fields - - private readonly SQLiteConnection Connection; - - private readonly Func LogLevelResolver; - - #endregion - - #region Constructors - - public DatabaseContext(String connectionString, - Func logLevelResolver) { - this.Connection = new SQLiteConnection(connectionString); - this.LogLevelResolver = logLevelResolver; - } - - #endregion - - #region Methods - - public async Task ClearStoredTransactions(List transactionRecords) { - foreach (var transactionRecord in transactionRecords) { - this.Connection.Delete(transactionRecord.TransactionNumber); - } - } - - public async Task CreateTransaction(TransactionRecord transactionRecord) { - this.Connection.Insert(transactionRecord); - - return SQLite3.LastInsertRowid(this.Connection.Handle); - } - - public async Task> GetLogMessages(Int32 batchSize, Boolean isTrainingMode) { - if (this.Connection == null) - return new List(); - - List messages = this.Connection.Table() - .Where(l => l.IsTrainingMode == isTrainingMode) - .OrderByDescending(l => l.EntryDateTime) - .Take(batchSize).ToList(); - - return messages; - } - - public async Task> GetTransactions(Boolean isTrainingMode) { - return this.Connection.Table().Where(t => t.IsTrainingMode == isTrainingMode).ToList(); - } - - public async Task InitialiseDatabase() { - this.Connection.CreateTable(); - this.Connection.CreateTable(); - } - - public async Task InsertLogMessage(LogMessage logMessage) { - if (this.Connection == null) - return; - - LogLevel messageLevel = (LogLevel)Enum.Parse(typeof(LogLevel), logMessage.LogLevel, true); - if (messageLevel <= this.LogLevelResolver()) { - this.Connection.Insert(logMessage); - } - } - - public async Task InsertLogMessages(List logMessages) { - foreach (LogMessage logMessage in logMessages) { - await this.InsertLogMessage(logMessage); - } - } - - public async Task RemoveUploadedMessages(List logMessagesToRemove) { - if (this.Connection == null) - return; - foreach (LogMessage logMessage in logMessagesToRemove) { - this.Connection.Delete(logMessage); - } - } - - public async Task UpdateTransaction(TransactionRecord transactionRecord) { - this.Connection.Update(transactionRecord); - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Database/IDatabaseContext.cs b/archive/TransactionMobile.Maui.BusinessLogic/Database/IDatabaseContext.cs deleted file mode 100644 index d05031873..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Database/IDatabaseContext.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.Database -{ - public interface IDatabaseContext - { - Task InitialiseDatabase(); - - Task CreateTransaction(TransactionRecord transactionRecord); - - Task UpdateTransaction(TransactionRecord transactionRecord); - - Task> GetTransactions(Boolean isTrainingMode); - Task ClearStoredTransactions(List transactionRecords); - - Task> GetLogMessages(Int32 batchSize, Boolean isTrainingMode); - - Task InsertLogMessage(LogMessage logMessage); - - Task InsertLogMessages(List logMessages); - - Task RemoveUploadedMessages(List logMessagesToRemove); - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Database/LogLevel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Database/LogLevel.cs deleted file mode 100644 index 099d6bef6..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Database/LogLevel.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace TransactionMobile.Maui.Database; - -public enum LogLevel -{ - /// - /// The fatal - /// - Fatal, - - /// - /// The error - /// - Error, - - /// - /// The warn - /// - Warn, - - /// - /// The information - /// - Info, - - /// - /// The debug - /// - Debug, - - /// - /// The trace - /// - Trace -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Database/LogMessage.cs b/archive/TransactionMobile.Maui.BusinessLogic/Database/LogMessage.cs deleted file mode 100644 index f1a24dadd..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Database/LogMessage.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace TransactionMobile.Maui.Database -{ - using SQLite; - using System.Diagnostics.CodeAnalysis; - - [ExcludeFromCodeCoverage] - public class LogMessage - { - #region Properties - - public DateTime EntryDateTime { get; set; } - - [PrimaryKey, AutoIncrement] - public Int32 Id { get; set; } - - public String LogLevel { get; set; } - - public String Message { get; set; } - - public Boolean IsTrainingMode { get; set; } - - #endregion - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Database/TransactionRecord.cs b/archive/TransactionMobile.Maui.BusinessLogic/Database/TransactionRecord.cs deleted file mode 100644 index 78a58f6d7..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Database/TransactionRecord.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace TransactionMobile.Maui.Database -{ - using SQLite; - using System.Diagnostics.CodeAnalysis; - - [ExcludeFromCodeCoverage] - public class TransactionRecord - { - public String ApplicationVersion { get; set; } - - public Guid ContractId { get; set; } - - public String CustomerAccountNumber { get; set; } - - public String CustomerEmailAddress { get; set; } - - public String DeviceIdentifier { get; set; } - - public Guid ProductId { get; set; } - - public Decimal Amount { get; set; } - - public DateTime TransactionDateTime { get; set; } - - [PrimaryKey, AutoIncrement] - public Int32 TransactionNumber { get; set; } - - public String RecipientMobileNumber { get; set; } - public String RecipientEmailAddress { get; set; } - - public Int32 TransactionType { get; set; } - - public Guid EstateId { get; set; } - public Guid MerchantId { get; set; } - public Boolean IsSuccessful { get; set; } - - public String ResponseMessage { get; set; } - - public Boolean IsTrainingMode { get; set; } - public Guid OperatorId { get; set; } - - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Logging/ConsoleLogger.cs b/archive/TransactionMobile.Maui.BusinessLogic/Logging/ConsoleLogger.cs deleted file mode 100644 index 9f80d6ada..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Logging/ConsoleLogger.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Logging; - -using System.Diagnostics.CodeAnalysis; -using Models; - -[ExcludeFromCodeCoverage] -public class ConsoleLogger : ILogger{ - #region Constructors - - public ConsoleLogger(){ - this.IsInitialised = true; - } - - #endregion - - #region Properties - - public Boolean IsInitialised{ get; set; } - - #endregion - - #region Methods - - internal void Log(LogMessage logMessageModel) - { - List logMessageModels = new List{ - logMessageModel - }; - Log(logMessageModels); - } - - internal void Log(List logMessageModels) - { - foreach (LogMessage item in logMessageModels) - { - Console.WriteLine($"AppLog|{item.EntryDateTime}|{item.LogLevel}|{item.Message}"); - } - } - - public void LogCritical(String message, Exception exception) => Log(LogMessage.CreateFatalLogMessages(message, exception)); - - public void LogDebug(String message) => Log(LogMessage.CreateDebugLogMessage(message)); - - public void LogError(String message, Exception exception) => Log(LogMessage.CreateErrorLogMessages(message, exception)); - - public void LogInformation(String message) => this.Log(LogMessage.CreateInformationLogMessage(message)); - - public void LogTrace(String message) => this.Log(LogMessage.CreateTraceLogMessage(message)); - - public void LogWarning(String message) => this.Log(LogMessage.CreateWarningLogMessage(message)); - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Logging/DatabaseLogger.cs b/archive/TransactionMobile.Maui.BusinessLogic/Logging/DatabaseLogger.cs deleted file mode 100644 index 909d4935f..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Logging/DatabaseLogger.cs +++ /dev/null @@ -1,72 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Logging; - -using System.Diagnostics.CodeAnalysis; -using Database; -using Services; -using LogMessage = Models.LogMessage; - -[ExcludeFromCodeCoverage] -public class DatabaseLogger : ILogger{ - #region Fields - - private readonly IApplicationCache ApplicationCache; - - private readonly IDatabaseContext DatabaseContext; - - #endregion - - #region Constructors - - public DatabaseLogger(IDatabaseContext databaseContext, IApplicationCache applicationCache){ - this.DatabaseContext = databaseContext; - this.ApplicationCache = applicationCache; - this.IsInitialised = true; - } - - #endregion - - #region Properties - - public Boolean IsInitialised{ get; set; } - - #endregion - - #region Methods - - internal void Log(LogMessage logMessageModel) - { - List logMessageModels = new List{ - logMessageModel - }; - Log(logMessageModels); - } - - internal void Log(List logMessageModels) - { - List logMessages = new List(); - foreach (LogMessage item in logMessageModels) - { - logMessages.Add(new Database.LogMessage - { - EntryDateTime = item.EntryDateTime, - LogLevel = item.LogLevel.ToString(), - Message = item.Message - }); - } - - this.DatabaseContext.InsertLogMessages(logMessages); - } - - public void LogCritical(String message, Exception exception) => this.Log(LogMessage.CreateFatalLogMessages(message, exception)); - - public void LogDebug(String message) => this.Log(LogMessage.CreateDebugLogMessage(message)); - - public void LogError(String message, Exception exception) => this.Log(LogMessage.CreateErrorLogMessages(message, exception)); - public void LogInformation(String message) => this.Log(LogMessage.CreateInformationLogMessage(message)); - - public void LogTrace(String message) => this.Log(LogMessage.CreateTraceLogMessage(message)); - - public void LogWarning(String message) => this.Log(LogMessage.CreateWarningLogMessage(message)); - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Logging/ILogger.cs b/archive/TransactionMobile.Maui.BusinessLogic/Logging/ILogger.cs deleted file mode 100644 index da4184a41..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Logging/ILogger.cs +++ /dev/null @@ -1,57 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Logging -{ - public interface ILogger - { - #region Properties - - /// - /// Gets or sets a value indicating whether this instance is initialised. - /// - /// - /// true if this instance is initialised; otherwise, false. - /// - Boolean IsInitialised { get; set; } - - #endregion - - #region Methods - - /// - /// Logs the critical. - /// - /// The exception. - void LogCritical(String message, Exception exception); - - /// - /// Logs the debug. - /// - /// The message. - void LogDebug(String message); - - /// - /// Logs the error. - /// - /// The exception. - void LogError(String message, Exception exception); - - /// - /// Logs the information. - /// - /// The message. - void LogInformation(String message); - - /// - /// Logs the trace. - /// - /// The message. - void LogTrace(String message); - - /// - /// Logs the warning. - /// - /// The message. - void LogWarning(String message); - - #endregion - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Logging/Logger.cs b/archive/TransactionMobile.Maui.BusinessLogic/Logging/Logger.cs deleted file mode 100644 index 438bc3744..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Logging/Logger.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Logging; - -[ExcludeFromCodeCoverage] -public static class Logger -{ - #region Fields - - /// - /// The logger object - /// - private static List LoggerObjects; - - #endregion - - #region Properties - - /// - /// Gets or sets a value indicating whether this instance is initialised. - /// - /// - /// true if this instance is initialised; otherwise, false. - /// - public static Boolean IsInitialised { get; set; } - - #endregion - - #region Methods - - /// - /// Initialises the specified logger object. - /// - /// The logger object. - /// loggerObject - public static void Initialise(ILogger loggerObject) - { - if (loggerObject == null) { - throw new ArgumentNullException(nameof(loggerObject)); - } - - if (Logger.LoggerObjects == null) { - Logger.LoggerObjects = new List(); - } - - if (Logger.LoggerObjects.Any(l => l.GetType() == loggerObject.GetType())) { - // Already initialised - return; - } - Logger.LoggerObjects.Add(loggerObject); - - Logger.IsInitialised = true; - } - - /// - /// Logs the critical. - /// - /// The exception. - public static void LogCritical(String message, Exception exception) - { - foreach (ILogger loggerObject in Logger.LoggerObjects) { - loggerObject.LogCritical(message, exception); - } - - } - - /// - /// Logs the debug. - /// - /// The message. - public static void LogDebug(String message) - { - foreach (ILogger loggerObject in Logger.LoggerObjects) - { - loggerObject.LogDebug(message); - } - } - - /// - /// Logs the error. - /// - /// The exception. - public static void LogError(String message, Exception exception) - { - foreach (ILogger loggerObject in Logger.LoggerObjects) { - loggerObject.LogError(message, exception); - } - } - - /// - /// Logs the information. - /// - /// The message. - public static void LogInformation(String message) - { - if (Logger.LoggerObjects == null || Logger.LoggerObjects.Any() == false){ - Console.WriteLine(message); - return; - } - foreach (ILogger loggerObject in Logger.LoggerObjects) - { - loggerObject.LogInformation(message); - } - } - - /// - /// Logs the trace. - /// - /// The message. - public static void LogTrace(String message) - { - foreach (ILogger loggerObject in Logger.LoggerObjects) { - loggerObject.LogTrace(message); - } - } - - /// - /// Logs the warning. - /// - /// The message. - public static void LogWarning(String message) - { - foreach (ILogger loggerObject in Logger.LoggerObjects) - { - loggerObject.LogWarning(message); - } - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Logging/NullLogger.cs b/archive/TransactionMobile.Maui.BusinessLogic/Logging/NullLogger.cs deleted file mode 100644 index 11b4b2495..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Logging/NullLogger.cs +++ /dev/null @@ -1,81 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Logging; - -using System.Diagnostics.CodeAnalysis; - -[ExcludeFromCodeCoverage] -public class NullLogger : ILogger{ - #region Properties - - /// - /// Instances this instance. - /// - /// - public static NullLogger Instance{ - get{ - return new NullLogger(); - } - } - - /// - /// Gets or sets a value indicating whether this instance is initialised. - /// - /// - /// true if this instance is initialised; otherwise, false. - /// - public Boolean IsInitialised{ get; set; } - - #endregion - - #region Methods - - /// - /// Initialises this instance. - /// - public void Initialise(){ - this.IsInitialised = true; - } - - /// - /// Logs the critical. - /// - /// The exception. - public void LogCritical(String message, Exception exception){ - } - - /// - /// Logs the debug. - /// - /// The message. - public void LogDebug(String message){ - } - - /// - /// Logs the error. - /// - /// The exception. - public void LogError(String message, Exception exception){ - } - - /// - /// Logs the information. - /// - /// The message. - public void LogInformation(String message){ - } - - /// - /// Logs the trace. - /// - /// The message. - public void LogTrace(String message){ - } - - /// - /// Logs the warning. - /// - /// The message. - public void LogWarning(String message){ - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/AddressModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/AddressModel.cs deleted file mode 100644 index c0c6282f1..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/AddressModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class AddressModel -{ - public String AddressLine1 { get; set; } - public String AddressLine2 { get; set; } - public String AddressLine3 { get; set; } - public String AddressLine4 { get; set; } - public String PostalCode { get; set; } - public String Region { get; set; } - public String Town { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/AppCenterConfiguration.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/AppCenterConfiguration.cs deleted file mode 100644 index 99a4ec766..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/AppCenterConfiguration.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class AppCenterConfiguration -{ - public String AndroidKey { get; set; } - public String iOSKey { get; set; } - public String MacOSKey { get; set; } - public String WindowsKey { get; set; } - - public String GetAppCenterKey() { - List apiKeys = new List(); - if (String.IsNullOrEmpty(AndroidKey) == false) { - apiKeys.Add($"android={this.AndroidKey};"); - } - if (String.IsNullOrEmpty(iOSKey) == false) - { - apiKeys.Add($"ios={this.iOSKey};"); - } - if (String.IsNullOrEmpty(WindowsKey) == false) - { - apiKeys.Add($"uwp={this.WindowsKey};"); - } - if (String.IsNullOrEmpty(MacOSKey) == false) - { - apiKeys.Add($"macos={this.MacOSKey};"); - } - - return String.Join("+", apiKeys); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/Configuration.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/Configuration.cs deleted file mode 100644 index e4063e4d1..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/Configuration.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class Configuration -{ - public String ClientId { get; set; } - - public String ClientSecret { get; set; } - - public String SecurityServiceUri { get; set; } - - public String TransactionProcessorAclUri { get; set; } - - public String TransactionProcessorUri { get; set; } - - public String EstateReportingUri { get; set; } - - public LogLevel LogLevel { get; set; } - - public Boolean EnableAutoUpdates { get; set; } - - public Boolean ShowDebugMessages { get; set; } - - public AppCenterConfiguration AppCenterConfig { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/ContactModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/ContactModel.cs deleted file mode 100644 index 980e9d31d..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/ContactModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class ContactModel -{ - public String EmailAddress { get; set; } - public String Name { get; set; } - public String MobileNumber { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/ContractOperatorModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/ContractOperatorModel.cs deleted file mode 100644 index c36793e04..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/ContractOperatorModel.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class ContractOperatorModel -{ - #region Properties - - /// - /// Gets or sets the operator identifier. - /// - /// - /// The operator identifier. - /// - public Guid OperatorId { get; set; } - - /// - /// Gets or sets the operator identfier. - /// - /// - /// The operator identfier. - /// - public String OperatorIdentfier { get; set; } - - /// - /// Gets or sets the name of the operator. - /// - /// - /// The name of the operator. - /// - public String OperatorName { get; set; } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/ContractProductModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/ContractProductModel.cs deleted file mode 100644 index 583ff765c..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/ContractProductModel.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models -{ - [ExcludeFromCodeCoverage] - public class ContractProductModel - { - #region Properties - - public Guid ContractId { get; set; } - - public Boolean IsFixedValue { get; set; } - - public Guid OperatorId { get; set; } - - public String OperatorIdentfier { get; set; } - - public String OperatorName { get; set; } - - public String ProductDisplayText { get; set; } - public Guid ProductId { get; set; } - - public ProductType ProductType { get; set; } - public ProductSubType ProductSubType { get; set; } - public Decimal Value { get; set; } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/ListViewItem.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/ListViewItem.cs deleted file mode 100644 index 36b0f3063..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/ListViewItem.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class ListViewItem -{ - public String Title { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/LogLevel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/LogLevel.cs deleted file mode 100644 index d7711c0ea..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/LogLevel.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Models; - -public enum LogLevel -{ - Fatal, - - Error, - - Warn, - - Info, - - Debug, - - Trace -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/LogMessage.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/LogMessage.cs deleted file mode 100644 index 623609c3f..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/LogMessage.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Models -{ - [ExcludeFromCodeCoverage] - public class LogMessage - { - #region Properties - - public DateTime EntryDateTime { get; set; } - public Int32 Id { get; set; } - public LogLevel LogLevel { get; set; } - public String LogLevelString { get; set; } - public String Message { get; set; } - - #endregion - - private static LogMessage CreateLogMessage(String message, - LogLevel logLevel) - { - return new LogMessage - { - EntryDateTime = DateTime.UtcNow, - Message = message, - LogLevel = logLevel, - LogLevelString = logLevel.ToString() - }; - } - - /// - /// Creates the debug log message. - /// - /// The message. - /// - public static LogMessage CreateDebugLogMessage(String message) - { - return LogMessage.CreateLogMessage(message, Models.LogLevel.Debug); - } - - /// - /// Creates the error log message. - /// - /// The message. - /// - public static LogMessage CreateErrorLogMessage(String message) - { - return LogMessage.CreateLogMessage(message, Models.LogLevel.Error); - } - - /// - /// Creates the error log messages. - /// - /// The exception. - /// - public static List CreateErrorLogMessages(String message, Exception exception) - { - List logMessages = new List(); - logMessages.Add(LogMessage.CreateLogMessage(message, Models.LogLevel.Error)); - Exception e = exception; - while (e != null) - { - logMessages.Add(LogMessage.CreateLogMessage(e.Message, Models.LogLevel.Error)); - e = e.InnerException; - } - - return logMessages; - } - - /// - /// Creates the fatal log message. - /// - /// The message. - /// - public static LogMessage CreateFatalLogMessage(String message) - { - return LogMessage.CreateLogMessage(message, Models.LogLevel.Fatal); - } - - /// - /// Creates the fatal log messages. - /// - /// The exception. - /// - public static List CreateFatalLogMessages(String message,Exception exception) - { - List logMessages = new List(); - logMessages.Add(LogMessage.CreateLogMessage(message, Models.LogLevel.Fatal)); - Exception e = exception; - while (e != null) - { - logMessages.Add(LogMessage.CreateLogMessage(e.Message, Models.LogLevel.Fatal)); - e = e.InnerException; - } - - return logMessages; - } - - /// - /// Creates the information log message. - /// - /// The message. - /// - public static LogMessage CreateInformationLogMessage(String message) - { - return LogMessage.CreateLogMessage(message, Models.LogLevel.Info); - } - - /// - /// Creates the trace log message. - /// - /// The message. - /// - public static LogMessage CreateTraceLogMessage(String message) - { - return LogMessage.CreateLogMessage(message, Models.LogLevel.Trace); - } - - /// - /// Creates the warning log message. - /// - /// The message. - /// - public static LogMessage CreateWarningLogMessage(String message) - { - return LogMessage.CreateLogMessage(message, Models.LogLevel.Warn); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/LogMessageModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/LogMessageModel.cs deleted file mode 100644 index f55424f7c..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/LogMessageModel.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Models; - -using System.Diagnostics.CodeAnalysis; -using Microsoft.Maui.Graphics; - -[ExcludeFromCodeCoverage] -public class LogMessageModel -{ - #region Properties - - public DateTime EntryDateTime { get; set; } - - public Int32 Id { get; set; } - - public LogLevel LogLevel { get; set; } - - public String LogLevelString { get; set; } - - public String Message { get; set; } - - public Color TextColor { - get { - return this.LogLevel switch { - LogLevel.Debug => Colors.Gray, - LogLevel.Trace => Colors.Gray, - LogLevel.Info => Colors.Blue, - LogLevel.Warn => Colors.Orange, - LogLevel.Error => Colors.Red, - LogLevel.Fatal => Colors.Red, - _ => Colors.Gray - }; - } - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/MerchantDetailsModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/MerchantDetailsModel.cs deleted file mode 100644 index 83f5f3c13..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/MerchantDetailsModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class MerchantDetailsModel -{ - public Decimal Balance { get; set; } - public Decimal AvailableBalance { get; set; } - public String MerchantName { get; set; } - public DateTime NextStatementDate { get; set; } - public DateTime LastStatementDate { get; set; } - public String SettlementSchedule { get; set; } - public AddressModel Address { get; set; } - public ContactModel Contact { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/OperatorTotalModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/OperatorTotalModel.cs deleted file mode 100644 index a22eb202c..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/OperatorTotalModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class OperatorTotalModel -{ - public Guid ContractId { get; set; } - public Guid OperatorId { get; set; } - public Decimal TransactionValue { get; set; } - public Int32 TransactionCount { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetAccountModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetAccountModel.cs deleted file mode 100644 index 98b76a403..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetAccountModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class PerformBillPaymentGetAccountModel -{ - #region Properties - - public String ApplicationVersion { get; set; } - - public Guid ContractId { get; set; } - - public String CustomerAccountNumber { get; set; } - - public String DeviceIdentifier { get; set; } - - public Guid OperatorId { get; set; } - - public Guid ProductId { get; set; } - - public DateTime TransactionDateTime { get; set; } - - public String TransactionNumber { get; set; } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetAccountResponseModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetAccountResponseModel.cs deleted file mode 100644 index 0f752d448..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetAccountResponseModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Models; - -using System.Diagnostics.CodeAnalysis; -using ViewModels.Transactions; - -[ExcludeFromCodeCoverage] -public class PerformBillPaymentGetAccountResponseModel -{ - public Boolean IsSuccessful => this.BillDetails != null; - - public BillDetails BillDetails{ get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetMeterModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetMeterModel.cs deleted file mode 100644 index cd6e51bbe..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetMeterModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class PerformBillPaymentGetMeterModel -{ - #region Properties - - public String ApplicationVersion { get; set; } - - public Guid ContractId { get; set; } - - public String MeterNumber { get; set; } - - public String DeviceIdentifier { get; set; } - - public Guid OperatorId { get; set; } - - public Guid ProductId { get; set; } - - public DateTime TransactionDateTime { get; set; } - - public String TransactionNumber { get; set; } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetMeterResponseModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetMeterResponseModel.cs deleted file mode 100644 index 2f1544f76..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentGetMeterResponseModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Models; - -using System.Diagnostics.CodeAnalysis; -using ViewModels.Transactions; - -[ExcludeFromCodeCoverage] -public class PerformBillPaymentGetMeterResponseModel -{ - public Boolean IsSuccessful => this.MeterDetails != null; - - public MeterDetails MeterDetails { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentMakePaymentModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentMakePaymentModel.cs deleted file mode 100644 index 4fdf7c11c..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentMakePaymentModel.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class PerformBillPaymentMakePaymentModel -{ - #region Properties - - public String ApplicationVersion { get; set; } - - public Guid ContractId { get; set; } - - public String CustomerAccountNumber { get; set; } - - public String CustomerMobileNumber { get; set; } - - public String CustomerAccountName { get; set; } - - public Decimal PaymentAmount { get; set; } - - public String DeviceIdentifier { get; set; } - - public Guid OperatorId { get; set; } - - public Guid ProductId { get; set; } - - public DateTime TransactionDateTime { get; set; } - - public String TransactionNumber { get; set; } - - public Boolean PostPayment{ get; set; } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentMakePaymentResponseModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentMakePaymentResponseModel.cs deleted file mode 100644 index 5806d31ab..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformBillPaymentMakePaymentResponseModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class PerformBillPaymentMakePaymentResponseModel -{ - public string ResponseCode { get; set; } - - public string ResponseMessage { get; set; } - - public Guid EstateId { get; set; } - - public Guid MerchantId { get; set; } - public Boolean IsSuccessful => this.ResponseCode == "0000"; -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformLogonRequestModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformLogonRequestModel.cs deleted file mode 100644 index 9892aa6df..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformLogonRequestModel.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class PerformLogonRequestModel -{ - #region Properties - - public String ApplicationVersion { get; set; } - - public String DeviceIdentifier { get; set; } - - public DateTime TransactionDateTime { get; set; } - - public String TransactionNumber { get; set; } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformLogonResponseModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformLogonResponseModel.cs deleted file mode 100644 index 9e56f6ac8..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformLogonResponseModel.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class PerformLogonResponseModel -{ - #region Properties - public String ResponseCode { get; set; } - public String ResponseMessage { get; set; } - - public Guid EstateId { get; set; } - - public Guid MerchantId { get; set; } - - public Boolean IsSuccessful => ResponseCode == "0000"; - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformMobileTopupRequestModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformMobileTopupRequestModel.cs deleted file mode 100644 index 525324f19..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformMobileTopupRequestModel.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models -{ - [ExcludeFromCodeCoverage] - public class PerformMobileTopupRequestModel - { - // TODO: should we have a base transaction request model ? - - #region Properties - - public String ApplicationVersion { get; set; } - - public Guid ContractId { get; set; } - - public String CustomerAccountNumber { get; set; } - - public String CustomerEmailAddress { get; set; } - - public String DeviceIdentifier { get; set; } - - public Guid OperatorId { get; set; } - - public Guid ProductId { get; set; } - - public Decimal TopupAmount { get; set; } - - public DateTime TransactionDateTime { get; set; } - - public String TransactionNumber { get; set; } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformMobileTopupResponseModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformMobileTopupResponseModel.cs deleted file mode 100644 index 1688b488b..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformMobileTopupResponseModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class PerformMobileTopupResponseModel -{ - public string ResponseCode { get; set; } - - public string ResponseMessage { get; set; } - - public Guid EstateId { get; set; } - - public Guid MerchantId { get; set; } - - public Boolean IsSuccessful => this.ResponseCode == "0000"; -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformReconciliationResponseModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformReconciliationResponseModel.cs deleted file mode 100644 index 85196294a..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformReconciliationResponseModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models -{ - [ExcludeFromCodeCoverage] - public class PerformReconciliationResponseModel - { - public string ResponseCode { get; set; } - - public string ResponseMessage { get; set; } - - public Guid EstateId { get; set; } - - public Guid MerchantId { get; set; } - public Boolean IsSuccessful => this.ResponseCode == "0000"; - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformVoucherIssueRequestModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformVoucherIssueRequestModel.cs deleted file mode 100644 index 0c66aa6d9..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformVoucherIssueRequestModel.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class PerformVoucherIssueRequestModel -{ - // TODO: should we have a base transaction request model ? - - #region Properties - - public String ApplicationVersion { get; set; } - - public Guid ContractId { get; set; } - - public String RecipientMobileNumber { get; set; } - public String RecipientEmailAddress { get; set; } - - public String CustomerEmailAddress { get; set; } - - public String DeviceIdentifier { get; set; } - - public Guid OperatorId { get; set; } - - public Guid ProductId { get; set; } - - public Decimal VoucherAmount { get; set; } - - public DateTime TransactionDateTime { get; set; } - - public String TransactionNumber { get; set; } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformVoucherIssueResponseModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformVoucherIssueResponseModel.cs deleted file mode 100644 index 04bdf1bd2..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/PerformVoucherIssueResponseModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class PerformVoucherIssueResponseModel -{ - public string ResponseCode { get; set; } - - public string ResponseMessage { get; set; } - - public Guid EstateId { get; set; } - - public Guid MerchantId { get; set; } - - public Boolean IsSuccessful => this.ResponseCode == "0000"; -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/ProductType.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/ProductType.cs deleted file mode 100644 index 5c61144f5..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/ProductType.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Models; - -public enum ProductType -{ - NotSet = 0, - MobileTopup, - MobileWallet, - BillPayment, - Voucher -} - -public enum ProductSubType -{ - NotSet = 0, - MobileTopup, - MobileWallet, - BillPaymentPostPay, - BillPaymentPrePay, - Voucher -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/ReconciliationRequestModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/ReconciliationRequestModel.cs deleted file mode 100644 index 4933531bc..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/ReconciliationRequestModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class PerformReconciliationRequestModel -{ - public List OperatorTotals { get; set; } - public Decimal TransactionValue { get; set; } - public Int32 TransactionCount { get; set; } - public String DeviceIdentifier { get; set; } - public DateTime TransactionDateTime { get; set; } - public String ApplicationVersion { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Models/TokenResponseModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Models/TokenResponseModel.cs deleted file mode 100644 index e5dde6402..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Models/TokenResponseModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Models; - -[ExcludeFromCodeCoverage] -public class TokenResponseModel -{ - public String AccessToken { get; set; } - public String RefreshToken { get; set; } - public Int64 ExpiryInMinutes { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Platforms/Android/PlatformClass1.cs b/archive/TransactionMobile.Maui.BusinessLogic/Platforms/Android/PlatformClass1.cs deleted file mode 100644 index afbc0a31e..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Platforms/Android/PlatformClass1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic2 -{ - // All the code in this file is only included on Android. - public class PlatformClass1 - { - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Platforms/MacCatalyst/PlatformClass1.cs b/archive/TransactionMobile.Maui.BusinessLogic/Platforms/MacCatalyst/PlatformClass1.cs deleted file mode 100644 index 02a39a043..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Platforms/MacCatalyst/PlatformClass1.cs +++ /dev/null @@ -1,7 +0,0 @@ -//namespace TransactionMobile.Maui.BusinessLogic2 -//{ -// // All the code in this file is only included on Mac Catalyst. -// public class PlatformClass1 -// { -// } -//} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Platforms/Windows/PlatformClass1.cs b/archive/TransactionMobile.Maui.BusinessLogic/Platforms/Windows/PlatformClass1.cs deleted file mode 100644 index 1bbe4199c..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Platforms/Windows/PlatformClass1.cs +++ /dev/null @@ -1,7 +0,0 @@ -//namespace TransactionMobile.Maui.BusinessLogic2 -//{ -// // All the code in this file is only included on Windows. -// public class PlatformClass1 -// { -// } -//} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Platforms/iOS/PlatformClass1.cs b/archive/TransactionMobile.Maui.BusinessLogic/Platforms/iOS/PlatformClass1.cs deleted file mode 100644 index 64b528992..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Platforms/iOS/PlatformClass1.cs +++ /dev/null @@ -1,7 +0,0 @@ -//namespace TransactionMobile.Maui.BusinessLogic2 -//{ -// // All the code in this file is only included on iOS. -// public class PlatformClass1 -// { -// } -//} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/LoginRequestHandler.cs b/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/LoginRequestHandler.cs deleted file mode 100644 index 24a7b0acc..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/LoginRequestHandler.cs +++ /dev/null @@ -1,69 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.RequestHandlers -{ - using Common; - using MediatR; - using Models; - using Requests; - using Services; - using SimpleResults; - - public class LoginRequestHandler : IRequestHandler>, - IRequestHandler>, - IRequestHandler> - { - private readonly Func ConfigurationServiceResolver; - private readonly IApplicationCache ApplicationCache; - public Func AuthenticationServiceResolver { get; } - - #region Constructors - public LoginRequestHandler(Func authenticationServiceResolver, - Func configurationServiceResolver, - IApplicationCache applicationCache) - { - this.ConfigurationServiceResolver = configurationServiceResolver; - this.AuthenticationServiceResolver = authenticationServiceResolver; - this.ApplicationCache = applicationCache; - } - - #endregion - - - #region Methods - - public async Task> Handle(LoginRequest request, - CancellationToken cancellationToken) { - - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - - IAuthenticationService authenticationService = this.AuthenticationServiceResolver(useTrainingMode); - - Result tokenResult = await authenticationService.GetToken(request.UserName, request.Password, cancellationToken); - - return tokenResult; - } - - public async Task> Handle(GetConfigurationRequest request, - CancellationToken cancellationToken) { - - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - - IConfigurationService configurationService = this.ConfigurationServiceResolver(useTrainingMode); - - return await configurationService.GetConfiguration(request.DeviceIdentifier, cancellationToken); - } - - #endregion - - public async Task> Handle(RefreshTokenRequest request, - CancellationToken cancellationToken) - { - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - - IAuthenticationService authenticationService = this.AuthenticationServiceResolver(useTrainingMode); - - Result tokenResult = await authenticationService.RefreshAccessToken(request.RefreshToken, cancellationToken); - - return tokenResult; - } - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs b/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs deleted file mode 100644 index eab590dac..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs +++ /dev/null @@ -1,78 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.RequestHandlers; - -using Common; -using MediatR; -using Models; -using Requests; -using Services; -using SimpleResults; - -public class MerchantRequestHandler : IRequestHandler>>, - IRequestHandler>, - IRequestHandler> -{ - #region Fields - - private readonly IApplicationCache ApplicationCache; - - private readonly Func MerchantServiceResolver; - - #endregion - - #region Constructors - - public MerchantRequestHandler(Func merchantServiceResolver, - IApplicationCache applicationCache) { - this.MerchantServiceResolver = merchantServiceResolver; - this.ApplicationCache = applicationCache; - } - - #endregion - - #region Methods - - public async Task>> Handle(GetContractProductsRequest request, - CancellationToken cancellationToken) { - List products = this.ApplicationCache.GetContractProducts(); - - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - IMerchantService merchantService = this.MerchantServiceResolver(useTrainingMode); - - if (products == null || products.Any() == false) { - Result> getProductsResult = await merchantService.GetContractProducts(cancellationToken); - if (getProductsResult.IsSuccess) { - products = getProductsResult.Data; - } - else { - return getProductsResult; - } - } - - if (request.ProductType.HasValue) { - products = products.Where(p => p.ProductType == request.ProductType).ToList(); - } - - return Result.Success(products); - } - - public async Task> Handle(GetMerchantBalanceRequest request, - CancellationToken cancellationToken) { - - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - IMerchantService merchantService = this.MerchantServiceResolver(useTrainingMode); - - return await merchantService.GetMerchantBalance(cancellationToken); - } - - public async Task> Handle(GetMerchantDetailsRequest request, - CancellationToken cancellationToken) { - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - IMerchantService merchantService = this.MerchantServiceResolver(useTrainingMode); - - Result merchantDetails = await merchantService.GetMerchantDetails(cancellationToken); - - return merchantDetails; - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/SupportRequestHandler.cs b/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/SupportRequestHandler.cs deleted file mode 100644 index 07089ad95..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/SupportRequestHandler.cs +++ /dev/null @@ -1,83 +0,0 @@ -using MediatR; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using TransactionMobile.Maui.BusinessLogic.Requests; -using TransactionMobile.Maui.BusinessLogic.Services; -using TransactionMobile.Maui.Database; - -namespace TransactionMobile.Maui.BusinessLogic.RequestHandlers -{ - public class SupportRequestHandler : IRequestHandler, - IRequestHandler> - { - private readonly Func ConfigurationServiceResolver; - private readonly IDatabaseContext DatabaseContext; - - private readonly IApplicationCache ApplicationCache; - - public SupportRequestHandler(Func configurationServiceResolver, - IDatabaseContext databaseContext, - IApplicationCache applicationCache) - { - this.ConfigurationServiceResolver = configurationServiceResolver; - this.DatabaseContext = databaseContext; - this.ApplicationCache = applicationCache; - } - - public async Task Handle(UploadLogsRequest request, CancellationToken cancellationToken) - { - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - - while (true) - { - List logEntries = await this.DatabaseContext.GetLogMessages(10, useTrainingMode); // TODO: Configurable batch size - - if (logEntries.Any() == false) - { - break; - } - - List logMessageModels = new List(); - - logEntries.ForEach(l => logMessageModels.Add(new Models.LogMessage - { - LogLevel = Enum.Parse(l.LogLevel), - LogLevelString = l.LogLevel, - Message = l.Message, - EntryDateTime = l.EntryDateTime, - Id = l.Id - })); - - IConfigurationService configurationService = this.ConfigurationServiceResolver(useTrainingMode); - await configurationService.PostDiagnosticLogs(request.DeviceIdentifier, logMessageModels, CancellationToken.None); - - // Clear the logs that have been uploaded - await this.DatabaseContext.RemoveUploadedMessages(logEntries); - } - - return true; - } - - public async Task> Handle(ViewLogsRequest request, - CancellationToken cancellationToken) { - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - - List logEntries = await this.DatabaseContext.GetLogMessages(50, useTrainingMode); // TODO: Configurable batch size - - List logMessageModels = new List(); - - logEntries.ForEach(l => logMessageModels.Add(new Models.LogMessage { - LogLevel = Enum.Parse(l.LogLevel), - LogLevelString = l.LogLevel, - Message = l.Message, - EntryDateTime = l.EntryDateTime, - Id = l.Id - })); - - return logMessageModels.OrderByDescending(l => l.EntryDateTime).ToList(); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs b/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs deleted file mode 100644 index 77ef3a3ec..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs +++ /dev/null @@ -1,352 +0,0 @@ -using Newtonsoft.Json; - -namespace TransactionMobile.Maui.BusinessLogic.RequestHandlers; - -using Database; -using MediatR; -using Models; -using Requests; -using Services; -using Common; -using SimpleResults; -using UIServices; - -public class TransactionRequestHandler : IRequestHandler>, - IRequestHandler>, - IRequestHandler>, - IRequestHandler>, - IRequestHandler>, - IRequestHandler>, - IRequestHandler>, - IRequestHandler> -{ - #region Fields - - private readonly IDatabaseContext DatabaseContext; - - private readonly IApplicationCache ApplicationCache; - - private readonly IApplicationInfoService ApplicationInfoService; - - private readonly IDeviceService DeviceService; - - private readonly Func TransactionServiceResolver; - - #endregion - - #region Constructors - - public TransactionRequestHandler(Func transactionServiceResolver, - IDatabaseContext databaseContext, - IApplicationCache applicationCache, - IApplicationInfoService applicationInfoService, - IDeviceService deviceService) { - this.TransactionServiceResolver = transactionServiceResolver; - this.DatabaseContext = databaseContext; - this.ApplicationCache = applicationCache; - this.ApplicationInfoService = applicationInfoService; - this.DeviceService = deviceService; - } - - #endregion - - #region Methods - - public async Task> Handle(PerformMobileTopupRequest request, - CancellationToken cancellationToken){ - - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - - (Int64 transactionNumber, TransactionRecord transactionRecord) transaction = await this.CreateTransactionRecord(request.ToTransactionRecord(useTrainingMode)); - - ITransactionService transactionService = this.TransactionServiceResolver(useTrainingMode); - - PerformMobileTopupRequestModel model = new(){ - ContractId = request.ContractId, - CustomerAccountNumber = request.CustomerAccountNumber, - CustomerEmailAddress = request.CustomerEmailAddress, - OperatorId = request.OperatorId, - ProductId = request.ProductId, - TopupAmount = request.TopupAmount, - TransactionDateTime = request.TransactionDateTime, - TransactionNumber = transaction.transactionNumber.ToString(), - DeviceIdentifier = this.DeviceService.GetIdentifier(), - ApplicationVersion = this.ApplicationInfoService.VersionString - }; - - Result result = await transactionService.PerformMobileTopup(model, cancellationToken); - - await this.UpdateTransactionRecord(transaction.transactionRecord.UpdateFrom(result)); - - if (result.IsSuccess && result.Data.IsSuccessful == false) - { - return Result.Failure("Logon transaction not successful"); - } - - return Result.Success(result.Data); - - - } - - private async Task<(Int64 transactionNumber, TransactionRecord transactionRecord)> CreateTransactionRecord(TransactionRecord transactionRecord) { - - transactionRecord.ApplicationVersion = this.ApplicationInfoService.VersionString; - transactionRecord.DeviceIdentifier = this.DeviceService.GetIdentifier(); - Int64 transactionNumber = await this.DatabaseContext.CreateTransaction(transactionRecord); - - return (transactionNumber, transactionRecord); - } - - private async Task UpdateTransactionRecord(TransactionRecord transactionRecord) { - await this.DatabaseContext.UpdateTransaction(transactionRecord); - } - - public async Task> Handle(LogonTransactionRequest request, - CancellationToken cancellationToken) - { - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - (Int64 transactionNumber, TransactionRecord transactionRecord) transaction = await this.CreateTransactionRecord(request.ToTransactionRecord(useTrainingMode)); - - ITransactionService transactionService = this.TransactionServiceResolver(useTrainingMode); - - PerformLogonRequestModel model = new PerformLogonRequestModel - { - TransactionDateTime = request.TransactionDateTime, - TransactionNumber = transaction.transactionNumber.ToString(), - DeviceIdentifier = this.DeviceService.GetIdentifier(), - ApplicationVersion = this.ApplicationInfoService.VersionString - }; - - Result result = await transactionService.PerformLogon(model, cancellationToken); - - await this.UpdateTransactionRecord(transaction.transactionRecord.UpdateFrom(result)); - if (result.IsSuccess && result.Data.IsSuccessful == false) - { - return Result.Failure($"Logon transaction not successful {JsonConvert.SerializeObject(result.Data)}"); - } - - return Result.Success(result.Data); - } - - public async Task> Handle(PerformVoucherIssueRequest request, - CancellationToken cancellationToken) - { - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - (Int64 transactionNumber, TransactionRecord transactionRecord) transaction = await this.CreateTransactionRecord(request.ToTransactionRecord(useTrainingMode)); - - ITransactionService transactionService = this.TransactionServiceResolver(useTrainingMode); - - PerformVoucherIssueRequestModel model = new PerformVoucherIssueRequestModel - { - ContractId = request.ContractId, - RecipientEmailAddress = request.RecipientEmailAddress, - RecipientMobileNumber = request.RecipientMobileNumber, - CustomerEmailAddress = request.CustomerEmailAddress, - OperatorId = request.OperatorId, - ProductId = request.ProductId, - VoucherAmount = request.VoucherAmount, - TransactionDateTime = request.TransactionDateTime, - TransactionNumber = transaction.transactionNumber.ToString(), - DeviceIdentifier = this.DeviceService.GetIdentifier(), - ApplicationVersion = this.ApplicationInfoService.VersionString - }; - - Result result = await transactionService.PerformVoucherIssue(model, cancellationToken); - - await this.UpdateTransactionRecord(transaction.transactionRecord.UpdateFrom(result)); - - if (result.IsSuccess && result.Data.IsSuccessful == false) - { - return Result.Failure("Voucher Issue not successful"); - } - - return Result.Success(result.Data); - } - - public async Task> Handle(PerformBillPaymentGetAccountRequest request, - CancellationToken cancellationToken) - { - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - (Int64 transactionNumber, TransactionRecord transactionRecord) transaction = await this.CreateTransactionRecord(request.ToTransactionRecord(useTrainingMode)); - - ITransactionService transactionService = this.TransactionServiceResolver(useTrainingMode); - - PerformBillPaymentGetAccountModel model = new PerformBillPaymentGetAccountModel - { - ContractId = request.ContractId, - OperatorId = request.OperatorId, - ProductId = request.ProductId, - TransactionDateTime = request.TransactionDateTime, - TransactionNumber = transaction.transactionNumber.ToString(), - CustomerAccountNumber = request.CustomerAccountNumber, - DeviceIdentifier = this.DeviceService.GetIdentifier(), - ApplicationVersion = this.ApplicationInfoService.VersionString - }; - - Result result = await transactionService.PerformBillPaymentGetAccount(model, cancellationToken); - - await this.UpdateTransactionRecord(transaction.transactionRecord.UpdateFrom(result)); - - return result; - } - - public async Task> Handle(PerformReconciliationRequest request, - CancellationToken cancellationToken) - { - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - List storedTransactions = await this.DatabaseContext.GetTransactions(useTrainingMode); - - ITransactionService transactionService = this.TransactionServiceResolver(useTrainingMode); - - var workingTotals = (from t in storedTransactions - where t.IsSuccessful && t.TransactionType != 1 // Filter out logons - group t by new - { - t.ContractId, - t.OperatorId - } - into tempOperatorTotals - select new - { - ContractId = tempOperatorTotals.Key.ContractId, - OperatorId = tempOperatorTotals.Key.OperatorId, - TransactionValue = tempOperatorTotals.Sum(t => t.Amount), - TransactionCount = tempOperatorTotals.Count() - }).ToList(); - - List operatorTotals = (from t in workingTotals - select new OperatorTotalModel - { - ContractId = t.ContractId, - OperatorId = t.OperatorId, - TransactionValue = t.TransactionValue, - TransactionCount = t.TransactionCount - }).ToList(); - - var grandTotals = new - { - TransactionValue = operatorTotals.Sum(t => t.TransactionValue), - TransactionCount = operatorTotals.Sum(t => t.TransactionCount) - }; - - PerformReconciliationRequestModel model = new PerformReconciliationRequestModel - { - ApplicationVersion = request.ApplicationVersion, - DeviceIdentifier = request.DeviceIdentifier, - TransactionDateTime = request.TransactionDateTime, - TransactionValue = grandTotals.TransactionValue, - TransactionCount = grandTotals.TransactionCount, - OperatorTotals = operatorTotals - }; - - // Send to the host - Result result = await transactionService.PerformReconciliation(model, cancellationToken); - - // Clear store (if successful) - if (result.IsSuccess && result.Data.IsSuccessful) - { - await this.DatabaseContext.ClearStoredTransactions(storedTransactions); - } - - return result; - } - - public async Task> Handle(PerformBillPaymentMakePostPaymentRequest request, - CancellationToken cancellationToken) - { - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - (Int64 transactionNumber, TransactionRecord transactionRecord) transaction = await this.CreateTransactionRecord(request.ToTransactionRecord(useTrainingMode)); - - ITransactionService transactionService = this.TransactionServiceResolver(useTrainingMode); - - PerformBillPaymentMakePaymentModel model = new PerformBillPaymentMakePaymentModel - { - ContractId = request.ContractId, - OperatorId = request.OperatorId, - ProductId = request.ProductId, - TransactionDateTime = request.TransactionDateTime, - TransactionNumber = transaction.transactionNumber.ToString(), - CustomerAccountNumber = request.CustomerAccountNumber, - PaymentAmount = request.PaymentAmount, - CustomerAccountName = request.CustomerAccountName, - CustomerMobileNumber = request.CustomerMobileNumber, - DeviceIdentifier = this.DeviceService.GetIdentifier(), - ApplicationVersion = this.ApplicationInfoService.VersionString, - PostPayment = true - }; - - Result result = await transactionService.PerformBillPaymentMakePayment(model, cancellationToken); - - await this.UpdateTransactionRecord(transaction.transactionRecord.UpdateFrom(result)); - - if (result.IsSuccess && result.Data.IsSuccessful == false) - { - return Result.Failure("Bill Payment not successful"); - } - - return Result.Success(result.Data); - - } - - public async Task> Handle(PerformBillPaymentMakePrePaymentRequest request, - CancellationToken cancellationToken) - { - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - (Int64 transactionNumber, TransactionRecord transactionRecord) transaction = await this.CreateTransactionRecord(request.ToTransactionRecord(useTrainingMode)); - - ITransactionService transactionService = this.TransactionServiceResolver(useTrainingMode); - - PerformBillPaymentMakePaymentModel model = new PerformBillPaymentMakePaymentModel - { - ContractId = request.ContractId, - OperatorId = request.OperatorId, - ProductId = request.ProductId, - TransactionDateTime = request.TransactionDateTime, - TransactionNumber = transaction.transactionNumber.ToString(), - CustomerAccountNumber = request.MeterNumber, - PaymentAmount = request.PaymentAmount, - CustomerAccountName = request.CustomerAccountName, - DeviceIdentifier = this.DeviceService.GetIdentifier(), - ApplicationVersion = this.ApplicationInfoService.VersionString, - PostPayment = false - }; - - Result result = await transactionService.PerformBillPaymentMakePayment(model, cancellationToken); - - await this.UpdateTransactionRecord(transaction.transactionRecord.UpdateFrom(result)); - - if (result.IsSuccess && result.Data.IsSuccessful == false) - { - return Result.Failure("Bill Payment not successful"); - } - - return Result.Success(result.Data); - - } - #endregion - - public async Task> Handle(PerformBillPaymentGetMeterRequest request, CancellationToken cancellationToken){ - Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode(); - (Int64 transactionNumber, TransactionRecord transactionRecord) transaction = await this.CreateTransactionRecord(request.ToTransactionRecord(useTrainingMode)); - - ITransactionService transactionService = this.TransactionServiceResolver(useTrainingMode); - - PerformBillPaymentGetMeterModel model = new PerformBillPaymentGetMeterModel - { - ContractId = request.ContractId, - OperatorId = request.OperatorId, - ProductId = request.ProductId, - TransactionDateTime = request.TransactionDateTime, - TransactionNumber = transaction.transactionNumber.ToString(), - MeterNumber = request.MeterNumber, - DeviceIdentifier = this.DeviceService.GetIdentifier(), - ApplicationVersion = this.ApplicationInfoService.VersionString - }; - - Result result = await transactionService.PerformBillPaymentGetMeter(model, cancellationToken); - - await this.UpdateTransactionRecord(transaction.transactionRecord.UpdateFrom(result)); - - return result; - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetConfigurationRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetConfigurationRequest.cs deleted file mode 100644 index 942e4feff..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetConfigurationRequest.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using Models; -using RequestHandlers; -using SimpleResults; - -public class GetConfigurationRequest : IRequest> -{ - public String DeviceIdentifier { get; private set; } - - private GetConfigurationRequest(String deviceIdentifier) - { - this.DeviceIdentifier = deviceIdentifier; - } - - public static GetConfigurationRequest Create(String deviceIdentifier) - { - return new GetConfigurationRequest(deviceIdentifier); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetContractProductsRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetContractProductsRequest.cs deleted file mode 100644 index 3a7828a82..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetContractProductsRequest.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using Models; -using RequestHandlers; -using SimpleResults; - -public class GetContractProductsRequest : IRequest>> -{ - #region Constructors - - private GetContractProductsRequest(ProductType? productType) - { - this.ProductType = productType; - } - - #endregion - - #region Properties - public ProductType? ProductType { get; } - #endregion - - #region Methods - - public static GetContractProductsRequest Create(ProductType? productType =null) - { - return new GetContractProductsRequest(productType); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetMerchantBalanceRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetMerchantBalanceRequest.cs deleted file mode 100644 index f84fc89fa..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetMerchantBalanceRequest.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using RequestHandlers; -using SimpleResults; - -public class GetMerchantBalanceRequest : IRequest> -{ - #region Constructors - - private GetMerchantBalanceRequest() - { - - } - - #endregion - - #region Properties - #endregion - - #region Methods - - public static GetMerchantBalanceRequest Create() - { - return new GetMerchantBalanceRequest(); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetMerchantDetailsRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetMerchantDetailsRequest.cs deleted file mode 100644 index d63561715..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/GetMerchantDetailsRequest.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using Models; -using RequestHandlers; -using SimpleResults; - -public class GetMerchantDetailsRequest : IRequest> -{ - #region Constructors - - #endregion - - #region Methods - - public static GetMerchantDetailsRequest Create() { - return new GetMerchantDetailsRequest(); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/LoginRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/LoginRequest.cs deleted file mode 100644 index b9019a115..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/LoginRequest.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests -{ - using Common; - using MediatR; - using Models; - using RequestHandlers; - using SimpleResults; - - public class LoginRequest : IRequest> - { - #region Constructors - - private LoginRequest(String username, - String password) - { - this.UserName = username; - this.Password = password; - } - - #endregion - - #region Properties - - public String Password { get; } - - public String UserName { get; } - - #endregion - - #region Methods - - public static LoginRequest Create(String username, - String password) - { - return new LoginRequest(username, password); - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/LogonTransactionRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/LogonTransactionRequest.cs deleted file mode 100644 index 9ed83eb9e..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/LogonTransactionRequest.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using Models; -using RequestHandlers; -using SimpleResults; - -public class LogonTransactionRequest : IRequest> -{ - public DateTime TransactionDateTime { get; private set; } - - private LogonTransactionRequest(DateTime transactionDateTime) - { - this.TransactionDateTime=transactionDateTime; - } - - public static LogonTransactionRequest Create(DateTime transactionDateTime) - { - return new LogonTransactionRequest(transactionDateTime); - } - -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformBillPaymentGetAccountRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformBillPaymentGetAccountRequest.cs deleted file mode 100644 index 8cebd88a5..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformBillPaymentGetAccountRequest.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using Models; -using RequestHandlers; -using SimpleResults; - -public class PerformBillPaymentGetAccountRequest : IRequest> -{ - #region Constructors - - private PerformBillPaymentGetAccountRequest(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String customerAccountNumber) { - this.CustomerAccountNumber = customerAccountNumber; - this.TransactionDateTime = transactionDateTime; - this.ContractId = contractId; - this.ProductId = productId; - this.OperatorId = operatorId; - } - - #endregion - - #region Properties - - public Guid ContractId { get; } - - public String CustomerAccountNumber { get; } - - public Guid OperatorId { get; } - - public Guid ProductId { get; } - - public DateTime TransactionDateTime { get; } - - #endregion - - #region Methods - - public static PerformBillPaymentGetAccountRequest Create(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String customerAccountNumber) { - return new PerformBillPaymentGetAccountRequest(transactionDateTime, - contractId, - productId, - operatorId, - customerAccountNumber); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformBillPaymentGetMeterRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformBillPaymentGetMeterRequest.cs deleted file mode 100644 index 403b38f5f..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformBillPaymentGetMeterRequest.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using Models; -using RequestHandlers; -using SimpleResults; - -public class PerformBillPaymentGetMeterRequest : IRequest> -{ - #region Constructors - - private PerformBillPaymentGetMeterRequest(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String meterNumber) - { - this.MeterNumber = meterNumber; - this.TransactionDateTime = transactionDateTime; - this.ContractId = contractId; - this.ProductId = productId; - this.OperatorId = operatorId; - } - - #endregion - - #region Properties - - public Guid ContractId { get; } - - public String MeterNumber { get; } - - public Guid OperatorId { get; } - - public Guid ProductId { get; } - - public DateTime TransactionDateTime { get; } - - #endregion - - #region Methods - - public static PerformBillPaymentGetMeterRequest Create(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String meterNumber) - { - return new PerformBillPaymentGetMeterRequest(transactionDateTime, - contractId, - productId, - operatorId, - meterNumber); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformBillPaymentMakePaymentRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformBillPaymentMakePaymentRequest.cs deleted file mode 100644 index 1d7ae1709..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformBillPaymentMakePaymentRequest.cs +++ /dev/null @@ -1,140 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using Models; -using RequestHandlers; -using SimpleResults; -using TransactionProcessorACL.DataTransferObjects.Responses; - -public class PerformBillPaymentMakePostPaymentRequest : IRequest> -{ - #region Constructors - - private PerformBillPaymentMakePostPaymentRequest(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String customerAccountNumber, - String customerAccountName, - String customerMobileNumber, - Decimal paymentAmount) - { - this.CustomerAccountNumber = customerAccountNumber; - this.CustomerAccountName = customerAccountName; - this.CustomerMobileNumber = customerMobileNumber; - this.PaymentAmount = paymentAmount; - this.TransactionDateTime = transactionDateTime; - this.ContractId = contractId; - this.ProductId = productId; - this.OperatorId = operatorId; - } - - #endregion - - #region Properties - - public Guid ContractId { get; } - - public String CustomerAccountNumber { get; } - - public String CustomerAccountName { get; } - - public String CustomerMobileNumber { get; } - - public Decimal PaymentAmount { get; } - - public Guid OperatorId { get; } - - public Guid ProductId { get; } - - public DateTime TransactionDateTime { get; } - - #endregion - - #region Methods - - public static PerformBillPaymentMakePostPaymentRequest Create(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String customerAccountNumber, - String customerAccountName, - String customerMobileNumber, - Decimal paymentAmount) - { - return new PerformBillPaymentMakePostPaymentRequest(transactionDateTime, - contractId, - productId, - operatorId, - customerAccountNumber, - customerAccountName, - customerMobileNumber, - paymentAmount); - } - - #endregion -} - -public class PerformBillPaymentMakePrePaymentRequest : IRequest> -{ - #region Constructors - - private PerformBillPaymentMakePrePaymentRequest(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String meterNumber, - String customerAccountName, - Decimal paymentAmount) - { - this.CustomerAccountName = customerAccountName; - this.MeterNumber = meterNumber; - this.PaymentAmount = paymentAmount; - this.TransactionDateTime = transactionDateTime; - this.ContractId = contractId; - this.ProductId = productId; - this.OperatorId = operatorId; - } - - #endregion - - #region Properties - - public Guid ContractId { get; } - - public String MeterNumber { get; } - - public String CustomerAccountName { get; } - - public Decimal PaymentAmount { get; } - - public Guid OperatorId { get; } - - public Guid ProductId { get; } - - public DateTime TransactionDateTime { get; } - - #endregion - - #region Methods - - public static PerformBillPaymentMakePrePaymentRequest Create(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String meterNumber, - String customerAccountName, - Decimal paymentAmount) - { - return new PerformBillPaymentMakePrePaymentRequest(transactionDateTime, - contractId, - productId, - operatorId, - meterNumber, - customerAccountName, - paymentAmount); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformMobileTopupRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformMobileTopupRequest.cs deleted file mode 100644 index 9fffa3cba..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformMobileTopupRequest.cs +++ /dev/null @@ -1,71 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using RequestHandlers; -using SimpleResults; -using TransactionMobile.Maui.BusinessLogic.Models; -using TransactionProcessorACL.DataTransferObjects.Responses; - -public class PerformMobileTopupRequest : IRequest> -{ - #region Constructors - - private PerformMobileTopupRequest(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String customerAccountNumber, - Decimal topupAmount, - String customerEmailAddress) - { - this.TransactionDateTime = transactionDateTime; - this.ContractId = contractId; - this.ProductId = productId; - this.OperatorId = operatorId; - this.CustomerAccountNumber = customerAccountNumber; - this.TopupAmount = topupAmount; - this.CustomerEmailAddress = customerEmailAddress; - } - - #endregion - - #region Properties - - public Guid ContractId { get; } - - public String CustomerAccountNumber { get; } - - public String CustomerEmailAddress { get; } - - public Guid OperatorId { get; } - - public Guid ProductId { get; } - - public Decimal TopupAmount { get; } - - public DateTime TransactionDateTime { get; } - - #endregion - - #region Methods - - public static PerformMobileTopupRequest Create(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String customerAccountNumber, - Decimal topupAmount, - String customerEmailAddress) - { - return new PerformMobileTopupRequest(transactionDateTime, - contractId, - productId, - operatorId, - customerAccountNumber, - topupAmount, - customerEmailAddress); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformReconciliationRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformReconciliationRequest.cs deleted file mode 100644 index c23f11bb4..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformReconciliationRequest.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Requests -{ - using Common; - using MediatR; - using Models; - using RequestHandlers; - using SimpleResults; - using TransactionProcessorACL.DataTransferObjects.Responses; - - public class PerformReconciliationRequest : IRequest> - { - public String DeviceIdentifier { get; private set; } - public DateTime TransactionDateTime { get; private set; } - public String ApplicationVersion { get; private set; } - - - private PerformReconciliationRequest(DateTime transactionDateTime, - String deviceIdentifier, - String applicationVersion) - { - this.TransactionDateTime = transactionDateTime; - this.DeviceIdentifier = deviceIdentifier; - this.ApplicationVersion = applicationVersion; - } - - public static PerformReconciliationRequest Create(DateTime transactionDateTime, - String deviceIdentifier, - String applicationVersion) - { - return new PerformReconciliationRequest(transactionDateTime, deviceIdentifier, applicationVersion); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformVoucherIssueRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformVoucherIssueRequest.cs deleted file mode 100644 index 3df4c18b5..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/PerformVoucherIssueRequest.cs +++ /dev/null @@ -1,77 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using Models; -using RequestHandlers; -using SimpleResults; -using TransactionProcessorACL.DataTransferObjects.Responses; - -public class PerformVoucherIssueRequest : IRequest> -{ - #region Constructors - - private PerformVoucherIssueRequest(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String recipientMobileNumber, - String recipientEmailAddress, - Decimal voucherAmount, - String customerEmailAddress) - { - this.TransactionDateTime = transactionDateTime; - this.ContractId = contractId; - this.ProductId = productId; - this.OperatorId = operatorId; - this.RecipientEmailAddress = recipientEmailAddress; - this.RecipientMobileNumber = recipientMobileNumber; - this.VoucherAmount = voucherAmount; - this.CustomerEmailAddress = customerEmailAddress; - } - - #endregion - - #region Properties - - public Guid ContractId { get; } - - public String RecipientMobileNumber { get; } - - public String RecipientEmailAddress { get; } - - public String CustomerEmailAddress { get; } - - public Guid OperatorId { get; } - - public Guid ProductId { get; } - - public DateTime TransactionDateTime { get; } - - public Decimal VoucherAmount { get; } - - #endregion - - #region Methods - - public static PerformVoucherIssueRequest Create(DateTime transactionDateTime, - Guid contractId, - Guid productId, - Guid operatorId, - String recipientMobileNumber, - String recipientEmailAddress, - Decimal voucherAmount, - String customerEmailAddress) - { - return new PerformVoucherIssueRequest(transactionDateTime, - contractId, - productId, - operatorId, - recipientMobileNumber, - recipientEmailAddress, - voucherAmount, - customerEmailAddress); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/RefreshTokenRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/RefreshTokenRequest.cs deleted file mode 100644 index 91215ef9b..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/RefreshTokenRequest.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using Common; -using MediatR; -using Models; -using RequestHandlers; -using SimpleResults; - -public class RefreshTokenRequest : IRequest> -{ - #region Constructors - - private RefreshTokenRequest(String refreshToken) - { - this.RefreshToken = refreshToken; - } - - #endregion - - #region Properties - - public String RefreshToken { get; } - - #endregion - - #region Methods - - public static RefreshTokenRequest Create(String refreshToken) - { - return new RefreshTokenRequest(refreshToken); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/UploadLogsRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/UploadLogsRequest.cs deleted file mode 100644 index 5fd6db1f7..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/UploadLogsRequest.cs +++ /dev/null @@ -1,24 +0,0 @@ -using MediatR; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Requests -{ - public class UploadLogsRequest : IRequest - { - private UploadLogsRequest(String deviceIdentifier) - { - DeviceIdentifier = deviceIdentifier; - } - - public string DeviceIdentifier { get; } - - public static UploadLogsRequest Create(String deviceIdentifier) - { - return new UploadLogsRequest(deviceIdentifier); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Requests/ViewLogsRequest.cs b/archive/TransactionMobile.Maui.BusinessLogic/Requests/ViewLogsRequest.cs deleted file mode 100644 index 90adff6d3..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Requests/ViewLogsRequest.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Requests; - -using MediatR; - -public class ViewLogsRequest : IRequest> -{ - private ViewLogsRequest() { - - } - - public static ViewLogsRequest Create() { - return new ViewLogsRequest(); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/ApplicationCache.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/ApplicationCache.cs deleted file mode 100644 index 0f996f780..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/ApplicationCache.cs +++ /dev/null @@ -1,123 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services -{ - using System.Diagnostics.CodeAnalysis; - using Microsoft.Extensions.Caching.Memory; - using Models; - - [ExcludeFromCodeCoverage] - public class ApplicationCache : IApplicationCache - { - #region Fields - - private readonly IMemoryCache MemoryCache; - - #endregion - - #region Constructors - - public ApplicationCache(IMemoryCache memoryCache) { - this.MemoryCache = memoryCache; - } - - #endregion - - #region Methods - - public TokenResponseModel GetAccessToken() { - return this.TryGetValue("AccessToken"); - } - - public Configuration GetConfiguration() { - return this.TryGetValue("Configuration"); - } - - public List GetContractProducts() { - return this.TryGetValue>("ContractProducts"); - } - - public Guid GetEstateId() { - return this.TryGetValue("EstateId"); - } - - public Boolean GetIsLoggedIn() { - return this.TryGetValue("isLoggedIn"); - } - - public Guid GetMerchantId() { - return this.TryGetValue("MerchantId"); - } - - public String GetConfigHostUrl() { - return this.TryGetValue("ConfigHostUrl"); - } - - public void SetConfigHostUrl(String value, - MemoryCacheEntryOptions options = default) { - this.Set("ConfigHostUrl", value, options); - } - - public Boolean GetUseTrainingMode() { - return this.TryGetValue("UseTrainingMode"); - } - - public void SetAccessToken(TokenResponseModel value, - MemoryCacheEntryOptions options = default) { - this.Set("AccessToken", value, options); - } - - public void SetConfiguration(Configuration value, - MemoryCacheEntryOptions options = default) { - this.Set("Configuration", value, options); - } - - public void SetContractProducts(List value, - MemoryCacheEntryOptions options = default) { - this.Set("ContractProducts", value, options); - } - - public void SetEstateId(Guid value, - MemoryCacheEntryOptions options = default) { - this.Set("EstateId", value, options); - } - - public void SetIsLoggedIn(Boolean value, - MemoryCacheEntryOptions options = default) { - this.Set("isLoggedIn", value, options); - } - - public void SetMerchantId(Guid value, - MemoryCacheEntryOptions options = default) { - this.Set("MerchantId", value, options); - } - - public MerchantDetailsModel GetMerchantDetails() { - return this.TryGetValue("MerchantDetails"); - } - - public void SetMerchantDetails(MerchantDetailsModel value, - MemoryCacheEntryOptions options = default) { - this.Set("MerchantDetails", value, options); - } - - public void SetUseTrainingMode(Boolean value, - MemoryCacheEntryOptions options = default) { - this.Set("UseTrainingMode", value, options); - } - - private void Set(String key, - T cache, - MemoryCacheEntryOptions options) { - this.MemoryCache.Set(key, cache, options); - } - - private T TryGetValue(String Key) { - if (this.MemoryCache.TryGetValue(Key, out T cachedItem)) { - return cachedItem; - } - - return default; - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/AuthenticationService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/AuthenticationService.cs deleted file mode 100644 index 1113507da..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/AuthenticationService.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Shared.Results; - -namespace TransactionMobile.Maui.BusinessLogic.Services -{ - using Common; - using Logging; - using Microsoft.Extensions.Caching.Memory; - using Models; - using Newtonsoft.Json; - using RequestHandlers; - using SecurityService.Client; - using SecurityService.DataTransferObjects.Responses; - using SimpleResults; - using ViewModels; - - public class AuthenticationService : IAuthenticationService - { - private readonly ISecurityServiceClient SecurityServiceClient; - - private readonly IApplicationCache ApplicationCache; - - public AuthenticationService(ISecurityServiceClient securityServiceClient, IApplicationCache applicationCache) - { - this.SecurityServiceClient = securityServiceClient; - this.ApplicationCache = applicationCache; - } - - public async Task> GetToken(String username, - String password, - CancellationToken cancellationToken) - { - try - { - Configuration configuration = this.ApplicationCache.GetConfiguration(); - - //username = "merchantuser@v28emulatormerchant.co.uk"; - //password = "123456"; - - Logger.LogInformation($"About to request token for {username}"); - Logger.LogDebug($"Token Request details UserName: {username} Password: {password} ClientId: {configuration.ClientId} ClientSecret: {configuration.ClientSecret}"); - - Result tokenResult = - await this.SecurityServiceClient.GetToken(username, password, configuration.ClientId, configuration.ClientSecret, cancellationToken); - - if (tokenResult.IsFailed) - { - return ResultHelpers.CreateFailure(tokenResult); - } - - Logger.LogInformation($"Token for {username} requested successfully"); - Logger.LogDebug($"Token Response: [{JsonConvert.SerializeObject(tokenResult.Data.AccessToken)}]"); - - return Result.Success(new TokenResponseModel - { - AccessToken = tokenResult.Data.AccessToken, - ExpiryInMinutes = tokenResult.Data.ExpiresIn, - RefreshToken = tokenResult.Data.RefreshToken - }); - } - catch(Exception ex) - { - Logger.LogError($"Error getting Token", ex); - return ResultExtensions.FailureExtended("Error getting Token", ex); - } - - - } - - public async Task> RefreshAccessToken(String refreshToken, - CancellationToken cancellationToken) - { - Configuration configuration = this.ApplicationCache.GetConfiguration(); - try - { - Logger.LogInformation($"About to request refresh token"); - Logger.LogDebug($"Refresh Token Request details Token: {refreshToken} ClientId: {configuration.ClientId} ClientSecret: {configuration.ClientSecret}"); - - Result tokenResult = await this.SecurityServiceClient.GetToken(configuration.ClientId, configuration.ClientSecret, refreshToken, cancellationToken); - - if (tokenResult.IsFailed) - { - return ResultHelpers.CreateFailure(tokenResult); - } - - Logger.LogInformation($"Refresh Token requested successfully"); - Logger.LogDebug($"Token Response: [{JsonConvert.SerializeObject(tokenResult.Data.AccessToken)}]"); - - return Result.Success(new TokenResponseModel - { - AccessToken = tokenResult.Data.AccessToken, - ExpiryInMinutes = tokenResult.Data.ExpiresIn, - RefreshToken = tokenResult.Data.RefreshToken - }); - } - catch (Exception ex) - { - Logger.LogError($"Error refreshing Token", ex); - return ResultExtensions.FailureExtended("Error refreshing Token", ex); - } - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/ConfigurationService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/ConfigurationService.cs deleted file mode 100644 index 45f610d12..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/ConfigurationService.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Services -{ - using System.Diagnostics.CodeAnalysis; - using System.Net; - using ClientProxyBase; - using Common; - using Logging; - using Microsoft.Extensions.Logging; - using Models; - using Newtonsoft.Json; - using RequestHandlers; - using SimpleResults; - using TransactionMobile.Maui.BusinessLogic.Services.DataTransferObjects; - using ViewModels; - using LogLevel = Models.LogLevel; - - public class ConfigurationService : ClientProxyBase, IConfigurationService - { - private readonly Func BaseAddressResolver; - - public ConfigurationService(Func baseAddressResolver, - HttpClient httpClient) : base(httpClient) { - this.BaseAddressResolver = baseAddressResolver; - } - - - private String BuildRequestUrl(String route) - { - String baseAddress = this.BaseAddressResolver("ConfigServiceUrl"); - - String requestUri = $"{baseAddress}{route}"; - - return requestUri; - } - - protected override async Task HandleResponse(HttpResponseMessage responseMessage, - CancellationToken cancellationToken) - { - String content = await responseMessage.Content.ReadAsStringAsync(); - - if (responseMessage.StatusCode == HttpStatusCode.NotFound) - { - // No error as maybe running under CI (which has no internet) - return content; - } - - return await base.HandleResponse(responseMessage, cancellationToken); - } - - public async Task> GetConfiguration(String deviceIdentifier, - CancellationToken cancellationToken) - { - Configuration response = null; - String requestUri = this.BuildRequestUrl($"/api/transactionmobileconfiguration/{deviceIdentifier}"); - - try - { - Logger.LogInformation($"About to request configuration for device identifier {deviceIdentifier}"); - Logger.LogDebug($"Configuration Request details: Uri {requestUri}"); - - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); - Logger.LogDebug($"Configuration Response [{httpResponse.StatusCode}]"); - - // Process the response - String content = await this.HandleResponse(httpResponse, cancellationToken); - Logger.LogDebug($"Configuration Response Content [{content}]"); - - // call was successful so now deserialise the body to the response object - ConfigurationResponse apiResponse = JsonConvert.DeserializeObject(content); - - Logger.LogDebug($"About to build Configuration"); - response = new Configuration() { - ClientSecret = apiResponse.ClientSecret, - ClientId = apiResponse.ClientId, - EnableAutoUpdates = apiResponse.EnableAutoUpdates, - TransactionProcessorUri = apiResponse.HostAddresses.Single(h => h.ServiceType == ServiceType.TransactionProcessor).Uri, - SecurityServiceUri = apiResponse.HostAddresses.Single(h => h.ServiceType == ServiceType.Security).Uri, - TransactionProcessorAclUri = - apiResponse.HostAddresses.Single(h => h.ServiceType == ServiceType.TransactionProcessorAcl).Uri, - }; - - Logger.LogDebug($"About to xlate log level"); - response.LogLevel = apiResponse.LogLevel switch - { - LoggingLevel.Debug => LogLevel.Debug, - LoggingLevel.Error => LogLevel.Error, - LoggingLevel.Fatal => LogLevel.Fatal, - LoggingLevel.Information => LogLevel.Info, - LoggingLevel.Trace => LogLevel.Trace, - LoggingLevel.Warning => LogLevel.Warn, - _ => LogLevel.Info - }; - - Logger.LogDebug($"About to xlate app centre config"); - response.AppCenterConfig = new AppCenterConfiguration() { - AndroidKey = apiResponse.ApplicationCentreConfiguration.AndroidKey, - MacOSKey = apiResponse.ApplicationCentreConfiguration.MacosKey, - WindowsKey = apiResponse.ApplicationCentreConfiguration.WindowsKey, - iOSKey = apiResponse.ApplicationCentreConfiguration.IosKey - }; - - Logger.LogInformation($"Configuration for device identifier {deviceIdentifier} requested successfully"); - Logger.LogDebug($"Configuration Response: [{content}]"); - - return Result.Success(response); - } - catch (Exception ex) - { - // An exception has occurred, add some additional information to the message - Logger.LogError($"Error getting configuration for device Id {deviceIdentifier}.",ex); - - return ResultExtensions.FailureExtended($"Error getting configuration data for device Id {deviceIdentifier}", ex); - } - } - - public async Task PostDiagnosticLogs(String deviceIdentifier, - List logMessages, - CancellationToken cancellationToken) - { - String requestUri = this.BuildRequestUrl($"/transactionmobilelogging/{deviceIdentifier}"); - - // Create a container - var container = new - { - messages = logMessages - }; - StringContent content = new StringContent(JsonConvert.SerializeObject(container), Encoding.UTF8, "application/json"); - - HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, content, cancellationToken); - - await this.HandleResponse(httpResponse, cancellationToken); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/ApplicationCentreConfiguration.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/ApplicationCentreConfiguration.cs deleted file mode 100644 index 0cd120a32..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/ApplicationCentreConfiguration.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Services.DataTransferObjects; - -[ExcludeFromCodeCoverage] -public class ApplicationCentreConfiguration -{ - public string ApplicationId { get; set; } - public string AndroidKey { get; set; } - public string IosKey { get; set; } - public string MacosKey { get; set; } - public string WindowsKey { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/ConfigurationResponse.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/ConfigurationResponse.cs deleted file mode 100644 index 414973125..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/ConfigurationResponse.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Services.DataTransferObjects; - -[ExcludeFromCodeCoverage] -public class ConfigurationResponse -{ - public string ClientId { get; set; } - public string ClientSecret { get; set; } - - public string DeviceIdentifier { get; set; } - - public bool EnableAutoUpdates { get; set; } - - public List HostAddresses { get; set; } - - public string Id { get; set; } - - public LoggingLevel LogLevel { get; set; } - - public ApplicationCentreConfiguration ApplicationCentreConfiguration { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/HostAddress.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/HostAddress.cs deleted file mode 100644 index e929f5b9b..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/HostAddress.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.BusinessLogic.Services.DataTransferObjects; - -[ExcludeFromCodeCoverage] -public class HostAddress -{ - public ServiceType ServiceType { get; set; } - - public string Uri { get; set; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/LoggingLevel.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/LoggingLevel.cs deleted file mode 100644 index a77cf51fb..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/LoggingLevel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services.DataTransferObjects; - - -public enum LoggingLevel -{ - Fatal = 0, - Error = 1, - Warning = 2, - Information = 3, - Debug = 4, - Trace = 5 -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/ServiceType.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/ServiceType.cs deleted file mode 100644 index b3af5533f..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/DataTransferObjects/ServiceType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services.DataTransferObjects; - -public enum ServiceType -{ - TransactionProcessor = 0, - Security = 1, - TransactionProcessorAcl = 2 -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/IApplicationCache.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/IApplicationCache.cs deleted file mode 100644 index c74f082ee..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/IApplicationCache.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services; - -using Microsoft.Extensions.Caching.Memory; -using Models; - -public interface IApplicationCache -{ - String GetConfigHostUrl(); - - void SetConfigHostUrl(String value, MemoryCacheEntryOptions options = default); - - Boolean GetUseTrainingMode(); - - void SetUseTrainingMode(Boolean value, MemoryCacheEntryOptions options = default); - - Boolean GetIsLoggedIn(); - - void SetIsLoggedIn(Boolean value, MemoryCacheEntryOptions options = default); - - Configuration GetConfiguration(); - - void SetConfiguration(Configuration value, MemoryCacheEntryOptions options = default); - - List GetContractProducts(); - - void SetContractProducts(List value, MemoryCacheEntryOptions options = default); - - TokenResponseModel GetAccessToken(); - - void SetAccessToken(TokenResponseModel value, MemoryCacheEntryOptions options = default); - - Guid GetEstateId(); - - void SetEstateId(Guid value, MemoryCacheEntryOptions options = default); - - Guid GetMerchantId(); - - void SetMerchantId(Guid value, MemoryCacheEntryOptions options = default); - - MerchantDetailsModel GetMerchantDetails(); - - void SetMerchantDetails(MerchantDetailsModel value, MemoryCacheEntryOptions options = default); -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/IAuthenticationService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/IAuthenticationService.cs deleted file mode 100644 index f38afb3ec..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/IAuthenticationService.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services -{ - using Common; - using Models; - using RequestHandlers; - using SimpleResults; - - public interface IAuthenticationService - { - #region Methods - - Task> GetToken(String username, - String password, - CancellationToken cancellationToken); - - Task> RefreshAccessToken(String refreshToken, - CancellationToken cancellationToken); - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/IConfigurationService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/IConfigurationService.cs deleted file mode 100644 index 565db9485..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/IConfigurationService.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Services; - -using Common; -using Models; -using RequestHandlers; -using SimpleResults; - -public interface IConfigurationService -{ - Task> GetConfiguration(String deviceIdentifier, - CancellationToken cancellationToken); - - Task PostDiagnosticLogs(String deviceIdentifier, - List logMessages, - CancellationToken cancellationToken); -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/IMerchantService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/IMerchantService.cs deleted file mode 100644 index 710ddc5bc..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/IMerchantService.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services; - -using Common; -using Microsoft.Extensions.Caching.Memory; -using Models; -using RequestHandlers; -using SimpleResults; - -public interface IMerchantService -{ - #region Methods - - Task>> GetContractProducts(CancellationToken cancellationToken); - - Task> GetMerchantBalance(CancellationToken cancellationToken); - - Task> GetMerchantDetails(CancellationToken cancellationToken); - - #endregion -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/ITransactionService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/ITransactionService.cs deleted file mode 100644 index 93c5b606b..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/ITransactionService.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services -{ - using Common; - using Models; - using RequestHandlers; - using SimpleResults; - using TransactionProcessorACL.DataTransferObjects.Responses; - - public interface ITransactionService - { - #region Methods - - Task> PerformLogon(PerformLogonRequestModel model, CancellationToken cancellationToken); - - Task> PerformMobileTopup(PerformMobileTopupRequestModel model, CancellationToken cancellationToken); - - Task> PerformReconciliation(PerformReconciliationRequestModel model, CancellationToken cancellationToken); - - Task> PerformVoucherIssue(PerformVoucherIssueRequestModel model, CancellationToken cancellationToken); - - Task> PerformBillPaymentGetAccount(PerformBillPaymentGetAccountModel model, CancellationToken cancellationToken); - - Task> PerformBillPaymentMakePayment(PerformBillPaymentMakePaymentModel model, CancellationToken cancellationToken); - - Task> PerformBillPaymentGetMeter(PerformBillPaymentGetMeterModel model, CancellationToken cancellationToken); - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/MerchantService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/MerchantService.cs deleted file mode 100644 index 44345d3f7..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/MerchantService.cs +++ /dev/null @@ -1,245 +0,0 @@ -using TransactionMobile.Maui.BusinessLogic.UIServices; -using TransactionProcessorACL.DataTransferObjects.Responses; - -namespace TransactionMobile.Maui.BusinessLogic.Services; - -using ClientProxyBase; -using Common; -using Logging; -using Models; -using Newtonsoft.Json; -using RequestHandlers; -using SimpleResults; -using System.Diagnostics.CodeAnalysis; -using System.Net.Http.Headers; -using ViewModels; - -public class MerchantService : ClientProxyBase, IMerchantService -{ - #region Fields - - private readonly IApplicationCache ApplicationCache; - private readonly IApplicationInfoService ApplicationInfoService; - - private readonly Func BaseAddressResolver; - - #endregion - - #region Constructors - - public MerchantService(Func baseAddressResolver, - HttpClient httpClient, - IApplicationCache applicationCache, - IApplicationInfoService applicationInfoService) : base(httpClient) { - this.BaseAddressResolver = baseAddressResolver; - this.ApplicationCache = applicationCache; - this.ApplicationInfoService = applicationInfoService; - } - - #endregion - - #region Methods - - private String BuildRequestUrl(String route) - { - String baseAddress = this.BaseAddressResolver("TransactionProcessorACL"); - - String requestUri = $"{baseAddress}{route}"; - - return requestUri; - } - - public async Task>> GetContractProducts(CancellationToken cancellationToken) { - List models = new(); - - TokenResponseModel accessToken = this.ApplicationCache.GetAccessToken(); - Guid estateId = this.ApplicationCache.GetEstateId(); - Guid merchantId = this.ApplicationCache.GetMerchantId(); - - String requestUri = this.BuildRequestUrl($"/api/merchants/contracts?application_version={this.ApplicationInfoService.VersionString}"); - - Logger.LogInformation("About to request merchant contracts"); - Logger.LogDebug($"Merchant Contract Request details: Estate Id {estateId} Merchant Id {merchantId} Access Token {accessToken.AccessToken}"); - - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri); - request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.AccessToken); - var httpResponse = await this.HttpClient.SendAsync(request, cancellationToken); - - // Process the response - Result content = await this.HandleResponseX(httpResponse, cancellationToken); - - if (content.IsFailed) { - Logger.LogInformation($"GetMerchantContracts failed {content.Status}"); - return Result.Failure(content.Message); - } - - Logger.LogDebug($"Transaction Response details: Status {httpResponse.StatusCode} Payload {content.Data}"); - - ResponseData> responseData = this.HandleResponseContent>(content.Data); - - Logger.LogInformation($"{responseData.Data.Count} for merchant requested successfully"); - Logger.LogDebug($"Merchant Contract Response: [{JsonConvert.SerializeObject(responseData.Data)}]"); - - foreach (ContractResponse contractResponse in responseData.Data) { - foreach (ContractProduct contractResponseProduct in contractResponse.Products) { - var productType = GetProductType(contractResponse.OperatorName); - - models.Add(new ContractProductModel { - OperatorId = contractResponse.OperatorId, - ContractId = contractResponse.ContractId, - ProductId = contractResponseProduct.ProductId, - OperatorIdentfier = contractResponse.OperatorName, - OperatorName = GetOperatorName(contractResponse, productType), - Value = contractResponseProduct.Value ?? 0, - IsFixedValue = contractResponseProduct.Value.HasValue, - ProductDisplayText = contractResponseProduct.DisplayText, - ProductType = productType, - ProductSubType = GetProductSubType(contractResponse.OperatorName), - }); - } - } - - return Result.Success(models); - } - - [ExcludeFromCodeCoverage(Justification = "Need to have a think of best way of this data being retrieved")] - public async Task> GetMerchantBalance(CancellationToken cancellationToken) { - try { - TokenResponseModel accessToken = this.ApplicationCache.GetAccessToken(); - Guid estateId = this.ApplicationCache.GetEstateId(); - Guid merchantId = this.ApplicationCache.GetMerchantId(); - - - Logger.LogInformation("About to request merchant balance"); - Logger.LogDebug($"Merchant Balance Request details: Estate Id {estateId} Merchant Id {merchantId} Access Token {accessToken.AccessToken}"); - - //MerchantBalanceResponse merchantBalance = new MerchantBalanceResponse { - // AvailableBalance = 0, - // Balance = 0 - // }; - //await this.EstateClient.GetMerchantBalance(accessToken.AccessToken, estateId, merchantId, cancellationToken); - - Logger.LogInformation("Balance for merchant requested successfully"); - //Logger.LogDebug($"Merchant Balance Response: [{JsonConvert.SerializeObject(merchantBalance)}]"); - - return Result.Success(0.0m); - } - catch(Exception ex) { - Logger.LogError("Error getting merchant balance",ex); - return ResultExtensions.FailureExtended("Error getting merchant balance", ex); - } - } - - public async Task> GetMerchantDetails(CancellationToken cancellationToken) { - TokenResponseModel accessToken = this.ApplicationCache.GetAccessToken(); - Guid estateId = this.ApplicationCache.GetEstateId(); - Guid merchantId = this.ApplicationCache.GetMerchantId(); - - - String requestUri = this.BuildRequestUrl($"/api/merchants?application_version={this.ApplicationInfoService.VersionString}"); - - Logger.LogInformation("About to request merchant details"); - Logger.LogDebug($"Merchant Details Request details: Estate Id {estateId} Merchant Id {merchantId} Access Token {accessToken.AccessToken}"); - - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri); - request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.AccessToken); - var httpResponse = await this.HttpClient.SendAsync(request, cancellationToken); - - // Process the response - Result content = await this.HandleResponseX(httpResponse, cancellationToken); - - if (content.IsFailed) - { - Logger.LogInformation($"GetMerchantContracts failed {content.Status}"); - return Result.Failure(content.Message); - } - - Logger.LogDebug($"Transaction Response details: Status {httpResponse.StatusCode} Payload {content.Data}"); - - ResponseData responseData = this.HandleResponseContent(content.Data); - - Logger.LogInformation("Merchant details requested successfully"); - Logger.LogDebug($"Merchant Details Response: [{JsonConvert.SerializeObject(responseData.Data)}]"); - - MerchantDetailsModel model = new MerchantDetailsModel { - MerchantName = responseData.Data.MerchantName, - NextStatementDate = responseData.Data.NextStatementDate, - LastStatementDate = new DateTime(), - SettlementSchedule = responseData.Data.SettlementSchedule.ToString(), - //AvailableBalance = merchantResponse.AvailableBalance, - //Balance = merchantResponse.Balance, - Contact = new ContactModel { - Name = responseData.Data.Contacts.First().ContactName, - EmailAddress = responseData.Data.Contacts.First().ContactEmailAddress, - MobileNumber = responseData.Data.Contacts.First().ContactPhoneNumber - }, - Address = new AddressModel { - AddressLine3 = responseData.Data.Addresses.First().AddressLine3, - Town = responseData.Data.Addresses.First().Town, - AddressLine4 = responseData.Data.Addresses.First().AddressLine4, - PostalCode = responseData.Data.Addresses.First().PostalCode, - Region = responseData.Data.Addresses.First().Region, - AddressLine1 = responseData.Data.Addresses.First().AddressLine1, - AddressLine2 = responseData.Data.Addresses.First().AddressLine2 - } - }; - - return Result.Success(model); - } - - public static String GetOperatorName(ContractResponse contractResponse, ProductType productType) { - String operatorName = null; - switch(productType) { - case ProductType.Voucher: - operatorName = contractResponse.Description; - break; - default: - operatorName = contractResponse.OperatorName; - break; - } - - return operatorName; - } - - public static ProductType GetProductType(String operatorName) { - ProductType productType = ProductType.NotSet; - switch(operatorName) { - case "Safaricom": - productType = ProductType.MobileTopup; - break; - case "Voucher": - productType = ProductType.Voucher; - break; - case "PataPawa PostPay": - case "PataPawa PrePay": - productType = ProductType.BillPayment; - break; - } - - return productType; - } - - public static ProductSubType GetProductSubType(String operatorName) - { - ProductSubType productType = ProductSubType.NotSet; - switch (operatorName) - { - case "Safaricom": - productType = ProductSubType.MobileTopup; - break; - case "Voucher": - productType = ProductSubType.Voucher; - break; - case "PataPawa PostPay": - productType = ProductSubType.BillPaymentPostPay; - break; - case "PataPawa PrePay": - productType = ProductSubType.BillPaymentPrePay; - break; - } - - return productType; - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingAuthenticationService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingAuthenticationService.cs deleted file mode 100644 index 554fd2eb1..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingAuthenticationService.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.Services.TrainingModeServices -{ - using Common; - using Models; - using RequestHandlers; - using SimpleResults; - using TransactionProcessorACL.DataTransferObjects.Responses; - - [ExcludeFromCodeCoverage] - public class TrainingAuthenticationService : IAuthenticationService - { - public async Task> GetToken(String username, - String password, - CancellationToken cancellationToken) { - return Result.Success(new TokenResponseModel { - AccessToken = "Token", - RefreshToken = "RefreshToken", - ExpiryInMinutes = 1 - }); - } - - public async Task> RefreshAccessToken(String refreshToken, - CancellationToken cancellationToken) { - return Result.Success(new TokenResponseModel - { - AccessToken = "Token", - RefreshToken = "RefreshToken", - ExpiryInMinutes = 1 - }); - } - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingConfigurationService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingConfigurationService.cs deleted file mode 100644 index 90dd4b73d..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingConfigurationService.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services.TrainingModeServices; - -using Models; -using RequestHandlers; -using System.Diagnostics.CodeAnalysis; -using Common; -using SimpleResults; - -[ExcludeFromCodeCoverage] -public class TrainingConfigurationService : IConfigurationService -{ - public async Task> GetConfiguration(String deviceIdentifier, - CancellationToken cancellationToken) { - return Result.Success(new Configuration { - ClientId = "dummyClientId", - ClientSecret = "dummyClientSecret", - EnableAutoUpdates = false, - ShowDebugMessages = true, - TransactionProcessorUri = "http://localhost:5001", - EstateReportingUri = "http://localhost:5006", - LogLevel = LogLevel.Debug, - SecurityServiceUri = "http://localhost:5001", - TransactionProcessorAclUri = "http://localhost:5003", - AppCenterConfig = new AppCenterConfiguration { - AndroidKey = String.Empty, - MacOSKey = String.Empty, - WindowsKey = String.Empty, - iOSKey = String.Empty - } - }); - } - - public async Task PostDiagnosticLogs(String deviceIdentifier, - List logMessages, - CancellationToken cancellationToken) { - - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingMerchantService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingMerchantService.cs deleted file mode 100644 index 801eedd52..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingMerchantService.cs +++ /dev/null @@ -1,142 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services.TrainingModeServices; - -using Models; -using RequestHandlers; -using System.Diagnostics.CodeAnalysis; -using Common; -using SimpleResults; - -[ExcludeFromCodeCoverage] -public class TrainingMerchantService : IMerchantService -{ - public async Task>> GetContractProducts(CancellationToken cancellationToken) { - return Result.Success(new List { - new ContractProductModel { - ContractId = Guid.Parse("21DA6AC5-70E6-478E-A5E9-74C9B27F5725"), - IsFixedValue = true, - OperatorId = Guid.Parse("2CA5F4C7-34EC-425B-BB53-7EEDF48D9967"), - OperatorIdentfier = "Hospital 1 Contract", - OperatorName = "Hospital 1 Contract", - ProductDisplayText = "10 KES", - ProductId = Guid.Parse("CBF55D95-306A-4E85-B367-24FA442998F6"), - ProductType = ProductType.Voucher, - Value = 10 - }, - new ContractProductModel { - ContractId = Guid.Parse("21DA6AC5-70E6-478E-A5E9-74C9B27F5725"), - IsFixedValue = true, - OperatorId = Guid.Parse("2CA5F4C7-34EC-425B-BB53-7EEDF48D9967"), - OperatorIdentfier = "Hospital 1 Contract", - OperatorName = "Hospital 1 Contract", - ProductDisplayText = "20 KES", - ProductId = Guid.Parse("F5F9B63F-9F68-45E8-960B-CE0FC15ED672"), - ProductType = ProductType.Voucher, - Value = 20 - }, - new ContractProductModel { - ContractId = Guid.Parse("21DA6AC5-70E6-478E-A5E9-74C9B27F5725"), - IsFixedValue = false, - OperatorId = Guid.Parse("2CA5F4C7-34EC-425B-BB53-7EEDF48D9967"), - OperatorIdentfier = "Hospital 1 Contract", - OperatorName = "Hospital 1 Contract", - ProductDisplayText = "Custom", - ProductId = Guid.Parse("268CBAF5-95E0-4D4C-9725-3BB2B76E4273"), - ProductType = ProductType.Voucher - }, - new ContractProductModel { - ContractId = Guid.Parse("D57DAC9B-4039-4120-B5A8-F7FDF1D3A3C2"), - IsFixedValue = true, - OperatorId = Guid.Parse("2CA5F4C7-34EC-425B-BB53-7EEDF48D9967"), - OperatorIdentfier = "Safaricom", - OperatorName = "Safaricom", - ProductDisplayText = "100 KES", - ProductId = Guid.Parse("48D96AE5-A829-498B-8C0D-D7107610EBDC"), - ProductType = ProductType.MobileTopup, - Value = 100 - }, - new ContractProductModel { - ContractId = Guid.Parse("D57DAC9B-4039-4120-B5A8-F7FDF1D3A3C2"), - IsFixedValue = true, - OperatorId = Guid.Parse("2CA5F4C7-34EC-425B-BB53-7EEDF48D9967"), - OperatorIdentfier = "Safaricom", - OperatorName = "Safaricom", - ProductDisplayText = "200 KES", - ProductId = Guid.Parse("63821A48-D35E-451D-9E88-C8DCB548E7ED"), - ProductType = ProductType.MobileTopup, - Value = 200 - }, - new ContractProductModel { - ContractId = Guid.Parse("D57DAC9B-4039-4120-B5A8-F7FDF1D3A3C2"), - IsFixedValue = false, - OperatorId = Guid.Parse("2CA5F4C7-34EC-425B-BB53-7EEDF48D9967"), - OperatorIdentfier = "Safaricom", - OperatorName = "Safaricom", - ProductDisplayText = "Custom", - ProductId = Guid.Parse("63821A48-D35E-451D-9E88-C8DCB548E7ED"), - ProductType = ProductType.MobileTopup - }, - new ContractProductModel { - ContractId = Guid.Parse("D57DAC9B-4039-4120-B5A8-F7FDF1D3A3C2"), - IsFixedValue = false, - OperatorId = Guid.Parse("1CA5F4C7-34EC-425B-BB53-7EEDF48D9968"), - OperatorIdentfier = "Safaricom1", - OperatorName = "Safaricom1", - ProductDisplayText = "Custom", - ProductId = Guid.Parse("63821A48-D35E-451D-9E88-C8DCB548E7ED"), - ProductType = ProductType.MobileTopup - }, - new ContractProductModel { - ContractId = Guid.Parse("0615E7F6-2749-4507-8588-E019E8110C95"), - IsFixedValue = false, - OperatorId = Guid.Parse("C485F21B-EF17-448D-8B8C-E217A07C1863"), - OperatorIdentfier = "PataPawaPostPay", - OperatorName = "Pata Pawa PostPay", - ProductDisplayText = "Bill Pay (Post)", - ProductId = Guid.Parse("DE92018C-513E-44B2-B96D-F5B3621C48A2"), - ProductType = ProductType.BillPayment, - ProductSubType = ProductSubType.BillPaymentPostPay - }, - new ContractProductModel { - ContractId = Guid.Parse("7AAFFE8D-4EA2-485F-8600-D4D29A0043F0"), - IsFixedValue = false, - OperatorId = Guid.Parse("C485F21B-EF17-448D-8B8C-E217A07C1863"), - OperatorIdentfier = "PataPawaPrePay", - OperatorName = "Pata Pawa PrePay", - ProductDisplayText = "Bill Pay (Pre)", - ProductId = Guid.Parse("A7472650-4420-43BF-8132-3A094EB084FE"), - ProductType = ProductType.BillPayment, - ProductSubType = ProductSubType.BillPaymentPrePay - } - - }); - } - - public async Task> GetMerchantBalance(CancellationToken cancellationToken) { - return Result.Success(100.00m); - } - - public async Task> GetMerchantDetails(CancellationToken cancellationToken) { - return Result.Success(new MerchantDetailsModel { - Address = new AddressModel { - AddressLine1 = "test address line 1", - AddressLine2 = "test address line 2", - AddressLine3 = "test address line 3", - AddressLine4 = "test address line 4", - PostalCode = "TE57 1NG", - Region = "Region", - Town = "Town" - }, - Contact = new ContactModel { - Name = "Test Contact", - EmailAddress = "stuart_ferguson1@outlook.com", - MobileNumber = "123456789" - }, - LastStatementDate = new DateTime(2022, 8, 1), - NextStatementDate = new DateTime(2022, 9, 1), - MerchantName = "Dummy Merchant", - SettlementSchedule = "Monthly", - AvailableBalance = 100, - Balance = 99 - }); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingTransactionService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingTransactionService.cs deleted file mode 100644 index aec6abfae..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/TrainingModeServices/TrainingTransactionService.cs +++ /dev/null @@ -1,114 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services.TrainingModeServices; - -using Models; -using RequestHandlers; -using System.Diagnostics.CodeAnalysis; -using Common; -using SimpleResults; -using ViewModels.Transactions; - -[ExcludeFromCodeCoverage] -public class TrainingTransactionService : ITransactionService -{ - public async Task> PerformLogon(PerformLogonRequestModel model, - CancellationToken cancellationToken) { - return Result.Success(new PerformLogonResponseModel { - EstateId = Guid.Parse("D7E52254-E0BE-436A-9A34-CC291DA0D66A"), - MerchantId = Guid.Parse("DD034A3B-D8EE-45A4-A29F-8774751CEE76"), - ResponseCode = "0000", - ResponseMessage = "SUCCESS" - }); - } - - public async Task> PerformMobileTopup(PerformMobileTopupRequestModel model, - CancellationToken cancellationToken){ - - PerformMobileTopupResponseModel responseModel = model.TopupAmount switch{ - 150 => new PerformMobileTopupResponseModel(){ - ResponseCode = "1000", - ResponseMessage = "Failed" - }, - _ => new(){ - ResponseCode = "0000", - ResponseMessage = "SUCCESS" - } - }; - - return Result.Success(responseModel); - } - - public async Task> PerformReconciliation(PerformReconciliationRequestModel model, - CancellationToken cancellationToken) { - return Result.Success(new PerformReconciliationResponseModel { - ResponseMessage = "SUCCESS", - ResponseCode = "0000" - }); - } - - public async Task> PerformVoucherIssue(PerformVoucherIssueRequestModel model, - CancellationToken cancellationToken) { - - PerformVoucherIssueResponseModel responseModel = model.VoucherAmount switch - { - 150 => new () - { - ResponseCode = "1000", - ResponseMessage = "Failed" - }, - _ => new() - { - ResponseCode = "0000", - ResponseMessage = "SUCCESS" - } - }; - - return Result.Success(responseModel); - } - - public async Task> PerformBillPaymentGetAccount(PerformBillPaymentGetAccountModel model, - CancellationToken cancellationToken){ - PerformBillPaymentGetAccountResponseModel responseMessage = new PerformBillPaymentGetAccountResponseModel{ - BillDetails = new BillDetails{ - AccountName = "Mr Test Customer", - AccountNumber = model.CustomerAccountNumber, - Balance = "100.00", - DueDate = DateTime.Now.AddDays(3).ToString("dd-MM-yyyy"), - - }, - }; - - - return Result.Success(responseMessage); - } - - public async Task> PerformBillPaymentMakePayment(PerformBillPaymentMakePaymentModel model, - CancellationToken cancellationToken){ - - PerformBillPaymentMakePaymentResponseModel responseModel = model.PaymentAmount switch{ - 150 => new PerformBillPaymentMakePaymentResponseModel(){ - ResponseMessage = "Failed", - ResponseCode = "1000" - }, - _ => new PerformBillPaymentMakePaymentResponseModel{ - ResponseCode = "0000", - ResponseMessage = "SUCCESS" - } - }; - - return Result.Success(responseModel); - } - - public async Task> PerformBillPaymentGetMeter(PerformBillPaymentGetMeterModel model, CancellationToken cancellationToken){ - PerformBillPaymentGetMeterResponseModel responseMessage = new PerformBillPaymentGetMeterResponseModel - { - MeterDetails = new MeterDetails() - { - CustomerName = "Mr Test Customer", - MeterNumber = model.MeterNumber - } - }; - - - return Result.Success(responseMessage); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/Services/TransactionService.cs b/archive/TransactionMobile.Maui.BusinessLogic/Services/TransactionService.cs deleted file mode 100644 index 6ba2c16fa..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/Services/TransactionService.cs +++ /dev/null @@ -1,286 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.Services -{ - using ClientProxyBase; - using Common; - using Logging; - using Models; - using Newtonsoft.Json; - using RequestHandlers; - using SimpleResults; - using System.Diagnostics.CodeAnalysis; - using System.Net; - using System.Net.Http.Headers; - using System.Text; - using TransactionProcessorACL.DataTransferObjects; - using TransactionProcessorACL.DataTransferObjects.Responses; - using ViewModels; - using ViewModels.Transactions; - - //[ExcludeFromCodeCoverage(Justification = "Need to refactor to allow injection of client for mocking")] - public class TransactionService : ClientProxyBase, ITransactionService - { - #region Fields - - private readonly IApplicationCache ApplicationCache; - - private readonly Func BaseAddressResolver; - - #endregion - - #region Constructors - - public TransactionService(Func baseAddressResolver, - HttpClient httpClient, - IApplicationCache applicationCache) : base(httpClient) { - this.BaseAddressResolver = baseAddressResolver; - this.ApplicationCache = applicationCache; - - // Add the API version header - this.HttpClient.DefaultRequestHeaders.Add("api-version", "1.0"); - } - - #endregion - - #region Methods - - public async Task> PerformBillPaymentGetAccount(PerformBillPaymentGetAccountModel model, - CancellationToken cancellationToken) { - Logger.LogInformation("About to perform bill payment get account transaction"); - - Result result = await this.SendTransactionRequest(model.ToSaleTransactionRequest(), cancellationToken); - - if (result.IsSuccess == false) - { - Logger.LogWarning("Error performing bill payment - get account transaction"); - return Result.Failure("Error performing bill payment - get account transaction"); - } - - PerformBillPaymentGetAccountResponseModel responseModel = new() - { - BillDetails = result.Data.AdditionalResponseMetaData.ToBillDetails() - }; - - Logger.LogInformation("Bill payment - get account transaction performed successfully"); - - return Result.Success(responseModel); - } - - public async Task> PerformBillPaymentMakePayment(PerformBillPaymentMakePaymentModel model, - CancellationToken cancellationToken) { - Logger.LogInformation("About to perform bill payment make payment transaction"); - - Result result = await this.SendTransactionRequest(model.ToSaleTransactionRequest(), cancellationToken); - - if (result.IsSuccess == false) - { - Logger.LogWarning("Error performing bill payment - make payment transaction"); - return Result.Failure("Error performing bill payment - make payment transaction"); - - } - - // TODO: Factory - PerformBillPaymentMakePaymentResponseModel responseModel = new() - { - EstateId = result.Data.EstateId, - MerchantId = result.Data.EstateId, - ResponseCode = result.Data.ResponseCode, - ResponseMessage = result.Data.ResponseMessage - }; - - Logger.LogInformation("Bill payment - make payment transaction performed successfully"); - - return Result.Success(responseModel); - } - - public async Task> PerformBillPaymentGetMeter(PerformBillPaymentGetMeterModel model, CancellationToken cancellationToken){ - Logger.LogInformation("About to perform bill payment get meter transaction"); - - Result result = await this.SendTransactionRequest(model.ToSaleTransactionRequest(), cancellationToken); - - if (result.IsSuccess == false) - { - Logger.LogWarning("Error performing bill payment - get meter transaction"); - return Result.Failure("Error performing bill payment - get meter transaction"); - - } - - MeterDetails meterDetails = result.Data.AdditionalResponseMetaData switch{ - null => null, - _ => result.Data.AdditionalResponseMetaData.ToMeterDetails(model.MeterNumber) - }; - - PerformBillPaymentGetMeterResponseModel responseModel = new() - { - MeterDetails = meterDetails - }; - - Logger.LogInformation("Bill payment - get meter transaction performed successfully"); - - return Result.Success(responseModel); - } - - public async Task> PerformLogon(PerformLogonRequestModel model, - CancellationToken cancellationToken) { - Logger.LogInformation("About to perform logon transaction"); - - Result result = await this.SendTransactionRequest(model.ToLogonTransactionRequest(), cancellationToken); - - if (result.IsSuccess == false) - { - Logger.LogWarning("Error performing Logon transaction"); - return Result.Failure("Error performing Logon transaction"); - } - - // TODO: Factory - PerformLogonResponseModel responseModel = new() - { - EstateId = result.Data.EstateId, - MerchantId = result.Data.MerchantId, - ResponseCode = result.Data.ResponseCode, - ResponseMessage = result.Data.ResponseMessage, - }; - - Logger.LogInformation("Logon transaction performed successfully"); - - return Result.Success(responseModel); - } - - public async Task> PerformMobileTopup(PerformMobileTopupRequestModel model, - CancellationToken cancellationToken) { - Logger.LogInformation("About to perform mobile top-up transaction"); - - Result result = - await this.SendTransactionRequest(model.ToSaleTransactionRequest(), cancellationToken); - - if (result.IsSuccess == false) { - Logger.LogWarning("Error performing Mobile top-up transaction"); - return Result.Failure("Error performing Mobile top-up transaction"); - - } - - PerformMobileTopupResponseModel responseModel = new (){ - EstateId = result.Data.EstateId, - MerchantId = result.Data.MerchantId, - ResponseCode = result.Data.ResponseCode, - ResponseMessage = result.Data.ResponseMessage - }; - - Logger.LogInformation("Mobile top-up transaction performed successfully"); - - return Result.Success(responseModel); - - } - - public async Task> PerformReconciliation(PerformReconciliationRequestModel model, - CancellationToken cancellationToken) { - Logger.LogInformation("About to perform reconciliation transaction"); - - Result result = await this.SendTransactionRequest(model.ToReconciliationRequest(), cancellationToken); - - if (result.IsSuccess == false) - { - Logger.LogWarning("Error performing Reconciliation transaction"); - return Result.Failure("Error performing Reconciliation transaction"); - - } - - // TODO: Factory - PerformReconciliationResponseModel responseModel = new() - { - EstateId = result.Data.EstateId, - MerchantId = result.Data.MerchantId, - ResponseCode = result.Data.ResponseCode, - ResponseMessage = result.Data.ResponseMessage - }; - - Logger.LogInformation("Reconciliation transaction performed successfully"); - - return Result.Success(responseModel); - - } - - public async Task> PerformVoucherIssue(PerformVoucherIssueRequestModel model, - CancellationToken cancellationToken) { - Logger.LogInformation("About to perform voucher transaction"); - - Result result = await this.SendTransactionRequest(model.ToSaleTransactionRequest(), cancellationToken); - - if (result.IsSuccess == false) - { - Logger.LogWarning("Error performing Voucher transaction"); - return Result.Failure("Error performing Voucher transaction"); - } - - PerformVoucherIssueResponseModel responseModel = new() - { - EstateId = result.Data.EstateId, - MerchantId = result.Data.MerchantId, - ResponseCode = result.Data.ResponseCode, - ResponseMessage = result.Data.ResponseMessage - }; - - Logger.LogInformation("Voucher transaction performed successfully"); - - return Result.Success(responseModel); - } - - protected override async Task> HandleResponseX(HttpResponseMessage responseMessage, - CancellationToken cancellationToken) { - if (responseMessage.StatusCode == HttpStatusCode.HttpVersionNotSupported) { - throw new ApplicationException("Application needs to be updated to the latest version"); - } - - return await base.HandleResponseX(responseMessage, cancellationToken); - } - - private String BuildRequestUrl(String route) { - String baseAddress = this.BaseAddressResolver("TransactionProcessorACL"); - - String requestUri = $"{baseAddress}{route}"; - - return requestUri; - } - - private async Task> SendTransactionRequest(TRequest request, - CancellationToken cancellationToken) { - String requestUri = this.BuildRequestUrl("/api/transactions"); - try { - String requestSerialised = JsonConvert.SerializeObject(request, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); - - StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); - - // Add the access token to the client headers - TokenResponseModel accessToken = this.ApplicationCache.GetAccessToken(); - - Logger.LogDebug($"Transaction Request details: Uri {requestUri} Payload {requestSerialised} Access Token {accessToken.AccessToken}"); - - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.AccessToken); - - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); - - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); - - if (result.IsSuccess == false) { - Logger.LogWarning("Error performing Voucher transaction"); - return Result.Failure("Error performing Voucher transaction"); - } - - Logger.LogDebug($"Transaction Response details: Status {httpResponse.StatusCode} Payload {result.Data}"); - - ResponseData responseData = this.HandleResponseContent(result.Data); - - return Result.Success(responseData.Data); - } - catch (Exception ex) { - // An exception has occurred, add some additional information to the message - Logger.LogError("Error posting transaction.", ex); - - return ResultExtensions.FailureExtended("Error posting transaction", ex); - } - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/TransactionMobile.Maui.BusinessLogic.csproj b/archive/TransactionMobile.Maui.BusinessLogic/TransactionMobile.Maui.BusinessLogic.csproj deleted file mode 100644 index 661fe4ad0..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/TransactionMobile.Maui.BusinessLogic.csproj +++ /dev/null @@ -1,91 +0,0 @@ - - - - net8.0;net8.0-android - - - - net8.0;net8.0-android;net8.0-windows10.0.19041.0 - - - - - net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst - - - - maccatalyst-x64;maccatalyst-arm64 - - - - true - true - Full - enable - - 11.0 - 13.1 - 21.0 - 10.0.17763.0 - 10.0.17763.0 - 6.5 - - - - $(DefineConstants);NET8_TARGET - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.0.0 - - - - - - 1.0.0 - - - - - - 1.0.0 - - - - - - 1.0.0 - - - - - - - - - diff --git a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/IApplicationInfoService.cs b/archive/TransactionMobile.Maui.BusinessLogic/UIServices/IApplicationInfoService.cs deleted file mode 100644 index 03a4e00bd..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/IApplicationInfoService.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.UIServices; - -public interface IApplicationInfoService -{ - String BuildString { get; } - - String ApplicationName { get; } - - String PackageName { get; } - - String Theme { get; } - - Version Version { get; } - - String VersionString { get; } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/IDeviceService.cs b/archive/TransactionMobile.Maui.BusinessLogic/UIServices/IDeviceService.cs deleted file mode 100644 index 2bbc9e29b..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/IDeviceService.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.UIServices -{ - public interface IDeviceService - { - String GetIdentifier(); - - String GetModel(); - - String GetPlatform(); - - Boolean IsIOS(); - - String GetManufacturer(); - - void SetOrientation(Orientation displayOrientation); - } - - public enum Orientation { - Unknown = 0, - Portrait = 1, - Landscape = 2 - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/IDialogService.cs b/archive/TransactionMobile.Maui.BusinessLogic/UIServices/IDialogService.cs deleted file mode 100644 index f9229ac79..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/IDialogService.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.UIServices; - - -public interface IDialogService -{ - #region Methods - - Task ShowDialog(String title, - String message, - String acceptString); - - Task ShowDialog(String title, - String message, - String acceptString, - String cancelString); - - Task ShowErrorToast(String message, - Action? action = null, - String? actionButtonText = "OK", - TimeSpan? duration = null, - CancellationToken cancellationToken = default); - - Task ShowInformationToast(String message, - Action? action = null, - String? actionButtonText = "OK", - TimeSpan? duration = null, - CancellationToken cancellationToken = default); - - //Task ShowPrompt(String title, - // String message, - // String acceptString, - // String cancelString, - // String placeHolder = "", - // Int32 maxLength = -1, - // Keyboard keyboard = null, - // String initialValue = ""); - - Task ShowWarningToast(String message, - Action? action = null, - String? actionButtonText = "OK", - TimeSpan? duration = null, - CancellationToken cancellationToken = default); - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/INavigationParameterService.cs b/archive/TransactionMobile.Maui.BusinessLogic/UIServices/INavigationParameterService.cs deleted file mode 100644 index 7677720a4..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/INavigationParameterService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TransactionMobile.Maui.UIServices; - -public interface INavigationParameterService -{ - void SetParameters(IDictionary parameters); - IDictionary GetParameters(); -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/INavigationService.cs b/archive/TransactionMobile.Maui.BusinessLogic/UIServices/INavigationService.cs deleted file mode 100644 index a84d4a88f..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/INavigationService.cs +++ /dev/null @@ -1,69 +0,0 @@ -namespace TransactionMobile.Maui.UIServices; - -using BusinessLogic.ViewModels.Transactions; - -public interface INavigationService -{ - #region Methods - - Task QuitApplication(); - Task GoBack(); - - Task GoToHome(); - - Task GoToMobileTopupFailedPage(); - - Task GoToMobileTopupPerformTopupPage(ProductDetails productDetails, - Decimal topupAmount); - - Task GoToMobileTopupSelectOperatorPage(); - - Task GoToBillPaymentSelectOperatorPage(); - - Task GoToBillPaymentSelectProductPage(ProductDetails productDetails); - - Task GoToAdminPage(); - - Task GoToMobileTopupSelectProductPage(ProductDetails productDetails); - - Task GoToMobileTopupSuccessPage(); - - Task GoToVoucherIssueSuccessPage(); - - Task GoToVoucherIssueFailedPage(); - - Task GoToBillPaymentSuccessPage(); - - Task GoToBillPaymentFailedPage(); - - Task PopToRoot(); - - Task GoToVoucherSelectOperatorPage(); - - Task GoToVoucherSelectProductPage(ProductDetails productDetails); - - Task GoToVoucherIssueVoucherPage(ProductDetails productDetails, - Decimal voucherAmount); - - Task GoToBillPaymentGetAccountPage(ProductDetails productDetails); - - Task GoToBillPaymentGetMeterPage(ProductDetails productDetails); - Task GoToBillPaymentPayBillPage(ProductDetails productDetails, - BillDetails billDetails); - - Task GoToBillPaymentPayBillPage(ProductDetails productDetails, - MeterDetails meterDetails); - - Task GoToLoginPage(); - - Task GoToViewLogsPage(); - - Task GoToMyAccountAddresses(); - Task GoToMyAccountContacts(); - Task GoToMyAccountDetails(); - - Task GoToReportsSalesAnalysis(); - Task GoToReportsBalanceAnalysis(); - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/NavigationParameterService.cs b/archive/TransactionMobile.Maui.BusinessLogic/UIServices/NavigationParameterService.cs deleted file mode 100644 index 90a43e0ad..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/UIServices/NavigationParameterService.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace TransactionMobile.Maui.UIServices; - -[ExcludeFromCodeCoverage] -public class NavigationParameterService : INavigationParameterService -{ - private IDictionary parameters; - public void SetParameters(IDictionary parameters) - { - this.parameters = parameters; - } - public IDictionary GetParameters() - { - return this.parameters; - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Admin/AdminPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Admin/AdminPageViewModel.cs deleted file mode 100644 index d3d1cd29f..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Admin/AdminPageViewModel.cs +++ /dev/null @@ -1,63 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Admin -{ - using System.Windows.Input; - using Common; - using Logging; - using Maui.UIServices; - using MediatR; - using Microsoft.Extensions.Caching.Memory; - using Models; - using MvvmHelpers; - using MvvmHelpers.Commands; - using RequestHandlers; - using Requests; - using Services; - using SimpleResults; - using TransactionProcessorACL.DataTransferObjects.Responses; - using UIServices; - - public class AdminPageViewModel : ExtendedBaseViewModel - { - private readonly IMediator Mediator; - - private readonly IApplicationInfoService ApplicationInfoService; - - #region Constructors - - public AdminPageViewModel(IMediator mediator, INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, IApplicationInfoService applicationInfoService, - INavigationParameterService navigationParameterService) : - base(applicationCache,dialogService, navigationService, deviceService, navigationParameterService) - { - this.Mediator = mediator; - this.ApplicationInfoService = applicationInfoService; - this.ReconciliationCommand = new AsyncCommand(this.ReconciliationCommandExecute); - this.Title = "Select Admin Transaction Type"; - } - - #endregion - - #region Properties - - public ICommand ReconciliationCommand { get; set; } - - #endregion - - #region Methods - - private async Task ReconciliationCommandExecute() - { - PerformReconciliationRequest request = - PerformReconciliationRequest.Create(DateTime.Now, String.Empty, this.ApplicationInfoService.VersionString); - - Result result = await this.Mediator.Send(request); - - // TODO: Act on the response (display message or something)... - await this.NavigationService.GoToHome(); - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/ExtendedBaseViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/ExtendedBaseViewModel.cs deleted file mode 100644 index 95aace533..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/ExtendedBaseViewModel.cs +++ /dev/null @@ -1,108 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels; - -using System.Windows.Input; -using Logging; -using Maui.UIServices; -using MvvmHelpers; -using MvvmHelpers.Commands; -using MyAccount; -using Reports; -using Services; -using SimpleResults; -using Support; -using Transactions; -using UIServices; - -public class ExtendedBaseViewModel : BaseViewModel -{ - #region Fields - - protected readonly IApplicationCache ApplicationCache; - - protected readonly IDialogService DialogService; - - protected readonly INavigationService NavigationService; - - protected readonly IDeviceService DeviceService; - protected readonly INavigationParameterService NavigationParameterService; - - #endregion - - #region Constructors - - public ExtendedBaseViewModel(IApplicationCache applicationCache, - IDialogService dialogService, - INavigationService navigationService, - IDeviceService deviceService, - INavigationParameterService navigationParameterService, - Orientation orientation = Orientation.Portrait) { - this.NavigationService = navigationService; - this.DeviceService = deviceService; - this.NavigationParameterService = navigationParameterService; - this.ApplicationCache = applicationCache; - this.DialogService = dialogService; - this.BackButtonCommand = new AsyncCommand(this.BackButtonCommandExecute); - this.Orientation = orientation; - } - - #endregion - - #region Properties - - public ICommand BackButtonCommand { get; } - - public virtual async Task Initialise(CancellationToken cancellationToken) { - this.DeviceService.SetOrientation(this.Orientation); - } - - public Orientation Orientation { get; private set; } - - #endregion - - #region Methods - - protected async Task BackButtonCommandExecute() { - Type type = this.GetType().UnderlyingSystemType; - Task t = type.Name switch { - nameof(TransactionsPageViewModel) => this.ShowHomePage(), - nameof(MyAccountPageViewModel) => this.ShowHomePage(), - nameof(ReportsPageViewModel) => this.ShowHomePage(), - nameof(SupportPageViewModel) => this.ShowHomePage(), - nameof(HomePageViewModel) => this.ShowLoginPage(), - nameof(LoginPageViewModel) => this.NavigationService.QuitApplication(), - _ => this.NavigationService.GoBack() - }; - await t; - } - - private async Task ShowHomePage() { - await this.NavigationService.GoToHome(); - } - - private async Task ShowLoginPage() { - - Boolean leave = await this.DialogService.ShowDialog("Title", "Logout Message", "yes", "no"); - if (leave) { - Logger.LogInformation("LogoutCommand called"); - this.ApplicationCache.SetIsLoggedIn(false); - this.ApplicationCache.SetAccessToken(null); - - await this.NavigationService.GoToLoginPage(); - } - } - - public virtual void HandleResult(Result result) - { - if (result == null) { - throw new ApplicationException("Result from function call was null"); - } - - if (result.IsFailed) - { - throw new ApplicationException(result.Message); - } - // Success so carry on - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/HomePageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/HomePageViewModel.cs deleted file mode 100644 index de2bc28a8..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/HomePageViewModel.cs +++ /dev/null @@ -1,121 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels; - -using System.Diagnostics.CodeAnalysis; -using Logging; -using Maui.UIServices; -#if !IOS -using Microsoft.AppCenter; -using Microsoft.AppCenter.Distribute; -#endif -using Models; -using Services; -using UIServices; - -[ExcludeFromCodeCoverage] -public class HomePageViewModel : ExtendedBaseViewModel -{ - #region Constructors - - public HomePageViewModel(IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - INavigationService navigationService, - INavigationParameterService navigationParameterService) :base(applicationCache,dialogService, navigationService, deviceService,navigationParameterService) - { - - } - - public async Task ShowDebugMessage(String message) { - Configuration configuration = this.ApplicationCache.GetConfiguration(); - - if (configuration.ShowDebugMessages) - { - await this.DialogService.ShowDialog("Debug", message, "OK"); - } - } - - #endregion - - #region Methods - -#if !IOS - public async Task Initialise(CancellationToken cancellationToken) { - Configuration configuration = this.ApplicationCache.GetConfiguration(); - - if (configuration.EnableAutoUpdates) { - await Distribute.SetEnabledAsync(true); - Distribute.ReleaseAvailable = this.OnReleaseAvailable; - Distribute.NoReleaseAvailable = NoReleaseAvailable; - Distribute.UpdateTrack = UpdateTrack.Public; - Distribute.CheckForUpdate(); - } - else { - Distribute.DisableAutomaticCheckForUpdate(); - } - - try { - if (this.DeviceService.IsIOS() == false) { - AppCenter.Start(configuration.AppCenterConfig.GetAppCenterKey(), typeof(Distribute)); - } - } - catch(Exception ex) { - Logger.LogError("Error during initialise", ex); - } - } -#endif - - private async void NoReleaseAvailable() { - await this.DialogService.ShowDialog("Software Update", "No Release Available","OK"); - } - - -#if !IOS - private Boolean OnReleaseAvailable(ReleaseDetails releaseDetails) { - Logger.LogInformation("In OnReleaseAvailable"); - // Look at releaseDetails public properties to get version information, release notes text or release notes URL - String versionName = releaseDetails.ShortVersion; - String versionCodeOrBuildNumber = releaseDetails.Version; - String releaseNotes = releaseDetails.ReleaseNotes; - Uri releaseNotesUrl = releaseDetails.ReleaseNotesUrl; - - // custom dialog - String title = "Version " + versionName + " available!"; - Task answer; - - // On mandatory update, user can't postpone - if (releaseDetails.MandatoryUpdate) - { - Logger.LogInformation("In OnReleaseAvailable - mandatory update"); - answer = this.DialogService.ShowDialog(title, releaseNotes, "Download and Install"); - } - else - { - Logger.LogInformation("In OnReleaseAvailable - non mandatory update"); - answer = this.DialogService.ShowDialog(title, releaseNotes, "Download and Install", "Later"); - } - - answer.ContinueWith(task => - { - // If mandatory or if answer was positive - if (releaseDetails.MandatoryUpdate || (task as Task).Result) - { - Logger.LogInformation("In OnReleaseAvailable - updating"); - // Notify SDK that user selected update - Distribute.NotifyUpdateAction(UpdateAction.Update); - } - else - { - // Notify SDK that user selected postpone (for 1 day) - // This method call is ignored by the SDK if the update is mandatory - Logger.LogInformation("In OnReleaseAvailable - postponing"); - Distribute.NotifyUpdateAction(UpdateAction.Postpone); - } - }); - - // Return true if you're using your own dialog, false otherwise - return true; - } -#endif - -#endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/LoginPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/LoginPageViewModel.cs deleted file mode 100644 index 26cac7652..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/LoginPageViewModel.cs +++ /dev/null @@ -1,249 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels -{ - using System.Diagnostics; - using System.Diagnostics.CodeAnalysis; - using System.Windows.Input; - using Common; - using Logging; - using Maui.UIServices; - using MediatR; - using Microsoft.Extensions.Caching.Memory; - using Microsoft.Extensions.Logging; - using Microsoft.Extensions.Primitives; - using Models; - using MvvmHelpers; - using MvvmHelpers.Commands; - using Newtonsoft.Json; - using RequestHandlers; - using Requests; - using Services; - using SimpleResults; - using TransactionMobile.Maui.Database; - using UIServices; - - public class LoginPageViewModel : ExtendedBaseViewModel - { - private readonly IApplicationInfoService ApplicationInfoService; - - private String userName; - - private String password; - - private String configHostUrl; - - private Boolean useTrainingMode; - - #region Constructors - - public LoginPageViewModel(IMediator mediator, INavigationService navigationService, IApplicationCache applicationCache, - IDeviceService deviceService,IApplicationInfoService applicationInfoService, - IDialogService dialogService, - INavigationParameterService navigationParameterService) : base(applicationCache,dialogService,navigationService, deviceService, navigationParameterService) - { - this.ApplicationInfoService = applicationInfoService; - this.LoginCommand = new AsyncCommand(this.LoginCommandExecute); - this.Mediator = mediator; - } - - #endregion - - #region Properties - - public ICommand LoginCommand { get; } - - public IMediator Mediator { get; } - - public String UserName - { - get => this.userName; - set => this.SetProperty(ref this.userName, value); - } - - public String Password - { - get => this.password; - set => this.SetProperty(ref this.password, value); - } - - public Boolean UseTrainingMode - { - get => this.useTrainingMode; - set => this.SetProperty(ref this.useTrainingMode, value); - } - - public String DeviceIdentifier => this.DeviceService.GetIdentifier(); - - public String ConfigHostUrl - { - get => this.configHostUrl; - set => this.SetProperty(ref this.configHostUrl, value); - } - - #endregion - - #region Methods - private void CacheUseTrainingMode() => this.ApplicationCache.SetUseTrainingMode(this.useTrainingMode); - - private async Task> GetConfiguration() { - if (String.IsNullOrEmpty(ConfigHostUrl) == false) { - this.ApplicationCache.SetConfigHostUrl(ConfigHostUrl); - } - - GetConfigurationRequest getConfigurationRequest = GetConfigurationRequest.Create(this.DeviceService.GetIdentifier()); - Result configurationResult = await this.Mediator.Send(getConfigurationRequest); - - if (configurationResult.IsSuccess) { - // Cache the config object - this.ApplicationCache.SetConfiguration(configurationResult.Data); - } - - return configurationResult; - } - - private async Task> GetUserToken() { - LoginRequest loginRequest = LoginRequest.Create(this.UserName, this.Password); - Result tokenResult = await this.Mediator.Send(loginRequest); - - if (tokenResult.IsSuccess) { - // Cache the token - this.CacheAccessToken(tokenResult.Data); - } - - return tokenResult; - } - - private async Task> PerformLogonTransaction() { - // Logon Transaction - LogonTransactionRequest logonTransactionRequest = LogonTransactionRequest.Create(DateTime.Now); - Result logonResult = await this.Mediator.Send(logonTransactionRequest); - - if (logonResult.IsSuccess) { - // Set the user information - this.ApplicationCache.SetEstateId(logonResult.Data.EstateId); - this.ApplicationCache.SetMerchantId(logonResult.Data.MerchantId); - } - - return logonResult; - } - - private async Task>> GetMerchantContractProducts() { - // Get Contracts - GetContractProductsRequest getContractProductsRequest = GetContractProductsRequest.Create(); - Result> productsResult = await this.Mediator.Send(getContractProductsRequest); - - if (productsResult.IsSuccess) { - this.CacheContractData(productsResult.Data); - } - - return productsResult; - } - - private void CacheContractData(List contractProductModels) - { - DateTime expirationTime = DateTime.Now.AddMinutes(60); - CancellationChangeToken expirationToken = new CancellationChangeToken(new CancellationTokenSource(TimeSpan.FromMinutes(60)).Token); - MemoryCacheEntryOptions cacheEntryOptions = new MemoryCacheEntryOptions() - // Pin to cache. - .SetPriority(CacheItemPriority.NeverRemove) - // Set the actual expiration time - .SetAbsoluteExpiration(expirationTime) - // Force eviction to run - .AddExpirationToken(expirationToken); - - this.ApplicationCache.SetContractProducts(contractProductModels, cacheEntryOptions); - } - - private async Task> GetMerchantBalance() { - // Get the merchant balance - // TODO: Cache the result, but will add this to a timer call to keep up to date... - GetMerchantBalanceRequest getMerchantBalanceRequest = GetMerchantBalanceRequest.Create(); - Result getMerchantBalanceResult = await this.Mediator.Send(getMerchantBalanceRequest); - - return getMerchantBalanceResult; - } - - private async Task LoginCommandExecute(){ - this.CacheUseTrainingMode(); - - Stopwatch sw = Stopwatch.StartNew(); - WriteTimingTrace(sw, "Start of LoginCommandExecute"); - try { - Logger.LogInformation("LoginCommandExecute called"); - - Result configurationResult = await this.GetConfiguration(); - this.HandleResult(configurationResult); - - await WriteTimingTrace(sw, "After GetConfiguration"); - Result getTokenResult = await this.GetUserToken(); - this.HandleResult(getTokenResult); - - await WriteTimingTrace(sw, "After GetUserToken"); - Result logonResult = await this.PerformLogonTransaction(); - this.HandleResult(logonResult); - - await WriteTimingTrace(sw, "After PerformLogonTransaction"); - Result> getMerchantContractProductsResult = await this.GetMerchantContractProducts(); - this.HandleResult(getMerchantContractProductsResult); - - await WriteTimingTrace(sw, "After GetMerchantContractProducts"); - Result getMerchantBalanceResult = await this.GetMerchantBalance(); - this.HandleResult(getMerchantBalanceResult); - - await WriteTimingTrace(sw, "After GetMerchantBalance"); - this.ApplicationCache.SetIsLoggedIn(true); - - await WriteTimingTrace(sw, "After SetIsLoggedIn"); - await this.NavigationService.GoToHome(); - } - catch(ApplicationException aex) { - Logger.LogError("Error during logon", aex); - await this.DialogService.ShowWarningToast(aex.Message); - } - } - - private async Task WriteTimingTrace(Stopwatch sw, String message) { - sw.Stop(); - Logger.LogWarning($"{message} - Elapsed ms [{sw.ElapsedMilliseconds}]"); - sw.Start(); - } - - [ExcludeFromCodeCoverage] - private async void AccessTokenExpired(Object key, - Object value, - EvictionReason reason, - Object state) - { - if (reason == EvictionReason.Expired || reason == EvictionReason.TokenExpired) - { - // access token has expired need to make another call to get new one - TokenResponseModel token = value as TokenResponseModel; - - RefreshTokenRequest request = RefreshTokenRequest.Create(token.RefreshToken); - Result newTokenResult = await this.Mediator.Send(request, CancellationToken.None); - - if (newTokenResult.IsSuccess) { - this.CacheAccessToken(newTokenResult.Data); - } - } - } - - private void CacheAccessToken(TokenResponseModel token) - { - DateTime expirationTime = DateTime.Now.AddMinutes(token.ExpiryInMinutes).AddSeconds(-30); - CancellationChangeToken expirationToken = new CancellationChangeToken(new CancellationTokenSource(TimeSpan.FromMinutes(token.ExpiryInMinutes).Add(TimeSpan.FromSeconds(-30))).Token); - MemoryCacheEntryOptions cacheEntryOptions = new MemoryCacheEntryOptions() - // Pin to cache. - .SetPriority(CacheItemPriority.NeverRemove) - // Set the actual expiration time - .SetAbsoluteExpiration(expirationTime) - // Force eviction to run - .AddExpirationToken(expirationToken) - // Add eviction callback - .RegisterPostEvictionCallback(callback:this.AccessTokenExpired); - - this.ApplicationCache.SetAccessToken(token, cacheEntryOptions); - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountAddressPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountAddressPageViewModel.cs deleted file mode 100644 index 360773d03..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountAddressPageViewModel.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.MyAccount; - -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using Services; -using UIServices; - -public class MyAccountAddressPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private AddressModel address; - - private readonly IMediator Mediator; - - #endregion - - #region Constructors - - public MyAccountAddressPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - IMediator mediator, INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService,navigationParameterService) { - this.Mediator = mediator; - this.Title = "My Addresses"; - } - - #endregion - - #region Properties - - public AddressModel Address { - get => this.address; - set => this.SetProperty(ref this.address, value); - } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken cancellationToken) { - MerchantDetailsModel merchantDetails = this.ApplicationCache.GetMerchantDetails(); - - // TODO: handle a null - - this.Address = merchantDetails.Address; - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountContactPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountContactPageViewModel.cs deleted file mode 100644 index a64ceb2b1..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountContactPageViewModel.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.MyAccount; - -using Logging; -using Maui.UIServices; -using MediatR; -using MvvmHelpers; -using Services; -using TransactionMobile.Maui.BusinessLogic.Models; -using TransactionMobile.Maui.BusinessLogic.UIServices; - -public class MyAccountContactPageViewModel : ExtendedBaseViewModel -{ - private ContactModel contact; - - public ContactModel Contact { - get => this.contact; - set => this.SetProperty(ref this.contact, value); - } - - #region Constructors - - public MyAccountContactPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) { - this.Title = "My Contacts"; - } - - - #endregion - - #region Properties - - #endregion - - public async Task Initialise(CancellationToken none) { - MerchantDetailsModel merchantDetails = this.ApplicationCache.GetMerchantDetails(); - - // TODO: handle a null - this.Contact = merchantDetails.Contact; - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountDetailsPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountDetailsPageViewModel.cs deleted file mode 100644 index d722d387e..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountDetailsPageViewModel.cs +++ /dev/null @@ -1,89 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.MyAccount; - -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using MvvmHelpers; -using Services; -using UIServices; - -public class MyAccountDetailsPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private Decimal availableBalance; - - private Decimal balance; - - private DateTime lastStatementDate; - - private String merchantName; - - private DateTime nextStatementDate; - - private String settlementSchedule; - - #endregion - - #region Constructors - - public MyAccountDetailsPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) { - this.Title = "My Details"; - } - - #endregion - - #region Properties - - public Decimal AvailableBalance { - get => this.availableBalance; - set => this.SetProperty(ref this.availableBalance, value); - } - - public Decimal Balance { - get => this.balance; - set => this.SetProperty(ref this.balance, value); - } - - public DateTime LastStatementDate { - get => this.lastStatementDate; - set => this.SetProperty(ref this.lastStatementDate, value); - } - - public String MerchantName { - get => this.merchantName; - set => this.SetProperty(ref this.merchantName, value); - } - - public DateTime NextStatementDate { - get => this.nextStatementDate; - set => this.SetProperty(ref this.nextStatementDate, value); - } - - public String SettlementSchedule { - get => this.settlementSchedule; - set => this.SetProperty(ref this.settlementSchedule, value); - } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken none) { - MerchantDetailsModel merchantDetails = this.ApplicationCache.GetMerchantDetails(); - - this.Balance = merchantDetails.Balance; - this.AvailableBalance = merchantDetails.AvailableBalance; - this.NextStatementDate = merchantDetails.NextStatementDate; - this.LastStatementDate = merchantDetails.LastStatementDate; - this.MerchantName = merchantDetails.MerchantName; - this.SettlementSchedule = merchantDetails.SettlementSchedule; - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountPageViewModel.cs deleted file mode 100644 index 7bc2cccb7..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/MyAccount/MyAccountPageViewModel.cs +++ /dev/null @@ -1,142 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.MyAccount -{ - using System.Windows.Input; - using Common; - using Logging; - using Maui.UIServices; - using MediatR; - using Microsoft.Extensions.Caching.Memory; - using Microsoft.Extensions.Primitives; - using Models; - using MvvmHelpers; - using MvvmHelpers.Commands; - using RequestHandlers; - using Requests; - using Services; - using SimpleResults; - using UIServices; - - public class MyAccountPageViewModel : ExtendedBaseViewModel - { - #region Fields - - private DateTime lastLogin; - - private readonly IMediator Mediator; - - private String merchantName; - - #endregion - - #region Constructors - - public MyAccountPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - IMediator mediator, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService,navigationParameterService) { - this.Mediator = mediator; - this.OptionSelectedCommand = new AsyncCommand>(this.OptionSelectedCommandExecute); - this.Title = "My Account"; - } - - #endregion - - #region Properties - - public DateTime LastLogin { - get => this.lastLogin; - set => this.SetProperty(ref this.lastLogin, value); - } - - public String MerchantName { - get => this.merchantName; - set => this.SetProperty(ref this.merchantName, value); - } - - public List MyAccountOptions { get; set; } - - public ICommand OptionSelectedCommand { get; set; } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken cancellationToken) { - this.MyAccountOptions = new List { - new ListViewItem { - Title = "Addresses" - }, - new ListViewItem { - Title = "Contacts" - }, - new ListViewItem { - Title = "Account Info" - }, - new ListViewItem { - Title = "Logout" - } - }; - - GetMerchantDetailsRequest request = GetMerchantDetailsRequest.Create(); - - Result merchantDetailsResult = await this.Mediator.Send(request, cancellationToken); - // TODO: handle failure result - this.MerchantName = merchantDetailsResult.Data.MerchantName; - - DateTime expirationTime = DateTime.Now.AddMinutes(60); - CancellationChangeToken expirationToken = new CancellationChangeToken(new CancellationTokenSource(TimeSpan.FromMinutes(60)).Token); - MemoryCacheEntryOptions cacheEntryOptions = new MemoryCacheEntryOptions() - // Pin to cache. - .SetPriority(CacheItemPriority.NeverRemove) - // Set the actual expiration time - .SetAbsoluteExpiration(expirationTime) - // Force eviction to run - .AddExpirationToken(expirationToken); - - this.ApplicationCache.SetMerchantDetails(merchantDetailsResult.Data, cacheEntryOptions); - - this.LastLogin = DateTime.Now; // TODO: might cache this in the application - } - - private async Task LogoutCommandExecute() { - Logger.LogInformation("LogoutCommand called"); - this.ApplicationCache.SetAccessToken(null); - this.ApplicationCache.SetIsLoggedIn(false); - - await this.NavigationService.GoToLoginPage(); - } - - private async Task OptionSelectedCommandExecute(ItemSelected arg) { - AccountOptions selectedOption = (AccountOptions)arg.SelectedItemIndex; - - Task navigationTask = selectedOption switch { - AccountOptions.Addresses => this.NavigationService.GoToMyAccountAddresses(), - AccountOptions.Contacts => this.NavigationService.GoToMyAccountContacts(), - AccountOptions.AccountInfo => this.NavigationService.GoToMyAccountDetails(), - AccountOptions.Logout => this.LogoutCommandExecute(), - _ => Task.Factory.StartNew(() => Logger.LogWarning($"Unsupported option selected {selectedOption}")) - }; - - await navigationTask; - } - - #endregion - - #region Others - - public enum AccountOptions - { - Addresses = 0, - - Contacts = 1, - - AccountInfo = 2, - - Logout = 3 - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Reports/ReportsPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Reports/ReportsPageViewModel.cs deleted file mode 100644 index e859307f8..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Reports/ReportsPageViewModel.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Reports -{ - using System.Windows.Input; - using Common; - using Logging; - using Maui.UIServices; - using MediatR; - using Microsoft.Extensions.Caching.Memory; - using Microsoft.Extensions.Primitives; - using Models; - using MvvmHelpers.Commands; - using MyAccount; - using RequestHandlers; - using Requests; - using Services; - using UIServices; - - public class ReportsPageViewModel : ExtendedBaseViewModel - { - #region Fields - - private readonly IMediator Mediator; - - #endregion - - #region Constructors - - public ReportsPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - IMediator mediator, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService,navigationParameterService) - { - this.Mediator = mediator; - this.OptionSelectedCommand = new AsyncCommand>(this.OptionSelectedCommandExecute); - this.Title = "Reports"; - } - - #endregion - - #region Properties - - public List ReportsMenuOptions { get; set; } - - public ICommand OptionSelectedCommand { get; set; } - - #endregion - - #region Methods - - public override async Task Initialise(CancellationToken cancellationToken) - { - this.ReportsMenuOptions = new List { - new ListViewItem { - Title = "Sales Analysis" - }, - new ListViewItem { - Title = "Balance Analysis" - } - }; - await base.Initialise(cancellationToken); - } - - private async Task OptionSelectedCommandExecute(ItemSelected arg) - { - ReportsOptions selectedOption = (ReportsOptions)arg.SelectedItemIndex; - - Task navigationTask = selectedOption switch - { - ReportsOptions.SalesAnalysis => this.NavigationService.GoToReportsSalesAnalysis(), - ReportsOptions.BalanceAnalysis => this.NavigationService.GoToReportsBalanceAnalysis(), - _ => Task.Factory.StartNew(() => Logger.LogWarning($"Unsupported option selected {selectedOption}")) - }; - - await navigationTask; - } - - #endregion - - #region Others - - public enum ReportsOptions - { - SalesAnalysis = 0, - - BalanceAnalysis = 1, - } - - #endregion - } -} diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Reports/ReportsSalesAnalysisPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Reports/ReportsSalesAnalysisPageViewModel.cs deleted file mode 100644 index 80e89c0c5..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Reports/ReportsSalesAnalysisPageViewModel.cs +++ /dev/null @@ -1,150 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Reports; - -using Maui.UIServices; -using MediatR; -using Services; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using MvvmHelpers.Commands; -using UIServices; -using System.Windows.Input; -using LiveChartsCore; -using LiveChartsCore.SkiaSharpView; -using LiveChartsCore.Defaults; -using LiveChartsCore.Kernel.Sketches; -using LiveChartsCore.Measure; - -public class ReportsSalesAnalysisPageViewModel : ExtendedBaseViewModel{ - - private readonly IMediator Mediator; - public ReportsSalesAnalysisPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - IMediator mediator, INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService,navigationParameterService) - { - this.Mediator = mediator; - this.ComparisonDatePickerSelectedIndexChangedCommand = new AsyncCommand(this.ComparisonDatePickerSelectedExecute); - this.Title = "Sales Analysis"; - } - - public ICommand ComparisonDatePickerSelectedIndexChangedCommand { get; } - - private async Task ComparisonDatePickerSelectedExecute(ComparisonDate selectedDate){ - // TODO: we will re fire the api calls here on a date change - await this.GetApiData(); - } - - private async Task GetApiData(){ - // TODO: Initial api call to get data would be done here - List salesAnalysisList = new List(); - salesAnalysisList.Add(new SalesAnalysis("100.00 KES", "90.00 KES", "10%", "Sales Value", "Today's Sales", SelectedItem.DisplayText, "Variance:","salesvalue.png")); - salesAnalysisList.Add(new SalesAnalysis("100", "90", "10%", "Sales Count", "Today's Sales", SelectedItem.DisplayText, "Variance:", "salescount.png")); - this.SalesAnalysisList = salesAnalysisList; - } - - - private List comparisonDates; - - ComparisonDate _selectedItem; - - private List salesAnalysisList; - - public ComparisonDate SelectedItem - { - get => _selectedItem; - set => SetProperty(ref _selectedItem, value); - } - - public List SalesAnalysisList - { - get => this.salesAnalysisList; - set => this.SetProperty(ref this.salesAnalysisList, value); - } - - public List ComparisonDates - { - get => this.comparisonDates; - set => this.SetProperty(ref this.comparisonDates, value); - } - - public override async Task Initialise(CancellationToken cancellationToken){ - await base.Initialise(cancellationToken); - // TODO: This list will come from an api call - List dates = new List(); - dates.Add(new ComparisonDate(new DateTime(2024,1,12), "Yesterday")); - dates.Add(new ComparisonDate(new DateTime(2024,1,11), "2024-01-11")); - dates.Add(new ComparisonDate(new DateTime(2024,1,10), "2024-01-10")); - this.ComparisonDates = dates; - } - -} - -[ExcludeFromCodeCoverage] -public record ComparisonDate(DateTime DateTime, String DisplayText); - -[ExcludeFromCodeCoverage] -public record SalesAnalysis(String TodaysValue, String ComparisonValue, String VarianceValue, String MainTitle, String TodaysTitle, String ComparisonTitle, String VarianceTitle, String Icon); - -public class ReportsBalanceAnalysisPageViewModel : ExtendedBaseViewModel{ - private readonly IMediator Mediator; - - public ReportsBalanceAnalysisPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - IMediator mediator, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService, Orientation.Landscape) - { - this.Mediator = mediator; - this.Title = "Balance Analysis"; - } - - public async Task Initialise(CancellationToken cancellationToken){ - await base.Initialise(cancellationToken); - - DateTimeAxis axis1 = new DateTimeAxis(TimeSpan.FromDays(1), (d) => d.ToString("dd/MM/yyyy")); - this.XAxes = new List{ - axis1 - }; - - Axis axis2 = new Axis(); - axis2.Labeler = Labelers.Currency; - - this.YAxes = new List{ - axis2 - }; - - this.TooltipFindingStrategy = LiveChartsCore.Measure.TooltipFindingStrategy.CompareOnlyX; - this.TooltipPosition = LiveChartsCore.Measure.TooltipPosition.Top; - - this.Series = new ISeries[]{ - new LineSeries{ - - Values = new List{ - new DateTimePoint(new DateTime(2024, 1, 7), 1985), - new DateTimePoint(new DateTime(2024, 1, 8), 3882), - new DateTimePoint(new DateTime(2024, 1, 11), 2511), - new DateTimePoint(new DateTime(2024, 1, 15), 3905), - new DateTimePoint(new DateTime(2024, 1, 20), 4256) - }, - Fill = null, - Name = "Balance", - TooltipLabelFormatter = - (chartPoint) => $"{chartPoint.Context.Series.Name}: {chartPoint.PrimaryValue}" - } - }; - } - - public TooltipPosition TooltipPosition{ get; set; } - - public List YAxes{ get; set; } - - public List XAxes{ get; set; } - - public ISeries[] Series { get; set; } - - public TooltipFindingStrategy TooltipFindingStrategy { get; set; } - - -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Support/SupportPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Support/SupportPageViewModel.cs deleted file mode 100644 index 2005aa379..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Support/SupportPageViewModel.cs +++ /dev/null @@ -1,93 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Support -{ - using System.Text; - using System.Windows.Input; - using Database; - using Logging; - using Maui.UIServices; - using MediatR; - using MvvmHelpers; - using MvvmHelpers.Commands; - using Requests; - using Services; - using UIServices; - - public class SupportPageViewModel : ExtendedBaseViewModel - { - #region Fields - - private readonly IApplicationInfoService ApplicationInfoService; - - private readonly IDatabaseContext DatabaseContext; - - private readonly IMediator Mediator; - - #endregion - - #region Constructors - - public SupportPageViewModel(IDeviceService deviceService, - IApplicationInfoService applicationInfoService, - IDatabaseContext databaseContext, - IMediator mediator, - INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService,navigationParameterService) - { - this.ApplicationInfoService = applicationInfoService; - this.DatabaseContext = databaseContext; - this.UploadLogsCommand = new AsyncCommand(this.UploadLogsCommandExecute); - this.ViewLogsCommand = new AsyncCommand(this.ViewLogsCommandExecute); - this.Mediator = mediator; - this.Title = "Support"; - } - - #endregion - - #region Properties - - public String ApplicationName => $"{this.ApplicationInfoService.ApplicationName} v{this.ApplicationInfoService.VersionString}"; - - public String NumberTransactionsStored => $"Transactions Stored: {this.DatabaseContext.GetTransactions(this.ApplicationCache.GetUseTrainingMode()).Result.Count()}"; - - public String Platform { - get { - StringBuilder platform = new(); - platform.Append("Platform: ").AppendLine(this.DeviceService.GetPlatform()); - platform.Append("Manufacturer: ").AppendLine(this.DeviceService.GetManufacturer()); - platform.Append("Device: ").AppendLine(this.DeviceService.GetModel()); - - return platform.ToString(); - } - } - - public ICommand UploadLogsCommand { get; } - - public ICommand ViewLogsCommand { get; } - - #endregion - - #region Methods - - private async Task UploadLogsCommandExecute() { - Logger.LogInformation("UploadLogsCommandExecute called"); - - UploadLogsRequest uploadLogsRequest = UploadLogsRequest.Create(String.Empty); - - Boolean response = await this.Mediator.Send(uploadLogsRequest, CancellationToken.None); - - // TODO: Act on the response (display message or something)... - //await this.NavigationService.GoBack(); - } - - private async Task ViewLogsCommandExecute() { - Logger.LogInformation("ViewLogsCommandExecute called"); - - // TODO: Act on the response (display message or something)... - await this.NavigationService.GoToViewLogsPage(); - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Support/ViewLogsPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Support/ViewLogsPageViewModel.cs deleted file mode 100644 index d3bb03f11..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Support/ViewLogsPageViewModel.cs +++ /dev/null @@ -1,63 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Support; - -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using MvvmHelpers; -using Requests; -using Services; -using UIServices; - -public class ViewLogsPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private readonly IMediator Mediator; - - #endregion - - #region Constructors - - public ViewLogsPageViewModel(IMediator mediator, INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) { - this.Mediator = mediator; - this.Title = "View Logs"; - } - - #endregion - - #region Properties - - public List LogMessages { get; private set; } - - #endregion - - #region Methods - - public async Task LoadLogMessages() { - ViewLogsRequest viewLogsRequest = ViewLogsRequest.Create(); - - List logMessages = await this.Mediator.Send(viewLogsRequest, CancellationToken.None); - - List logMessageViewModels = new List(); - - logMessages.ForEach(l => { - logMessageViewModels.Add(new LogMessageModel - { - LogLevel = l.LogLevel, - LogLevelString = l.LogLevelString, - Message = l.Message, - EntryDateTime = l.EntryDateTime, - Id = l.Id - }); - }); - - this.LogMessages = logMessageViewModels; - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentFailedPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentFailedPageViewModel.cs deleted file mode 100644 index 6640dd68c..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentFailedPageViewModel.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Logging; -using Maui.UIServices; -using Microsoft.Extensions.Logging; -using MvvmHelpers; -using MvvmHelpers.Commands; - -public class BillPaymentFailedPageViewModel : BaseViewModel -{ - private readonly INavigationService NavigationService; - - #region Constructors - - public BillPaymentFailedPageViewModel(INavigationService navigationService) - { - this.NavigationService = navigationService; - this.CancelledCommand = new AsyncCommand(this.CancelledCommandExecute); - this.Title = "Bill Payment Failed"; - } - - #endregion - - #region Properties - - public ICommand CancelledCommand { get; } - - #endregion - - #region Methods - - private async Task CancelledCommandExecute() - { - Logger.LogInformation("CancelledCommandExecute called"); - await this.NavigationService.PopToRoot(); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentGetAccountPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentGetAccountPageViewModel.cs deleted file mode 100644 index 6ee06a209..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentGetAccountPageViewModel.cs +++ /dev/null @@ -1,206 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using MvvmHelpers.Commands; -using Requests; -using Services; -using SimpleResults; -using UIServices; - -public class BillPaymentGetAccountPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private String customerAccountNumber; - - private readonly IMediator Mediator; - private readonly INavigationParameterService NavigationParameterService; - - #endregion - - #region Constructors - - public BillPaymentGetAccountPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - IMediator mediator, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) { - this.Mediator = mediator; - this.NavigationParameterService = navigationParameterService; - this.GetAccountCommand = new AsyncCommand(this.GetAccountCommandExecute); - this.Title = "Get Customer Account"; - } - - #endregion - - #region Properties - - public String CustomerAccountNumber { - get => this.customerAccountNumber; - set => this.SetProperty(ref this.customerAccountNumber, value); - } - - public ICommand GetAccountCommand { get; } - - public ProductDetails ProductDetails { get; set; } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken cancellationToken) { - var query = this.NavigationParameterService.GetParameters(); - this.ProductDetails = query[nameof(this.ProductDetails)] as ProductDetails; - } - - private async Task GetAccountCommandExecute() { - Logger.LogInformation("GetAccountCommandExecute called"); - - PerformBillPaymentGetAccountRequest request = PerformBillPaymentGetAccountRequest.Create(DateTime.Now, - this.ProductDetails.ContractId, - this.ProductDetails.ProductId, - this.ProductDetails.OperatorId, - this.CustomerAccountNumber); - - Result result = await this.Mediator.Send(request); - - if (result.IsSuccess && result.Data.IsSuccessful) { - ProductDetails productDetails = new ProductDetails { - ContractId = this.ProductDetails.ContractId, - ProductId = this.ProductDetails.ProductId, - OperatorId = this.ProductDetails.OperatorId - }; - - await this.NavigationService.GoToBillPaymentPayBillPage(productDetails, result.Data.BillDetails); - } - else { - await this.NavigationService.GoToBillPaymentFailedPage(); - } - } - - #endregion -} - -public class BillPaymentGetMeterPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private String meterNumber; - - private readonly IMediator Mediator; - - #endregion - - #region Constructors - - public BillPaymentGetMeterPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - IMediator mediator, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) - { - this.Mediator = mediator; - this.GetMeterCommand = new AsyncCommand(this.GetMeterCommandExecute); - this.Title = "Get Meter"; - } - - #endregion - - #region Properties - - public String MeterNumber - { - get => this.meterNumber; - set => this.SetProperty(ref this.meterNumber, value); - } - - public ICommand GetMeterCommand { get; } - - public ProductDetails ProductDetails { get; set; } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken cancellationToken) - { - var query = this.NavigationParameterService.GetParameters(); - this.ProductDetails = query[nameof(this.ProductDetails)] as ProductDetails; - } - private async Task GetMeterCommandExecute() - { - Logger.LogInformation("GetMeterCommandExecute called"); - - PerformBillPaymentGetMeterRequest request = PerformBillPaymentGetMeterRequest.Create(DateTime.Now, - this.ProductDetails.ContractId, - this.ProductDetails.ProductId, - this.ProductDetails.OperatorId, - this.MeterNumber); - - Result result = await this.Mediator.Send(request); - - if (result.IsSuccess && result.Data.IsSuccessful) - { - ProductDetails productDetails = new ProductDetails - { - ContractId = this.ProductDetails.ContractId, - ProductId = this.ProductDetails.ProductId, - OperatorId = this.ProductDetails.OperatorId - }; - - await this.NavigationService.GoToBillPaymentPayBillPage(productDetails, result.Data.MeterDetails); - } - else - { - await this.NavigationService.GoToBillPaymentFailedPage(); - } - } - - #endregion -} - - -public class BillDetails -{ - #region Properties - - public String AccountName { get; set; } - - public String AccountNumber { get; set; } - - public String Balance { get; set; } - - public String DueDate { get; set; } - - #endregion -} - -public class ProductDetails -{ - #region Properties - - public Guid ContractId { get; set; } - - public Guid OperatorId { get; set; } - - public Guid ProductId { get; set; } - - #endregion -} - -public class MeterDetails -{ - #region Properties - - public String CustomerName { get; set; } - - public String MeterNumber { get; set; } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentPayBillPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentPayBillPageViewModel.cs deleted file mode 100644 index ef748bd74..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentPayBillPageViewModel.cs +++ /dev/null @@ -1,160 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using MvvmHelpers.Commands; -using RequestHandlers; -using Requests; -using Services; -using SimpleResults; -using TransactionProcessorACL.DataTransferObjects.Responses; -using UIServices; - -public class BillPaymentPayBillPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private readonly IMediator Mediator; - - private BillDetails billdetails; - private MeterDetails meterdetails; - - #endregion - - #region Constructors - - public Action OnCustomerMobileNumberEntryCompleted { get; set; } - - public Action OnPaymentAmountEntryCompleted { get; set; } - - public async Task Initialise(CancellationToken cancellationToken){ - IDictionary query = this.NavigationParameterService.GetParameters(); - this.IsPostPayVisible = false; - this.IsPrePayVisible = false; - - this.ProductDetails = query[nameof(this.ProductDetails)] as ProductDetails; - if (query.ContainsKey("BillDetails") == true){ - this.BillDetails = query["BillDetails"] as BillDetails; - this.IsPostPayVisible = true; - } - - if (query.ContainsKey("MeterDetails") == true){ - this.IsPrePayVisible = true; - this.MeterDetails = query["MeterDetails"] as MeterDetails; - } - } - - public ProductDetails ProductDetails { get; set; } - - public BillPaymentPayBillPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IMediator mediator, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) - { - this.Mediator = mediator; - this.MakeBillPaymentCommand = new AsyncCommand(this.MakeBillPaymentCommandExecute); - this.CustomerMobileNumberEntryCompletedCommand = new AsyncCommand(this.CustomerMobileNumberEntryCompletedExecute); - this.PaymentAmountEntryCompletedCommand = new AsyncCommand(this.PaymentAmountEntryCompletedCommandExecute); - this.Title = "Make Bill Payment"; - } - private async Task PaymentAmountEntryCompletedCommandExecute() { - Logger.LogInformation("PaymentAmountEntryCompletedCommandExecute called"); - this.OnPaymentAmountEntryCompleted(); - } - - private async Task CustomerMobileNumberEntryCompletedExecute() { - Logger.LogInformation("CustomerMobileNumberEntryCompletedExecute called"); - this.OnCustomerMobileNumberEntryCompleted(); - } - - #endregion - - private async Task MakeBillPaymentCommandExecute() { - Logger.LogInformation("MakeBillPaymentCommandExecute called"); - IRequest> request = null; - - if (this.BillDetails != null){ - request = PerformBillPaymentMakePostPaymentRequest.Create(DateTime.Now, - this.ProductDetails.ContractId, - this.ProductDetails.ProductId, - this.ProductDetails.OperatorId, - this.BillDetails.AccountNumber, - this.BillDetails.AccountName, - this.CustomerMobileNumber, - this.PaymentAmount); - - - } - else if (this.MeterDetails != null){ - request = PerformBillPaymentMakePrePaymentRequest.Create(DateTime.Now, - this.ProductDetails.ContractId, - this.ProductDetails.ProductId, - this.ProductDetails.OperatorId, - this.MeterDetails.MeterNumber, - this.MeterDetails.CustomerName, - this.PaymentAmount); - } - - - - Result result = await this.Mediator.Send(request); - - if (result.IsSuccess && result.Data.IsSuccessful) { - await this.NavigationService.GoToBillPaymentSuccessPage(); - } - else { - await this.NavigationService.GoToBillPaymentFailedPage(); - } - } - - public ICommand CustomerMobileNumberEntryCompletedCommand { get; } - - public ICommand PaymentAmountEntryCompletedCommand { get; } - - private Decimal paymentAmount; - public Decimal PaymentAmount - { - get => this.paymentAmount; - set => this.SetProperty(ref this.paymentAmount, value); - } - - private String customerMobileNumber; - public String CustomerMobileNumber { - get => this.customerMobileNumber; - set => this.SetProperty(ref this.customerMobileNumber, value); - } - - public BillDetails BillDetails - { - get => this.billdetails; - set => this.SetProperty(ref this.billdetails, value); - } - - public MeterDetails MeterDetails - { - get => this.meterdetails; - set => this.SetProperty(ref this.meterdetails, value); - } - - public ICommand MakeBillPaymentCommand { get; } - - private Boolean isPostPayVisible; - public Boolean IsPostPayVisible - { - get => this.isPostPayVisible; - set => this.SetProperty(ref this.isPostPayVisible, value); - } - - private Boolean isPrePayVisible; - public Boolean IsPrePayVisible - { - get => this.isPrePayVisible; - set => this.SetProperty(ref this.isPrePayVisible, value); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentSelectOperatorPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentSelectOperatorPageViewModel.cs deleted file mode 100644 index 961e683be..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentSelectOperatorPageViewModel.cs +++ /dev/null @@ -1,86 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using MvvmHelpers.Commands; -using RequestHandlers; -using Requests; -using Services; -using SimpleResults; -using UIServices; - -public class BillPaymentSelectOperatorPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private readonly IMediator Mediator; - - #endregion - - #region Constructors - - public BillPaymentSelectOperatorPageViewModel(IMediator mediator, INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService,navigationParameterService) - - { - this.Mediator = mediator; - this.OperatorSelectedCommand = new AsyncCommand>(this.OperatorSelectedCommandExecute); - this.Title = "Select an Operator"; - } - - #endregion - - #region Properties - - public List Operators { get; private set; } - - public ICommand OperatorSelectedCommand { get; } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken cancellationToken) - { - GetContractProductsRequest request = GetContractProductsRequest.Create(ProductType.BillPayment); - - Result> productsresult = await this.Mediator.Send(request, cancellationToken); - // TODO: Handle the failure result - List products = productsresult.Data; - - // TODO: Should this logic live in the Reqest handler ??? - List operators = products.GroupBy(c => new - { - c.OperatorName, - c.OperatorId, - c.OperatorIdentfier - }).Select(g => new ContractOperatorModel - { - OperatorId = g.Key.OperatorId, - OperatorName = g.Key.OperatorName, - OperatorIdentfier = g.Key.OperatorIdentfier - }).ToList(); - - this.Operators = operators; - } - - private async Task OperatorSelectedCommandExecute(ItemSelected e) - { - Logger.LogInformation("OperatorSelectedCommandExecute called"); - - ProductDetails productDetails = new() { - OperatorId = e.SelectedItem.OperatorId - }; - - await this.NavigationService.GoToBillPaymentSelectProductPage(productDetails); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentSelectProductPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentSelectProductPageViewModel.cs deleted file mode 100644 index 5058ac513..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentSelectProductPageViewModel.cs +++ /dev/null @@ -1,83 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using MvvmHelpers.Commands; -using Requests; -using Services; -using SimpleResults; -using UIServices; - -public class BillPaymentSelectProductPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private readonly IMediator Mediator; - - #endregion - - #region Constructors - - public BillPaymentSelectProductPageViewModel(IMediator mediator, INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) - { - this.Mediator = mediator; - this.ProductSelectedCommand = new AsyncCommand>(this.ProductSelectedCommandExecute); - this.Title = "Select a Product"; - } - - #endregion - - #region Properties - - public ProductDetails ProductDetails { get; private set; } - - public List Products { get; private set; } - - public ICommand ProductSelectedCommand { get; } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken cancellationToken) - { - IDictionary query = this.NavigationParameterService.GetParameters(); - this.ProductDetails = query[nameof(this.ProductDetails)] as ProductDetails; - - GetContractProductsRequest request = GetContractProductsRequest.Create(ProductType.BillPayment); - - Result> productsresult = await this.Mediator.Send(request, cancellationToken); - // TODO: Handle the failure result - List products = productsresult.Data; - products = products.Where(p => p.OperatorId == this.ProductDetails.OperatorId).ToList(); - - this.Products = products; - } - - private async Task ProductSelectedCommandExecute(ItemSelected e) - { - Logger.LogInformation("ProductSelectedCommandExecute called"); - ProductDetails productDetails = new() - { - OperatorId = e.SelectedItem.OperatorId, - ContractId = e.SelectedItem.ContractId, - ProductId = e.SelectedItem.ProductId - }; - Task task = e.SelectedItem.ProductSubType switch{ - ProductSubType.BillPaymentPostPay => this.NavigationService.GoToBillPaymentGetAccountPage(productDetails), - _ => this.NavigationService.GoToBillPaymentGetMeterPage(productDetails) - }; - - await task; - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentSuccessPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentSuccessPageViewModel.cs deleted file mode 100644 index 7e7b4d7c7..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/BillPaymentSuccessPageViewModel.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Logging; -using Maui.UIServices; -using Microsoft.Extensions.Logging; -using MvvmHelpers; -using MvvmHelpers.Commands; - -public class BillPaymentSuccessPageViewModel : BaseViewModel -{ - private readonly INavigationService NavigationService; - - #region Constructors - - public BillPaymentSuccessPageViewModel(INavigationService navigationService) - { - this.NavigationService = navigationService; - this.CompletedCommand = new AsyncCommand(this.CompletedCommandExecute); - this.Title = "Bill Payment Successful"; - } - - #endregion - - #region Properties - - public ICommand CompletedCommand { get; } - - #endregion - - #region Methods - - private async Task CompletedCommandExecute() - { - Logger.LogInformation("CompletedCommandExecute called"); - await this.NavigationService.PopToRoot(); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupFailedPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupFailedPageViewModel.cs deleted file mode 100644 index 74445edb6..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupFailedPageViewModel.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Logging; -using Maui.UIServices; -using MvvmHelpers; -using MvvmHelpers.Commands; -using Services; -using UIServices; - -public class MobileTopupFailedPageViewModel : BaseViewModel -{ - private readonly INavigationService NavigationService; - - #region Constructors - - public MobileTopupFailedPageViewModel(INavigationService navigationService) { - this.NavigationService = navigationService; - this.CancelledCommand = new AsyncCommand(this.CancelledCommandExecute); - this.Title = "Mobile Topup Failed"; - } - - #endregion - - #region Properties - - public ICommand CancelledCommand { get; } - - #endregion - - #region Methods - - private async Task CancelledCommandExecute() - { - Logger.LogInformation("CancelledCommandExecute called"); - await this.NavigationService.PopToRoot(); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupPerformTopupPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupPerformTopupPageViewModel.cs deleted file mode 100644 index eb6604b16..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupPerformTopupPageViewModel.cs +++ /dev/null @@ -1,137 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Web; -using System.Windows.Input; -using Logging; -using Maui.UIServices; -using MediatR; -using MvvmHelpers.Commands; -using Requests; -using Services; -using UIServices; - -public class MobileTopupPerformTopupPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private String customerEmailAddress; - - private String customerMobileNumber; - - private readonly IMediator Mediator; - - private Decimal topupAmount; - - public ProductDetails ProductDetails { get; set; } - - #endregion - - #region Constructors - - public async Task Initialise(CancellationToken cancellationToken) - { - - var query = this.NavigationParameterService.GetParameters(); - this.ProductDetails = query[nameof(this.ProductDetails)] as ProductDetails; - this.TopupAmount = Decimal.Parse(HttpUtility.UrlDecode(query[nameof(TopupAmount)].ToString())); - } - - public MobileTopupPerformTopupPageViewModel(IMediator mediator, - INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) - { - this.Mediator = mediator; - this.PerformTopupCommand = new AsyncCommand(this.PerformTopupCommandExecute); - this.CustomerMobileNumberEntryCompletedCommand = new AsyncCommand(this.CustomerMobileNumberEntryCompletedCommandExecute); - this.TopupAmountEntryCompletedCommand = new AsyncCommand(this.TopupAmountEntryCompletedCommandExecute); - this.CustomerEmailAddressEntryCompletedCommand = new AsyncCommand(this.CustomerEmailAddressEntryCompletedCommandExecute); - this.Title = "Enter Topup Details"; - } - - #endregion - - #region Properties - - public String CustomerEmailAddress - { - get => this.customerEmailAddress; - set => this.SetProperty(ref this.customerEmailAddress, value); - } - - public ICommand CustomerEmailAddressEntryCompletedCommand { get; } - - public String CustomerMobileNumber - { - get => this.customerMobileNumber; - set => this.SetProperty(ref this.customerMobileNumber, value); - } - - public ICommand CustomerMobileNumberEntryCompletedCommand { get; } - - public Action OnCustomerEmailAddressEntryCompleted { get; set; } - - public Action OnCustomerMobileNumberEntryCompleted { get; set; } - - public Action OnTopupAmountEntryCompleted { get; set; } - - public ICommand PerformTopupCommand { get; } - - public Decimal TopupAmount - { - get => this.topupAmount; - set => this.SetProperty(ref this.topupAmount, value); - } - - public ICommand TopupAmountEntryCompletedCommand { get; } - - #endregion - - #region Methods - - private async Task CustomerEmailAddressEntryCompletedCommandExecute() - { - Logger.LogInformation("CustomerEmailAddressEntryCompletedCommandExecute called"); - this.OnCustomerEmailAddressEntryCompleted(); - } - - private async Task CustomerMobileNumberEntryCompletedCommandExecute() - { - Logger.LogInformation("CustomerMobileNumberEntryCompletedCommandExecute called"); - this.OnCustomerMobileNumberEntryCompleted(); - } - - private async Task PerformTopupCommandExecute() - { - Logger.LogInformation("PerformTopupCommandExecute called"); - // Create Command and Send - PerformMobileTopupRequest request = PerformMobileTopupRequest.Create(DateTime.Now, - this.ProductDetails.ContractId, - this.ProductDetails.ProductId, - this.ProductDetails.OperatorId, - this.CustomerMobileNumber, - this.TopupAmount, - this.CustomerEmailAddress); - - var response = await this.Mediator.Send(request); - - if (response.IsSuccess && response.Data.IsSuccessful) - { - await this.NavigationService.GoToMobileTopupSuccessPage(); - } - else - { - await this.NavigationService.GoToMobileTopupFailedPage(); - } - } - - private async Task TopupAmountEntryCompletedCommandExecute() - { - Logger.LogInformation("TopupAmountEntryCompletedCommandExecute called"); - this.OnTopupAmountEntryCompleted(); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupSelectOperatorPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupSelectOperatorPageViewModel.cs deleted file mode 100644 index 552a821fb..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupSelectOperatorPageViewModel.cs +++ /dev/null @@ -1,84 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using MvvmHelpers; -using MvvmHelpers.Commands; -using RequestHandlers; -using Requests; -using Services; -using SimpleResults; -using UIServices; - -public class MobileTopupSelectOperatorPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private readonly IMediator Mediator; - - #endregion - - #region Constructors - - public MobileTopupSelectOperatorPageViewModel(IMediator mediator, INavigationService navigationService, IDialogService dialogService, - IApplicationCache applicationCache, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) : base(applicationCache,dialogService, navigationService, deviceService,navigationParameterService) - { - this.Mediator = mediator; - this.OperatorSelectedCommand = new AsyncCommand>(this.OperatorSelectedCommandExecute); - this.Title = "Select an Operator"; - } - - #endregion - - #region Properties - - public List Operators { get; private set; } - - public ICommand OperatorSelectedCommand { get; } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken cancellationToken) - { - GetContractProductsRequest request = GetContractProductsRequest.Create(ProductType.MobileTopup); - - Result> productsresult = await this.Mediator.Send(request, cancellationToken); - List products = productsresult.Data; - - // TODO: Should this logic live in the Request handler ??? - List operators = products.GroupBy(c => new - { - c.OperatorName, - c.OperatorId, - c.OperatorIdentfier - }).Select(g => new ContractOperatorModel - { - OperatorId = g.Key.OperatorId, - OperatorName = g.Key.OperatorName, - OperatorIdentfier = g.Key.OperatorIdentfier - }).ToList(); - - this.Operators = operators; - } - - private async Task OperatorSelectedCommandExecute(ItemSelected e) - { - Logger.LogInformation("OperatorSelectedCommandExecute called"); - ProductDetails productDetails = new ProductDetails() { - OperatorId = e.SelectedItem.OperatorId - }; - - await this.NavigationService.GoToMobileTopupSelectProductPage(productDetails); - - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupSelectProductPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupSelectProductPageViewModel.cs deleted file mode 100644 index da2dd8576..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupSelectProductPageViewModel.cs +++ /dev/null @@ -1,80 +0,0 @@ -using SimpleResults; - -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using MvvmHelpers.Commands; -using Requests; -using Services; -using UIServices; - -public class MobileTopupSelectProductPageViewModel : ExtendedBaseViewModel//, IQueryAttributableX -{ - #region Fields - - private readonly IMediator Mediator; - - public ProductDetails ProductDetails { get; private set; } - - #endregion - - #region Constructors - - - public MobileTopupSelectProductPageViewModel(IMediator mediator, INavigationService navigationService, - IApplicationCache applicationCache, IDialogService dialogService, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) :base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) - { - this.Mediator = mediator; - this.ProductSelectedCommand = new AsyncCommand>(this.ProductSelectedCommandExecute); - this.Title = "Select a Product"; - } - - #endregion - - #region Properties - - public List Products { get; private set; } - - public ICommand ProductSelectedCommand { get; } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken cancellationToken) - { - IDictionary query = this.NavigationParameterService.GetParameters(); - this.ProductDetails = query[nameof(this.ProductDetails)] as ProductDetails; - - GetContractProductsRequest request = GetContractProductsRequest.Create(ProductType.MobileTopup); - - Result> productsResult = await this.Mediator.Send(request, cancellationToken); - List products = productsResult.Data; - - products = products.Where(p => p.OperatorId == this.ProductDetails.OperatorId).ToList(); - - this.Products = products; - } - - private async Task ProductSelectedCommandExecute(ItemSelected e) - { - Logger.LogInformation("ProductSelectedCommandExecute called"); - ProductDetails productDetails = new ProductDetails() - { - OperatorId = e.SelectedItem.OperatorId, - ContractId = e.SelectedItem.ContractId, - ProductId = e.SelectedItem.ProductId - }; - - await this.NavigationService.GoToMobileTopupPerformTopupPage(productDetails, e.SelectedItem.Value); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupSuccessPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupSuccessPageViewModel.cs deleted file mode 100644 index 560c243b2..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/MobileTopupSuccessPageViewModel.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions -{ - using System.Windows.Input; - using Logging; - using Maui.UIServices; - using MvvmHelpers; - using MvvmHelpers.Commands; - using Services; - using UIServices; - - public class MobileTopupSuccessPageViewModel : BaseViewModel - { - private readonly INavigationService NavigationService; - - #region Constructors - - public MobileTopupSuccessPageViewModel(INavigationService navigationService) - { - this.NavigationService = navigationService; - this.CompletedCommand = new AsyncCommand(this.CompletedCommandExecute); - this.Title = "Mobile Topup Successful"; - } - - #endregion - - #region Properties - - public ICommand CompletedCommand { get; } - - #endregion - - #region Methods - - private async Task CompletedCommandExecute() - { - Logger.LogInformation("CompletedCommandExecute called"); - await this.NavigationService.PopToRoot(); - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/TransactionsPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/TransactionsPageViewModel.cs deleted file mode 100644 index 7f7d36efa..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/TransactionsPageViewModel.cs +++ /dev/null @@ -1,79 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions -{ - using System.Windows.Input; - using Logging; - using Maui.UIServices; - using MvvmHelpers; - using MvvmHelpers.Commands; - using Services; - using UIServices; - - public class TransactionsPageViewModel : ExtendedBaseViewModel - { - #region Constructors - - public TransactionsPageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) - { - this.MobileTopupCommand = new AsyncCommand(this.MobileTopupCommandExecute); - this.MobileWalletCommand = new AsyncCommand(this.MobileWalletCommandExecute); - this.BillPaymentCommand = new AsyncCommand(this.BillPaymentCommandExecute); - this.VoucherCommand = new AsyncCommand(this.VoucherCommandExecute); - this.AdminCommand = new AsyncCommand(this.AdminCommandExecute); - this.Title = "Select Transaction Type"; - } - - #endregion - - #region Properties - - public ICommand AdminCommand { get; set; } - - public ICommand BillPaymentCommand { get; set; } - - public ICommand MobileTopupCommand { get; set; } - - public ICommand MobileWalletCommand { get; set; } - - public ICommand VoucherCommand { get; set; } - - #endregion - - #region Methods - - private async Task AdminCommandExecute() - { - Logger.LogInformation("AdminCommandExecute called"); - await this.NavigationService.GoToAdminPage(); - } - - private async Task BillPaymentCommandExecute() - { - Logger.LogInformation("AdminCommandExecute called"); - await this.NavigationService.GoToBillPaymentSelectOperatorPage(); - } - - private async Task MobileTopupCommandExecute() - { - Logger.LogInformation("MobileTopupCommandExecute called"); - await this.NavigationService.GoToMobileTopupSelectOperatorPage(); - } - - private async Task MobileWalletCommandExecute() - { - Logger.LogInformation("MobileWalletCommandExecute called"); - await this.NavigationService.GoToHome(); - } - - private async Task VoucherCommandExecute() - { - Logger.LogInformation("VoucherCommandExecute called"); - await this.NavigationService.GoToVoucherSelectOperatorPage(); - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherIssueFailedPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherIssueFailedPageViewModel.cs deleted file mode 100644 index a42401677..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherIssueFailedPageViewModel.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Logging; -using Maui.UIServices; -using MvvmHelpers; -using MvvmHelpers.Commands; -using Services; -using UIServices; - -public class VoucherIssueFailedPageViewModel : BaseViewModel -{ - private readonly INavigationService NavigationService; - - #region Constructors - - public VoucherIssueFailedPageViewModel(INavigationService navigationService) - { - this.NavigationService = navigationService; - this.CancelledCommand = new AsyncCommand(this.CancelledCommandExecute); - this.Title = "Voucher Issue Failed"; - } - - #endregion - - #region Properties - - public ICommand CancelledCommand { get; } - - #endregion - - #region Methods - - private async Task CancelledCommandExecute() - { - Logger.LogInformation("CancelledCommandExecute called"); - await this.NavigationService.PopToRoot(); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherIssueSuccessPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherIssueSuccessPageViewModel.cs deleted file mode 100644 index c0c392afe..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherIssueSuccessPageViewModel.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions -{ - using System.Windows.Input; - using Logging; - using Maui.UIServices; - using Microsoft.Extensions.Logging; - using MvvmHelpers; - using MvvmHelpers.Commands; - using Services; - using UIServices; - - public class VoucherIssueSuccessPageViewModel : BaseViewModel - { - private readonly INavigationService NavigationService; - - #region Constructors - - public VoucherIssueSuccessPageViewModel(INavigationService navigationService) - { - this.NavigationService = navigationService; - this.CompletedCommand = new AsyncCommand(this.CompletedCommandExecute); - this.Title = "Voucher Issue Successful"; - } - - #endregion - - #region Properties - - public ICommand CompletedCommand { get; } - - #endregion - - #region Methods - - private async Task CompletedCommandExecute() - { - Logger.LogInformation("CompletedCommandExecute called"); - await this.NavigationService.PopToRoot(); - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherPerformIssuePageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherPerformIssuePageViewModel.cs deleted file mode 100644 index 15413921c..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherPerformIssuePageViewModel.cs +++ /dev/null @@ -1,162 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Web; -using System.Windows.Input; -using Logging; -using Maui.UIServices; -using MediatR; -using MvvmHelpers.Commands; -using Requests; -using Services; -using UIServices; - -public class VoucherPerformIssuePageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private String customerEmailAddress; - - private String recipientMobileNumber; - - private String recipientEmailAddress; - - private readonly IMediator Mediator; - - private Decimal voucherAmount; - - public ProductDetails ProductDetails { get; private set; } - - #endregion - - #region Constructors - - public async Task Initialise(CancellationToken cancellationToken) - { - Logger.LogInformation("in Initialise"); - var query = this.NavigationParameterService.GetParameters(); - this.ProductDetails = query[nameof(this.ProductDetails)] as ProductDetails; - this.VoucherAmount = Decimal.Parse(HttpUtility.UrlDecode(query[nameof(this.VoucherAmount)].ToString())); - } - - public VoucherPerformIssuePageViewModel(INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - IMediator mediator, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) - { - this.Mediator = mediator; - this.IssueVoucherCommand = new AsyncCommand(this.IssueVoucherCommandExecute); - this.RecipientMobileNumberEntryCompletedCommand = new AsyncCommand(this.RecipientMobileNumberEntryCompletedCommandExecute); - this.RecipientEmailAddressEntryCompletedCommand = new AsyncCommand(this.RecipientEmailAddressEntryCompletedCommandExecute); - this.VoucherAmountEntryCompletedCommand = new AsyncCommand(this.VoucherAmountEntryCompletedCommandExecute); - this.CustomerEmailAddressEntryCompletedCommand = new AsyncCommand(this.CustomerEmailAddressEntryCompletedCommandExecute); - this.Title = "Enter Voucher Issue Details"; - } - - #endregion - - #region Properties - - public String CustomerEmailAddress - { - get => this.customerEmailAddress; - set => this.SetProperty(ref this.customerEmailAddress, value); - } - - public ICommand CustomerEmailAddressEntryCompletedCommand { get; } - - public String RecipientMobileNumber - { - get => this.recipientMobileNumber; - set => this.SetProperty(ref this.recipientMobileNumber, value); - } - - public String RecipientEmailAddress - { - get => this.recipientEmailAddress; - set => this.SetProperty(ref this.recipientEmailAddress, value); - } - - public ICommand RecipientMobileNumberEntryCompletedCommand { get; } - - public ICommand RecipientEmailAddressEntryCompletedCommand { get; } - - public Action OnCustomerEmailAddressEntryCompleted { get; set; } - - public Action OnRecipientEmailAddressEntryCompleted { get; set; } - - public Action OnRecipientMobileNumberEntryCompleted { get; set; } - - public Action OnVoucherAmountEntryCompleted { get; set; } - - public ICommand IssueVoucherCommand { get; } - - public Decimal VoucherAmount - { - get => this.voucherAmount; - set => this.SetProperty(ref this.voucherAmount, value); - } - - public ICommand VoucherAmountEntryCompletedCommand { get; } - - #endregion - - #region Methods - - private async Task CustomerEmailAddressEntryCompletedCommandExecute() { - Logger.LogInformation("CustomerEmailAddressEntryCompletedCommandExecute called"); - this.OnCustomerEmailAddressEntryCompleted(); - } - - private async Task RecipientMobileNumberEntryCompletedCommandExecute() { - Logger.LogInformation("RecipientMobileNumberEntryCompletedCommandExecute called"); - this.OnRecipientMobileNumberEntryCompleted(); - } - - private async Task RecipientEmailAddressEntryCompletedCommandExecute() - { - Logger.LogInformation("RecipientEmailAddressEntryCompletedCommandExecute called"); - this.OnRecipientEmailAddressEntryCompleted(); - } - - private async Task IssueVoucherCommandExecute() - { - - - Logger.LogInformation("IssueVoucherCommandExecute called"); - // TODO: Create Command and Send - PerformVoucherIssueRequest request = PerformVoucherIssueRequest.Create(DateTime.Now, - this.ProductDetails.ContractId, - this.ProductDetails.ProductId, - this.ProductDetails.OperatorId, - this.RecipientMobileNumber, - this.recipientMobileNumber, - this.VoucherAmount, - this.CustomerEmailAddress); - - - Logger.LogInformation("about to call Send "); - var result = await this.Mediator.Send(request); - Logger.LogInformation("about to check result "); - if (result.IsSuccess && result.Data.IsSuccessful) - { - Logger.LogInformation("about to go to success"); - await this.NavigationService.GoToVoucherIssueSuccessPage(); - - } - else - { - Logger.LogInformation("about to go to failed"); - await this.NavigationService.GoToVoucherIssueFailedPage(); - } - } - - private async Task VoucherAmountEntryCompletedCommandExecute() - { - Logger.LogInformation("VoucherAmountEntryCompletedCommandExecute called"); - this.OnVoucherAmountEntryCompleted(); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherSelectOperatorPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherSelectOperatorPageViewModel.cs deleted file mode 100644 index 119cc6988..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherSelectOperatorPageViewModel.cs +++ /dev/null @@ -1,82 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using MvvmHelpers; -using MvvmHelpers.Commands; -using Requests; -using Services; -using UIServices; - -public class VoucherSelectOperatorPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private readonly IMediator Mediator; - - #endregion - - #region Constructors - - public VoucherSelectOperatorPageViewModel(IMediator mediator, INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) - - { - this.Mediator = mediator; - this.OperatorSelectedCommand = new AsyncCommand>(this.OperatorSelectedCommandExecute); - this.Title = "Select an Operator"; - } - - #endregion - - #region Properties - - public List Operators { get; private set; } - - public ICommand OperatorSelectedCommand { get; } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken cancellationToken) - { - GetContractProductsRequest request = GetContractProductsRequest.Create(ProductType.Voucher); - - var productsresult = await this.Mediator.Send(request, cancellationToken); - List products = productsresult.Data; - - // TODO: Should this logic live in the Reqest handler ??? - List operators = products.GroupBy(c => new - { - c.OperatorName, - c.OperatorId, - c.OperatorIdentfier - }).Select(g => new ContractOperatorModel - { - OperatorId = g.Key.OperatorId, - OperatorName = g.Key.OperatorName, - OperatorIdentfier = g.Key.OperatorIdentfier - }).ToList(); - - this.Operators = operators; - } - - private async Task OperatorSelectedCommandExecute(ItemSelected e) - { - Logger.LogInformation("OperatorSelectedCommandExecute called"); - ProductDetails productDetails = new ProductDetails() - { - OperatorId = e.SelectedItem.OperatorId - }; - await this.NavigationService.GoToVoucherSelectProductPage(productDetails); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherSelectProductPageViewModel.cs b/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherSelectProductPageViewModel.cs deleted file mode 100644 index a63eca37d..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/ViewModels/Transactions/VoucherSelectProductPageViewModel.cs +++ /dev/null @@ -1,77 +0,0 @@ -namespace TransactionMobile.Maui.BusinessLogic.ViewModels.Transactions; - -using System.Windows.Input; -using Common; -using Logging; -using Maui.UIServices; -using MediatR; -using Models; -using MvvmHelpers.Commands; -using Requests; -using Services; -using UIServices; - -public class VoucherSelectProductPageViewModel : ExtendedBaseViewModel -{ - #region Fields - - private readonly IMediator Mediator; - - public ProductDetails ProductDetails { get; private set; } - - #endregion - - #region Constructors - - public VoucherSelectProductPageViewModel(IMediator mediator, - INavigationService navigationService, - IApplicationCache applicationCache, - IDialogService dialogService, - IDeviceService deviceService, - INavigationParameterService navigationParameterService) : base(applicationCache, dialogService, navigationService, deviceService, navigationParameterService) - { - this.Mediator = mediator; - this.ProductSelectedCommand = new AsyncCommand>(this.ProductSelectedCommandExecute); - this.Title = "Select a Product"; - } - - #endregion - - #region Properties - - public List Products { get; private set; } - - public ICommand ProductSelectedCommand { get; } - - #endregion - - #region Methods - - public async Task Initialise(CancellationToken cancellationToken) - { - IDictionary query = this.NavigationParameterService.GetParameters(); - this.ProductDetails = query[nameof(this.ProductDetails)] as ProductDetails; - - GetContractProductsRequest request = GetContractProductsRequest.Create(ProductType.Voucher); - - var result = await this.Mediator.Send(request, cancellationToken); - var products = result.Data; - products = products.Where(p => p.OperatorId == this.ProductDetails.OperatorId).ToList(); - - this.Products = products; - } - - private async Task ProductSelectedCommandExecute(ItemSelected e) - { - Logger.LogInformation("ProductSelectedCommandExecute called"); - ProductDetails productDetails = new ProductDetails() - { - OperatorId = e.SelectedItem.OperatorId, - ContractId = e.SelectedItem.ContractId, - ProductId = e.SelectedItem.ProductId - }; - await this.NavigationService.GoToVoucherIssueVoucherPage(productDetails, e.SelectedItem.Value); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.BusinessLogic/global.json b/archive/TransactionMobile.Maui.BusinessLogic/global.json deleted file mode 100644 index 36dd2fe4a..000000000 --- a/archive/TransactionMobile.Maui.BusinessLogic/global.json +++ /dev/null @@ -1,6 +0,0 @@ -{ -// "sdk": { -// "rollForward": "disable", -// "version": "6.0.401" -// } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Common/BaseTestFixture.cs b/archive/TransactionMobile.Maui.UiTests/Common/BaseTestFixture.cs deleted file mode 100644 index ee347d466..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Common/BaseTestFixture.cs +++ /dev/null @@ -1,19 +0,0 @@ -using NUnit.Framework; -using OpenQA.Selenium.Appium; -using TransactionMobile.Maui.UiTests.Drivers; - -namespace TransactionMobile.Maui.UITests.Common -{ - [NonParallelizable] - public abstract class BaseTestFixture - { - #region Constructors - - protected BaseTestFixture(MobileTestPlatform mobileTestPlatform) - { - AppiumDriverWrapper.MobileTestPlatform = mobileTestPlatform; - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Common/DockerHelper.cs b/archive/TransactionMobile.Maui.UiTests/Common/DockerHelper.cs deleted file mode 100644 index 5853dbc64..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Common/DockerHelper.cs +++ /dev/null @@ -1,574 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using TransactionProcessor.DataTransferObjects.Responses.Contract; -using TransactionProcessor.IntegrationTesting.Helpers; - -namespace TransactionMobile.Maui.UiTests.Common -{ - using System.Net.Sockets; - using System.Net; - using System.Runtime.CompilerServices; - using System.Threading; - using Ductus.FluentDocker; - using Ductus.FluentDocker.Builders; - using Ductus.FluentDocker.Services; - using Ductus.FluentDocker.Services.Extensions; - using SecurityService.Client; - using SecurityService.DataTransferObjects.Responses; - using Shared.IntegrationTesting; - using Shared.Logger; - using Shouldly; - using TransactionProcessor.Client; - using Ductus.FluentDocker.Commands; - using Ductus.FluentDocker.Common; - using Microsoft.Extensions.Hosting; - using EventStore.Client; - using Reqnroll; - - public class DockerHelper : global::Shared.IntegrationTesting.DockerHelper - { - #region Fields - - /// - /// The HTTP client - /// - public HttpClient HttpClient; - - /// - /// The security service client - /// - public ISecurityServiceClient SecurityServiceClient; - - /// - /// The transaction processor client - /// - public ITransactionProcessorClient TransactionProcessorClient; - - private const String MinimumSupportedApplicationVersion = "1.0.5"; - - private readonly TestingContext TestingContext; - - #endregion - - public EventStoreProjectionManagementClient ProjectionManagementClient; - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The logger. - public DockerHelper() - { - this.TestingContext = new TestingContext(); - } - - #endregion - - #region Methods - - public string GetLocalIPAddress() - { - String result = String.Empty; - if (String.IsNullOrEmpty(Environment.GetEnvironmentVariable("ENV_IPADDRESS"))) - { - // Nothing in environment so not running under CI - IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); - foreach (IPAddress ip in host.AddressList) - { - this.Trace($"{ip}"); - if (ip.AddressFamily == AddressFamily.InterNetwork) - { - result = ip.ToString(); - break; - } - } - } - else { - result= Environment.GetEnvironmentVariable("ENV_IPADDRESS"); - } - - return result; - } - - public String LocalIPAddress { get; private set; } - - public override ContainerBuilder SetupTransactionProcessorAclContainer(){ - this.AdditionalVariables.Add(ContainerType.TransactionProcessorAcl, new List()); - this.SetAdditionalVariables(ContainerType.TransactionProcessorAcl, - new List{ - "AppSettings:SkipVersionCheck=true" - }); - return base.SetupTransactionProcessorAclContainer(); - } - - public override async Task CreateSubscriptions() - { - List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new List<(String streamName, String groupName, Int32 maxRetries)>(); - subscriptions.AddRange(TransactionProcessor.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); - - foreach ((String streamName, String groupName, Int32 maxRetries) subscription in subscriptions) - { - var x = subscription; - x.maxRetries = 2; - await this.CreatePersistentSubscription(x); - } - } - - /// - /// Starts the containers for scenario run. - /// - /// Name of the scenario. - public override async Task StartContainersForScenarioRun(String scenarioName, DockerServices dockerServices) - { - DockerEnginePlatform engineType = BaseDockerHelper.GetDockerEnginePlatform(); - if (engineType == DockerEnginePlatform.Windows){ - this.SetImageDetails(ContainerType.EventStore, ("stuartferguson/eventstore_windows", true)); - } - - //this.SetImageDetails(ContainerType.TransactionProcessorAcl, ("transactionprocessoracl", false)); - - // Get the address of the host - this.LocalIPAddress = this.GetLocalIPAddress(); - this.Trace(this.LocalIPAddress); - - await base.StartContainersForScenarioRun(scenarioName, dockerServices); - await SetupConfigHostContainer(this.TestNetworks); - - // Setup the base address resolvers - - HttpClientHandler clientHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (message, - certificate2, - arg3, - arg4) => - { - return true; - } - - }; - HttpClient httpClient = new HttpClient(clientHandler); - this.SecurityServiceClient = new SecurityServiceClient(this.SecurityServiceBaseAddressResolver, httpClient); - this.TransactionProcessorClient = new TransactionProcessorClient(this.TransactionProcessorBaseAddressResolver, httpClient); - - this.HttpClient = new HttpClient(); - this.HttpClient.BaseAddress = new Uri(this.TransactionProcessorAclBaseAddressResolver(string.Empty)); - - this.TestHostHttpClient = new HttpClient(clientHandler); - this.TestHostHttpClient.BaseAddress = new Uri($"http://127.0.0.1:{this.TestHostServicePort}"); - - this.ProjectionManagementClient = new EventStoreProjectionManagementClient(ConfigureEventStoreSettings()); - } - - public String TransactionProcessorBaseAddressResolver(String api) => $"http://127.0.0.1:{this.TransactionProcessorPort}"; - - public String TransactionProcessorAclBaseAddressResolver(String api) => $"http://127.0.0.1:{this.TransactionProcessorAclPort}"; - - public String SecurityServiceBaseAddressResolver(String api) => $"https://127.0.0.1:{this.SecurityServicePort}"; - - 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)); - } - } - - /// - /// Stops the containers for scenario run. - /// - public override async Task StopContainersForScenarioRun(DockerServices sharedDockerServices) { - await RemoveEstateReadModel().ConfigureAwait(false); - - await base.StopContainersForScenarioRun(sharedDockerServices); - } - - public const int ConfigHostDockerPort = 9200; - - public String ConfigHostContainerName; - public Int32 ConfigHostPort; - - public HttpClient TestHostHttpClient; - - public async Task SetupConfigHostContainer(List networkServices) - { - this.Trace("About to Start Config Host Container"); - List environmentVariables = new List(); - environmentVariables.Add("AppSettings:InMemoryDatabase=true"); - ConfigHostContainerName = $"mobileconfighost{this.TestId:N}"; - - String imageName = "stuartferguson/mobileconfiguration:latest"; - - if (FdOs.IsWindows() && Shared.IntegrationTesting.DockerHelper.GetDockerEnginePlatform() == DockerEnginePlatform.Windows){ - imageName = "stuartferguson/mobileconfigurationwindows:master"; - } - - ContainerBuilder configHostContainer = new Builder().UseContainer().WithName(ConfigHostContainerName) - .WithEnvironment(environmentVariables.ToArray()) - .UseImageDetails((imageName, true)) - .ExposePort(ConfigHostDockerPort) - .MountHostFolder(this.DockerPlatform, this.HostTraceFolder) - .SetDockerCredentials(this.DockerCredentials); - - // Now build and return the container - IContainerService builtContainer = configHostContainer.Build().Start().WaitForPort($"{ConfigHostDockerPort}/tcp", 30000); - - foreach (INetworkService networkService in networkServices) - { - networkService.Attach(builtContainer, false); - } - - this.Trace("Config Host Container Started"); - this.Containers.Add((DockerServices.TestHost, builtContainer)); - - // Do a health check here - this.ConfigHostPort = builtContainer.ToHostExposedEndpoint($"{ConfigHostDockerPort}/tcp").Port; - - //await this.DoHealthCheck(ContainerType.CallbackHandler); - return builtContainer; - } - - - public override ContainerBuilder SetupTransactionProcessorContainer() - { - List variables = new List(); - variables.Add($"OperatorConfiguration:PataPawaPrePay:Url=http://{this.TestHostContainerName}:{DockerPorts.TestHostPort}/api/patapawaprepay"); - - this.AdditionalVariables.Add(ContainerType.FileProcessor, variables); - //this.SetAdditionalVariables(ContainerType.FileProcessor, variables); - - return base.SetupTransactionProcessorContainer(); - } - - #endregion - } - - public class TestingContext - { - #region Fields - - /// - /// The clients - /// - private readonly List Clients; - - /// - /// The estates - /// - public readonly List Estates; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - public TestingContext() - { - this.Estates = new List(); - this.Clients = new List(); - this.Users = new Dictionary(); - this.Roles = new Dictionary(); - this.ApiResources = new List(); - } - - #endregion - - #region Properties - - /// - /// Gets or sets the access token. - /// - /// - /// The access token. - /// - public String AccessToken { get; set; } - - /// - /// Gets or sets the docker helper. - /// - /// - /// The docker helper. - /// - public DockerHelper DockerHelper { get; set; } - - /// - /// Gets or sets the logger. - /// - /// - /// The logger. - /// - public NlogLogger Logger { get; set; } - public Dictionary Users; - public Dictionary Roles; - public List ApiResources; - //public List IdentityResources; - - #endregion - - #region Methods - - /// - /// Adds the client details. - /// - /// The client identifier. - /// The client secret. - /// Type of the grant. - public void AddClientDetails(String clientId, - String clientSecret, - List grantTypes) - { - this.Clients.Add(ClientDetails.Create(clientId, clientSecret, grantTypes)); - } - - /// - /// Adds the estate details. - /// - /// The estate identifier. - /// Name of the estate. - public void AddEstateDetails(Guid estateId, - String estateName, - String estateReference) - { - this.Estates.Add(EstateDetails.Create(estateId, estateName, estateReference)); - } - - /// - /// Gets all estate ids. - /// - /// - public List GetAllEstateIds() - { - return this.Estates.Select(e => e.EstateId).ToList(); - } - - /// - /// Gets the client details. - /// - /// The client identifier. - /// - public ClientDetails GetClientDetails(String clientId) - { - ClientDetails clientDetails = this.Clients.SingleOrDefault(c => c.ClientId == clientId); - - clientDetails.ShouldNotBeNull(); - - return clientDetails; - } - - /// - /// Gets the estate details. - /// - /// The table row. - /// - public EstateDetails GetEstateDetails(DataTableRow tableRow) - { - String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); - - EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateName == estateName); - - estateDetails.ShouldNotBeNull(); - - return estateDetails; - } - - /// - /// Gets the estate details. - /// - /// Name of the estate. - /// - public EstateDetails GetEstateDetails(String estateName) - { - EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateName == estateName); - - estateDetails.ShouldNotBeNull(); - - return estateDetails; - } - - /// - /// Gets the estate details. - /// - /// The estate identifier. - /// - public EstateDetails GetEstateDetails(Guid estateId) - { - EstateDetails estateDetails = this.Estates.SingleOrDefault(e => e.EstateId == estateId); - - estateDetails.ShouldNotBeNull(); - - return estateDetails; - } - - #endregion - } - - public class TransactionFee - { - #region Properties - - /// - /// Gets or sets the type of the calculation. - /// - /// - /// The type of the calculation. - /// - public CalculationType CalculationType { get; set; } - - /// - /// Gets or sets the description. - /// - /// - /// The description. - /// - public String Description { get; set; } - - /// - /// Gets or sets the transaction fee identifier. - /// - /// - /// The transaction fee identifier. - /// - public Guid TransactionFeeId { get; set; } - - /// - /// Gets or sets the value. - /// - /// - /// The value. - /// - public Decimal Value { get; set; } - - #endregion - } - - 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); - } - } - - //public class Contract - //{ - // #region Properties - - // /// - // /// Gets or sets the contract identifier. - // /// - // /// - // /// The contract identifier. - // /// - // public Guid ContractId { get; set; } - - // /// - // /// Gets or sets the description. - // /// - // /// - // /// The description. - // /// - // public String Description { get; set; } - - // /// - // /// Gets or sets the operator identifier. - // /// - // /// - // /// The operator identifier. - // /// - // public Guid OperatorId { get; set; } - - // /// - // /// Gets or sets the products. - // /// - // /// - // /// The products. - // /// - // public List Products { get; set; } - - // #endregion - - // #region Methods - - // /// - // /// Adds the product. - // /// - // /// The product identifier. - // /// The name. - // /// The display text. - // /// The value. - // public void AddProduct(Guid productId, - // String name, - // String displayText, - // Decimal? value = null) - // { - // Product product = new Product - // { - // ProductId = productId, - // DisplayText = displayText, - // Name = name, - // Value = value - // }; - - // if (this.Products == null) - // { - // this.Products = new List(); - // } - - // this.Products.Add(product); - // } - - // /// - // /// Gets the product. - // /// - // /// The product identifier. - // /// - // public Product GetProduct(Guid productId) - // { - // return this.Products.SingleOrDefault(p => p.ProductId == productId); - // } - - // /// - // /// Gets the product. - // /// - // /// The name. - // /// - // public Product GetProduct(String name) - // { - // return this.Products.SingleOrDefault(p => p.Name == name); - // } - - // #endregion - //} -} diff --git a/archive/TransactionMobile.Maui.UiTests/Common/GenericSteps.cs b/archive/TransactionMobile.Maui.UiTests/Common/GenericSteps.cs deleted file mode 100644 index 522538fc7..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Common/GenericSteps.cs +++ /dev/null @@ -1,94 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Common; - -using System; -using System.Linq; -using System.Threading.Tasks; -using NLog; -using Reqnroll; -using Shared.IntegrationTesting; -using Shared.Logger; - -[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 = 0)] - public async Task StartSystem(){ - if (this.ScenarioContext.ScenarioInfo.Tags.Contains("PRNavTest") || - this.ScenarioContext.ScenarioInfo.Tags.Contains("PRHWNavTest") || - this.ScenarioContext.ScenarioInfo.Tags.Contains("iOSPRTest")) - { - // 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); - this.TestingContext.Logger = logger; - } - else{ - DockerServices dockerServices = DockerServices.EventStore | - DockerServices.MessagingService | DockerServices.SecurityService | - DockerServices.TestHost | DockerServices.SqlServer | DockerServices.TransactionProcessor | - DockerServices.TransactionProcessorAcl; - - // 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); - - 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"); - - String? isCi = Environment.GetEnvironmentVariable("IsCI"); - this.TestingContext.Logger.LogInformation($"IsCI [{isCi}]"); - if (String.Compare(isCi, Boolean.TrueString, StringComparison.InvariantCultureIgnoreCase) == 0) - { - // override teh SQL Server image - this.TestingContext.Logger.LogInformation("Sql Image overridden"); - this.TestingContext.DockerHelper.SetImageDetails(ContainerType.SqlServer, ("mssqlserver:2022-ltsc2022", false)); - } - - await Setup.GlobalSetup(this.TestingContext.DockerHelper); - - this.TestingContext.DockerHelper.SqlServerContainer = Setup.DatabaseServerContainer; - this.TestingContext.DockerHelper.SqlServerNetwork = Setup.DatabaseServerNetwork; - this.TestingContext.DockerHelper.DockerCredentials = Setup.DockerCredentials; - this.TestingContext.DockerHelper.SqlCredentials = Setup.SqlCredentials; - this.TestingContext.DockerHelper.SqlServerContainerName = "sharedsqlserver"; - - 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 = 0)] - public async Task StopSystem() - { - if (this.ScenarioContext.ScenarioInfo.Tags.Contains("PRNavTest") == false && this.ScenarioContext.ScenarioInfo.Tags.Contains("PRHWNavTest") == false - && this.ScenarioContext.ScenarioInfo.Tags.Contains("iOSPRTest") == false) - { - this.TestingContext.Logger.LogInformation("About to Stop Containers for Scenario Run"); - await this.TestingContext.DockerHelper.StopContainersForScenarioRun(DockerServices.SqlServer).ConfigureAwait(false); - this.TestingContext.Logger.LogInformation("Containers for Scenario Run Stopped"); - } - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Common/Setup.cs b/archive/TransactionMobile.Maui.UiTests/Common/Setup.cs deleted file mode 100644 index 1763157ac..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Common/Setup.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Ductus.FluentDocker.Services; -using NLog; -using Shared.Logger; -using Shouldly; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace TransactionMobile.Maui.UiTests.Common -{ - using System.Threading.Tasks; - using Ductus.FluentDocker.Services.Extensions; - using Reqnroll; - using ILogger = Shared.Logger.ILogger; - using Logger = Shared.Logger.Logger; - - [Binding] - [Scope(Tag = "base")] - public class Setup{ - public static IContainerService DatabaseServerContainer; - public static INetworkService DatabaseServerNetwork; - public static (String usename, String password) SqlCredentials = ("sa", "thisisalongpassword123!"); - public static (String url, String username, String password) DockerCredentials = ("https://www.docker.com", "stuartferguson", "Sc0tland"); - //[BeforeTestRun] - public static async Task GlobalSetup(DockerHelper dockerHelper) - { - ShouldlyConfiguration.DefaultTaskTimeout = TimeSpan.FromMinutes(1); - dockerHelper.SqlCredentials = Setup.SqlCredentials; - dockerHelper.DockerCredentials = Setup.DockerCredentials; - dockerHelper.SqlServerContainerName = "sharedsqlserver"; - - Setup.DatabaseServerNetwork = dockerHelper.SetupTestNetwork("sharednetwork", true); - Setup.DatabaseServerContainer = await dockerHelper.SetupSqlServerContainer(Setup.DatabaseServerNetwork); - } - - public static String GetConnectionString(String databaseName) - { - return $"server={Setup.DatabaseServerContainer.Name};database={databaseName};user id={Setup.SqlCredentials.usename};password={Setup.SqlCredentials.password}"; - } - - public static String GetLocalConnectionString(String databaseName) - { - Int32 databaseHostPort = Setup.DatabaseServerContainer.ToHostExposedEndpoint("1433/tcp").Port; - - return $"server=localhost,{databaseHostPort};database={databaseName};user id={Setup.SqlCredentials.usename};password={Setup.SqlCredentials.password}"; - } - - } -} diff --git a/archive/TransactionMobile.Maui.UiTests/Drivers/AppiumDriver.cs b/archive/TransactionMobile.Maui.UiTests/Drivers/AppiumDriver.cs deleted file mode 100644 index cef18b0fa..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Drivers/AppiumDriver.cs +++ /dev/null @@ -1,204 +0,0 @@ -using OpenQA.Selenium.Appium; -using OpenQA.Selenium.Appium.Enums; -using OpenQA.Selenium.Appium.Service; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using Google.Protobuf.WellKnownTypes; - -namespace TransactionMobile.Maui.UiTests.Drivers -{ - using Microsoft.Testing.Platform.Capabilities; - using OpenQA.Selenium; - using OpenQA.Selenium.Appium.Service.Options; - using OpenQA.Selenium.Appium.Windows; - using System.Collections.ObjectModel; - using System.Diagnostics; - using System.Threading; - - public enum MobileTestPlatform - { - iOS, - Android, - Windows, - MacCatalyst - } - - public class AppiumDriverWrapper - { - public static MobileTestPlatform MobileTestPlatform; - public static AppiumDriver Driver; - - public void StartApp() { - //OptionCollector o = new OptionCollector(); - //o.AddArguments(GeneralOptionList.BasePath("/wd/hub")); - AppiumLocalService appiumService = new AppiumServiceBuilder().UsingPort(4723) - //.WithArguments(o) - .Build(); - - if (appiumService.IsRunning == false){ - appiumService.OutputDataReceived += (sender, - args) => { - //Console.WriteLine(args.Data); - Debug.WriteLine(args.Data); - }; - appiumService.Start(); - } - - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Android){ - AppiumDriverWrapper.SetupAndroidDriver(appiumService); - } - else if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.iOS){ - AppiumDriverWrapper.SetupiOSDriver(appiumService); - } - else if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows) - { - AppiumDriverWrapper.SetupWindowsDriver(appiumService); - } - } - - private static void SetupWindowsDriver(AppiumLocalService appiumService){ - var driverOptions = new AppiumOptions(); - driverOptions.AutomationName = "windows"; - driverOptions.PlatformName = "windows"; - driverOptions.DeviceName = "WindowsPC"; - - driverOptions.AddAdditionalAppiumOption(MobileCapabilityType.FullReset, true); - driverOptions.AddAdditionalAppiumOption(MobileCapabilityType.NewCommandTimeout, 6000); - driverOptions.AddAdditionalAppiumOption("ms:waitForAppLaunch", "50"); - //driverOptions.AddAdditionalAppiumOption("appium:createSessionTimeout", "100000"); - driverOptions.App = "TransactionMobile_zct748q4xfh0m!App"; - AppiumDriverWrapper.Driver = new WindowsDriver(appiumService, driverOptions, TimeSpan.FromMinutes(10)); - } - - private static void SetupiOSDriver(AppiumLocalService appiumService) { - String assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - String binariesFolder = Path.Combine(assemblyFolder, "..", "..", "..", "..", @"TransactionMobile.Maui/bin/Release/net8.0-ios/iossimulator-arm64/"); - var apkPath = Path.Combine(binariesFolder, "TransactionMobile.Maui.app"); - - var caps = new AppiumOptions(); - caps.PlatformName = "iOS"; - caps.PlatformVersion = "17.4"; - caps.DeviceName = "iPhone 15"; - caps.AutomationName = "XCUITest"; - caps.App = apkPath; - caps.AddAdditionalAppiumOption("fullReset", true); - caps.AddAdditionalAppiumOption("noReset", false); - caps.AddAdditionalAppiumOption("useNewWDA", true); - - //var driverOptions = new AppiumOptions(); - //driverOptions.AutomationName = "XCUITest"; - ////driverOptions.PlatformName = "iOS"; - ////driverOptions.PlatformVersion = "17.4"; - ////driverOptions.DeviceName = "iPhone 11"; - //driverOptions.AutomationName = "XCUITest"; - //driverOptions.PlatformName = "iOS"; - //driverOptions.PlatformVersion = "17.2"; - //driverOptions.AddAdditionalAppiumOption("udid", Environment.GetEnvironmentVariable("UDID")); // Corrected capability. - - //String assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - //String binariesFolder = Path.Combine(assemblyFolder, "..", "..", "..", "..", @"TransactionMobile.Maui/bin/Release/net8.0-ios/iossimulator-arm64/"); - //var apkPath = Path.Combine(binariesFolder, "TransactionMobile.Maui.app"); - //driverOptions.App = apkPath; - //driverOptions.AddAdditionalAppiumOption(MobileCapabilityType.NewCommandTimeout, 6000); - //driverOptions.AddAdditionalAppiumOption("waitForQuiescence", false); - //driverOptions.AddAdditionalAppiumOption("shouldWaitForQuiescence", false); - //driverOptions.AddAdditionalAppiumOption("showXcodeLog", true); - ////driverOptions.AddAdditionalAppiumOption("useNewWDA", true); - ////driverOptions.AddAdditionalAppiumOption("wdaLaunchTimeout", 60000); - ////driverOptions.AddAdditionalAppiumOption("wdaConnectionTimeout", 60000); - ////driverOptions.AddAdditionalAppiumOption("wdaLaunchTimeout", 120000); - ////driverOptions.AddAdditionalAppiumOption("wdaConnectionTimeout", 120000); - ////driverOptions.AddAdditionalAppiumOption("useNewWDA", false); - ////driverOptions.AddAdditionalAppiumOption("wdaStartupRetryInterval", 10000); - ////driverOptions.AddAdditionalAppiumOption("wdaStartupRetries", 4); - //driverOptions.AddAdditionalAppiumOption("usePrebuiltWDA", true); - //driverOptions.AddAdditionalAppiumOption("skipServerInstallation", true); - //driverOptions.AddAdditionalAppiumOption("skipProvisioningDeviceDetection", true); - //driverOptions.AddAdditionalAppiumOption("wdaLocalPort", Environment.GetEnvironmentVariable("WDA_PATH")); - //driverOptions.AddAdditionalAppiumOption("updatedWDABundleId", "WebDriverAgent/build"); - // Tell Appium to use the prebuilt WDA - //driverOptions.AddAdditionalAppiumOption("usePrebuiltWDA", true); - //driverOptions.AddAdditionalAppiumOption("useNewWDA", false); - //driverOptions.AddAdditionalAppiumOption("shouldUseSingletonTestManager", true); - - //driverOptions.AddAdditionalAppiumOption("derivedDataPath", "/Users/runner/work/WebDriverAgent/build/Build/Products/Debug-iphonesimulator"); - //driverOptions.AddAdditionalAppiumOption("wdaLocalPort", 8100); - - - //// Avoid unnecessary WDA rebuild attempts and add resilience - //driverOptions.AddAdditionalAppiumOption("wdaLaunchTimeout", 60000); - //driverOptions.AddAdditionalAppiumOption("wdaStartupRetries", 3); - //driverOptions.AddAdditionalAppiumOption("wdaStartupRetryInterval", 10000); - - //// (Optional but often helpful) - //driverOptions.AddAdditionalAppiumOption("waitForQuiescence", false); - //driverOptions.AddAdditionalAppiumOption("startIWDP", true); // if you want to inspect webviews - //driverOptions.AddAdditionalAppiumOption(MobileCapabilityType.FullReset, false); - //driverOptions.AddAdditionalAppiumOption(MobileCapabilityType.NoReset, true); - //driverOptions.AddAdditionalAppiumOption("usePrebuiltWDA", true); - //driverOptions.AddAdditionalAppiumOption("wdaLocalPort", 8100); // optional, but helpful - //driverOptions.AddAdditionalAppiumOption("shouldUseSingletonTestManager", true); // avoids extra processes - //driverOptions.AddAdditionalAppiumOption("showXcodeLog", true); // shows build errors in logs - //driverOptions.AddAdditionalAppiumOption("bundleId", "com.appium.WebDriverAgentRunner"); // match WDA bundle ID - - - AppiumDriverWrapper.Driver = new OpenQA.Selenium.Appium.iOS.IOSDriver(appiumService, caps, TimeSpan.FromMinutes(10)); - } - - private static void SetupAndroidDriver(AppiumLocalService appiumService) { - // Do Android stuff to start up - var driverOptions = new AppiumOptions(); - driverOptions.AddAdditionalAppiumOption("adbExecTimeout", TimeSpan.FromMinutes(5).TotalMilliseconds); - driverOptions.AutomationName = "UIAutomator2"; - driverOptions.PlatformName = "Android"; - driverOptions.PlatformVersion = "14.0"; - driverOptions.DeviceName = "emulator-5554"; - - // TODO: Only do this locally - driverOptions.AddAdditionalAppiumOption(MobileCapabilityType.FullReset, true); - driverOptions.AddAdditionalAppiumOption("appPackage", "com.transactionprocessing.pos"); - driverOptions.AddAdditionalAppiumOption("enforceAppInstall", true); - driverOptions.AddAdditionalAppiumOption("uiautomator2ServerInstallTimeout", "40000"); - driverOptions.AddAdditionalAppiumOption(MobileCapabilityType.NewCommandTimeout, 6000); - - String assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - String binariesFolder = Path.Combine(assemblyFolder, "..", "..", "..", "..", @"TransactionMobile.Maui/bin/Release/net8.0-android/"); - - var apkPath = Path.Combine(binariesFolder, "com.transactionprocessing.pos-Signed.apk"); - var fileinfo = new FileInfo(apkPath); - - driverOptions.App = apkPath; - - AppiumDriverWrapper.Driver = new OpenQA.Selenium.Appium.Android.AndroidDriver(appiumService, driverOptions, TimeSpan.FromMinutes(5)); - - } - - public List GetLogs() { - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Android) { - if (AppiumDriverWrapper.Driver == null) { - return new List(); - } - ReadOnlyCollection? logs = AppiumDriverWrapper.Driver.Manage().Logs.GetLog("logcat"); - return logs.ToList(); - } - - return null; - } - - public void StopApp() - { - try { - AppiumDriverWrapper.Driver?.Close(); - AppiumDriverWrapper.Driver?.Quit(); - } - catch(Exception e) { - Console.WriteLine(e.Message); - } - } - } -} diff --git a/archive/TransactionMobile.Maui.UiTests/Features/EndToEndTests.feature b/archive/TransactionMobile.Maui.UiTests/Features/EndToEndTests.feature deleted file mode 100644 index c9a26ebba..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/EndToEndTests.feature +++ /dev/null @@ -1,209 +0,0 @@ -@background @login @toolbar @profile @base @sharedapp @shared @transactions -Feature: EndToEndTests - -Background: - - Given the following bills are available at the PataPawa PostPaid Host - | AccountNumber | AccountName | DueDate | Amount | - | 12345678 | Test Account 1 | Today | 100.00 | - - Given the following users are available at the PataPawa PrePay Host - | Username | Password | - | operatora | 1234567898 | - - Given the following meters are available at the PataPawa PrePay Host - | MeterNumber | CustomerName | - | 00000001 | Customer 1 | - | 00000002 | Customer 2 | - | 00000003 | Customer 3 | - - Given the following security roles exist - | Role Name | - | Merchant | - - Given I create the following api scopes - | Name | DisplayName | Description | - | transactionProcessor | Transaction Processor REST Scope | A scope for Transaction Processor REST | - | transactionProcessorACL | Transaction Processor ACL REST Scope | A scope for Transaction Processor ACL REST | - | voucherManagement | Voucher Management REST Scope | A scope for Voucher Management REST | - - Given the following api resources exist - | Name | DisplayName | Secret | Scopes | UserClaims | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | merchantId, estateId, role | - | transactionProcessorACL | Transaction Processor ACL REST | Secret1 | transactionProcessorACL | merchantId, estateId, role | - | voucherManagement | Voucher Management REST | Secret1 | voucherManagement | | - - Given the following clients exist - | ClientId | ClientName | Secret | Scopes | GrantTypes | - | serviceClient | Service Client | Secret1 | transactionProcessor,transactionProcessorACL,voucherManagement | client_credentials | - | mobileAppClient | Mobile App Client | Secret1 | transactionProcessorACL,transactionProcessor | password | - - Given I have a token to access the estate management and transaction processor acl resources - | ClientId | - | serviceClient | - - Given I have created the following estates - | EstateName | - | Test Estate 1 | - - Given I have created the following operators - | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | - | Test Estate 1 | Safaricom | True | True | - | Test Estate 1 | Voucher | True | True | - | Test Estate 1 | PataPawa PostPay | True | True | - | Test Estate 1 | PataPawa PrePay | True | True | - - And I have assigned the following operators to the estates - | EstateName | OperatorName | - | Test Estate 1 | Safaricom | - | Test Estate 1 | Voucher | - | Test Estate 1 | PataPawa PostPay | - | Test Estate 1 | PataPawa PrePay | - - - Given I create a contract with the following values - | EstateName | OperatorName | ContractDescription | - | Test Estate 1 | Safaricom | Safaricom Contract | - | Test Estate 1 | Voucher | Hospital 1 Contract | - | Test Estate 1 | PataPawa PostPay | PataPawa PostPay Contract | - | Test Estate 1 | PataPawa PrePay | PataPawa PrePay Contract | - - When I create the following Products - | EstateName | OperatorName | ContractDescription | ProductName | DisplayText | Value | ProductType | - | Test Estate 1 | Safaricom | Safaricom Contract | Variable Topup | Custom | | MobileTopup | - | Test Estate 1 | Voucher | Hospital 1 Contract | 10 KES | 10 KES | 10.00 | Voucher | - | Test Estate 1 | PataPawa PostPay | PataPawa PostPay Contract | Post Pay Bill Pay | Bill Pay (Post) | | BillPayment | - | Test Estate 1 | PataPawa PrePay | PataPawa PrePay Contract | Pre Pay Bill Pay | Bill Pay (Pre) | | BillPayment | - - When I add the following Transaction Fees - | EstateName | OperatorName | ContractDescription | ProductName | CalculationType | FeeDescription | Value | - | Test Estate 1 | Safaricom | Safaricom Contract | Variable Topup | Fixed | Merchant Commission | 2.50 | - | Test Estate 1 | PataPawa PostPay | PataPawa PostPay Contract | Post Pay Bill Pay | Percentage | Merchant Commission | 0.50 | - | Test Estate 1 | PataPawa PrePay | PataPawa PrePay Contract | Pre Pay Bill Pay | Percentage | Merchant Commission | 0.50 | - - Given I create the following merchants - | MerchantName | AddressLine1 | AddressLine2 | AddressLine3 | AddressLine4 | Town | Region | Country | ContactName | EmailAddress | EstateName | - | Test Merchant 1 | test address line 1 | test address line 2 | test address line 3 | test address line 4 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant1.co.uk | Test Estate 1 | - - Given I have assigned the following operator to the merchants - | OperatorName | MerchantName | MerchantNumber | TerminalNumber | EstateName | - | Safaricom | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 | - | Voucher | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 | - | PataPawa PostPay | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 | - | PataPawa PrePay | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 | - - Given I have assigned the following devices to the merchants - | MerchantName | EstateName | - | Test Merchant 1 | Test Estate 1 | - - When I add the following contracts to the following merchants - | EstateName | MerchantName | ContractDescription | - | Test Estate 1 | Test Merchant 1 | Safaricom Contract | - | Test Estate 1 | Test Merchant 1 | Hospital 1 Contract | - | Test Estate 1 | Test Merchant 1 | PataPawa PostPay Contract | - | Test Estate 1 | Test Merchant 1 | PataPawa PrePay Contract | - - Given I have created the following security users - | EmailAddress | Password | GivenName | FamilyName | EstateName | MerchantName | - | user1 | 123456 | TestMerchant | User1 | Test Estate 1 | Test Merchant 1 | - - Given I make the following manual merchant deposits - | Reference | Amount | DateTime | MerchantName | EstateName | - | Deposit1 | 100.00 | Today | Test Merchant 1 | Test Estate 1 | - - Given I have created a config for my application - - Given I have created a config for my device - -@PRTest -Scenario: EndToEnd - Given I am on the Login Screen - And my device is registered - When I enter 'user1' as the Email Address - And I enter '123456' as the Password - And I tap on Login - Then the Merchant Home Page is displayed - When I tap on Profile - Then the My Profile Page is displayed - When I tap on the Addresses button - Then the Address List Page is displayed - And the Primary Address is displayed - | AddressLine1 | AddressTown | - | test address line 1 | TestTown | - When I click on the back button - Then the My Profile Page is displayed - When I tap on the Account Info button - Then the Account Info Page is displayed - And the Account Info is displayed - | Name | Balance | AvailableBalance | - | Test Merchant 1 | 0 | 0 | - When I click on the back button - Then the My Profile Page is displayed - When I click on the back button - Then the Merchant Home Page is displayed - When I tap on Transactions - Then the Transaction Page is displayed - When I tap on the Mobile Topup button - Then the Transaction Select Mobile Topup Operator Page is displayed - When I tap on the 'Safaricom' button - Then the Select Product Page is displayed - When I tap on the 'Custom' product button - Then the Enter Topup Details Page is displayed - When I enter '07777777775' as the Customer Mobile Number - And I enter 10.00 as the Topup Amount - And I tap on Perform Topup - Then the Mobile Topup Successful Page is displayed - And I tap on Complete - Then the Transaction Page is displayed - When I tap on the Voucher button - Then the Transaction Select Voucher Operator Page is displayed - When I tap on the 'Hospital 1 Contract' button - Then the Select Product Page is displayed - When I tap on the '10 KES' product button - Then the Enter Voucher Issue Details Page is displayed - When I enter '07777777775' as the Recipient Mobile Number - And I tap on Issue Voucher - Then the Voucher Issue Successful Page is displayed - And I tap on Complete - Then the Transaction Page is displayed - When I tap on the Bill Payment button - Then the Transaction Select Bill Payment Operator Page is displayed - When I tap on the 'PataPawa PostPay' button - Then the Select Product Page is displayed - When I tap on the 'Bill Pay (Post)' product button - Then the Enter Account Details Page is displayed - When I enter '12345678' as the Account Number - And I tap on the Get Account Button - Then the Make Bill Payment page is displayed - And the following Bill Details are displayed - | AccountNumber | AccountHolder | DueDate | Balance | - | 12345678 | Test Account 1 | Today | 100.00 | - When I enter '07777777775' as the Customer Mobile Number - And I enter 10.00 as the Payment Amount - And I tap on the Make Payment Button - Then the Bill Payment Successful Page is displayed - And I tap on Complete - Then the Transaction Page is displayed - When I tap on the Bill Payment button - Then the Transaction Select Bill Payment Operator Page is displayed - When I tap on the 'PataPawa PrePay' button - Then the Select Product Page is displayed - When I tap on the 'Bill Pay (Pre)' product button - Then the Enter Meter Details Page is displayed - When I enter '00000001' as the Meter Number - And I tap on the Get Meter Button - Then the Make Bill Payment page is displayed - And the following Meter Details are displayed - | MeterNumber | - | 00000001 | - When I enter 10.00 as the Payment Amount - And I tap on the Make Payment Button - Then the Bill Payment Successful Page is displayed - And I tap on Complete - Then the Transaction Page is displayed - When I click on the back button - Then the Merchant Home Page is displayed - When I click on the back button - Then A message is displayed confirming I want to log out - When I click yes - Then the Login Page is displayed diff --git a/archive/TransactionMobile.Maui.UiTests/Features/EndToEndTests.feature.cs b/archive/TransactionMobile.Maui.UiTests/Features/EndToEndTests.feature.cs deleted file mode 100644 index 6f8de628a..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/EndToEndTests.feature.cs +++ /dev/null @@ -1,812 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://www.reqnroll.net/). -// Reqnroll Version:2.0.0.0 -// Reqnroll Generator Version:2.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 -namespace TransactionMobile.Maui.UiTests.Features -{ - using Reqnroll; - using System; - using System.Linq; - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [NUnit.Framework.TestFixtureAttribute()] - [NUnit.Framework.DescriptionAttribute("EndToEndTests")] - [NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)] - [NUnit.Framework.CategoryAttribute("background")] - [NUnit.Framework.CategoryAttribute("login")] - [NUnit.Framework.CategoryAttribute("toolbar")] - [NUnit.Framework.CategoryAttribute("profile")] - [NUnit.Framework.CategoryAttribute("base")] - [NUnit.Framework.CategoryAttribute("sharedapp")] - [NUnit.Framework.CategoryAttribute("shared")] - [NUnit.Framework.CategoryAttribute("transactions")] - public partial class EndToEndTestsFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "background", - "login", - "toolbar", - "profile", - "base", - "sharedapp", - "shared", - "transactions"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "EndToEndTests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); - -#line 1 "EndToEndTests.feature" -#line hidden - - [NUnit.Framework.OneTimeSetUpAttribute()] - public static async System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [NUnit.Framework.OneTimeTearDownAttribute()] - public static async System.Threading.Tasks.Task FeatureTearDownAsync() - { - } - - [NUnit.Framework.SetUpAttribute()] - public async System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - - [NUnit.Framework.TearDownAttribute()] - public async System.Threading.Tasks.Task TestTearDownAsync() - { - await testRunner.OnScenarioEndAsync(); - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); - } - - public async System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() - { -#line 4 -#line hidden - global::Reqnroll.Table table1 = new global::Reqnroll.Table(new string[] { - "AccountNumber", - "AccountName", - "DueDate", - "Amount"}); - table1.AddRow(new string[] { - "12345678", - "Test Account 1", - "Today", - "100.00"}); -#line 6 - await testRunner.GivenAsync("the following bills are available at the PataPawa PostPaid Host", ((string)(null)), table1, "Given "); -#line hidden - global::Reqnroll.Table table2 = new global::Reqnroll.Table(new string[] { - "Username", - "Password"}); - table2.AddRow(new string[] { - "operatora", - "1234567898"}); -#line 10 - await testRunner.GivenAsync("the following users are available at the PataPawa PrePay Host", ((string)(null)), table2, "Given "); -#line hidden - global::Reqnroll.Table table3 = new global::Reqnroll.Table(new string[] { - "MeterNumber", - "CustomerName"}); - table3.AddRow(new string[] { - "00000001", - "Customer 1"}); - table3.AddRow(new string[] { - "00000002", - "Customer 2"}); - table3.AddRow(new string[] { - "00000003", - "Customer 3"}); -#line 14 - await testRunner.GivenAsync("the following meters are available at the PataPawa PrePay Host", ((string)(null)), table3, "Given "); -#line hidden - global::Reqnroll.Table table4 = new global::Reqnroll.Table(new string[] { - "Role Name"}); - table4.AddRow(new string[] { - "Merchant"}); -#line 20 - await testRunner.GivenAsync("the following security roles exist", ((string)(null)), table4, "Given "); -#line hidden - global::Reqnroll.Table table5 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Description"}); - table5.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST Scope", - "A scope for Transaction Processor REST"}); - table5.AddRow(new string[] { - "transactionProcessorACL", - "Transaction Processor ACL REST Scope", - "A scope for Transaction Processor ACL REST"}); - table5.AddRow(new string[] { - "voucherManagement", - "Voucher Management REST Scope", - "A scope for Voucher Management REST"}); -#line 24 - await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table5, "Given "); -#line hidden - global::Reqnroll.Table table6 = new global::Reqnroll.Table(new string[] { - "Name", - "DisplayName", - "Secret", - "Scopes", - "UserClaims"}); - table6.AddRow(new string[] { - "transactionProcessor", - "Transaction Processor REST", - "Secret1", - "transactionProcessor", - "merchantId, estateId, role"}); - table6.AddRow(new string[] { - "transactionProcessorACL", - "Transaction Processor ACL REST", - "Secret1", - "transactionProcessorACL", - "merchantId, estateId, role"}); - table6.AddRow(new string[] { - "voucherManagement", - "Voucher Management REST", - "Secret1", - "voucherManagement", - ""}); -#line 30 - await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table6, "Given "); -#line hidden - global::Reqnroll.Table table7 = new global::Reqnroll.Table(new string[] { - "ClientId", - "ClientName", - "Secret", - "Scopes", - "GrantTypes"}); - table7.AddRow(new string[] { - "serviceClient", - "Service Client", - "Secret1", - "transactionProcessor,transactionProcessorACL,voucherManagement", - "client_credentials"}); - table7.AddRow(new string[] { - "mobileAppClient", - "Mobile App Client", - "Secret1", - "transactionProcessorACL,transactionProcessor", - "password"}); -#line 36 - await testRunner.GivenAsync("the following clients exist", ((string)(null)), table7, "Given "); -#line hidden - global::Reqnroll.Table table8 = new global::Reqnroll.Table(new string[] { - "ClientId"}); - table8.AddRow(new string[] { - "serviceClient"}); -#line 41 - await testRunner.GivenAsync("I have a token to access the estate management and transaction processor acl reso" + - "urces", ((string)(null)), table8, "Given "); -#line hidden - global::Reqnroll.Table table9 = new global::Reqnroll.Table(new string[] { - "EstateName"}); - table9.AddRow(new string[] { - "Test Estate 1"}); -#line 45 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table9, "Given "); -#line hidden - global::Reqnroll.Table table10 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "RequireCustomMerchantNumber", - "RequireCustomTerminalNumber"}); - table10.AddRow(new string[] { - "Test Estate 1", - "Safaricom", - "True", - "True"}); - table10.AddRow(new string[] { - "Test Estate 1", - "Voucher", - "True", - "True"}); - table10.AddRow(new string[] { - "Test Estate 1", - "PataPawa PostPay", - "True", - "True"}); - table10.AddRow(new string[] { - "Test Estate 1", - "PataPawa PrePay", - "True", - "True"}); -#line 49 - await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table10, "Given "); -#line hidden - global::Reqnroll.Table table11 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName"}); - table11.AddRow(new string[] { - "Test Estate 1", - "Safaricom"}); - table11.AddRow(new string[] { - "Test Estate 1", - "Voucher"}); - table11.AddRow(new string[] { - "Test Estate 1", - "PataPawa PostPay"}); - table11.AddRow(new string[] { - "Test Estate 1", - "PataPawa PrePay"}); -#line 56 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table11, "And "); -#line hidden - global::Reqnroll.Table table12 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "ContractDescription"}); - table12.AddRow(new string[] { - "Test Estate 1", - "Safaricom", - "Safaricom Contract"}); - table12.AddRow(new string[] { - "Test Estate 1", - "Voucher", - "Hospital 1 Contract"}); - table12.AddRow(new string[] { - "Test Estate 1", - "PataPawa PostPay", - "PataPawa PostPay Contract"}); - table12.AddRow(new string[] { - "Test Estate 1", - "PataPawa PrePay", - "PataPawa PrePay Contract"}); -#line 64 - await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table12, "Given "); -#line hidden - global::Reqnroll.Table table13 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "ContractDescription", - "ProductName", - "DisplayText", - "Value", - "ProductType"}); - table13.AddRow(new string[] { - "Test Estate 1", - "Safaricom", - "Safaricom Contract", - "Variable Topup", - "Custom", - "", - "MobileTopup"}); - table13.AddRow(new string[] { - "Test Estate 1", - "Voucher", - "Hospital 1 Contract", - "10 KES", - "10 KES", - "10.00", - "Voucher"}); - table13.AddRow(new string[] { - "Test Estate 1", - "PataPawa PostPay", - "PataPawa PostPay Contract", - "Post Pay Bill Pay", - "Bill Pay (Post)", - "", - "BillPayment"}); - table13.AddRow(new string[] { - "Test Estate 1", - "PataPawa PrePay", - "PataPawa PrePay Contract", - "Pre Pay Bill Pay", - "Bill Pay (Pre)", - "", - "BillPayment"}); -#line 71 - await testRunner.WhenAsync("I create the following Products", ((string)(null)), table13, "When "); -#line hidden - global::Reqnroll.Table table14 = new global::Reqnroll.Table(new string[] { - "EstateName", - "OperatorName", - "ContractDescription", - "ProductName", - "CalculationType", - "FeeDescription", - "Value"}); - table14.AddRow(new string[] { - "Test Estate 1", - "Safaricom", - "Safaricom Contract", - "Variable Topup", - "Fixed", - "Merchant Commission", - "2.50"}); - table14.AddRow(new string[] { - "Test Estate 1", - "PataPawa PostPay", - "PataPawa PostPay Contract", - "Post Pay Bill Pay", - "Percentage", - "Merchant Commission", - "0.50"}); - table14.AddRow(new string[] { - "Test Estate 1", - "PataPawa PrePay", - "PataPawa PrePay Contract", - "Pre Pay Bill Pay", - "Percentage", - "Merchant Commission", - "0.50"}); -#line 78 - await testRunner.WhenAsync("I add the following Transaction Fees", ((string)(null)), table14, "When "); -#line hidden - global::Reqnroll.Table table15 = new global::Reqnroll.Table(new string[] { - "MerchantName", - "AddressLine1", - "AddressLine2", - "AddressLine3", - "AddressLine4", - "Town", - "Region", - "Country", - "ContactName", - "EmailAddress", - "EstateName"}); - table15.AddRow(new string[] { - "Test Merchant 1", - "test address line 1", - "test address line 2", - "test address line 3", - "test address line 4", - "TestTown", - "Test Region", - "United Kingdom", - "Test Contact 1", - "testcontact1@merchant1.co.uk", - "Test Estate 1"}); -#line 84 - await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table15, "Given "); -#line hidden - global::Reqnroll.Table table16 = new global::Reqnroll.Table(new string[] { - "OperatorName", - "MerchantName", - "MerchantNumber", - "TerminalNumber", - "EstateName"}); - table16.AddRow(new string[] { - "Safaricom", - "Test Merchant 1", - "00000001", - "10000001", - "Test Estate 1"}); - table16.AddRow(new string[] { - "Voucher", - "Test Merchant 1", - "00000001", - "10000001", - "Test Estate 1"}); - table16.AddRow(new string[] { - "PataPawa PostPay", - "Test Merchant 1", - "00000001", - "10000001", - "Test Estate 1"}); - table16.AddRow(new string[] { - "PataPawa PrePay", - "Test Merchant 1", - "00000001", - "10000001", - "Test Estate 1"}); -#line 88 - await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table16, "Given "); -#line hidden - global::Reqnroll.Table table17 = new global::Reqnroll.Table(new string[] { - "MerchantName", - "EstateName"}); - table17.AddRow(new string[] { - "Test Merchant 1", - "Test Estate 1"}); -#line 95 - await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table17, "Given "); -#line hidden - global::Reqnroll.Table table18 = new global::Reqnroll.Table(new string[] { - "EstateName", - "MerchantName", - "ContractDescription"}); - table18.AddRow(new string[] { - "Test Estate 1", - "Test Merchant 1", - "Safaricom Contract"}); - table18.AddRow(new string[] { - "Test Estate 1", - "Test Merchant 1", - "Hospital 1 Contract"}); - table18.AddRow(new string[] { - "Test Estate 1", - "Test Merchant 1", - "PataPawa PostPay Contract"}); - table18.AddRow(new string[] { - "Test Estate 1", - "Test Merchant 1", - "PataPawa PrePay Contract"}); -#line 99 - await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table18, "When "); -#line hidden - global::Reqnroll.Table table19 = new global::Reqnroll.Table(new string[] { - "EmailAddress", - "Password", - "GivenName", - "FamilyName", - "EstateName", - "MerchantName"}); - table19.AddRow(new string[] { - "user1", - "123456", - "TestMerchant", - "User1", - "Test Estate 1", - "Test Merchant 1"}); -#line 106 - await testRunner.GivenAsync("I have created the following security users", ((string)(null)), table19, "Given "); -#line hidden - global::Reqnroll.Table table20 = new global::Reqnroll.Table(new string[] { - "Reference", - "Amount", - "DateTime", - "MerchantName", - "EstateName"}); - table20.AddRow(new string[] { - "Deposit1", - "100.00", - "Today", - "Test Merchant 1", - "Test Estate 1"}); -#line 110 - await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table20, "Given "); -#line hidden -#line 114 - await testRunner.GivenAsync("I have created a config for my application", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 116 - await testRunner.GivenAsync("I have created a config for my device", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("EndToEnd")] - [NUnit.Framework.CategoryAttribute("PRTest")] - public async System.Threading.Tasks.Task EndToEnd() - { - string[] tagsOfScenario = new string[] { - "PRTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("EndToEnd", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 119 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 120 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 121 - await testRunner.AndAsync("my device is registered", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 122 - await testRunner.WhenAsync("I enter \'user1\' as the Email Address", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 123 - await testRunner.AndAsync("I enter \'123456\' as the Password", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 124 - await testRunner.AndAsync("I tap on Login", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 125 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 126 - await testRunner.WhenAsync("I tap on Profile", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 127 - await testRunner.ThenAsync("the My Profile Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 128 - await testRunner.WhenAsync("I tap on the Addresses button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 129 - await testRunner.ThenAsync("the Address List Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table21 = new global::Reqnroll.Table(new string[] { - "AddressLine1", - "AddressTown"}); - table21.AddRow(new string[] { - "test address line 1", - "TestTown"}); -#line 130 - await testRunner.AndAsync("the Primary Address is displayed", ((string)(null)), table21, "And "); -#line hidden -#line 133 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 134 - await testRunner.ThenAsync("the My Profile Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 135 - await testRunner.WhenAsync("I tap on the Account Info button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 136 - await testRunner.ThenAsync("the Account Info Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table22 = new global::Reqnroll.Table(new string[] { - "Name", - "Balance", - "AvailableBalance"}); - table22.AddRow(new string[] { - "Test Merchant 1", - "0", - "0"}); -#line 137 - await testRunner.AndAsync("the Account Info is displayed", ((string)(null)), table22, "And "); -#line hidden -#line 140 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 141 - await testRunner.ThenAsync("the My Profile Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 142 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 143 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 144 - await testRunner.WhenAsync("I tap on Transactions", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 145 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 146 - await testRunner.WhenAsync("I tap on the Mobile Topup button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 147 - await testRunner.ThenAsync("the Transaction Select Mobile Topup Operator Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 148 - await testRunner.WhenAsync("I tap on the \'Safaricom\' button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 149 - await testRunner.ThenAsync("the Select Product Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 150 - await testRunner.WhenAsync("I tap on the \'Custom\' product button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 151 - await testRunner.ThenAsync("the Enter Topup Details Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 152 - await testRunner.WhenAsync("I enter \'07777777775\' as the Customer Mobile Number", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 153 - await testRunner.AndAsync("I enter 10.00 as the Topup Amount", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 154 - await testRunner.AndAsync("I tap on Perform Topup", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 155 - await testRunner.ThenAsync("the Mobile Topup Successful Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 156 - await testRunner.AndAsync("I tap on Complete", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 157 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 158 - await testRunner.WhenAsync("I tap on the Voucher button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 159 - await testRunner.ThenAsync("the Transaction Select Voucher Operator Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 160 - await testRunner.WhenAsync("I tap on the \'Hospital 1 Contract\' button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 161 - await testRunner.ThenAsync("the Select Product Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 162 - await testRunner.WhenAsync("I tap on the \'10 KES\' product button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 163 - await testRunner.ThenAsync("the Enter Voucher Issue Details Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 164 - await testRunner.WhenAsync("I enter \'07777777775\' as the Recipient Mobile Number", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 165 - await testRunner.AndAsync("I tap on Issue Voucher", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 166 - await testRunner.ThenAsync("the Voucher Issue Successful Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 167 - await testRunner.AndAsync("I tap on Complete", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 168 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 169 - await testRunner.WhenAsync("I tap on the Bill Payment button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 170 - await testRunner.ThenAsync("the Transaction Select Bill Payment Operator Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 171 - await testRunner.WhenAsync("I tap on the \'PataPawa PostPay\' button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 172 - await testRunner.ThenAsync("the Select Product Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 173 - await testRunner.WhenAsync("I tap on the \'Bill Pay (Post)\' product button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 174 - await testRunner.ThenAsync("the Enter Account Details Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 175 - await testRunner.WhenAsync("I enter \'12345678\' as the Account Number", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 176 - await testRunner.AndAsync("I tap on the Get Account Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 177 - await testRunner.ThenAsync("the Make Bill Payment page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table23 = new global::Reqnroll.Table(new string[] { - "AccountNumber", - "AccountHolder", - "DueDate", - "Balance"}); - table23.AddRow(new string[] { - "12345678", - "Test Account 1", - "Today", - "100.00"}); -#line 178 - await testRunner.AndAsync("the following Bill Details are displayed", ((string)(null)), table23, "And "); -#line hidden -#line 181 - await testRunner.WhenAsync("I enter \'07777777775\' as the Customer Mobile Number", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 182 - await testRunner.AndAsync("I enter 10.00 as the Payment Amount", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 183 - await testRunner.AndAsync("I tap on the Make Payment Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 184 - await testRunner.ThenAsync("the Bill Payment Successful Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 185 - await testRunner.AndAsync("I tap on Complete", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 186 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 187 - await testRunner.WhenAsync("I tap on the Bill Payment button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 188 - await testRunner.ThenAsync("the Transaction Select Bill Payment Operator Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 189 - await testRunner.WhenAsync("I tap on the \'PataPawa PrePay\' button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 190 - await testRunner.ThenAsync("the Select Product Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 191 - await testRunner.WhenAsync("I tap on the \'Bill Pay (Pre)\' product button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 192 - await testRunner.ThenAsync("the Enter Meter Details Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 193 - await testRunner.WhenAsync("I enter \'00000001\' as the Meter Number", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 194 - await testRunner.AndAsync("I tap on the Get Meter Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 195 - await testRunner.ThenAsync("the Make Bill Payment page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table24 = new global::Reqnroll.Table(new string[] { - "MeterNumber"}); - table24.AddRow(new string[] { - "00000001"}); -#line 196 - await testRunner.AndAsync("the following Meter Details are displayed", ((string)(null)), table24, "And "); -#line hidden -#line 199 - await testRunner.WhenAsync("I enter 10.00 as the Payment Amount", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 200 - await testRunner.AndAsync("I tap on the Make Payment Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 201 - await testRunner.ThenAsync("the Bill Payment Successful Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 202 - await testRunner.AndAsync("I tap on Complete", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 203 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 204 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 205 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 206 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 207 - await testRunner.ThenAsync("A message is displayed confirming I want to log out", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 208 - await testRunner.WhenAsync("I click yes", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 209 - await testRunner.ThenAsync("the Login Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/archive/TransactionMobile.Maui.UiTests/Features/EndToEndTestsFeature.cs b/archive/TransactionMobile.Maui.UiTests/Features/EndToEndTestsFeature.cs deleted file mode 100644 index 198abe1c1..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/EndToEndTestsFeature.cs +++ /dev/null @@ -1,27 +0,0 @@ -using EmptyFiles; -using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using TransactionMobile.Maui.UITests.Common; -using TransactionMobile.Maui.UiTests.Drivers; - -namespace TransactionMobile.Maui.UiTests.Features -{ - [TestFixture(MobileTestPlatform.Android, Category = "Android")] - //[TestFixture(MobileTestPlatform.iOS, Category = "iOS")] - [TestFixture(MobileTestPlatform.Windows, Category = "Windows")] - [NonParallelizable] - public partial class EndToEndTestsFeature : BaseTestFixture - { - #region Constructors - - public EndToEndTestsFeature(MobileTestPlatform mobileTestPlatform) : base(mobileTestPlatform) - { - } - - #endregion - } -} diff --git a/archive/TransactionMobile.Maui.UiTests/Features/HardwarePageNavigation.feature b/archive/TransactionMobile.Maui.UiTests/Features/HardwarePageNavigation.feature deleted file mode 100644 index 43b7e734f..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/HardwarePageNavigation.feature +++ /dev/null @@ -1,65 +0,0 @@ -@background @login @toolbar @profile @shared @transactions @sharedapp @base @reports -Feature: HardwarePageNavigation - -@PRNavTest -Scenario: Back Button from Login Screen - Given I am on the Login Screen - When I click on the device back button - Then The application closes - -# Home Page Back Button Tests -@PRHWNavTest -Scenario: Device Back Button from Home Page Screen - Given I am on the Login Screen - And the application is in training mode - When I enter 'user1' as the Email Address - And I enter '123456' as the Password - And I tap on Login - Then the Merchant Home Page is displayed - When I click on the device back button - Then A message is displayed confirming I want to log out - When I click no - Then the Merchant Home Page is displayed - When I click on the device back button - Then A message is displayed confirming I want to log out - When I click yes - Then the Login Page is displayed - -# Transaction Page Back Button Tests -@PRHWNavTest -Scenario: Back Button from Transaction Page Screen - Given I am on the Login Screen - And the application is in training mode - When I enter 'user1' as the Email Address - And I enter '123456' as the Password - And I tap on Login - Then the Merchant Home Page is displayed - When I tap on Transactions - Then the Transaction Page is displayed - When I tap on the Mobile Topup button - Then the Transaction Select Mobile Topup Operator Page is displayed - When I click on the device back button - Then the Transaction Page is displayed - When I click on the device back button - Then the Merchant Home Page is displayed - -# Reports Page Back Button Tests -@PRHWNavTest -Scenario: Back Button from Reports Page Screen - Given I am on the Login Screen - And the application is in training mode - When I enter 'user1' as the Email Address - And I enter '123456' as the Password - And I tap on Login - Then the Merchant Home Page is displayed - When I tap on Reports - Then the Reports Page is displayed - When I tap on the Sales Analysis Button - Then the Sales Analysis Report is displayed - When I click on the device back button - Then the Transaction Page is displayed - When I click on the device back button - Then the Merchant Home Page is displayed - -# My Account Page Back Button Tests -# Support Page Back Button Tests diff --git a/archive/TransactionMobile.Maui.UiTests/Features/HardwarePageNavigation.feature.cs b/archive/TransactionMobile.Maui.UiTests/Features/HardwarePageNavigation.feature.cs deleted file mode 100644 index 8583fa499..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/HardwarePageNavigation.feature.cs +++ /dev/null @@ -1,332 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://www.reqnroll.net/). -// Reqnroll Version:2.0.0.0 -// Reqnroll Generator Version:2.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 -namespace TransactionMobile.Maui.UiTests.Features -{ - using Reqnroll; - using System; - using System.Linq; - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [NUnit.Framework.TestFixtureAttribute()] - [NUnit.Framework.DescriptionAttribute("HardwarePageNavigation")] - [NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)] - [NUnit.Framework.CategoryAttribute("background")] - [NUnit.Framework.CategoryAttribute("login")] - [NUnit.Framework.CategoryAttribute("toolbar")] - [NUnit.Framework.CategoryAttribute("profile")] - [NUnit.Framework.CategoryAttribute("shared")] - [NUnit.Framework.CategoryAttribute("transactions")] - [NUnit.Framework.CategoryAttribute("sharedapp")] - [NUnit.Framework.CategoryAttribute("base")] - [NUnit.Framework.CategoryAttribute("reports")] - public partial class HardwarePageNavigationFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "background", - "login", - "toolbar", - "profile", - "shared", - "transactions", - "sharedapp", - "base", - "reports"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "HardwarePageNavigation", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); - -#line 1 "HardwarePageNavigation.feature" -#line hidden - - [NUnit.Framework.OneTimeSetUpAttribute()] - public static async System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [NUnit.Framework.OneTimeTearDownAttribute()] - public static async System.Threading.Tasks.Task FeatureTearDownAsync() - { - } - - [NUnit.Framework.SetUpAttribute()] - public async System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - - [NUnit.Framework.TearDownAttribute()] - public async System.Threading.Tasks.Task TestTearDownAsync() - { - await testRunner.OnScenarioEndAsync(); - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); - } - - public async System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Back Button from Login Screen")] - [NUnit.Framework.CategoryAttribute("PRNavTest")] - public async System.Threading.Tasks.Task BackButtonFromLoginScreen() - { - string[] tagsOfScenario = new string[] { - "PRNavTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Back Button from Login Screen", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 5 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 6 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 7 - await testRunner.WhenAsync("I click on the device back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 8 - await testRunner.ThenAsync("The application closes", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Device Back Button from Home Page Screen")] - [NUnit.Framework.CategoryAttribute("PRHWNavTest")] - public async System.Threading.Tasks.Task DeviceBackButtonFromHomePageScreen() - { - string[] tagsOfScenario = new string[] { - "PRHWNavTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Device Back Button from Home Page Screen", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 12 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 13 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 14 - await testRunner.AndAsync("the application is in training mode", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 15 - await testRunner.WhenAsync("I enter \'user1\' as the Email Address", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 16 - await testRunner.AndAsync("I enter \'123456\' as the Password", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 17 - await testRunner.AndAsync("I tap on Login", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 18 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 19 - await testRunner.WhenAsync("I click on the device back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 20 - await testRunner.ThenAsync("A message is displayed confirming I want to log out", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 21 - await testRunner.WhenAsync("I click no", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 22 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 23 - await testRunner.WhenAsync("I click on the device back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 24 - await testRunner.ThenAsync("A message is displayed confirming I want to log out", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 25 - await testRunner.WhenAsync("I click yes", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 26 - await testRunner.ThenAsync("the Login Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Back Button from Transaction Page Screen")] - [NUnit.Framework.CategoryAttribute("PRHWNavTest")] - public async System.Threading.Tasks.Task BackButtonFromTransactionPageScreen() - { - string[] tagsOfScenario = new string[] { - "PRHWNavTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Back Button from Transaction Page Screen", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 30 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 31 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 32 - await testRunner.AndAsync("the application is in training mode", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 33 - await testRunner.WhenAsync("I enter \'user1\' as the Email Address", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 34 - await testRunner.AndAsync("I enter \'123456\' as the Password", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 35 - await testRunner.AndAsync("I tap on Login", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 36 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 37 - await testRunner.WhenAsync("I tap on Transactions", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 38 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 39 - await testRunner.WhenAsync("I tap on the Mobile Topup button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 40 - await testRunner.ThenAsync("the Transaction Select Mobile Topup Operator Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 41 - await testRunner.WhenAsync("I click on the device back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 42 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 43 - await testRunner.WhenAsync("I click on the device back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 44 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Back Button from Reports Page Screen")] - [NUnit.Framework.CategoryAttribute("PRHWNavTest")] - public async System.Threading.Tasks.Task BackButtonFromReportsPageScreen() - { - string[] tagsOfScenario = new string[] { - "PRHWNavTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Back Button from Reports Page Screen", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 48 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 49 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 50 - await testRunner.AndAsync("the application is in training mode", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 51 - await testRunner.WhenAsync("I enter \'user1\' as the Email Address", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 52 - await testRunner.AndAsync("I enter \'123456\' as the Password", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 53 - await testRunner.AndAsync("I tap on Login", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 54 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 55 - await testRunner.WhenAsync("I tap on Reports", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 56 - await testRunner.ThenAsync("the Reports Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 57 - await testRunner.WhenAsync("I tap on the Sales Analysis Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 58 - await testRunner.ThenAsync("the Sales Analysis Report is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 59 - await testRunner.WhenAsync("I click on the device back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 60 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 61 - await testRunner.WhenAsync("I click on the device back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 62 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/archive/TransactionMobile.Maui.UiTests/Features/HardwarePageNavigationFeature.cs b/archive/TransactionMobile.Maui.UiTests/Features/HardwarePageNavigationFeature.cs deleted file mode 100644 index 0ce9ee4e5..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/HardwarePageNavigationFeature.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Features; - -using Drivers; -using NUnit.Framework; -using UITests.Common; - -[TestFixture(MobileTestPlatform.Android, Category = "Android")] -[NonParallelizable] -public partial class HardwarePageNavigationFeature : BaseTestFixture -{ - #region Constructors - - public HardwarePageNavigationFeature(MobileTestPlatform mobileTestPlatform) : base(mobileTestPlatform) { - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Features/IOSEndToEndTestsFeature.cs b/archive/TransactionMobile.Maui.UiTests/Features/IOSEndToEndTestsFeature.cs deleted file mode 100644 index 47ceb0dd6..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/IOSEndToEndTestsFeature.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NUnit.Framework; -using TransactionMobile.Maui.UITests.Common; -using TransactionMobile.Maui.UiTests.Drivers; - -namespace TransactionMobile.Maui.UiTests.Features; - -[TestFixture(MobileTestPlatform.Android, Category = "Android")] -[TestFixture(MobileTestPlatform.iOS, Category = "iOS")] -//[TestFixture(MobileTestPlatform.Windows, Category = "Windows")] -[NonParallelizable] -public partial class IOSEndToEndTestsFeature : BaseTestFixture -{ - #region Constructors - - public IOSEndToEndTestsFeature(MobileTestPlatform mobileTestPlatform) : base(mobileTestPlatform) - { - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Features/PageNavigation.feature b/archive/TransactionMobile.Maui.UiTests/Features/PageNavigation.feature deleted file mode 100644 index d952f9803..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/PageNavigation.feature +++ /dev/null @@ -1,102 +0,0 @@ -@background @login @toolbar @profile @shared @transactions @sharedapp @base @reports @support -Feature: PageNavigation - -# Home Page Back Button Tests -@PRNavTest -Scenario: Back Button from Home Page Screen - Given I am on the Login Screen - And the application is in training mode - When I enter 'user1' as the Email Address - And I enter '123456' as the Password - And I tap on Login - Then the Merchant Home Page is displayed - When I click on the back button - Then A message is displayed confirming I want to log out - When I click no - Then the Merchant Home Page is displayed - When I click on the back button - Then A message is displayed confirming I want to log out - When I click yes - Then the Login Page is displayed - -# Transaction Page Back Button Tests -@PRNavTest -Scenario: Back Button from Transaction Page Screen - Given I am on the Login Screen - And the application is in training mode - When I enter 'user1' as the Email Address - And I enter '123456' as the Password - And I tap on Login - Then the Merchant Home Page is displayed - When I tap on Transactions - Then the Transaction Page is displayed - When I tap on the Mobile Topup button - Then the Transaction Select Mobile Topup Operator Page is displayed - When I click on the back button - Then the Transaction Page is displayed - When I click on the back button - Then the Merchant Home Page is displayed - -# Reports Page Back Button Tests -@PRNavTest -Scenario: Back Button from Reports Page Screen - Given I am on the Login Screen - And the application is in training mode - When I enter 'user1' as the Email Address - And I enter '123456' as the Password - And I tap on Login - Then the Merchant Home Page is displayed - When I tap on Reports - Then the Reports Page is displayed - When I tap on the Sales Analysis Button - Then the Sales Analysis Report is displayed - When I click on the back button - Then the Reports Page is displayed - When I click on the back button - Then the Merchant Home Page is displayed - -# Profile Page Back Button Tests -@PRNavTest -Scenario: Back Button from Profile Page Screen - Given I am on the Login Screen - And the application is in training mode - When I enter 'user1' as the Email Address - And I enter '123456' as the Password - And I tap on Login - Then the Merchant Home Page is displayed - When I tap on Profile - Then the My Profile Page is displayed - When I tap on the Addresses button - Then the Address List Page is displayed - When I click on the back button - Then the My Profile Page is displayed - When I tap on the Contacts button - Then the Contact List Page is displayed - When I click on the back button - Then the My Profile Page is displayed - When I tap on the Account Info button - Then the Account Info Page is displayed - When I click on the back button - Then the My Profile Page is displayed - When I click on the back button - Then the Merchant Home Page is displayed - -# Support Page Back Button Tests -@PRNavTest -Scenario: Back Button from Support Page Screen - Given I am on the Login Screen - And the application is in training mode - When I enter 'user1' as the Email Address - And I enter '123456' as the Password - And I tap on Login - Then the Merchant Home Page is displayed - When I tap on Support - Then the Support Page is displayed - When I tap on the Upload Logs Button - Then the Support Page is displayed - When I tap on the View Logs Button - Then the View Logs Page is displayed - When I click on the back button - Then the Support Page is displayed - When I click on the back button - Then the Merchant Home Page is displayed diff --git a/archive/TransactionMobile.Maui.UiTests/Features/PageNavigation.feature.cs b/archive/TransactionMobile.Maui.UiTests/Features/PageNavigation.feature.cs deleted file mode 100644 index 539018446..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/PageNavigation.feature.cs +++ /dev/null @@ -1,462 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://www.reqnroll.net/). -// Reqnroll Version:2.0.0.0 -// Reqnroll Generator Version:2.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 -namespace TransactionMobile.Maui.UiTests.Features -{ - using Reqnroll; - using System; - using System.Linq; - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [NUnit.Framework.TestFixtureAttribute()] - [NUnit.Framework.DescriptionAttribute("PageNavigation")] - [NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)] - [NUnit.Framework.CategoryAttribute("background")] - [NUnit.Framework.CategoryAttribute("login")] - [NUnit.Framework.CategoryAttribute("toolbar")] - [NUnit.Framework.CategoryAttribute("profile")] - [NUnit.Framework.CategoryAttribute("shared")] - [NUnit.Framework.CategoryAttribute("transactions")] - [NUnit.Framework.CategoryAttribute("sharedapp")] - [NUnit.Framework.CategoryAttribute("base")] - [NUnit.Framework.CategoryAttribute("reports")] - [NUnit.Framework.CategoryAttribute("support")] - public partial class PageNavigationFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "background", - "login", - "toolbar", - "profile", - "shared", - "transactions", - "sharedapp", - "base", - "reports", - "support"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "PageNavigation", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); - -#line 1 "PageNavigation.feature" -#line hidden - - [NUnit.Framework.OneTimeSetUpAttribute()] - public static async System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [NUnit.Framework.OneTimeTearDownAttribute()] - public static async System.Threading.Tasks.Task FeatureTearDownAsync() - { - } - - [NUnit.Framework.SetUpAttribute()] - public async System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - - [NUnit.Framework.TearDownAttribute()] - public async System.Threading.Tasks.Task TestTearDownAsync() - { - await testRunner.OnScenarioEndAsync(); - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); - } - - public async System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Back Button from Home Page Screen")] - [NUnit.Framework.CategoryAttribute("PRNavTest")] - public async System.Threading.Tasks.Task BackButtonFromHomePageScreen() - { - string[] tagsOfScenario = new string[] { - "PRNavTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Back Button from Home Page Screen", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 6 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 7 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 8 - await testRunner.AndAsync("the application is in training mode", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 9 - await testRunner.WhenAsync("I enter \'user1\' as the Email Address", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 10 - await testRunner.AndAsync("I enter \'123456\' as the Password", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 11 - await testRunner.AndAsync("I tap on Login", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 12 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 13 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 14 - await testRunner.ThenAsync("A message is displayed confirming I want to log out", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 15 - await testRunner.WhenAsync("I click no", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 16 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 17 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 18 - await testRunner.ThenAsync("A message is displayed confirming I want to log out", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 19 - await testRunner.WhenAsync("I click yes", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 20 - await testRunner.ThenAsync("the Login Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Back Button from Transaction Page Screen")] - [NUnit.Framework.CategoryAttribute("PRNavTest")] - public async System.Threading.Tasks.Task BackButtonFromTransactionPageScreen() - { - string[] tagsOfScenario = new string[] { - "PRNavTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Back Button from Transaction Page Screen", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 24 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 25 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 26 - await testRunner.AndAsync("the application is in training mode", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 27 - await testRunner.WhenAsync("I enter \'user1\' as the Email Address", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 28 - await testRunner.AndAsync("I enter \'123456\' as the Password", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 29 - await testRunner.AndAsync("I tap on Login", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 30 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 31 - await testRunner.WhenAsync("I tap on Transactions", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 32 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 33 - await testRunner.WhenAsync("I tap on the Mobile Topup button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 34 - await testRunner.ThenAsync("the Transaction Select Mobile Topup Operator Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 35 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 36 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 37 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 38 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Back Button from Reports Page Screen")] - [NUnit.Framework.CategoryAttribute("PRNavTest")] - public async System.Threading.Tasks.Task BackButtonFromReportsPageScreen() - { - string[] tagsOfScenario = new string[] { - "PRNavTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Back Button from Reports Page Screen", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 42 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 43 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 44 - await testRunner.AndAsync("the application is in training mode", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 45 - await testRunner.WhenAsync("I enter \'user1\' as the Email Address", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 46 - await testRunner.AndAsync("I enter \'123456\' as the Password", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 47 - await testRunner.AndAsync("I tap on Login", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 48 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 49 - await testRunner.WhenAsync("I tap on Reports", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 50 - await testRunner.ThenAsync("the Reports Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 51 - await testRunner.WhenAsync("I tap on the Sales Analysis Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 52 - await testRunner.ThenAsync("the Sales Analysis Report is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 53 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 54 - await testRunner.ThenAsync("the Reports Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 55 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 56 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Back Button from Profile Page Screen")] - [NUnit.Framework.CategoryAttribute("PRNavTest")] - public async System.Threading.Tasks.Task BackButtonFromProfilePageScreen() - { - string[] tagsOfScenario = new string[] { - "PRNavTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Back Button from Profile Page Screen", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 60 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 61 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 62 - await testRunner.AndAsync("the application is in training mode", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 63 - await testRunner.WhenAsync("I enter \'user1\' as the Email Address", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 64 - await testRunner.AndAsync("I enter \'123456\' as the Password", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 65 - await testRunner.AndAsync("I tap on Login", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 66 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 67 - await testRunner.WhenAsync("I tap on Profile", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 68 - await testRunner.ThenAsync("the My Profile Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 69 - await testRunner.WhenAsync("I tap on the Addresses button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 70 - await testRunner.ThenAsync("the Address List Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 71 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 72 - await testRunner.ThenAsync("the My Profile Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 73 - await testRunner.WhenAsync("I tap on the Contacts button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 74 - await testRunner.ThenAsync("the Contact List Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 75 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 76 - await testRunner.ThenAsync("the My Profile Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 77 - await testRunner.WhenAsync("I tap on the Account Info button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 78 - await testRunner.ThenAsync("the Account Info Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 79 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 80 - await testRunner.ThenAsync("the My Profile Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 81 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 82 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Back Button from Support Page Screen")] - [NUnit.Framework.CategoryAttribute("PRNavTest")] - public async System.Threading.Tasks.Task BackButtonFromSupportPageScreen() - { - string[] tagsOfScenario = new string[] { - "PRNavTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Back Button from Support Page Screen", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 86 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 87 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 88 - await testRunner.AndAsync("the application is in training mode", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 89 - await testRunner.WhenAsync("I enter \'user1\' as the Email Address", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 90 - await testRunner.AndAsync("I enter \'123456\' as the Password", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 91 - await testRunner.AndAsync("I tap on Login", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 92 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 93 - await testRunner.WhenAsync("I tap on Support", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 94 - await testRunner.ThenAsync("the Support Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 95 - await testRunner.WhenAsync("I tap on the Upload Logs Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 96 - await testRunner.ThenAsync("the Support Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 97 - await testRunner.WhenAsync("I tap on the View Logs Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 98 - await testRunner.ThenAsync("the View Logs Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 99 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 100 - await testRunner.ThenAsync("the Support Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 101 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 102 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/archive/TransactionMobile.Maui.UiTests/Features/PageNavigationFeature.cs b/archive/TransactionMobile.Maui.UiTests/Features/PageNavigationFeature.cs deleted file mode 100644 index ecac02c8a..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/PageNavigationFeature.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Features; - -using Drivers; -using NUnit.Framework; -using UITests.Common; - -[TestFixture(MobileTestPlatform.Android, Category = "Android")] -[TestFixture(MobileTestPlatform.iOS, Category = "iOS")] -[TestFixture(MobileTestPlatform.Windows, Category = "Windows")] -[NonParallelizable] -public partial class PageNavigationFeature : BaseTestFixture -{ - #region Constructors - - public PageNavigationFeature(MobileTestPlatform mobileTestPlatform) : base(mobileTestPlatform) { - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Features/iOSEndToEndTests.feature b/archive/TransactionMobile.Maui.UiTests/Features/iOSEndToEndTests.feature deleted file mode 100644 index 9593e9227..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/iOSEndToEndTests.feature +++ /dev/null @@ -1,99 +0,0 @@ -@background @login @toolbar @profile @base @sharedapp @shared @transactions -Feature: iOSEndToEndTests - -Background: - - - -@iOSPRTest -Scenario: EndToEnd Training Mode - Given I am on the Login Screen - And the application is in training mode - When I enter 'user1' as the Email Address - And I enter '123456' as the Password - And I tap on Login - Then the Merchant Home Page is displayed - When I tap on Profile - Then the My Profile Page is displayed - When I tap on the Addresses button - Then the Address List Page is displayed - And the Primary Address is displayed - | AddressLine1 | AddressTown | - | test address line 1 | Town | - When I click on the back button - Then the My Profile Page is displayed - When I tap on the Account Info button - Then the Account Info Page is displayed - And the Account Info is displayed - | Name | Balance | AvailableBalance | - | Dummy Merchant | 99 | 100 | - When I click on the back button - Then the My Profile Page is displayed - When I click on the back button - Then the Merchant Home Page is displayed - When I tap on Transactions - Then the Transaction Page is displayed - When I tap on the Mobile Topup button - Then the Transaction Select Mobile Topup Operator Page is displayed - When I tap on the 'Safaricom' button - Then the Select Product Page is displayed - When I tap on the 'Custom' product button - Then the Enter Topup Details Page is displayed - When I enter '07777777775' as the Customer Mobile Number - And I enter 10.00 as the Topup Amount - And I tap on Perform Topup - Then the Mobile Topup Successful Page is displayed - And I tap on Complete - Then the Transaction Page is displayed - When I tap on the Voucher button - Then the Transaction Select Voucher Operator Page is displayed - When I tap on the 'Hospital 1 Contract' button - Then the Select Product Page is displayed - When I tap on the '10 KES' product button - Then the Enter Voucher Issue Details Page is displayed - When I enter '07777777775' as the Recipient Mobile Number - And I tap on Issue Voucher - Then the Voucher Issue Successful Page is displayed - And I tap on Complete - Then the Transaction Page is displayed - When I tap on the Bill Payment button - Then the Transaction Select Bill Payment Operator Page is displayed - When I tap on the 'Pata Pawa PostPay' button - Then the Select Product Page is displayed - When I tap on the 'Bill Pay (Post)' product button - Then the Enter Account Details Page is displayed - When I enter '12345678' as the Account Number - And I tap on the Get Account Button - Then the Make Bill Payment page is displayed - And the following Bill Details are displayed - | AccountNumber | AccountHolder | DueDate | Balance | - | 12345678 | Mr Test Customer | 2025-04-17 | 100.00 | - When I enter '07777777775' as the Customer Mobile Number - And I enter 10.00 as the Payment Amount - And I tap on the Make Payment Button - Then the Bill Payment Successful Page is displayed - And I tap on Complete - Then the Transaction Page is displayed - When I tap on the Bill Payment button - Then the Transaction Select Bill Payment Operator Page is displayed - When I tap on the 'Pata Pawa PrePay' button - Then the Select Product Page is displayed - When I tap on the 'Bill Pay (Pre)' product button - Then the Enter Meter Details Page is displayed - When I enter '00000001' as the Meter Number - And I tap on the Get Meter Button - Then the Make Bill Payment page is displayed - And the following Meter Details are displayed - | MeterNumber | - | 00000001 | - When I enter 10.00 as the Payment Amount - And I tap on the Make Payment Button - Then the Bill Payment Successful Page is displayed - And I tap on Complete - Then the Transaction Page is displayed - When I click on the back button - Then the Merchant Home Page is displayed - When I click on the back button - Then A message is displayed confirming I want to log out - When I click yes - Then the Login Page is displayed \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Features/iOSEndToEndTests.feature.cs b/archive/TransactionMobile.Maui.UiTests/Features/iOSEndToEndTests.feature.cs deleted file mode 100644 index f71a27dab..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Features/iOSEndToEndTests.feature.cs +++ /dev/null @@ -1,409 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by Reqnroll (https://www.reqnroll.net/). -// Reqnroll Version:2.0.0.0 -// Reqnroll Generator Version:2.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 -namespace TransactionMobile.Maui.UiTests.Features -{ - using Reqnroll; - using System; - using System.Linq; - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [NUnit.Framework.TestFixtureAttribute()] - [NUnit.Framework.DescriptionAttribute("iOSEndToEndTests")] - [NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)] - [NUnit.Framework.CategoryAttribute("background")] - [NUnit.Framework.CategoryAttribute("login")] - [NUnit.Framework.CategoryAttribute("toolbar")] - [NUnit.Framework.CategoryAttribute("profile")] - [NUnit.Framework.CategoryAttribute("base")] - [NUnit.Framework.CategoryAttribute("sharedapp")] - [NUnit.Framework.CategoryAttribute("shared")] - [NUnit.Framework.CategoryAttribute("transactions")] - public partial class IOSEndToEndTestsFeature - { - - private global::Reqnroll.ITestRunner testRunner; - - private static string[] featureTags = new string[] { - "background", - "login", - "toolbar", - "profile", - "base", - "sharedapp", - "shared", - "transactions"}; - - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "iOSEndToEndTests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); - -#line 1 "iOSEndToEndTests.feature" -#line hidden - - [NUnit.Framework.OneTimeSetUpAttribute()] - public static async System.Threading.Tasks.Task FeatureSetupAsync() - { - } - - [NUnit.Framework.OneTimeTearDownAttribute()] - public static async System.Threading.Tasks.Task FeatureTearDownAsync() - { - } - - [NUnit.Framework.SetUpAttribute()] - public async System.Threading.Tasks.Task TestInitializeAsync() - { - testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) - { - await testRunner.OnFeatureEndAsync(); - } - if ((testRunner.FeatureContext == null)) - { - await testRunner.OnFeatureStartAsync(featureInfo); - } - } - - [NUnit.Framework.TearDownAttribute()] - public async System.Threading.Tasks.Task TestTearDownAsync() - { - await testRunner.OnScenarioEndAsync(); - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); - } - - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); - } - - public async System.Threading.Tasks.Task ScenarioStartAsync() - { - await testRunner.OnScenarioStartAsync(); - } - - public async System.Threading.Tasks.Task ScenarioCleanupAsync() - { - await testRunner.CollectScenarioErrorsAsync(); - } - - public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() - { -#line 4 -#line hidden - } - - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("EndToEnd Training Mode")] - [NUnit.Framework.CategoryAttribute("iOSPRTest")] - public async System.Threading.Tasks.Task EndToEndTrainingMode() - { - string[] tagsOfScenario = new string[] { - "iOSPRTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("EndToEnd Training Mode", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 9 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - await this.ScenarioStartAsync(); -#line 4 -await this.FeatureBackgroundAsync(); -#line hidden -#line 10 - await testRunner.GivenAsync("I am on the Login Screen", ((string)(null)), ((global::Reqnroll.Table)(null)), "Given "); -#line hidden -#line 11 - await testRunner.AndAsync("the application is in training mode", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 12 - await testRunner.WhenAsync("I enter \'user1\' as the Email Address", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 13 - await testRunner.AndAsync("I enter \'123456\' as the Password", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 14 - await testRunner.AndAsync("I tap on Login", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 15 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 16 - await testRunner.WhenAsync("I tap on Profile", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 17 - await testRunner.ThenAsync("the My Profile Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 18 - await testRunner.WhenAsync("I tap on the Addresses button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 19 - await testRunner.ThenAsync("the Address List Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table25 = new global::Reqnroll.Table(new string[] { - "AddressLine1", - "AddressTown"}); - table25.AddRow(new string[] { - "test address line 1", - "Town"}); -#line 20 - await testRunner.AndAsync("the Primary Address is displayed", ((string)(null)), table25, "And "); -#line hidden -#line 23 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 24 - await testRunner.ThenAsync("the My Profile Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 25 - await testRunner.WhenAsync("I tap on the Account Info button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 26 - await testRunner.ThenAsync("the Account Info Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table26 = new global::Reqnroll.Table(new string[] { - "Name", - "Balance", - "AvailableBalance"}); - table26.AddRow(new string[] { - "Dummy Merchant", - "99", - "100"}); -#line 27 - await testRunner.AndAsync("the Account Info is displayed", ((string)(null)), table26, "And "); -#line hidden -#line 30 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 31 - await testRunner.ThenAsync("the My Profile Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 32 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 33 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 34 - await testRunner.WhenAsync("I tap on Transactions", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 35 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 36 - await testRunner.WhenAsync("I tap on the Mobile Topup button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 37 - await testRunner.ThenAsync("the Transaction Select Mobile Topup Operator Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 38 - await testRunner.WhenAsync("I tap on the \'Safaricom\' button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 39 - await testRunner.ThenAsync("the Select Product Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 40 - await testRunner.WhenAsync("I tap on the \'Custom\' product button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 41 - await testRunner.ThenAsync("the Enter Topup Details Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 42 - await testRunner.WhenAsync("I enter \'07777777775\' as the Customer Mobile Number", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 43 - await testRunner.AndAsync("I enter 10.00 as the Topup Amount", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 44 - await testRunner.AndAsync("I tap on Perform Topup", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 45 - await testRunner.ThenAsync("the Mobile Topup Successful Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 46 - await testRunner.AndAsync("I tap on Complete", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 47 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 48 - await testRunner.WhenAsync("I tap on the Voucher button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 49 - await testRunner.ThenAsync("the Transaction Select Voucher Operator Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 50 - await testRunner.WhenAsync("I tap on the \'Hospital 1 Contract\' button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 51 - await testRunner.ThenAsync("the Select Product Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 52 - await testRunner.WhenAsync("I tap on the \'10 KES\' product button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 53 - await testRunner.ThenAsync("the Enter Voucher Issue Details Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 54 - await testRunner.WhenAsync("I enter \'07777777775\' as the Recipient Mobile Number", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 55 - await testRunner.AndAsync("I tap on Issue Voucher", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 56 - await testRunner.ThenAsync("the Voucher Issue Successful Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 57 - await testRunner.AndAsync("I tap on Complete", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 58 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 59 - await testRunner.WhenAsync("I tap on the Bill Payment button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 60 - await testRunner.ThenAsync("the Transaction Select Bill Payment Operator Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 61 - await testRunner.WhenAsync("I tap on the \'Pata Pawa PostPay\' button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 62 - await testRunner.ThenAsync("the Select Product Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 63 - await testRunner.WhenAsync("I tap on the \'Bill Pay (Post)\' product button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 64 - await testRunner.ThenAsync("the Enter Account Details Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 65 - await testRunner.WhenAsync("I enter \'12345678\' as the Account Number", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 66 - await testRunner.AndAsync("I tap on the Get Account Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 67 - await testRunner.ThenAsync("the Make Bill Payment page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table27 = new global::Reqnroll.Table(new string[] { - "AccountNumber", - "AccountHolder", - "DueDate", - "Balance"}); - table27.AddRow(new string[] { - "12345678", - "Mr Test Customer", - "2025-04-17", - "100.00"}); -#line 68 - await testRunner.AndAsync("the following Bill Details are displayed", ((string)(null)), table27, "And "); -#line hidden -#line 71 - await testRunner.WhenAsync("I enter \'07777777775\' as the Customer Mobile Number", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 72 - await testRunner.AndAsync("I enter 10.00 as the Payment Amount", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 73 - await testRunner.AndAsync("I tap on the Make Payment Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 74 - await testRunner.ThenAsync("the Bill Payment Successful Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 75 - await testRunner.AndAsync("I tap on Complete", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 76 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 77 - await testRunner.WhenAsync("I tap on the Bill Payment button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 78 - await testRunner.ThenAsync("the Transaction Select Bill Payment Operator Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 79 - await testRunner.WhenAsync("I tap on the \'Pata Pawa PrePay\' button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 80 - await testRunner.ThenAsync("the Select Product Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 81 - await testRunner.WhenAsync("I tap on the \'Bill Pay (Pre)\' product button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 82 - await testRunner.ThenAsync("the Enter Meter Details Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 83 - await testRunner.WhenAsync("I enter \'00000001\' as the Meter Number", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 84 - await testRunner.AndAsync("I tap on the Get Meter Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 85 - await testRunner.ThenAsync("the Make Bill Payment page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - global::Reqnroll.Table table28 = new global::Reqnroll.Table(new string[] { - "MeterNumber"}); - table28.AddRow(new string[] { - "00000001"}); -#line 86 - await testRunner.AndAsync("the following Meter Details are displayed", ((string)(null)), table28, "And "); -#line hidden -#line 89 - await testRunner.WhenAsync("I enter 10.00 as the Payment Amount", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 90 - await testRunner.AndAsync("I tap on the Make Payment Button", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 91 - await testRunner.ThenAsync("the Bill Payment Successful Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 92 - await testRunner.AndAsync("I tap on Complete", ((string)(null)), ((global::Reqnroll.Table)(null)), "And "); -#line hidden -#line 93 - await testRunner.ThenAsync("the Transaction Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 94 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 95 - await testRunner.ThenAsync("the Merchant Home Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 96 - await testRunner.WhenAsync("I click on the back button", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 97 - await testRunner.ThenAsync("A message is displayed confirming I want to log out", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden -#line 98 - await testRunner.WhenAsync("I click yes", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); -#line hidden -#line 99 - await testRunner.ThenAsync("the Login Page is displayed", ((string)(null)), ((global::Reqnroll.Table)(null)), "Then "); -#line hidden - } - await this.ScenarioCleanupAsync(); - } - } -} -#pragma warning restore -#endregion diff --git a/archive/TransactionMobile.Maui.UiTests/Hooks/AppiumHooks.cs b/archive/TransactionMobile.Maui.UiTests/Hooks/AppiumHooks.cs deleted file mode 100644 index f0a552e05..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Hooks/AppiumHooks.cs +++ /dev/null @@ -1,69 +0,0 @@ -using OpenQA.Selenium.Appium; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using TransactionMobile.Maui.UiTests.Common; -using TransactionMobile.Maui.UiTests.Drivers; - -namespace TransactionMobile.Maui.UiTests.Hooks -{ - using OpenQA.Selenium; - using OpenQA.Selenium.Appium.Enums; - using Reqnroll; - using Shared.IntegrationTesting; - using Shared.Logger; - using Shouldly; - - [Binding] - public class AppiumHooks - { - private readonly AppiumDriverWrapper AppiumDriver; - private readonly TestingContext TestingContext; - public AppiumHooks(AppiumDriverWrapper appiumDriver, - TestingContext testingContext) { - this.AppiumDriver = appiumDriver; - this.TestingContext = testingContext; - } - - [BeforeScenario(Order = 1)] - public void StartApp() - { - if (this.TestingContext.Logger == null) - { - this.TestingContext.Logger = new NlogLogger(); - } - - //this.TestingContext.Logger.LogInformation("About to Start App"); - //this.TestingContext.Logger.LogInformation("App Started"); - - Retry.For(async () => { - this.AppiumDriver.StartApp(); - //AppState state = AppiumDriverWrapper.Driver.GetAppState("com.transactionprocessing.pos"); - // state.ShouldBe(AppState.NotRunning); - }).Wait(); - } - - [AfterScenario(Order = 1)] - public void ShutdownApp() - { - if (this.AppiumDriver == null) { - return; - } - - if (this.TestingContext.Logger == null){ - this.TestingContext.Logger = new NlogLogger(); - } - this.TestingContext.Logger.LogInformation("About to Shutdown App"); - var logs = this.AppiumDriver.GetLogs(); - if (logs != null) { - foreach (LogEntry logEntry in logs) { - this.TestingContext.Logger.LogInformation($"{logEntry.Timestamp}|{logEntry.Level}|{logEntry.Message}"); - } - } - this.AppiumDriver.StopApp(); - this.TestingContext.Logger.LogInformation("App Shutdown"); - } - } -} diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/BasePage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/BasePage.cs deleted file mode 100644 index 82f1c921b..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/BasePage.cs +++ /dev/null @@ -1,241 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using TransactionMobile.Maui.UiTests.Drivers; - -namespace TransactionMobile.Maui.UITests -{ - using Common; - using OpenQA.Selenium; - using OpenQA.Selenium.Appium; - using OpenQA.Selenium.Interactions; - using Shared.IntegrationTesting; - using Shouldly; - using TransactionMobile.Maui.UiTests.Common; - - public abstract class BasePage2{ - protected readonly TestingContext TestingContext; - - protected abstract String Trait { get; } - - protected BasePage2(TestingContext testingContext) - { - this.TestingContext = testingContext; - } - - public async Task AssertOnPage(TimeSpan? timeout = null){ - String message = $"Unable to verify on page: {this.GetType().Name} with trait {this.Trait} {Environment.NewLine}";// Source: {AppiumDriverWrapper.Driver.PageSource}"; - - Should.NotThrow(async () => await this.WaitForElementByAccessibilityId(this.Trait, timeout), message); - } - - public async Task WaitForPageToLeave(TimeSpan? timeout = null) - { - String message = "Unable to verify *not* on page: " + this.GetType().Name; - Should.NotThrow(async () => await this.WaitForNoElementByAccessibilityId(this.Trait, timeout), message); - } - - public async Task GetPageSource() - { - return await AppiumDriverWrapper.Driver.GetPageSource(); - } - - public async Task WaitForToastMessage(String toastMessage) - { - await AppiumDriverWrapper.Driver.WaitForToastMessage(AppiumDriverWrapper.MobileTestPlatform, toastMessage); - } - - public void HideKeyboard() - { - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Android) - { - AppiumDriverWrapper.Driver.HideKeyboard(); - } - else if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.iOS) - { - AppiumDriverWrapper.Driver.FindElement(By.Name("Done")).Click(); - } - } - - public async Task AcceptAlert() - { - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows) - { - IWebElement acceptButton = await AppiumDriverWrapper.Driver.WaitForElementByAccessibilityId("PrimaryButton"); - acceptButton.Click(); - } - else - { - IAlert a = await this.SwitchToAlert(); - a.Accept(); - } - } - - public async Task DismissAlert() - { - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows) - { - IWebElement acceptButton = await AppiumDriverWrapper.Driver.WaitForElementByAccessibilityId("SecondaryButton"); - acceptButton.Click(); - } - else - { - IAlert a = await this.SwitchToAlert(); - a.Dismiss(); - } - } - - public async Task SwitchToAlert() - { - IAlert alert = null; - await Retry.For(async () => { - alert = AppiumDriverWrapper.Driver.SwitchTo().Alert(); - alert.ShouldNotBeNull(); - }); - return alert; - } - - public void NavigateBack() - { - AppiumDriverWrapper.Driver.Navigate().Back(); - } - - public async Task GetLabelValue(String labelAutomationId) - { - IWebElement element = await this.WaitForElementByAccessibilityId(labelAutomationId); - return element.Text; - } - - internal async Task WaitForElementByAccessibilityId(String accessibilityId, TimeSpan? timeout = null, Int32 i = 0) - { - return await AppiumDriverWrapper.Driver.WaitForElementByAccessibilityId(accessibilityId, timeout, i); - } - - internal async Task WaitForNoElementByAccessibilityId(String accessibilityId, TimeSpan? timeout = null) - { - await AppiumDriverWrapper.Driver.WaitForNoElementByAccessibilityId(accessibilityId, timeout); - } - - } - - //public abstract class BasePage - //{ - // protected readonly TestingContext TestingContext; - - // protected abstract String Trait { get; } - - // public BasePage(TestingContext testingContext){ - // this.TestingContext = testingContext; - // } - - // public async Task AssertOnPage(TimeSpan? timeout = null){ - // var retryFor = timeout switch{ - // null => TimeSpan.FromMinutes(3), - // _ => timeout.Value - // }; - - // await Retry.For(async () => - // { - // String message = $"Unable to verify on page: {this.GetType().Name} with trait {this.Trait} {Environment.NewLine} Source: {AppiumDriverWrapper.Driver.PageSource}"; - - // Should.NotThrow(() => this.WaitForElementByAccessibilityId(this.Trait), message); - // }, - // retryFor, - // TimeSpan.FromSeconds(60)).ConfigureAwait(false); - // } - - // /// - // /// Verifies that the trait is no longer present. Defaults to a 5 second wait. - // /// - // /// Time to wait before the assertion fails - // public async Task WaitForPageToLeave(TimeSpan? timeout = null) - // { - // var retryFor = timeout switch - // { - // null => TimeSpan.FromSeconds(60), - // _ => timeout.Value - // }; - - // String message = "Unable to verify *not* on page: " + this.GetType().Name; - // await Retry.For(async () => { Should.NotThrow(() => this.WaitForNoElementByAccessibilityId(this.Trait), message); }, retryFor); - // } - - // public async Task WaitForElementByAccessibilityId(String accessibilityId, TimeSpan? timeout = null, Int32 i = 0) { - // return await AppiumDriverWrapper.Driver.WaitForElementByAccessibilityId(accessibilityId, timeout,i); - // } - - // public async Task GetPageSource() - // { - // return await AppiumDriverWrapper.Driver.GetPageSource(); - // } - - // public async Task WaitForNoElementByAccessibilityId(String accessibilityId) - // { - // await AppiumDriverWrapper.Driver.WaitForNoElementByAccessibilityId(accessibilityId); - // } - - // public async Task WaitForToastMessage(String toastMessage) - // { - // await AppiumDriverWrapper.Driver.WaitForToastMessage(AppiumDriverWrapper.MobileTestPlatform, toastMessage); - // } - - // public void HideKeyboard() - // { - // if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Android) - // { - // AppiumDriverWrapper.Driver.HideKeyboard(); - // } - // else if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.iOS) - // { - // AppiumDriverWrapper.Driver.FindElement(By.Name("Done")).Click(); - // } - // } - - // public async Task AcceptAlert(){ - // if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows) - // { - // IWebElement acceptButton = await AppiumDriverWrapper.Driver.WaitForElementByAccessibilityId("PrimaryButton"); - // acceptButton.Click(); - // } - // else{ - // IAlert a = await this.SwitchToAlert(); - // a.Accept(); - // } - // } - - // public async Task DismissAlert() - // { - // if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows) - // { - // IWebElement acceptButton = await AppiumDriverWrapper.Driver.WaitForElementByAccessibilityId("SecondaryButton"); - // acceptButton.Click(); - // } - // else{ - // IAlert a = await this.SwitchToAlert(); - // a.Dismiss(); - // } - // } - - // public async Task SwitchToAlert(){ - // IAlert alert = null; - // await Retry.For(async () => { - // alert = AppiumDriverWrapper.Driver.SwitchTo().Alert(); - // alert.ShouldNotBeNull(); - // }); - // return alert; - // } - - // public void NavigateBack() - // { - // AppiumDriverWrapper.Driver.Navigate().Back(); - // } - - // public async Task GetLabelValue(String labelAutomationId) - // { - // IWebElement element = await this.WaitForElementByAccessibilityId(labelAutomationId); - // return element.Text; - // } - //} -} diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/Extenstions.cs b/archive/TransactionMobile.Maui.UiTests/Pages/Extenstions.cs deleted file mode 100644 index b9f33ec26..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/Extenstions.cs +++ /dev/null @@ -1,157 +0,0 @@ -using OpenQA.Selenium.Appium; -//using OpenQA.Selenium.Appium.MultiTouch; -using TransactionMobile.Maui.UiTests.Drivers; - -namespace TransactionMobile.Maui.UITests; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Common; -using OpenQA.Selenium; -using OpenQA.Selenium.Appium.Android; -using OpenQA.Selenium.Appium.iOS; -using OpenQA.Selenium.Appium.Windows; -using OpenQA.Selenium.Interactions; -using Shared.IntegrationTesting; -using Shouldly; - -public static class Extenstions -{ - // TODO: Mac & Windows Extensions - // TODO: May need a platform switch - //public static AndroidElement GetAlert(this AndroidDriver driver) - //{ - // return driver.FindElementByClassName("androidx.appcompat.widget.AppCompatTextView"); - //} - - public static async Task WaitForElementByAccessibilityId(this AppiumDriver driver, - String selector, - TimeSpan? timeout = null, - Int32 i = 0) { - IWebElement? element = null; - - TimeSpan retryFor = timeout switch{ - null => TimeSpan.FromSeconds(60), - _ => timeout.Value - }; - - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows && i == 1){ - - await Retry.For(async () => { - for (int i = 0; i < 10; i++){ - String message = $"Unable to find element on page: {selector} {Environment.NewLine} Source: {AppiumDriverWrapper.Driver.PageSource}"; - var elements = AppiumDriverWrapper.Driver.FindElements(MobileBy.AccessibilityId("navViewItem")); - elements.ShouldNotBeEmpty(); - element = elements.SingleOrDefault(e => e.Text == selector); - element.ShouldNotBeNull(); - } - }, retryFor); - return element; - } - - await Retry.For(async () => { - for (int i = 0; i < 10; i++) { - - String message = $"Unable to find element on page: {selector} {Environment.NewLine} Source: {AppiumDriverWrapper.Driver.PageSource}"; - driver.ScrollDown(); - element = driver.FindElement(MobileBy.AccessibilityId(selector)); - element.ShouldNotBeNull(message); - // All good so exit the loop - break; - } - }, retryFor); - return element; - } - - public static void ScrollDown(this AppiumDriver driver) - { - //if pressX was zero it didn't work for me - int pressX = driver.Manage().Window.Size.Width / 2; - // 4/5 of the screen as the bottom finger-press point - int bottomY = driver.Manage().Window.Size.Height * 4 / 5; - // just non zero point, as it didn't scroll to zero normally - int topY = driver.Manage().Window.Size.Height / 8; - //scroll with TouchAction by itself - if (driver is WindowsDriver){ - return; - } - else{ - driver.Scroll(pressX, bottomY, pressX, topY); - } - } - - /* - * don't forget that it's "natural scroll" where - * fromY is the point where you press the and toY where you release it - */ - public static void Scroll(this AppiumDriver driver, int fromX, int fromY, int toX, int toY) - { - // TODO: Implement this for new Appium Driver - //TouchAction touchAction = new TouchAction(driver); - //touchAction.LongPress(fromX, fromY).MoveTo(toX, toY).Release().Perform(); - } - - public static async Task WaitForNoElementByAccessibilityId(this AppiumDriver driver, - String selector, - TimeSpan? timeout = null) - { - TimeSpan retryFor = timeout switch - { - null => TimeSpan.FromSeconds(60), - _ => timeout.Value - }; - - await Retry.For(async () => - { - IWebElement? element = driver.FindElement(MobileBy.AccessibilityId(selector)); - element.ShouldBeNull(); - }, retryFor); - - } - - public static async Task WaitForToastMessage(this AppiumDriver driver, MobileTestPlatform platform, String expectedToast) - { - if (platform == MobileTestPlatform.Android) - { - await Retry.For(async () => - { - Dictionary args = new Dictionary - { - {"text", expectedToast}, - {"isRegexp", false} - }; - driver.ExecuteScript("mobile: isToastVisible", args); - - }); - } - else if (platform == MobileTestPlatform.iOS) - { - Boolean isDisplayed = false; - int count = 0; - do - { - if (driver.PageSource.Contains(expectedToast)) - { - Console.WriteLine(driver.PageSource); - isDisplayed = true; - break; - } - - Thread.Sleep(200); //Add your custom wait if exists - count++; - - } while (count < 10); - - Console.WriteLine(driver.PageSource); - isDisplayed.ShouldBeTrue(); - } - } - - public static async Task GetPageSource(this AppiumDriver driver) - { - return driver.PageSource; - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/LoginPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/LoginPage.cs deleted file mode 100644 index cd9b2eb18..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/LoginPage.cs +++ /dev/null @@ -1,126 +0,0 @@ -using TransactionMobile.Maui.UiTests.Drivers; - -namespace TransactionMobile.Maui.UITests; - -using System; -using System.Linq; -using System.Threading.Tasks; -using OpenQA.Selenium; -using OpenQA.Selenium.Interactions; -using Shared.IntegrationTesting; -using Shouldly; -using UiTests.Common; -using static System.Net.Mime.MediaTypeNames; - -public class LoginPage : BasePage2 -{ - protected override String Trait => "LoginLabel"; - - private readonly String UserNameEntry; - private readonly String PasswordEntry; - private readonly String LoginButton; - private readonly String UseTrainingModeSwitch; - private readonly String DeviceSerial; - - private readonly String ConfigHostUrlEntry; - - public LoginPage(TestingContext testingContext) : base(testingContext) - { - this.UserNameEntry = "UserNameEntry"; - this.PasswordEntry = "PasswordEntry"; - this.LoginButton = "LoginButton"; - this.UseTrainingModeSwitch = "UseTrainingModeSwitch"; - this.DeviceSerial = "DeviceSerial"; - this.ConfigHostUrlEntry = "ConfigHostUrlEntry"; - } - - public async Task GetDeviceSerial() { - IWebElement element = await this.WaitForElementByAccessibilityId(this.DeviceSerial); - return element.Text; - } - - public async Task SetConfigHostUrl(String configHostUrl) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.ConfigHostUrlEntry); - element.SendKeys(configHostUrl); - } - - public async Task IsTrainingModeOn() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.UseTrainingModeSwitch); - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Android) { - var text = element.GetAttribute("checked"); - if (text == "false") { - return false; - } - - return true; - } - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.iOS) { - String? text = element.GetAttribute("value"); - if (text == "0") { - return false; - } - - return true; - } - - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows){ - return false; - } - - return true; - } - - public async Task SetTrainingModeOn() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.UseTrainingModeSwitch); - element.Click(); - } - - public async Task SetTrainingModeOff() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.UseTrainingModeSwitch); - - element.Click(); - } - - public async Task EnterEmailAddress(String emailAddress) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.UserNameEntry); - - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Android){ - element.SendKeys(emailAddress); - } - else{ - emailAddress.ToCharArray().ToList().ForEach(x => element.SendKeys(x.ToString())); - } - } - - public async Task GetEmailAddress() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.UserNameEntry); - - return element.Text; - } - - public async Task EnterPassword(String password) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.PasswordEntry); - element.SendKeys(password); - } - - public async Task ClickLoginButton(){ - await Retry.For(async () => { - IWebElement element = await this.WaitForElementByAccessibilityId(this.LoginButton); - if (element.Displayed == false) - { - this.HideKeyboard(); - } - - //element.Displayed.ShouldBeTrue(); - element.Click(); - }); - - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/MainPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/MainPage.cs deleted file mode 100644 index e8e5b8263..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/MainPage.cs +++ /dev/null @@ -1,78 +0,0 @@ -namespace TransactionMobile.Maui.UITests; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using NUnit.Framework; -using OpenQA.Selenium; -using OpenQA.Selenium.Appium; -using Shared.IntegrationTesting; -using Shouldly; -using UiTests.Common; -using UiTests.Drivers; - -public class MainPage : BasePage2 -{ - protected override String Trait => "Home"; - - private readonly String TransactionsButton; - - private readonly String ReportsButton; - - private readonly String ProfileButton; - - private readonly String SupportButton; - - private readonly String AvailableBalanceLabel; - - /// - /// Initializes a new instance of the class. - /// - public MainPage(TestingContext testingContext) : base(testingContext) - { - this.TransactionsButton = "Transactions"; - this.ReportsButton = "Reports"; - this.ProfileButton = "My Account"; - this.SupportButton = "Support"; - this.AvailableBalanceLabel = "AvailableBalanceValueLabel"; - } - - public async Task ClickTransactionsButton(){ - var element = await this.WaitForElementByAccessibilityId(this.TransactionsButton, i:1); - element.Click(); - } - - public async Task ClickReportsButton() - { - var element = await this.WaitForElementByAccessibilityId(this.ReportsButton, i:1); - element.Click(); - } - - public async Task ClickProfileButton() { - var element = await this.WaitForElementByAccessibilityId(this.ProfileButton,i:1); - element.Click(); - } - - public async Task ClickSupportButton() - { - var element = await this.WaitForElementByAccessibilityId(this.SupportButton, i:1); - element.Click(); - } - - public async Task GetAvailableBalanceValue(TimeSpan? timeout = default(TimeSpan?)) - { - //await this.ScrollTo(this.Trait, this.AvailableBalanceLabel); - //var element = await this.WaitForElementByAccessibilityId(this.AvailableBalanceLabel, timeout: TimeSpan.FromSeconds(30)); - - //String availableBalanceText = element.Text.Replace(" KES", String.Empty); - - //if (Decimal.TryParse(availableBalanceText, out Decimal balanceValue) == false) - //{ - // throw new Exception($"Failed to parse [{availableBalanceText}] as a Decimal"); - //} - - //return balanceValue; - return 0; - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/ProfileAccountInfoPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/ProfileAccountInfoPage.cs deleted file mode 100644 index da17af22c..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/ProfileAccountInfoPage.cs +++ /dev/null @@ -1,72 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using TransactionMobile.Maui.UiTests.Common; -using UITests; - -public class ProfileAccountInfoPage : BasePage2 -{ - #region Fields - - public readonly String AvailableBalanceLabel; - - public readonly String BalanceLabel; - - public readonly String LastStatementDateLabel; - - public readonly String MerchantNameLabel; - - public readonly String NextStatementDateLabel; - - public readonly String SettlementScheduleLabel; - - #endregion - - #region Constructors - - public ProfileAccountInfoPage(TestingContext testingContext) : base(testingContext){ - this.MerchantNameLabel = "MerchantNameLabel"; - this.BalanceLabel = "BalanceLabel"; - this.AvailableBalanceLabel = "AvailableBalanceLabel"; - this.LastStatementDateLabel = "LastStatementDateLabel"; - this.NextStatementDateLabel = "NextStatementDateLabel"; - this.SettlementScheduleLabel = "SettlementScheduleLabel"; - } - - #endregion - - #region Properties - - protected override String Trait => "My Details"; - - #endregion - - #region Methods - - public async Task GetAvailableBalanceValue() { - return await this.GetLabelValue(this.AvailableBalanceLabel); - } - - public async Task GetBalanceValue() { - return await this.GetLabelValue(this.BalanceLabel); - } - - public async Task GetLastStatementDateValue() { - return await this.GetLabelValue(this.LastStatementDateLabel); - } - - public async Task GetMerchantNameValue() { - return await this.GetLabelValue(this.MerchantNameLabel); - } - - public async Task GetNextStatementDateValue() { - return await this.GetLabelValue(this.NextStatementDateLabel); - } - - public async Task GetSettlementScheduleValue() { - return await this.GetLabelValue(this.SettlementScheduleLabel); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/ProfileAddressesPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/ProfileAddressesPage.cs deleted file mode 100644 index 1fdf8b429..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/ProfileAddressesPage.cs +++ /dev/null @@ -1,80 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using TransactionMobile.Maui.UiTests.Common; -using UITests; - -public class ProfileAddressesPage : BasePage2 -{ - #region Fields - - public readonly String PrimaryAddressLabel; - - private readonly String AddressLine1Label; - - private readonly String AddressLine2Label; - - private readonly String AddressLine3Label; - - private readonly String AddressLine4Label; - - private readonly String AddressPostalCodeLabel; - - private readonly String AddressRegionLabel; - - private readonly String AddressTownLabel; - - #endregion - - #region Constructors - - public ProfileAddressesPage(TestingContext testingContext) : base(testingContext) - { - this.PrimaryAddressLabel = "PrimaryAddressLabel"; - this.AddressLine1Label = "AddressLine1Label"; - this.AddressLine2Label = "AddressLine2Label"; - this.AddressLine3Label = "AddressLine3Label"; - this.AddressLine4Label = "AddressLine4Label"; - this.AddressRegionLabel = "AddressRegionLabel"; - this.AddressTownLabel = "AddressTownLabel"; - this.AddressPostalCodeLabel = "AddressPostCodeLabel"; - } - - #endregion - - #region Properties - - protected override String Trait => "My Addresses"; - - #endregion - - #region Methods - - public async Task GetAddressLineValue(Int32 lineNumber) { - return lineNumber switch { - 1 => await this.GetLabelValue(this.AddressLine1Label), - 2 => await this.GetLabelValue(this.AddressLine2Label), - 3 => await this.GetLabelValue(this.AddressLine3Label), - 4 => await this.GetLabelValue(this.AddressLine4Label) - }; - } - - public async Task GetAddressPostalCodeValue() { - return await this.GetLabelValue(this.AddressPostalCodeLabel); - } - - public async Task GetAddressRegionValue() { - return await this.GetLabelValue(this.AddressRegionLabel); - } - - public async Task GetAddressTownValue() { - return await this.GetLabelValue(this.AddressTownLabel); - } - - public async Task IsPrimaryAddressShown() { - await this.WaitForElementByAccessibilityId(this.PrimaryAddressLabel); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/ProfileContactsPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/ProfileContactsPage.cs deleted file mode 100644 index c580d3b5c..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/ProfileContactsPage.cs +++ /dev/null @@ -1,59 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using TransactionMobile.Maui.UiTests.Common; -using UITests; - -public class ProfileContactsPage : BasePage2 -{ - #region Fields - - public readonly String PrimaryContactLabel; - - private readonly String ContactEmailAddressLabel; - - private readonly String ContactMobileNumberLabel; - - private readonly String ContactNameLabel; - - #endregion - - #region Constructors - - public ProfileContactsPage(TestingContext testingContext) : base(testingContext) - { - this.PrimaryContactLabel = "PrimaryContactLabel"; - this.ContactNameLabel = "ContactNameLabel"; - this.ContactEmailAddressLabel = "ContactEmailAddressLabel"; - this.ContactMobileNumberLabel = "ContactMobileNumberLabel"; - } - - #endregion - - #region Properties - - protected override String Trait => "My Contacts"; - - #endregion - - #region Methods - - public async Task GetContactEmailAddressValue() { - return await this.GetLabelValue(this.ContactEmailAddressLabel); - } - - public async Task GetContactMobileNumberValue() { - return await this.GetLabelValue(this.ContactMobileNumberLabel); - } - - public async Task GetContactNameValue() { - return await this.GetLabelValue(this.ContactNameLabel); - } - - public async Task IsPrimaryContactShown() { - await this.WaitForElementByAccessibilityId(this.PrimaryContactLabel); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/ProfilePage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/ProfilePage.cs deleted file mode 100644 index 2343824e3..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/ProfilePage.cs +++ /dev/null @@ -1,68 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages -{ - using System; - using System.Threading.Tasks; - using Drivers; - using OpenQA.Selenium; - using TransactionMobile.Maui.UiTests.Common; - using UITests; - - public class ProfilePage : BasePage2 - { - #region Fields - - private readonly String AccountInfoButton; - - private readonly String AddressesButton; - - private readonly String ContactsButton; - - private readonly String LogoutButton; - - #endregion - - #region Constructors - - public ProfilePage(TestingContext testingContext) : base(testingContext) - { - this.LogoutButton = "LogoutButton"; - this.AddressesButton = "AddressesButton"; - this.ContactsButton = "ContactsButton"; - this.AccountInfoButton = "AccountInfoButton"; - } - - #endregion - - #region Properties - - protected override String Trait => "My Account"; - - #endregion - - #region Methods - - public async Task ClickAccountInfoButton() { - IWebElement element = await this.WaitForElementByAccessibilityId(this.AccountInfoButton); - element.Click(); - } - - public async Task ClickAddressesButton() { - IWebElement element = await this.WaitForElementByAccessibilityId(this.AddressesButton); - element.Click(); - - var x = await AppiumDriverWrapper.Driver.GetPageSource(); - } - - public async Task ClickContactsButton() { - IWebElement element = await this.WaitForElementByAccessibilityId(this.ContactsButton); - element.Click(); - } - - public async Task ClickLogoutButton() { - IWebElement element = await this.WaitForElementByAccessibilityId(this.LogoutButton); - element.Click(); - } - - #endregion - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/ReportsPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/ReportsPage.cs deleted file mode 100644 index b11d0231f..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/ReportsPage.cs +++ /dev/null @@ -1,99 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using Common; -using Drivers; -using OpenQA.Selenium; -using UITests; - -public class ReportsPage : BasePage2 -{ - protected override String Trait - { - get - { - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows) - { - return "Reports"; - } - return "Reports"; - } - } - - private readonly String SalesAnalysisButton; - private readonly String BalanceAnalysisButton; - - - - public ReportsPage(TestingContext testingContext) : base(testingContext) - { - this.SalesAnalysisButton = "SalesAnalysisButton"; - this.BalanceAnalysisButton = "BalanceAnalysisButton"; - } - public async Task ClickBalanceAnalysisButton() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.BalanceAnalysisButton); - element.Click(); - } - - public async Task ClickSalesAnalysisButton() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.SalesAnalysisButton); - element.Click(); - } -} - -public class SupportPage : BasePage2{ - protected override String Trait{ - get{ - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows){ - return "Support"; - } - - return "Support"; - } - } - - private readonly String UploadLogsButton; - private readonly String ViewLogsButton; - - public SupportPage(TestingContext testingContext) : base(testingContext) - { - this.UploadLogsButton = "UploadLogsButton"; - this.ViewLogsButton = "ViewLogsButton"; - } - - public async Task ClickUploadLogsButton() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.UploadLogsButton); - element.Click(); - } - - public async Task ClickViewLogsButton() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.ViewLogsButton); - element.Click(); - } -} - -public class ViewLogsPage : BasePage2{ - public ViewLogsPage(TestingContext testingContext) : base(testingContext){ - - } - - protected override String Trait - { - get - { - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows) - { - return "View Logs"; - } - return "View Logs"; - } - } - - - -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/SalesAnalysisPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/SalesAnalysisPage.cs deleted file mode 100644 index 284c12b63..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/SalesAnalysisPage.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using Common; -using Drivers; -using UITests; - -public class SalesAnalysisPage : BasePage2 -{ - protected override String Trait - { - get - { - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows) - { - return "Sales Analysis"; - } - return "Sales Analysis"; - } - } - - public SalesAnalysisPage(TestingContext testingContext) : base(testingContext) - { - - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/SharedPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/SharedPage.cs deleted file mode 100644 index 75a59e7ee..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/SharedPage.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.UiTests.Pages -{ - using OpenQA.Selenium; - using OpenQA.Selenium.Appium; - using OpenQA.Selenium.Appium.Windows; - using Shouldly; - using TransactionMobile.Maui.UiTests.Common; - using TransactionMobile.Maui.UiTests.Drivers; - using UITests; - - public class SharedPage : BasePage2 - { - protected override String Trait => String.Empty; - private readonly String BackButton; - - public SharedPage(TestingContext testingContext) : base(testingContext) - { - this.BackButton = "BackButton"; - } - public async Task LogoutMessageIsDisplayed(String logoutAlertTitle, - String logoutAlertMessage) { - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows){ - - IWebElement alert = await AppiumDriverWrapper.Driver.WaitForElementByAccessibilityId("ContentScrollViewer"); - - var allLabels = alert.FindElements(MobileBy.ClassName("TextBlock")); - allLabels[0].Text.ShouldBe(logoutAlertTitle); - allLabels[1].Text.ShouldBe(logoutAlertMessage); - } - else{ - IAlert a = await this.SwitchToAlert(); - a.Text.ShouldBe($"{logoutAlertTitle}{Environment.NewLine}{logoutAlertMessage}"); - } - } - - public async Task ClickBackButton() { - IWebElement element = await this.WaitForElementByAccessibilityId(this.BackButton); - element.Click(); - } - } -} diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsBillPaymentSelectOperatorPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsBillPaymentSelectOperatorPage.cs deleted file mode 100644 index 7ae0c8103..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsBillPaymentSelectOperatorPage.cs +++ /dev/null @@ -1,213 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using Common; -using OpenQA.Selenium; -using Shared.IntegrationTesting; -using UITests; - -public class TransactionsBillPaymentSelectOperatorPage : BasePage2 -{ - public TransactionsBillPaymentSelectOperatorPage(TestingContext testingContext) : base(testingContext) - { - - } - - #region Properties - - protected override String Trait => "Select an Operator"; - - #endregion - - public async Task ClickOperatorButton(String operatorName) - { - IWebElement element = await this.WaitForElementByAccessibilityId(operatorName); - element.Click(); - } -} - -public class TransactionsBillPaymentSelectProductPage : BasePage2{ - public TransactionsBillPaymentSelectProductPage(TestingContext testingContext) : base(testingContext){ - } - - protected override String Trait{ get; } - - public async Task ClickProductButton(String productText) - { - IWebElement element = await this.WaitForElementByAccessibilityId(productText); - element.Click(); - } -} - -public class TransactionsBillPaymentEnterAccountDetailsPage : BasePage2 -{ - private readonly String CustomerAccountNumberEntry; - - private readonly String GetAccountButton; - - public TransactionsBillPaymentEnterAccountDetailsPage(TestingContext testingContext) : base(testingContext) - { - this.CustomerAccountNumberEntry = "CustomerAccountNumberEntry"; - this.GetAccountButton = "GetAccountButton"; - } - - protected override String Trait => "Get Customer Account"; - - public async Task EnterCustomerAccountNumber(String customerAccountNumber) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.CustomerAccountNumberEntry); - - element.SendKeys(customerAccountNumber); - } - - public async Task ClickGetAccountButton() - { - await Retry.For(async () => { - IWebElement element = await this.WaitForElementByAccessibilityId(this.GetAccountButton); - //element.Displayed.ShouldBeTrue(); - element.Click(); - }); - } -} - -public class TransactionsBillPaymentEnterMeterDetailsPage : BasePage2 -{ - private readonly String MeterNumberEntry; - - private readonly String GetMeterButton; - - public TransactionsBillPaymentEnterMeterDetailsPage(TestingContext testingContext) : base(testingContext) - { - this.MeterNumberEntry = "MeterNumberEntry"; - this.GetMeterButton = "GetMeterButton"; - } - - protected override String Trait => "Get Meter"; - - public async Task EnterMeterNumber(String meterNumber) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.MeterNumberEntry); - - element.SendKeys(meterNumber); - } - - public async Task ClickGetMeterButton() - { - await Retry.For(async () => { - IWebElement element = await this.WaitForElementByAccessibilityId(this.GetMeterButton); - //element.Displayed.ShouldBeTrue(); - element.Click(); - }); - } -} - -public class TransactionsBillPaymentMakeAPaymentPage : BasePage2 -{ - private readonly String CustomerMobileNumberEntry; - private readonly String PostPaymentAmountEntry; - private readonly String PrePaymentAmountEntry; - private readonly String MakePaymentButton; - - public TransactionsBillPaymentMakeAPaymentPage(TestingContext testingContext) : base(testingContext) - { - this.CustomerMobileNumberEntry = "CustomerMobileNumberEntry"; - - // TODO: handle prepayment as well - this.PostPaymentAmountEntry = "PostPaymentAmountEntry"; - this.PrePaymentAmountEntry = "PrePaymentAmountEntry"; - this.MakePaymentButton = "MakePaymentButton"; - this.AccountNumberLabel = "AccountNumber"; - this.AccountHolderLabel = "AccountName"; - this.BalanceLabel = "Balance"; - this.DueDateLabel = "DueDate"; - this.MeterNumberLabel = "MeterNumber"; - - } - - protected override String Trait => "Make Bill Payment"; - - public async Task EnterCustomerMobileNumber(String customerMobileNumber) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.CustomerMobileNumberEntry); - - element.SendKeys(customerMobileNumber); - } - - public readonly String AccountNumberLabel; - public readonly String AccountHolderLabel; - public readonly String BalanceLabel; - public readonly String DueDateLabel; - - public readonly String MeterNumberLabel; - - public async Task GetAccountNumberValue(){ - return await this.GetLabelValue(this.AccountNumberLabel); - } - public async Task GetMeterNumberValue() - { - return await this.GetLabelValue(this.MeterNumberLabel); - } - - public async Task GetAccountHolderValue() - { - return await this.GetLabelValue(this.AccountHolderLabel); - } - public async Task GetBalanceValue() - { - return await this.GetLabelValue(this.BalanceLabel); - } - public async Task GetDueDateValue() - { - return await this.GetLabelValue(this.DueDateLabel); - } - - public async Task EnterPostPaymentAmount(String paymentAmount) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.PostPaymentAmountEntry); - - element.SendKeys(paymentAmount); - } - - public async Task EnterPrePaymentAmount(String paymentAmount) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.PrePaymentAmountEntry); - - element.SendKeys(paymentAmount); - } - - public async Task ClickMakePaymentButton() - { - await Retry.For(async () => { - IWebElement element = await this.WaitForElementByAccessibilityId(this.MakePaymentButton); - //element.Displayed.ShouldBeTrue(); - element.Click(); - }); - } -} - -public class TransactionsBillPaymentSuccessfulPaymentPage : BasePage2 -{ - - private readonly String CompleteButton; - - public TransactionsBillPaymentSuccessfulPaymentPage(TestingContext testingContext) : base(testingContext) - { - this.CompleteButton = "CompleteButton"; - } - - #region Properties - - protected override String Trait => "Bill Payment Successful"; - - public async Task ClickCompleteButton() - { - await Retry.For(async () => { - IWebElement element = await this.WaitForElementByAccessibilityId(this.CompleteButton); - //element.Displayed.ShouldBeTrue(); - element.Click(); - }); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupEnterTopupDetailsPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupEnterTopupDetailsPage.cs deleted file mode 100644 index 2828fdbda..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupEnterTopupDetailsPage.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using Common; -using OpenQA.Selenium; -using Shared.IntegrationTesting; -using UITests; - -public class TransactionsMobileTopupEnterTopupDetailsPage : BasePage2 { - - private readonly String CustomerMobileNumberEntry; - private readonly String TopupAmountEntry; - private readonly String CustomerEmailAddressEntry; - private readonly String PerformTopupButton; - - public TransactionsMobileTopupEnterTopupDetailsPage(TestingContext testingContext) : base(testingContext){ - this.CustomerMobileNumberEntry = "CustomerMobileNumberEntry"; - this.TopupAmountEntry = "TopupAmountEntry"; - this.CustomerEmailAddressEntry = "CustomerEmailAddressEntry"; - this.PerformTopupButton = "PerformTopupButton"; - } - - #region Properties - - protected override String Trait => "Enter Topup Details"; - - public async Task EnterCustomerMobileNumber(String customerMobileNumber) { - IWebElement element = await this.WaitForElementByAccessibilityId(this.CustomerMobileNumberEntry); - - element.SendKeys(customerMobileNumber); - } - - public async Task EnterTopupAmount(String topupAmount) { - IWebElement element = await this.WaitForElementByAccessibilityId(this.TopupAmountEntry); - - element.SendKeys(topupAmount); - } - - public async Task EnterCustomerEmailAddress(String customerEmailAddress) { - IWebElement element = await this.WaitForElementByAccessibilityId(this.CustomerEmailAddressEntry); - - element.SendKeys(customerEmailAddress); - } - - public async Task ClickPerformTopupButton() { - await Retry.For(async () => { - IWebElement element = await this.WaitForElementByAccessibilityId(this.PerformTopupButton); - //element.Displayed.ShouldBeTrue(); - element.Click(); - }); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupSelectOperatorPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupSelectOperatorPage.cs deleted file mode 100644 index 8c9fd8f76..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupSelectOperatorPage.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using Common; -using OpenQA.Selenium; -using UITests; - -public class TransactionsMobileTopupSelectOperatorPage : BasePage2 -{ - public TransactionsMobileTopupSelectOperatorPage(TestingContext testingContext) : base(testingContext) - { - - } - - #region Properties - - protected override String Trait => "Select an Operator"; - - #endregion - - public async Task ClickOperatorButton(String operatorName) { - IWebElement element = await this.WaitForElementByAccessibilityId(operatorName); - element.Click(); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupSelectProductPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupSelectProductPage.cs deleted file mode 100644 index 0f7288cc1..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupSelectProductPage.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using Common; -using OpenQA.Selenium; -using UITests; - -public class TransactionsMobileTopupSelectProductPage : BasePage2 { - public TransactionsMobileTopupSelectProductPage(TestingContext testingContext) : base(testingContext) { - - } - - #region Properties - - protected override String Trait => "Select a Product"; - - #endregion - - public async Task ClickProductButton(String productText) { - IWebElement element = await this.WaitForElementByAccessibilityId(productText); - element.Click(); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupSuccessfulTopupPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupSuccessfulTopupPage.cs deleted file mode 100644 index 7a1999f42..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsMobileTopupSuccessfulTopupPage.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using Common; -using OpenQA.Selenium; -using Shared.IntegrationTesting; -using UITests; - -public class TransactionsMobileTopupSuccessfulTopupPage : BasePage2 { - - private readonly String CompleteButton; - - public TransactionsMobileTopupSuccessfulTopupPage(TestingContext testingContext) : base(testingContext) { - this.CompleteButton = "CompleteButton"; - } - - #region Properties - - protected override String Trait => "Mobile Topup Successful"; - - public async Task ClickCompleteButton() { - await Retry.For(async () => { - IWebElement element = await this.WaitForElementByAccessibilityId(this.CompleteButton); - //element.Displayed.ShouldBeTrue(); - element.Click(); - }); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsPage.cs deleted file mode 100644 index 1964c0078..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsPage.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using OpenQA.Selenium; -using System; -using System.Threading.Tasks; -using Common; -using Drivers; -using UITests; - -public class TransactionsPage : BasePage2 -{ - protected override String Trait{ - get{ - if (AppiumDriverWrapper.MobileTestPlatform == MobileTestPlatform.Windows){ - return "Select Transaction Type"; - } - return "Transactions"; - } - } - - private readonly String MobileTopupButton; - private readonly String VoucherButton; - private readonly String BillPaymentButton; - - public TransactionsPage(TestingContext testingContext) : base(testingContext) - { - this.MobileTopupButton = "MobileTopupButton"; - this.VoucherButton = "VoucherButton"; - this.BillPaymentButton = "BillPaymentButton"; - } - public async Task ClickMobileTopupButton() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.MobileTopupButton); - element.Click(); - } - - public async Task ClickVoucherButton() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.VoucherButton); - element.Click(); - } - - public async Task ClickBillPaymentButton() - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.BillPaymentButton); - element.Click(); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherEnterVoucherIssueDetailsPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherEnterVoucherIssueDetailsPage.cs deleted file mode 100644 index 23f255362..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherEnterVoucherIssueDetailsPage.cs +++ /dev/null @@ -1,70 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using Common; -using OpenQA.Selenium; -using Shared.IntegrationTesting; -using UITests; - -public class TransactionsVoucherEnterVoucherIssueDetailsPage : BasePage2 -{ - - private readonly String RecipientMobileNumberEntry; - private readonly String RecipientEmailAddressEntry; - private readonly String VoucherAmountEntry; - private readonly String CustomerEmailAddressEntry; - private readonly String IssueVoucherButton; - - public TransactionsVoucherEnterVoucherIssueDetailsPage(TestingContext testingContext) : base(testingContext) - { - this.RecipientMobileNumberEntry = "RecipientMobileNumberEntry"; - this.RecipientEmailAddressEntry = "RecipientEmailAddressEntry"; - this.VoucherAmountEntry = "VoucherAmountEntry"; - this.CustomerEmailAddressEntry = "CustomerEmailAddressEntry"; - this.IssueVoucherButton = "IssueVoucherButton"; - } - - #region Properties - - protected override String Trait => "Enter Voucher Issue Details"; - - public async Task EnterRecipientMobileNumber(String recipientMobileNumber) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.RecipientMobileNumberEntry); - - element.SendKeys(recipientMobileNumber); - } - - public async Task EnterRecipientEmailAddress(String recipientEmailAddress) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.RecipientEmailAddressEntry); - - element.SendKeys(recipientEmailAddress); - } - - public async Task EnterVoucherAmount(String voucherAmount) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.VoucherAmountEntry); - - element.SendKeys(voucherAmount); - } - - public async Task EnterCustomerEmailAddress(String customerEmailAddress) - { - IWebElement element = await this.WaitForElementByAccessibilityId(this.CustomerEmailAddressEntry); - - element.SendKeys(customerEmailAddress); - } - - public async Task ClickIssueVoucherButton() - { - await Retry.For(async () => { - IWebElement element = await this.WaitForElementByAccessibilityId(this.IssueVoucherButton); - //element.Displayed.ShouldBeTrue(); - element.Click(); - }); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherIssueSuccessfulTopupPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherIssueSuccessfulTopupPage.cs deleted file mode 100644 index 188abd5b6..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherIssueSuccessfulTopupPage.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using Common; -using OpenQA.Selenium; -using Shared.IntegrationTesting; -using UITests; - -public class TransactionsVoucherIssueSuccessfulTopupPage : BasePage2 -{ - - private readonly String CompleteButton; - - public TransactionsVoucherIssueSuccessfulTopupPage(TestingContext testingContext) : base(testingContext) - { - this.CompleteButton = "CompleteButton"; - } - - #region Properties - - protected override String Trait => "Voucher Issue Successful"; - - public async Task ClickCompleteButton() - { - await Retry.For(async () => { - IWebElement element = await this.WaitForElementByAccessibilityId(this.CompleteButton); - //element.Displayed.ShouldBeTrue(); - element.Click(); - }); - } - - #endregion -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherSelectOperatorPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherSelectOperatorPage.cs deleted file mode 100644 index 4c5be1a0f..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherSelectOperatorPage.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using Common; -using OpenQA.Selenium; -using UITests; - -public class TransactionsVoucherSelectOperatorPage : BasePage2 -{ - public TransactionsVoucherSelectOperatorPage(TestingContext testingContext) : base(testingContext) - { - - } - - #region Properties - - protected override String Trait => "Select an Operator"; - - #endregion - - public async Task ClickOperatorButton(String operatorName) - { - IWebElement element = await this.WaitForElementByAccessibilityId(operatorName); - element.Click(); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherSelectProductPage.cs b/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherSelectProductPage.cs deleted file mode 100644 index 6745eeb7d..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Pages/TransactionsVoucherSelectProductPage.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace TransactionMobile.Maui.UiTests.Pages; - -using System; -using System.Threading.Tasks; -using Common; -using OpenQA.Selenium; -using UITests; - -public class TransactionsVoucherSelectProductPage : BasePage2 -{ - public TransactionsVoucherSelectProductPage(TestingContext testingContext) : base(testingContext) - { - - } - - #region Properties - - protected override String Trait => "Select a Product"; - - #endregion - - public async Task ClickProductButton(String productText) - { - IWebElement element = await this.WaitForElementByAccessibilityId(productText); - element.Click(); - } -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Steps/LoginSteps.cs b/archive/TransactionMobile.Maui.UiTests/Steps/LoginSteps.cs deleted file mode 100644 index a276983e9..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Steps/LoginSteps.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using TransactionProcessor.DataTransferObjects.Requests.Merchant; -using TransactionProcessor.IntegrationTesting.Helpers; - -namespace TransactionMobile.Maui.UITests.Steps -{ - using System.Runtime.CompilerServices; - using System.Threading; - using Reqnroll; - using Shared.IntegrationTesting; - using Shouldly; - using TransactionMobile.Maui.UiTests.Common; - - [Binding] - [Scope(Tag = "login")] - public class LoginSteps - { - private readonly TestingContext TestingContext; - - private LoginPage loginPage; - - private MainPage mainPage; - - public LoginSteps(TestingContext testingContext) { - this.TestingContext = testingContext; - this.loginPage = new LoginPage(testingContext); - this.mainPage = new MainPage(testingContext); - } - - [Given(@"I am on the Login Screen")] - [Then("the Login Page is displayed")] - public async Task GivenIAmOnTheLoginScreen() { - await this.loginPage.AssertOnPage(); - } - - [Given(@"my device is registered")] - public async Task GivenMyDeviceIsRegistered() { - String configHostUrl = $"http://{this.TestingContext.DockerHelper.LocalIPAddress}:{this.TestingContext.DockerHelper.ConfigHostPort}"; - await this.loginPage.SetConfigHostUrl(configHostUrl); - - String serial = await this.loginPage.GetDeviceSerial(); - - AddMerchantDeviceRequest request = new AddMerchantDeviceRequest { - DeviceIdentifier = serial - }; - Guid estateId = this.TestingContext.GetAllEstateIds().Single(); - EstateDetails estate = this.TestingContext.GetEstateDetails(estateId); - Guid merchantId = estate.GetMerchantId("Test Merchant 1"); // TODO: stop this from being hard coded - await this.TestingContext.DockerHelper.TransactionProcessorClient.AddDeviceToMerchant(this.TestingContext.AccessToken, estateId, merchantId, request, CancellationToken.None); - } - - [Given(@"the application is in training mode")] - public async Task GivenTheApplicationIsInTrainingMode() { - var isTrainingModeOn = await this.loginPage.IsTrainingModeOn(); - if (isTrainingModeOn == false) - await this.loginPage.SetTrainingModeOn(); - } - - [When(@"I enter '(.*)' as the Email Address")] - public async Task WhenIEnterAsTheEmailAddress(String emailAddress) { - //Char[] x = emailAddress.ToCharArray(); - //StringBuilder expected = new StringBuilder(); - //foreach (Char c in x){ - // expected.Append(c); - // await this.loginPage.EnterEmailAddress(c.ToString()); - // await Task.Delay(2000); - // String text = await this.loginPage.GetEmailAddress(); - // text.ShouldBe(expected.ToString()); - //} - await this.loginPage.EnterEmailAddress(emailAddress); - await Task.Delay(2000); - String text = await this.loginPage.GetEmailAddress(); - text.ShouldBe(emailAddress); - } - - [When(@"I enter '(.*)' as the Password")] - public async Task WhenIEnterAsThePassword(String password) { - await this.loginPage.EnterPassword(password); - } - - [When(@"I tap on Login")] - public async Task WhenITapOnLogin() { - await this.loginPage.ClickLoginButton(); - } - - [Then(@"the Merchant Home Page is displayed")] - public async Task ThenTheMerchantHomePageIsDisplayed() { - try { - await this.mainPage.AssertOnPage(); - } - catch(Exception ex) - { - String pageSource = await this.mainPage.GetPageSource(); - throw new Exception($"Unable to verify on page: {this.mainPage.GetType().Name} {Environment.NewLine} Page Source: {pageSource}", ex); - } - } - - [Then(@"the available balance is shown as (.*)")] - public async Task ThenTheAvailableBalanceIsShownAs(Decimal expectedAvailableBalance) { - //Decimal availableBalance = await this.mainPage.GetAvailableBalanceValue(TimeSpan.FromSeconds(120)).ConfigureAwait(false); - //availableBalance.ShouldBe(expectedAvailableBalance); - } - - [Then(@"the Login Screen is displayed")] - public async Task ThenTheLoginScreenIsDisplayed() { - await this.loginPage.AssertOnPage(); - } - } -} diff --git a/archive/TransactionMobile.Maui.UiTests/Steps/ProfileSteps.cs b/archive/TransactionMobile.Maui.UiTests/Steps/ProfileSteps.cs deleted file mode 100644 index 70048819e..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Steps/ProfileSteps.cs +++ /dev/null @@ -1,173 +0,0 @@ -namespace TransactionMobile.Maui.UITests.Steps; - -using System; -using System.Linq; -using System.Threading.Tasks; -using Reqnroll; -using Shared.IntegrationTesting; -using Shouldly; -using TransactionMobile.Maui.UiTests.Drivers; -using UiTests.Common; -using UiTests.Pages; - -[Binding] -[Scope(Tag = "profile")] -public class ProfileSteps{ - private readonly TestingContext TestingContext; - - private ProfilePage profilePage; - - private ProfileAddressesPage profileAddressesPage; - - ProfileContactsPage profileContactsPage; - ProfileAccountInfoPage profileAccountInfoPage; - - public ProfileSteps(TestingContext testingContext){ - this.TestingContext = testingContext; - this.profilePage = new ProfilePage(testingContext); - this.profileAccountInfoPage = new ProfileAccountInfoPage(testingContext); - this.profileContactsPage = new ProfileContactsPage(testingContext); - this.profileAddressesPage = new ProfileAddressesPage(testingContext); - } - - [Then(@"the My Profile Page is displayed")] - public async Task ThenTheMyProfilePageIsDisplayed() - { - await this.profilePage.AssertOnPage(); - } - - [When(@"I tap on Logout")] - public async Task WhenITapOnLogout() - { - await this.profilePage.ClickLogoutButton(); - } - - [When(@"I tap on the Addresses button")] - public async Task WhenITapOnTheAddressesButton() { - await this.profilePage.ClickAddressesButton(); - } - - [Then(@"the Address List Page is displayed")] - public async Task ThenTheAddressListPageIsDisplayed() - { - await this.profileAddressesPage.AssertOnPage(); - } - - [Then(@"the Primary Address is displayed")] - public async Task ThenThePrimaryAddressIsDisplayed(DataTable table){ - await this.profileAddressesPage.IsPrimaryAddressShown(); - - DataTableRow? tableRow = table.Rows.Single(); - - String expectedAddressLine1= ReqnrollTableHelper.GetStringRowValue(tableRow, "AddressLine1"); - String expectedAddressLine2 = ReqnrollTableHelper.GetStringRowValue(tableRow, "AddressLine2"); - String expectedAddressLine3 = ReqnrollTableHelper.GetStringRowValue(tableRow, "AddressLine3"); - String expectedAddressLine4 = ReqnrollTableHelper.GetStringRowValue(tableRow, "AddressLine4"); - String expectedAddressTown = ReqnrollTableHelper.GetStringRowValue(tableRow, "AddressTown"); - String expectedAddressRegion = ReqnrollTableHelper.GetStringRowValue(tableRow, "AddressRegion"); - String expectedAddressPostCode = ReqnrollTableHelper.GetStringRowValue(tableRow, "AddressPostCode"); - - if (String.IsNullOrEmpty(expectedAddressLine1) == false){ - String addressLine1 = await this.profileAddressesPage.GetAddressLineValue(1); - addressLine1.ShouldBe(expectedAddressLine1); - } - - if (String.IsNullOrEmpty(expectedAddressLine2) == false){ - String addressLine2 = await this.profileAddressesPage.GetAddressLineValue(2); - addressLine2.ShouldBe(expectedAddressLine2); - } - - if (String.IsNullOrEmpty(expectedAddressLine3) == false){ - String addressLine3 = await this.profileAddressesPage.GetAddressLineValue(3); - addressLine3.ShouldBe(expectedAddressLine3); - } - - if (String.IsNullOrEmpty(expectedAddressLine4) == false){ - String addressLine4 = await this.profileAddressesPage.GetAddressLineValue(4); - addressLine4.ShouldBe(expectedAddressLine4); - } - - if (String.IsNullOrEmpty(expectedAddressTown) == false){ - String addressTown = await this.profileAddressesPage.GetAddressTownValue(); - addressTown.ShouldBe(expectedAddressTown); - } - - if (String.IsNullOrEmpty(expectedAddressRegion) == false){ - String addressRegion = await this.profileAddressesPage.GetAddressRegionValue(); - addressRegion.ShouldBe(expectedAddressRegion); - } - - if (String.IsNullOrEmpty(expectedAddressPostCode) == false){ - String addressPostalCode = await this.profileAddressesPage.GetAddressPostalCodeValue(); - addressPostalCode.ShouldBe(expectedAddressPostCode); - } - } - - [When(@"I tap on the Contacts button")] - public async Task WhenITapOnTheContactsButton() { - await this.profilePage.ClickContactsButton(); - } - - [Then(@"the Contact List Page is displayed")] - public async Task ThenTheContactListPageIsDisplayed() - { - await this.profileContactsPage.AssertOnPage(); - } - - [Then(@"the Primary Contact is displayed")] - public async Task ThenThePrimaryContactIsDisplayed(DataTable table) - { - await this.profileContactsPage.IsPrimaryContactShown(); - - String contactName = await this.profileContactsPage.GetContactNameValue(); - String contactEmailAddress = await this.profileContactsPage.GetContactEmailAddressValue(); - String contactMobileNumber = await this.profileContactsPage.GetContactMobileNumberValue(); - - DataTableRow? tableRow = table.Rows.Single(); - String? expectedContactName = ReqnrollTableHelper.GetStringRowValue(tableRow, "Name"); - String? expectedContactEmailAddress = ReqnrollTableHelper.GetStringRowValue(tableRow, "EmailAddress"); - String? expectedContactMobileNumber = ReqnrollTableHelper.GetStringRowValue(tableRow, "MobileNumber"); - - contactName.ShouldBe(expectedContactName); - contactEmailAddress.ShouldBe(expectedContactEmailAddress); - contactMobileNumber.ShouldBe(expectedContactMobileNumber); - } - - [When(@"I tap on the Account Info button")] - public async Task WhenITapOnTheAccountInfoButton() { - await this.profilePage.ClickAccountInfoButton(); - } - - [Then(@"the Account Info Page is displayed")] - public async Task ThenTheAccountInfoPageIsDisplayed() - { - await this.profileAccountInfoPage.AssertOnPage(); - } - - [Then(@"the Account Info is displayed")] - public async Task ThenTheAccountInfoIsDisplayed(DataTable table) - { - String merchantName = await this.profileAccountInfoPage.GetMerchantNameValue(); - String balance = await this.profileAccountInfoPage.GetBalanceValue(); - String availableBalance = await this.profileAccountInfoPage.GetAvailableBalanceValue(); - //String lastStatementDate = await this.profileAccountInfoPage.GetLastStatementDateValue(); - //String nextStatementDate = await this.profileAccountInfoPage.GetNextStatementDateValue(); - //String settlementSchedule = await this.profileAccountInfoPage.GetSettlementScheduleValue(); - - DataTableRow? tableRow = table.Rows.Single(); - String? expectedMerchantName = ReqnrollTableHelper.GetStringRowValue(tableRow,"Name"); - String? expectedBalance = ReqnrollTableHelper.GetStringRowValue(tableRow, "Balance"); - String? expectedAvailableBalance = ReqnrollTableHelper.GetStringRowValue(tableRow, "AvailableBalance"); - //String? expectedLastStatementDate = table.Rows.Single()["LastStatementDate"]; - //String? expectedNextStatementDate = table.Rows.Single()["NextStatementDate"]; - //String? expectedSettlementSchedule = table.Rows.Single()["SettlementSchedule"]; - - merchantName.ShouldBe(expectedMerchantName); - balance.ShouldBe(expectedBalance); - availableBalance.ShouldBe(expectedAvailableBalance); - //lastStatementDate.ShouldBe(expectedLastStatementDate); - //nextStatementDate.ShouldBe(expectedNextStatementDate); - //settlementSchedule.ShouldBe(expectedSettlementSchedule); - } - -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Steps/ReportsSteps.cs b/archive/TransactionMobile.Maui.UiTests/Steps/ReportsSteps.cs deleted file mode 100644 index 6c08f5f39..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Steps/ReportsSteps.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace TransactionMobile.Maui.UITests.Steps; - -using System.Threading.Tasks; -using Reqnroll; -using UiTests.Pages; - -[Binding] -[Scope(Tag = "reports")] -public class ReportsSteps{ - private readonly ReportsPage ReportsPage; - - private readonly SalesAnalysisPage SalesAnalysisPage; - - public ReportsSteps(ReportsPage reportsPage, SalesAnalysisPage salesAnalysisPage){ - this.ReportsPage = reportsPage; - this.SalesAnalysisPage = salesAnalysisPage; - } - - [Then(@"the Reports Page is displayed")] - public async Task ThenTheReportsPageIsDisplayed() - { - await this.ReportsPage.AssertOnPage(); - } - - [When(@"I tap on the Sales Analysis Button")] - public async Task WhenITapOnTheSalesAnalysisButton(){ - await this.ReportsPage.ClickSalesAnalysisButton(); - } - - [Then(@"the Sales Analysis Report is displayed")] - public async Task ThenTheSalesAnalysisReportIsDisplayed() - { - await this.SalesAnalysisPage.AssertOnPage(); - } - - -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Steps/SharedAppSteps.cs b/archive/TransactionMobile.Maui.UiTests/Steps/SharedAppSteps.cs deleted file mode 100644 index f7847657a..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Steps/SharedAppSteps.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.UiTests.Steps -{ - using Common; - using Drivers; - using OpenQA.Selenium; - using OpenQA.Selenium.Appium; - using OpenQA.Selenium.Appium.Enums; - using Pages; - using Reqnroll; - using Shouldly; - using UITests; - - [Binding] - [Scope(Tag = "sharedapp")] - public class SharedAppSteps - { - public SharedAppSteps(TestingContext testingContext){ - this.sharedPage = new SharedPage(testingContext); - } - - private SharedPage sharedPage; - - [When(@"I click on the device back button")] - public void WhenIClickOnTheDeviceBackButton() - { - this.sharedPage.NavigateBack(); - } - - [When(@"I click on the back button")] - public async Task WhenIClickOnTheBackButton() { - await this.sharedPage.ClickBackButton(); - } - - [Then(@"The application closes")] - public void ThenTheApplicationCloses() { - AppState state = AppiumDriverWrapper.Driver.GetAppState("com.transactionprocessing.pos"); - state.ShouldBe(AppState.NotRunning); - } - - [When(@"I click yes")] - public async Task WhenIClickYes(){ - await this.sharedPage.AcceptAlert(); - } - - [When(@"I click no")] - public async Task WhenIClickNo(){ - await this.sharedPage.DismissAlert(); - } - - [Then(@"A message is displayed confirming I want to log out")] - public async Task ThenAMessageIsDisplayedConfirmingIWantToLogOut() - { - await this.sharedPage.LogoutMessageIsDisplayed("Title", "Logout Message"); - } - } -} diff --git a/archive/TransactionMobile.Maui.UiTests/Steps/SharedSteps.cs b/archive/TransactionMobile.Maui.UiTests/Steps/SharedSteps.cs deleted file mode 100644 index 14124c2d0..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Steps/SharedSteps.cs +++ /dev/null @@ -1,373 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -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 AssignOperatorRequest = TransactionProcessor.DataTransferObjects.Requests.Estate.AssignOperatorRequest; - -namespace TransactionMobile.Maui.UiTests.Steps -{ - using System.Net; - using System.Net.Http; - using System.Text.Json; - using System.Threading; - using Common; - using Drivers; - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; - using Reqnroll; - using SecurityService.DataTransferObjects; - using SecurityService.DataTransferObjects.Requests; - using SecurityService.DataTransferObjects.Responses; - using SecurityService.IntegrationTesting.Helpers; - using Shared.IntegrationTesting; - using Shouldly; - using TransactionProcessor.DataTransferObjects; - using TransactionProcessor.IntegrationTesting.Helpers; - using UITests; - using ClientDetails = Common.ClientDetails; - using ReqnrollExtensions = TransactionProcessor.IntegrationTesting.Helpers.ReqnrollExtensions; - using ReqnrollTableHelper = Shared.IntegrationTesting.ReqnrollTableHelper; - - [Binding] - [Scope(Tag = "shared")] - public class SharedSteps - { - private readonly TestingContext TestingContext; - - private readonly SecurityServiceSteps SecurityServiceSteps; - - private readonly TransactionProcessorSteps TransactionProcessorSteps; - - private LoginPage loginPage; - - public SharedSteps(TestingContext testingContext) { - this.TestingContext = testingContext; - this.loginPage = new LoginPage(testingContext); - this.SecurityServiceSteps = new SecurityServiceSteps(testingContext.DockerHelper.SecurityServiceClient); - this.TransactionProcessorSteps = new TransactionProcessorSteps(this.TestingContext.DockerHelper.TransactionProcessorClient, this.TestingContext.DockerHelper.TestHostHttpClient, - this.TestingContext.DockerHelper.ProjectionManagementClient); - } - - [Given(@"the following security roles exist")] - public async Task GivenTheFollowingSecurityRolesExist(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 api scopes")] - public async Task GivenICreateTheFollowingApiScopes(DataTable table) { - List requests = table.Rows.ToCreateApiScopeRequests(); - await this.SecurityServiceSteps.GivenICreateTheFollowingApiScopes(requests); - } - - [Given(@"the following api resources exist")] - public async Task GivenTheFollowingApiResourcesExist(DataTable table) - { - List requests = table.Rows.ToCreateApiResourceRequests(); - await this.SecurityServiceSteps.GivenTheFollowingApiResourcesExist(requests); - - foreach (CreateApiResourceRequest createApiResourceRequest in requests) - { - this.TestingContext.ApiResources.Add(createApiResourceRequest.Name); - } - } - - [Given(@"the following clients exist")] - public async Task GivenTheFollowingClientsExist(DataTable table) - { - List requests = table.Rows.ToCreateClientRequests(this.TestingContext.DockerHelper.TestId); - 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 have a token to access the estate management and transaction processor acl resources")] - public async Task GivenIHaveATokenToAccessTheEstateManagementAndTransactionProcessorAclResources(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 EstateManagementSqlServerContext(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}"); - }, TimeSpan.FromMinutes(2)); - } - } - - [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 - } - - - [Given(@"I create a contract with the following values")] - public async Task GivenICreateAContractWithTheFollowingValues(DataTable table) - { - var estates = this.TestingContext.Estates.Select(e => e).ToList(); - List<(EstateDetails, CreateContractRequest)> requests = table.Rows.ToCreateContractRequests(estates); - List responses = await this.TransactionProcessorSteps.GivenICreateAContractWithTheFollowingValues(this.TestingContext.AccessToken, requests); - foreach (ContractResponse contractResponse in responses) - { - EstateDetails estate = this.TestingContext.Estates.Single(e => e.EstateId == contractResponse.EstateId); - estate.AddContract(contractResponse.ContractId, contractResponse.Description, contractResponse.OperatorId); - } - } - - [When(@"I create the following Products")] - public async Task WhenICreateTheFollowingProducts(Table table) - { - var estates = this.TestingContext.Estates.Select(e => e).ToList(); - List<(EstateDetails, Contract, AddProductToContractRequest)> requests = table.Rows.ToAddProductToContractRequest(estates); - await this.TransactionProcessorSteps.WhenICreateTheFollowingProducts(this.TestingContext.AccessToken, requests); - } - - [When(@"I add the following Transaction Fees")] - public async Task WhenIAddTheFollowingTransactionFees(DataTable table) - { - var estates = this.TestingContext.Estates.Select(e => e).ToList(); - List<(EstateDetails, Contract, Product, AddTransactionFeeForProductToContractRequest)> requests = table.Rows.ToAddTransactionFeeForProductToContractRequests(estates); - await this.TransactionProcessorSteps.WhenIAddTheFollowingTransactionFees(this.TestingContext.AccessToken, requests); - } - - [Given(@"I create the following merchants")] - public async Task GivenICreateTheFollowingMerchants(DataTable table) - { - var estates = this.TestingContext.Estates.Select(e => e).ToList(); - List<(EstateDetails estate, CreateMerchantRequest)> requests = table.Rows.ToCreateMerchantRequests(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}"); - } - } - - [Given(@"I have assigned the following operator to the merchants")] - public async Task GivenIHaveAssignedTheFollowingOperatorToTheMerchants(DataTable table) - { - List estates = this.TestingContext.Estates.Select(e => e).ToList(); - List<(EstateDetails, Guid, TransactionProcessor.DataTransferObjects.Requests.Merchant.AssignOperatorRequest)> requests = table.Rows.ToAssignOperatorRequests(estates); - - List<(EstateDetails, 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 have created a config for my device")] - public async Task GivenIHaveCreatedAConfigForMyDevice() { - var deviceSerial = await this.loginPage.GetDeviceSerial(); - - var clientDetails = this.TestingContext.GetClientDetails("mobileAppClient"); - var configRequest = new { - clientId = clientDetails.ClientId, - clientSecret = clientDetails.ClientSecret, - deviceIdentifier = deviceSerial, - id = deviceSerial, - enableAutoUpdates = false, - logLevel = 3, - hostAddresses = new List() - }; - configRequest.hostAddresses.Add(new { - servicetype = 0, - uri = this.TestingContext.DockerHelper.TransactionProcessorBaseAddressResolver("").Replace("127.0.0.1", this.TestingContext.DockerHelper.LocalIPAddress) - }); - configRequest.hostAddresses.Add(new - { - servicetype = 1, - uri = this.TestingContext.DockerHelper.SecurityServiceBaseAddressResolver("").Replace("127.0.0.1", this.TestingContext.DockerHelper.LocalIPAddress) - }); - configRequest.hostAddresses.Add(new - { - servicetype = 2, - uri = this.TestingContext.DockerHelper.TransactionProcessorAclBaseAddressResolver("").Replace("127.0.0.1", this.TestingContext.DockerHelper.LocalIPAddress) - }); - - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"http://127.0.0.1:{this.TestingContext.DockerHelper.ConfigHostPort}/api/transactionmobileconfiguration"); - request.Content = new StringContent(JsonConvert.SerializeObject(configRequest), Encoding.UTF8, "application/json"); - - HttpClientHandler clientHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (message, - certificate2, - arg3, - arg4) => - { - return true; - } - - }; - HttpClient httpClient = new HttpClient(clientHandler); - - var response = await httpClient.SendAsync(request, CancellationToken.None); - response.StatusCode.ShouldBe(HttpStatusCode.OK); - - this.TestingContext.Logger.LogInformation($"Config Created for serial {deviceSerial}"); - } - - [Given(@"I have created a config for my application")] - public async Task GivenIHaveCreatedAConfigForMyApplication() - { - var configRequest = new - { - applicationId = "transactionMobilePOS", - androidkey = "android", - ioskey = "ios", - macoskey = "macos", - windowskey = "windows", - }; - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"http://127.0.0.1:{this.TestingContext.DockerHelper.ConfigHostPort}/api/applicationcentreconfiguration"); - request.Content = new StringContent(JsonConvert.SerializeObject(configRequest), Encoding.UTF8, "application/json"); - - HttpClientHandler clientHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (message, - certificate2, - arg3, - arg4) => - { - return true; - } - - }; - HttpClient httpClient = new HttpClient(clientHandler); - - var response = await httpClient.SendAsync(request, CancellationToken.None); - response.StatusCode.ShouldBe(HttpStatusCode.OK); - } - - private async Task GetMerchantBalance(Guid merchantId) - { - JsonElement jsonElement = (JsonElement)await this.TestingContext.DockerHelper.ProjectionManagementClient.GetStateAsync("MerchantBalanceProjection", $"MerchantBalance-{merchantId:N}"); - JObject jsonObject = JObject.Parse(jsonElement.GetRawText()); - decimal balanceValue = jsonObject.SelectToken("merchant.balance").Value(); - return balanceValue; - } - - [Given(@"I make the following manual merchant deposits")] - public async Task GivenIMakeTheFollowingManualMerchantDeposits(DataTable table) { - var estates = this.TestingContext.Estates.Select(e => e).ToList(); - List<(EstateDetails, Guid, MakeMerchantDepositRequest)> requests = table.Rows.ToMakeMerchantDepositRequest(estates); - - foreach ((EstateDetails, Guid, MakeMerchantDepositRequest) request in requests) - { - Decimal previousMerchantBalance = await this.GetMerchantBalance(request.Item2); - - await this.TransactionProcessorSteps.GivenIMakeTheFollowingManualMerchantDeposits(this.TestingContext.AccessToken, request); - - await Retry.For(async () => { - Decimal currentMerchantBalance = await this.GetMerchantBalance(request.Item2); - - currentMerchantBalance.ShouldBe(previousMerchantBalance + request.Item3.Amount); - - this.TestingContext.Logger.LogInformation($"Deposit Reference {request.Item3.Reference} made for Merchant Id {request.Item2}"); - }); - } - } - - [Given(@"I have created the following security users")] - public async Task GivenIHaveCreatedTheFollowingSecurityUsers(DataTable table) - { - var estates = this.TestingContext.Estates.Select(e => e).ToList(); - List createUserRequests = table.Rows.ToCreateNewUserRequests(estates); - await this.TransactionProcessorSteps.WhenICreateTheFollowingSecurityUsers(this.TestingContext.AccessToken, createUserRequests, estates); - } - - [Given(@"I have assigned the following devices to the merchants")] - public void GivenIHaveAssignedTheFollowingDevicesToTheMerchants(DataTable table) { - - - - } - - [When(@"I add the following contracts to the following merchants")] - public async Task WhenIAddTheFollowingContractsToTheFollowingMerchants(DataTable table) - { - List estates = this.TestingContext.Estates.Select(e => e).ToList(); - List<(EstateDetails, Guid, Guid)> requests = table.Rows.ToAddContractToMerchantRequests(estates); - await this.TransactionProcessorSteps.WhenIAddTheFollowingContractsToTheFollowingMerchants(this.TestingContext.AccessToken, requests); - } - - [Given(@"the following bills are available at the PataPawa PostPaid Host")] - public async Task GivenTheFollowingBillsAreAvailableAtThePataPawaPostPaidHost(DataTable table) - { - List bills = table.Rows.ToPataPawaBills(); - await this.TransactionProcessorSteps.GivenTheFollowingBillsAreAvailableAtThePataPawaPostPaidHost(bills); - } - - [Given(@"the following users are available at the PataPawa PrePay Host")] - public async Task GivenTheFollowingUsersAreAvailableAtThePataPawaPrePayHost(DataTable table) - { - List users = table.Rows.ToPataPawaUsers(); - await this.TransactionProcessorSteps.GivenTheFollowingUsersAreAvailableAtThePataPawaPrePaidHost(users); - } - - [Given(@"the following meters are available at the PataPawa PrePay Host")] - public async Task GivenTheFollowingMetersAreAvailableAtThePataPawaPrePayHost(DataTable table) - { - List meters = table.Rows.ToPataPawaMeters(); - await this.TransactionProcessorSteps.GivenTheFollowingMetersAreAvailableAtThePataPawaPrePaidHost(meters); - } - } -} diff --git a/archive/TransactionMobile.Maui.UiTests/Steps/ToolbarSteps.cs b/archive/TransactionMobile.Maui.UiTests/Steps/ToolbarSteps.cs deleted file mode 100644 index c6b8e1860..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Steps/ToolbarSteps.cs +++ /dev/null @@ -1,76 +0,0 @@ -namespace TransactionMobile.Maui.UITests.Steps; - -using System.Threading.Tasks; -using Reqnroll; -using TransactionMobile.Maui.UiTests.Common; -using UiTests.Pages; - -[Binding] -[Scope(Tag = "toolbar")] -public class ToolbarSteps{ - private MainPage mainPage; - private readonly TestingContext TestingContext; - public ToolbarSteps(TestingContext testingContext){ - this.TestingContext = testingContext; - this.mainPage = new MainPage(testingContext); - } - - [When(@"I tap on Profile")] - public async Task WhenITapOnProfile() { - await this.mainPage.ClickProfileButton(); - } - - [When(@"I tap on Transactions")] - public async Task WhenITapOnTransactions() { - await this.mainPage.ClickTransactionsButton(); - } - - [When(@"I tap on Reports")] - public async Task WhenITapOnReports(){ - await this.mainPage.ClickReportsButton(); - } - - [When(@"I tap on Support")] - public async Task WhenITapOnSupport() - { - await this.mainPage.ClickSupportButton(); - } -} - -[Binding] -[Scope(Tag = "support")] -public class SupportSteps{ - private readonly TestingContext TestingContext; - - private SupportPage supportPage; - private ViewLogsPage viewLogsPage; - - public SupportSteps(TestingContext testingContext){ - this.TestingContext = testingContext; - this.supportPage = new SupportPage(testingContext); - this.viewLogsPage = new ViewLogsPage(testingContext); - } - - [Then(@"the Support Page is displayed")] - public async Task ThenTheSupportPageIsDisplayed(){ - await this.supportPage.AssertOnPage(); - } - - [When(@"I tap on the Upload Logs Button")] - public async Task WhenITapOnTheUploadLogsButton() - { - await this.supportPage.ClickUploadLogsButton(); - } - - [When(@"I tap on the View Logs Button")] - public async Task WhenITapOnTheViewLogsButton(){ - await this.supportPage.ClickViewLogsButton(); - } - - [Then(@"the View Logs Page is displayed")] - public async Task ThenTheViewLogsPageIsDisplayed() - { - await this.viewLogsPage.AssertOnPage(); - } - -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.UiTests/Steps/TransactionsSteps.cs b/archive/TransactionMobile.Maui.UiTests/Steps/TransactionsSteps.cs deleted file mode 100644 index 94b947b05..000000000 --- a/archive/TransactionMobile.Maui.UiTests/Steps/TransactionsSteps.cs +++ /dev/null @@ -1,292 +0,0 @@ -namespace TransactionMobile.Maui.UITests.Steps; - -using System; -using System.Linq; -using System.Threading.Tasks; -using Common; -using Reqnroll; -using Shared.IntegrationTesting; -using Shouldly; -using UiTests.Common; -using UiTests.Pages; -using static System.Runtime.InteropServices.JavaScript.JSType; -using Object = System.Object; -using String = System.String; - -public enum OperatorType{ - NotSet, - MobileTopup, - Voucher, - BillPayment -} - -public enum BillPaymentType -{ - NotSet, - PostPayment, - PrePayment -} - -[Binding] -[Scope(Tag = "transactions")] -public class TransactionsSteps{ - public OperatorType operatorType; - - private readonly TestingContext TestingContext; - - private TransactionsPage transactionsPage; - - private TransactionsMobileTopupSelectOperatorPage transactionsMobileTopupSelectOperatorPage; - private TransactionsMobileTopupSelectProductPage transactionsMobileTopupSelectProductPage; - private TransactionsMobileTopupEnterTopupDetailsPage transactionsMobileTopupEnterTopupDetailsPage; - private TransactionsMobileTopupSuccessfulTopupPage transactionsMobileTopupSuccessfulTopupPage; - private TransactionsVoucherSelectOperatorPage transactionsVoucherSelectOperatorPage; - private TransactionsVoucherSelectProductPage transactionsVoucherSelectProductPage; - private TransactionsVoucherEnterVoucherIssueDetailsPage transactionsVoucherEnterVoucherIssueDetailsPage; - private TransactionsVoucherIssueSuccessfulTopupPage transactionsVoucherIssueSuccessfulTopupPage; - private TransactionsBillPaymentSelectOperatorPage transactionsBillPaymentSelectOperatorPage; - private TransactionsBillPaymentSelectProductPage transactionsBillPaymentSelectProductPage; - private TransactionsBillPaymentEnterAccountDetailsPage transactionsBillPaymentEnterAccountDetailsPage; - private TransactionsBillPaymentEnterMeterDetailsPage transactionsBillPaymentEnterMeterDetailsPage; - private TransactionsBillPaymentMakeAPaymentPage transactionsBillPaymentMakeAPaymentPage; - private TransactionsBillPaymentSuccessfulPaymentPage transactionsBillPaymentSuccessfulPaymentPage; - - private BillPaymentType BillPaymentType; - - public TransactionsSteps(TestingContext testingContext){ - this.TestingContext = testingContext; - this.transactionsPage = new TransactionsPage(testingContext); - this.transactionsMobileTopupSelectOperatorPage = new TransactionsMobileTopupSelectOperatorPage(testingContext); - this.transactionsMobileTopupSelectProductPage = new TransactionsMobileTopupSelectProductPage(testingContext); - this.transactionsMobileTopupEnterTopupDetailsPage = new TransactionsMobileTopupEnterTopupDetailsPage(testingContext); - this.transactionsMobileTopupSuccessfulTopupPage = new TransactionsMobileTopupSuccessfulTopupPage(testingContext); - this.transactionsVoucherSelectOperatorPage = new TransactionsVoucherSelectOperatorPage(testingContext); - this.transactionsVoucherSelectProductPage = new TransactionsVoucherSelectProductPage(testingContext); - this.transactionsVoucherEnterVoucherIssueDetailsPage = new TransactionsVoucherEnterVoucherIssueDetailsPage(testingContext); - this.transactionsVoucherIssueSuccessfulTopupPage = new TransactionsVoucherIssueSuccessfulTopupPage(testingContext); - this.transactionsBillPaymentSelectOperatorPage = new TransactionsBillPaymentSelectOperatorPage(testingContext); - this.transactionsBillPaymentSelectProductPage = new TransactionsBillPaymentSelectProductPage(testingContext); - this.transactionsBillPaymentEnterAccountDetailsPage = new TransactionsBillPaymentEnterAccountDetailsPage(testingContext); - this.transactionsBillPaymentEnterMeterDetailsPage = new TransactionsBillPaymentEnterMeterDetailsPage(testingContext); - this.transactionsBillPaymentMakeAPaymentPage = new TransactionsBillPaymentMakeAPaymentPage(testingContext); - this.transactionsBillPaymentSuccessfulPaymentPage = new TransactionsBillPaymentSuccessfulPaymentPage(testingContext); - } - - [Then(@"the Transaction Page is displayed")] - public async Task ThenTheTransactionPageIsDisplayed() { - await this.transactionsPage.AssertOnPage(); - } - - [When(@"I tap on the Mobile Topup button")] - public async Task WhenITapOnTheMobileTopupButton(){ - operatorType = OperatorType.MobileTopup; - await this.transactionsPage.ClickMobileTopupButton(); - } - - [When(@"I tap on the Voucher button")] - public async Task WhenITapOnTheVoucherButton(){ - operatorType = OperatorType.Voucher; - await this.transactionsPage.ClickVoucherButton(); - } - - [When(@"I tap on the Bill Payment button")] - public async Task WhenITapOnTheBillPaymentButton() - { operatorType = OperatorType.BillPayment; - await this.transactionsPage.ClickBillPaymentButton(); - } - - [Then(@"the Enter Voucher Issue Details Page is displayed")] - public async Task ThenTheEnterVoucherIssueDetailsPageIsDisplayed(){ - await this.transactionsVoucherEnterVoucherIssueDetailsPage.AssertOnPage(); - } - - [When(@"I enter '([^']*)' as the Recipient Mobile Number")] - public async Task WhenIEnterAsTheRecipientMobileNumber(string recipientMobileNumber){ - await this.transactionsVoucherEnterVoucherIssueDetailsPage.EnterRecipientMobileNumber(recipientMobileNumber); - } - - [When(@"I tap on Issue Voucher")] - public async Task WhenITapOnIssueVoucher(){ - await this.transactionsVoucherEnterVoucherIssueDetailsPage.ClickIssueVoucherButton(); - } - - [Then(@"the Voucher Issue Successful Page is displayed")] - public async Task ThenTheVoucherIssueSuccessfulPageIsDisplayed() - { - await this.transactionsVoucherIssueSuccessfulTopupPage.AssertOnPage(); - } - - [Then(@"the Transaction Select Mobile Topup Operator Page is displayed")] - public async Task ThenTheTransactionSelectMobileTopupOperatorPageIsDisplayed() { - await this.transactionsMobileTopupSelectOperatorPage.AssertOnPage(); - } - - [Then(@"the Transaction Select Voucher Operator Page is displayed")] - public async Task ThenTheTransactionSelectVoucherOperatorPageIsDisplayed(){ - await this.transactionsVoucherSelectOperatorPage.AssertOnPage(); - } - - [Then(@"the Transaction Select Bill Payment Operator Page is displayed")] - public async Task ThenTheTransactionSelectBillPaymentOperatorPageIsDisplayed(){ - await this.transactionsBillPaymentSelectOperatorPage.AssertOnPage(); - } - - - [When(@"I tap on the '([^']*)' button")] - public async Task WhenITapOnTheButton(String operatorName){ - - Task t = this.operatorType switch{ - OperatorType.MobileTopup => this.transactionsMobileTopupSelectOperatorPage.ClickOperatorButton(operatorName), - OperatorType.Voucher => this.transactionsVoucherSelectOperatorPage.ClickOperatorButton(operatorName), - OperatorType.BillPayment => this.transactionsBillPaymentSelectOperatorPage.ClickOperatorButton(operatorName) - }; - - await t; - } - - [Then(@"the Select Product Page is displayed")] - public async Task ThenTheSelectProductPageIsDisplayed() { - await this.transactionsMobileTopupSelectProductPage.AssertOnPage(); - } - - [When(@"I tap on the '([^']*)' product button")] - public async Task WhenITapOnTheProductButton(String productText){ - - Task t = this.operatorType switch{ - OperatorType.MobileTopup => this.transactionsMobileTopupSelectProductPage.ClickProductButton(productText), - OperatorType.Voucher => this.transactionsVoucherSelectProductPage.ClickProductButton(productText), - OperatorType.BillPayment => this.transactionsBillPaymentSelectProductPage.ClickProductButton(productText) - }; - - await t; - } - - [Then(@"the Enter Topup Details Page is displayed")] - public async Task ThenTheEnterTopupDetailsPageIsDisplayed() { - await this.transactionsMobileTopupEnterTopupDetailsPage.AssertOnPage(); - } - - [When(@"I enter '([^']*)' as the Customer Mobile Number")] - public async Task WhenIEnterAsTheCustomerMobileNumber(string customerMobileNumber){ - await this.transactionsMobileTopupEnterTopupDetailsPage.EnterCustomerMobileNumber(customerMobileNumber); - } - - [When(@"I enter (.*) as the Topup Amount")] - public async Task WhenIEnterAsTheTopupAmount(Decimal topupAmount) { - await this.transactionsMobileTopupEnterTopupDetailsPage.EnterTopupAmount(topupAmount.ToString()); - } - - [When(@"I tap on Perform Topup")] - public async Task WhenITapOnPerformTopup(){ - await this.transactionsMobileTopupEnterTopupDetailsPage.ClickPerformTopupButton(); - } - - [Then(@"the Mobile Topup Successful Page is displayed")] - public async Task ThenTheMobileTopupSuccessfulPageIsDisplayed() { - await this.transactionsMobileTopupSuccessfulTopupPage.AssertOnPage(); - } - - [Then(@"I tap on Complete")] - public async Task ThenITapOnComplete(){ - Task t = this.operatorType switch{ - OperatorType.MobileTopup => this.transactionsMobileTopupSuccessfulTopupPage.ClickCompleteButton(), - OperatorType.Voucher => this.transactionsVoucherIssueSuccessfulTopupPage.ClickCompleteButton(), - OperatorType.BillPayment=> this.transactionsBillPaymentSuccessfulPaymentPage.ClickCompleteButton() - }; - - await t; - } - - [Then(@"the Enter Account Details Page is displayed")] - public async Task ThenTheEnterAccountDetailsPageIsDisplayed(){ - await this.transactionsBillPaymentEnterAccountDetailsPage.AssertOnPage(); - } - - [When(@"I enter '([^']*)' as the Account Number")] - public async Task WhenIEnterAsTheAccountNumber(String accountNumber){ - await this.transactionsBillPaymentEnterAccountDetailsPage.EnterCustomerAccountNumber(accountNumber); - } - - [When(@"I tap on the Get Account Button")] - public async Task WhenITapOnTheGetAccountButton(){ - await this.transactionsBillPaymentEnterAccountDetailsPage.ClickGetAccountButton(); - } - - [Then(@"the Make Bill Payment page is displayed")] - public async Task ThenTheMakeBillPaymentPageIsDisplayed(){ - await this.transactionsBillPaymentMakeAPaymentPage.AssertOnPage(); - } - - [Then(@"the following Bill Details are displayed")] - public async Task ThenTheFollowingBillDetailsAreDisplayed(DataTable table){ - String accountNumber = await this.transactionsBillPaymentMakeAPaymentPage.GetAccountNumberValue(); - String accountHolder = await this.transactionsBillPaymentMakeAPaymentPage.GetAccountHolderValue(); - String balance = await this.transactionsBillPaymentMakeAPaymentPage.GetBalanceValue(); - String dueDate= await this.transactionsBillPaymentMakeAPaymentPage.GetDueDateValue(); - - DataTableRow? tableRow = table.Rows.Single(); - String expectedAccountNumber = ReqnrollTableHelper.GetStringRowValue(tableRow, "AccountNumber"); - String expectedAccountHolder = ReqnrollTableHelper.GetStringRowValue(tableRow, "AccountHolder"); - String expectedBalance = ReqnrollTableHelper.GetStringRowValue(tableRow,"Balance"); - String dueDateValue = ReqnrollTableHelper.GetStringRowValue(tableRow, "DueDate"); - DateTime expectedBillDueDate = ReqnrollTableHelper.GetDateForDateString(dueDateValue, DateTime.Now); - - accountNumber.ShouldBe($"Account Number: {expectedAccountNumber}"); - accountHolder.ShouldBe($"Account Holder: {expectedAccountHolder}"); - balance.ShouldBe($"Balance: {expectedBalance} KES"); - // TODO: Handle BST date changes - //dueDate.ShouldBe($"Due Date: {expectedBillDueDate:yyyy-MM-dd}"); - this.BillPaymentType = BillPaymentType.PostPayment; - } - - [When(@"I enter (.*) as the Payment Amount")] - public async Task WhenIEnterAsThePaymentAmount(Decimal paymentAmount){ - - if (this.BillPaymentType == BillPaymentType.PostPayment){ - await this.transactionsBillPaymentMakeAPaymentPage.EnterPostPaymentAmount(paymentAmount.ToString()); - } - else{ - await this.transactionsBillPaymentMakeAPaymentPage.EnterPrePaymentAmount(paymentAmount.ToString()); - } - } - - [When(@"I tap on the Make Payment Button")] - public async Task WhenITapOnTheMakePaymentButton(){ - await this.transactionsBillPaymentMakeAPaymentPage.ClickMakePaymentButton(); - } - - [Then(@"the Bill Payment Successful Page is displayed")] - public async Task ThenTheBillPaymentSuccessfulPageIsDisplayed(){ - await this.transactionsBillPaymentSuccessfulPaymentPage.AssertOnPage(); - } - - [Then(@"the Enter Meter Details Page is displayed")] - public async Task ThenTheEnterMeterDetailsPageIsDisplayed() - { - await this.transactionsBillPaymentEnterMeterDetailsPage.AssertOnPage(); - } - - [When(@"I enter '([^']*)' as the Meter Number")] - public async Task WhenIEnterAsTheMeterNumber(string meterNumber){ - await this.transactionsBillPaymentEnterMeterDetailsPage.EnterMeterNumber(meterNumber); - } - - [When(@"I tap on the Get Meter Button")] - public async Task WhenITapOnTheGetMeterButton(){ - await this.transactionsBillPaymentEnterMeterDetailsPage.ClickGetMeterButton(); - } - - [Then(@"the following Meter Details are displayed")] - public async Task ThenTheFollowingMeterDetailsAreDisplayed(DataTable table) - { - String meterNumber = await this.transactionsBillPaymentMakeAPaymentPage.GetMeterNumberValue(); - - DataTableRow? tableRow = table.Rows.Single(); - String expectedMeterNumber = ReqnrollTableHelper.GetStringRowValue(tableRow, "MeterNumber"); - - meterNumber.ShouldBe($"Meter Number: {expectedMeterNumber}"); - - this.BillPaymentType = BillPaymentType.PrePayment; - } - -} diff --git a/archive/TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj b/archive/TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj deleted file mode 100644 index 84dc15d8f..000000000 --- a/archive/TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj +++ /dev/null @@ -1,53 +0,0 @@ - - - - net8.0 - enable - true - Full - false - - - - - - - - - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - PageNavigation.feature - - - - - - Always - - - - - - $(UsingMicrosoftNETSdk) - %(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension) - - - - diff --git a/archive/TransactionMobile.Maui.UiTests/nlog.config b/archive/TransactionMobile.Maui.UiTests/nlog.config deleted file mode 100644 index 84eca0f12..000000000 --- a/archive/TransactionMobile.Maui.UiTests/nlog.config +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/archive/TransactionMobile.Maui.sln b/archive/TransactionMobile.Maui.sln deleted file mode 100644 index 557d916ae..000000000 --- a/archive/TransactionMobile.Maui.sln +++ /dev/null @@ -1,74 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31611.283 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionMobile.Maui", "TransactionMobile.Maui\TransactionMobile.Maui.csproj", "{73668181-7A26-435D-83E3-CF141AC8FD0B}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1CBEF4C1-7D90-4A78-AA55-D81F1447A70E}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{AB312EE3-CBA4-469A-8694-67C5466298C5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionMobile.Maui.BusinessLogic.Tests", "TransactionMobile.Maui.BusinessLogic.Tests\TransactionMobile.Maui.BusinessLogic.Tests.csproj", "{0894F054-5C4D-4DDD-A8E9-636416189234}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionMobile.Maui.BusinessLogic", "TransactionMobile.Maui.BusinessLogic\TransactionMobile.Maui.BusinessLogic.csproj", "{902D54CF-CD5F-4932-B1DC-01A3937AC054}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{354A147A-375C-4002-9019-215F84AC389C}" - ProjectSection(SolutionItems) = preProject - .github\workflows\createrelease.yml = .github\workflows\createrelease.yml - Nuget.config = Nuget.config - pullrequest_endtoend.yml = pullrequest_endtoend.yml - pullrequest_navigationtests.yml = pullrequest_navigationtests.yml - pullrequest_unittests.yml = pullrequest_unittests.yml - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionMobile.Maui.UiTests", "TransactionMobile.Maui.UiTests\TransactionMobile.Maui.UiTests.csproj", "{1F7CE7A2-6350-4F8A-B758-5E275C9C88C9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - TestAuomation|Any CPU = TestAuomation|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {73668181-7A26-435D-83E3-CF141AC8FD0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {73668181-7A26-435D-83E3-CF141AC8FD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {73668181-7A26-435D-83E3-CF141AC8FD0B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {73668181-7A26-435D-83E3-CF141AC8FD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {73668181-7A26-435D-83E3-CF141AC8FD0B}.Release|Any CPU.Build.0 = Release|Any CPU - {73668181-7A26-435D-83E3-CF141AC8FD0B}.Release|Any CPU.Deploy.0 = Release|Any CPU - {73668181-7A26-435D-83E3-CF141AC8FD0B}.TestAuomation|Any CPU.ActiveCfg = Release|Any CPU - {73668181-7A26-435D-83E3-CF141AC8FD0B}.TestAuomation|Any CPU.Build.0 = Release|Any CPU - {73668181-7A26-435D-83E3-CF141AC8FD0B}.TestAuomation|Any CPU.Deploy.0 = Release|Any CPU - {0894F054-5C4D-4DDD-A8E9-636416189234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0894F054-5C4D-4DDD-A8E9-636416189234}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0894F054-5C4D-4DDD-A8E9-636416189234}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0894F054-5C4D-4DDD-A8E9-636416189234}.Release|Any CPU.Build.0 = Release|Any CPU - {0894F054-5C4D-4DDD-A8E9-636416189234}.TestAuomation|Any CPU.ActiveCfg = Release|Any CPU - {0894F054-5C4D-4DDD-A8E9-636416189234}.TestAuomation|Any CPU.Build.0 = Release|Any CPU - {902D54CF-CD5F-4932-B1DC-01A3937AC054}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {902D54CF-CD5F-4932-B1DC-01A3937AC054}.Debug|Any CPU.Build.0 = Debug|Any CPU - {902D54CF-CD5F-4932-B1DC-01A3937AC054}.Release|Any CPU.ActiveCfg = Release|Any CPU - {902D54CF-CD5F-4932-B1DC-01A3937AC054}.Release|Any CPU.Build.0 = Release|Any CPU - {902D54CF-CD5F-4932-B1DC-01A3937AC054}.TestAuomation|Any CPU.ActiveCfg = Release|Any CPU - {902D54CF-CD5F-4932-B1DC-01A3937AC054}.TestAuomation|Any CPU.Build.0 = Release|Any CPU - {1F7CE7A2-6350-4F8A-B758-5E275C9C88C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1F7CE7A2-6350-4F8A-B758-5E275C9C88C9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1F7CE7A2-6350-4F8A-B758-5E275C9C88C9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1F7CE7A2-6350-4F8A-B758-5E275C9C88C9}.Release|Any CPU.Build.0 = Release|Any CPU - {1F7CE7A2-6350-4F8A-B758-5E275C9C88C9}.TestAuomation|Any CPU.ActiveCfg = Debug|Any CPU - {1F7CE7A2-6350-4F8A-B758-5E275C9C88C9}.TestAuomation|Any CPU.Build.0 = Debug|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {73668181-7A26-435D-83E3-CF141AC8FD0B} = {1CBEF4C1-7D90-4A78-AA55-D81F1447A70E} - {0894F054-5C4D-4DDD-A8E9-636416189234} = {AB312EE3-CBA4-469A-8694-67C5466298C5} - {902D54CF-CD5F-4932-B1DC-01A3937AC054} = {1CBEF4C1-7D90-4A78-AA55-D81F1447A70E} - {1F7CE7A2-6350-4F8A-B758-5E275C9C88C9} = {AB312EE3-CBA4-469A-8694-67C5466298C5} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572} - EndGlobalSection -EndGlobal diff --git a/archive/TransactionMobile.Maui/App.xaml b/archive/TransactionMobile.Maui/App.xaml deleted file mode 100644 index 1918ee412..000000000 --- a/archive/TransactionMobile.Maui/App.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/archive/TransactionMobile.Maui/App.xaml.cs b/archive/TransactionMobile.Maui/App.xaml.cs deleted file mode 100644 index 3cc829057..000000000 --- a/archive/TransactionMobile.Maui/App.xaml.cs +++ /dev/null @@ -1,168 +0,0 @@ -using TransactionMobile.Maui.Pages.Transactions.MobileTopup; -using TransactionMobile.Maui.Pages.Transactions.Voucher; -using TransactionMobile.Maui.Pages.Transactions.BillPayment; -namespace TransactionMobile.Maui; - -using Microsoft.Maui.Handlers; -using Microsoft.Maui.Platform; -using Pages; -using Pages.AppHome; -using Pages.MyAccount; -using Pages.Reports; -using Pages.Support; -using Pages.Transactions.Admin; - -public partial class App : Application -{ - public App() - { - Console.WriteLine("In App Ctor"); - InitializeComponent(); - -#if ANDROID - ViewHandler.ViewMapper.ModifyMapping("AutomationId", (handler, view, previousAction) => - { - if (handler.PlatformView is Android.Views.View androidView) - { - if (String.IsNullOrWhiteSpace(view.AutomationId)) - return; - - if (AndroidX.Core.View.ViewCompat.GetAccessibilityDelegate(androidView) is not AutomationIdDelegate) - AndroidX.Core.View.ViewCompat.SetAccessibilityDelegate(androidView, new AutomationIdDelegate()); - - - if (AndroidX.Core.View.ViewCompat.GetAccessibilityDelegate(androidView) is AutomationIdDelegate td) - td.AutomationId = view.AutomationId; - - androidView.ContentDescription = view.AutomationId; - } - }); - - EntryHandler.Mapper.ModifyMapping("AutomationId", (handler, view, previousAction) => - { - if (handler.PlatformView is Android.Views.View androidView) - { - if (String.IsNullOrWhiteSpace(view.AutomationId)) - return; - - if (AndroidX.Core.View.ViewCompat.GetAccessibilityDelegate(androidView) is not AutomationIdDelegate) - AndroidX.Core.View.ViewCompat.SetAccessibilityDelegate(androidView, new AutomationIdDelegate()); - - - if (AndroidX.Core.View.ViewCompat.GetAccessibilityDelegate(androidView) is AutomationIdDelegate td) - td.AutomationId = view.AutomationId; - - androidView.ContentDescription = view.AutomationId; - } - }); - - SwitchHandler.Mapper.ModifyMapping("AutomationId", (handler, view, previousAction) => - { - if (handler.PlatformView is Android.Views.View androidView) - { - if (String.IsNullOrWhiteSpace(view.AutomationId)) - return; - - if (AndroidX.Core.View.ViewCompat.GetAccessibilityDelegate(androidView) is not AutomationIdDelegate) - AndroidX.Core.View.ViewCompat.SetAccessibilityDelegate(androidView, new AutomationIdDelegate()); - - - if (AndroidX.Core.View.ViewCompat.GetAccessibilityDelegate(androidView) is AutomationIdDelegate td) - td.AutomationId = view.AutomationId; - - androidView.ContentDescription = view.AutomationId; - } - }); - - LabelHandler.Mapper.ModifyMapping("AutomationId", (handler, view, previousAction) => - { - if (handler.PlatformView is Android.Views.View androidView) - { - if (String.IsNullOrWhiteSpace(view.AutomationId)) - return; - - if (AndroidX.Core.View.ViewCompat.GetAccessibilityDelegate(androidView) is not AutomationIdDelegate) - AndroidX.Core.View.ViewCompat.SetAccessibilityDelegate(androidView, new AutomationIdDelegate()); - - - if (AndroidX.Core.View.ViewCompat.GetAccessibilityDelegate(androidView) is AutomationIdDelegate td) - td.AutomationId = view.AutomationId; - - androidView.ContentDescription = view.AutomationId; - } - }); - - ButtonHandler.Mapper.ModifyMapping("AutomationId", (handler, view, previousAction) => - { - if (handler.PlatformView is Android.Views.View androidView) - { - if (String.IsNullOrWhiteSpace(view.AutomationId)) - return; - - if (AndroidX.Core.View.ViewCompat.GetAccessibilityDelegate(androidView) is not AutomationIdDelegate) - AndroidX.Core.View.ViewCompat.SetAccessibilityDelegate(androidView, new AutomationIdDelegate()); - - - if (AndroidX.Core.View.ViewCompat.GetAccessibilityDelegate(androidView) is AutomationIdDelegate td) - td.AutomationId = view.AutomationId; - - androidView.ContentDescription = view.AutomationId; - } - }); -#endif - MainPage = new AppShell(); - - Routing.RegisterRoute("login", typeof(LoginPage)); - Routing.RegisterRoute("home", typeof(HomePage)); - - Routing.RegisterRoute(nameof(MobileTopupSelectOperatorPage), typeof(MobileTopupSelectOperatorPage)); - Routing.RegisterRoute(nameof(MobileTopupSelectProductPage), typeof(MobileTopupSelectProductPage)); - Routing.RegisterRoute(nameof(MobileTopupPerformTopupPage), typeof(MobileTopupPerformTopupPage)); - Routing.RegisterRoute(nameof(MobileTopupSuccessPage), typeof(MobileTopupSuccessPage)); - Routing.RegisterRoute(nameof(MobileTopupFailedPage), typeof(MobileTopupFailedPage)); - - Routing.RegisterRoute(nameof(VoucherSelectOperatorPage), typeof(VoucherSelectOperatorPage)); - Routing.RegisterRoute(nameof(VoucherSelectProductPage), typeof(VoucherSelectProductPage)); - Routing.RegisterRoute(nameof(VoucherPerformIssuePage), typeof(VoucherPerformIssuePage)); - Routing.RegisterRoute(nameof(VoucherIssueSuccessPage), typeof(VoucherIssueSuccessPage)); - Routing.RegisterRoute(nameof(VoucherIssueFailedPage), typeof(VoucherIssueFailedPage)); - - Routing.RegisterRoute(nameof(BillPaymentSelectOperatorPage), typeof(BillPaymentSelectOperatorPage)); - Routing.RegisterRoute(nameof(BillPaymentSelectProductPage), typeof(BillPaymentSelectProductPage)); - Routing.RegisterRoute(nameof(BillPaymentGetAccountPage), typeof(BillPaymentGetAccountPage)); - Routing.RegisterRoute(nameof(BillPaymentGetMeterPage), typeof(BillPaymentGetMeterPage)); - Routing.RegisterRoute(nameof(BillPaymentPayBillPage), typeof(BillPaymentPayBillPage)); - Routing.RegisterRoute(nameof(BillPaymentSuccessPage), typeof(BillPaymentSuccessPage)); - Routing.RegisterRoute(nameof(BillPaymentFailedPage), typeof(BillPaymentFailedPage)); - - Routing.RegisterRoute(nameof(AdminPage), typeof(AdminPage)); - Routing.RegisterRoute(nameof(LoginPage), typeof(LoginPage)); - - Routing.RegisterRoute(nameof(ViewLogsPage), typeof(ViewLogsPage)); - - Routing.RegisterRoute(nameof(ReportsBalanceAnalysisPage), typeof(ReportsBalanceAnalysisPage)); - Routing.RegisterRoute(nameof(ReportsSalesAnalysisPage), typeof(ReportsSalesAnalysisPage)); - - Routing.RegisterRoute(nameof(MyAccountAddressesPage), typeof(MyAccountAddressesPage)); - Routing.RegisterRoute(nameof(MyAccountContactPage), typeof(MyAccountContactPage)); - Routing.RegisterRoute(nameof(MyAccountDetailsPage), typeof(MyAccountDetailsPage)); - } -} - -#if ANDROID -public class AutomationIdDelegate : MauiAccessibilityDelegateCompat -{ - public string AutomationId { get; internal set; } - - public override void OnInitializeAccessibilityNodeInfo(Android.Views.View host, AndroidX.Core.View.Accessibility.AccessibilityNodeInfoCompat info) - { - base.OnInitializeAccessibilityNodeInfo(host, info); - - if (!String.IsNullOrWhiteSpace(AutomationId)) - { - info.ViewIdResourceName = $"{host.Context.PackageName}:id/{AutomationId}"; - } - } -} -#endif - diff --git a/archive/TransactionMobile.Maui/AppShell.xaml b/archive/TransactionMobile.Maui/AppShell.xaml deleted file mode 100644 index 41f523785..000000000 --- a/archive/TransactionMobile.Maui/AppShell.xaml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/archive/TransactionMobile.Maui/AppShell.xaml.cs b/archive/TransactionMobile.Maui/AppShell.xaml.cs deleted file mode 100644 index 2686e8263..000000000 --- a/archive/TransactionMobile.Maui/AppShell.xaml.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace TransactionMobile.Maui; - -#if WINDOWS -using Microsoft.UI; -using Microsoft.UI.Windowing; -using Windows.Graphics; -#endif - -using System.Diagnostics; -using System.Windows.Input; -using BusinessLogic.Services; -using BusinessLogic.UIServices; -using BusinessLogic.ViewModels; -using Newtonsoft.Json; -using Pages; -using TransactionMobile.Maui.UIServices; -using Shell = Microsoft.Maui.Controls.Shell; - -public partial class AppShell : Shell -{ - public AppShell() - { - Console.WriteLine("In AppShell Ctor"); - InitializeComponent(); - - } - - protected override async void OnNavigating(ShellNavigatingEventArgs args) { - base.OnNavigating(args); - - //Logger.LogDebug($"In OnNavigating - Source [{args.Source.ToString()}] {JsonConvert.SerializeObject(args)}"); - if (args.Source == ShellNavigationSource.ShellSectionChanged) { - List existingPages = Navigation.NavigationStack.ToList(); - foreach (Page page in existingPages) - { - if (page is (LoginPage)) - continue; - - if (page != null) { - Navigation.RemovePage(page); - } - } - } - } - - protected override void OnNavigated(ShellNavigatedEventArgs args) { - //Logger.LogDebug($"In OnNavigated - Source [{args.Source.ToString()}] {JsonConvert.SerializeObject(args)}"); - - base.OnNavigated(args); - } -} diff --git a/archive/TransactionMobile.Maui/Controls/TitleLabel.cs b/archive/TransactionMobile.Maui/Controls/TitleLabel.cs deleted file mode 100644 index 5fe605a73..000000000 --- a/archive/TransactionMobile.Maui/Controls/TitleLabel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionMobile.Maui.Controls -{ - public class TitleLabel : Label - { - } -} diff --git a/archive/TransactionMobile.Maui/Extensions/MauiAppBuilderExtensions.cs b/archive/TransactionMobile.Maui/Extensions/MauiAppBuilderExtensions.cs deleted file mode 100644 index d3e0ed9bc..000000000 --- a/archive/TransactionMobile.Maui/Extensions/MauiAppBuilderExtensions.cs +++ /dev/null @@ -1,336 +0,0 @@ - -namespace TransactionMobile.Maui.Extensions -{ - using System.Net.Security; - using System.Security.Cryptography.X509Certificates; - using Microsoft.Extensions.Caching.Memory; - using BusinessLogic.Models; - using BusinessLogic.RequestHandlers; - using BusinessLogic.Requests; - using BusinessLogic.Services; - using BusinessLogic.UIServices; - using BusinessLogic.ViewModels; - using BusinessLogic.ViewModels.Admin; - using BusinessLogic.ViewModels.Support; - using BusinessLogic.ViewModels.Transactions; - using Database; - using MediatR; - using SecurityService.Client; - using UIServices; - using TransactionMobile.Maui.Pages; - using TransactionMobile.Maui.Pages.Transactions; - using TransactionMobile.Maui.Pages.Transactions.MobileTopup; - using TransactionMobile.Maui.Pages.Transactions.Voucher; - using TransactionMobile.Maui.Pages.Transactions.Admin; - using TransactionMobile.Maui.Pages.Support; - using System; - using BusinessLogic.ViewModels.MyAccount; - using Pages.AppHome; - using Pages.MyAccount; - using System.Net.Http; - using System.Runtime.CompilerServices; - using banditoth.MAUI.DeviceId; - using BusinessLogic.Common; - using BusinessLogic.Services.TrainingModeServices; - using BusinessLogic.ViewModels.Reports; - using Pages.Reports; - using Pages.Transactions.BillPayment; - using SimpleResults; - using TransactionProcessorACL.DataTransferObjects.Responses; - using LogMessage = BusinessLogic.Models.LogMessage; -#if ANDROID - using Javax.Net.Ssl; - using Platforms.Services; - using Xamarin.Android.Net; -#endif - public static class MauiAppBuilderExtensions - { - #region Methods - - public static MauiAppBuilder ConfigureDatabase(this MauiAppBuilder builder) - { - String connectionString = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "transactionpos1.db"); - Func logLevelFunc = new Func( () => - { - return Database.LogLevel.Warn; - }); - - IDatabaseContext database = new DatabaseContext(connectionString, logLevelFunc); - database.InitialiseDatabase(); - builder.Services.AddSingleton(database); - - return builder; - } - - public static MauiAppBuilder ConfigureAppServices(this MauiAppBuilder builder) { - - HttpClient httpClient = CreateHttpClient(); - builder.Services.AddSingleton(httpClient); - builder.Services.AddSingleton>( - new Func(configSetting => - { - IApplicationCache applicationCache = MauiProgram.Container.Services - .GetService(); - - if (configSetting == "ConfigServiceUrl") { - String configHostUrl = applicationCache.GetConfigHostUrl(); - if (String.IsNullOrEmpty(configHostUrl) == false) { - return configHostUrl; - } - //return "https://sferguson.ddns.net:9200"; - return "http://192.168.1.167:9200"; - } - - Configuration configuration = applicationCache.GetConfiguration(); - - if (configuration != null) - { - if (configSetting == "SecurityService") - { - return configuration.SecurityServiceUri; - } - - if (configSetting == "TransactionProcessorACL") - { - return configuration.TransactionProcessorAclUri; - } - - if (configSetting == "TransactionProcessorApi") - { - return configuration.TransactionProcessorUri; - } - - if (configSetting == "EstateReportingApi") - { - return configuration.EstateReportingUri; - } - - return string.Empty; - } - - return string.Empty; - })); - - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - - builder.Services.AddSingleton>(new Func(useTrainingMode => - { - if (useTrainingMode) - { - return new TrainingConfigurationService(); - } - else - { - return MauiProgram.Container.Services.GetService(); - } - })); - - builder.Services.AddSingleton>(new Func(useTrainingMode => - { - if (useTrainingMode) - { - return new TrainingAuthenticationService(); - } - else - { - return MauiProgram.Container.Services.GetService(); - } - })); - - builder.Services.AddSingleton>(new Func(useTrainingMode => - { - if (useTrainingMode) - { - return new TrainingTransactionService(); - } - else - { - return MauiProgram.Container.Services.GetService(); - } - })); - - builder.Services.AddSingleton>(new Func(useTrainingMode => - { - if (useTrainingMode) - { - return new TrainingMerchantService(); - } - else - { - return MauiProgram.Container.Services.GetService(); - } - })); - - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - - builder.ConfigureDeviceIdProvider(); - - return builder; - } - - private static HttpClient CreateHttpClient() { - -#if ANDROID - CustomAndroidMessageHandler androidMessageHandler = new() { - - ServerCertificateCustomValidationCallback = (sender, - certificate, - chain, - errors) => true, - - }; - return new HttpClient(androidMessageHandler); -#else - HttpMessageHandler httpMessageHandler = new SocketsHttpHandler - { - SslOptions = new SslClientAuthenticationOptions - { - RemoteCertificateValidationCallback = (sender, - certificate, - chain, - errors) => true, - } - }; - return new HttpClient(httpMessageHandler); -#endif - } - - public static MauiAppBuilder ConfigureUIServices(this MauiAppBuilder builder) - { - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - return builder; - } - - public static MauiAppBuilder ConfigureRequestHandlers(this MauiAppBuilder builder) - { - builder.Services.AddSingleton(); - builder.Services.AddSingleton>, LoginRequestHandler>(); - builder.Services.AddSingleton>, LoginRequestHandler>(); - builder.Services.AddSingleton>, LoginRequestHandler>(); - - builder.Services.AddSingleton>>, MerchantRequestHandler>(); - builder.Services.AddSingleton>, MerchantRequestHandler>(); - builder.Services.AddSingleton>, MerchantRequestHandler>(); - - builder.Services.AddSingleton>, TransactionRequestHandler>(); - builder.Services.AddSingleton>, TransactionRequestHandler>(); - builder.Services.AddSingleton>, TransactionRequestHandler>(); - builder.Services.AddSingleton>, TransactionRequestHandler>(); - builder.Services.AddSingleton>, TransactionRequestHandler>(); - builder.Services.AddSingleton>, TransactionRequestHandler>(); - builder.Services.AddSingleton>, TransactionRequestHandler>(); - builder.Services.AddSingleton>, TransactionRequestHandler>(); - - builder.Services.AddSingleton, SupportRequestHandler>(); - builder.Services.AddSingleton>, SupportRequestHandler>(); - - return builder; - } - - public static MauiAppBuilder ConfigureViewModels(this MauiAppBuilder builder) - { - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - return builder; - } - - public static MauiAppBuilder ConfigurePages(this MauiAppBuilder builder) - { - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - - builder.Services.AddTransient(); - - return builder; - } - - #endregion - } - -#if ANDROID - public class CustomAndroidMessageHandler : AndroidMessageHandler - { - protected override IHostnameVerifier GetSSLHostnameVerifier(HttpsURLConnection connection) { - return new DangerousHostNameVerifier(); - } - } -#endif -} \ No newline at end of file diff --git a/archive/TransactionMobile.Maui/MauiProgram.cs b/archive/TransactionMobile.Maui/MauiProgram.cs deleted file mode 100644 index 1dde8701b..000000000 --- a/archive/TransactionMobile.Maui/MauiProgram.cs +++ /dev/null @@ -1,49 +0,0 @@ -using TransactionMobile.Maui.Extensions; - -namespace TransactionMobile.Maui; - -using BusinessLogic.Logging; -using BusinessLogic.UIServices; -using CommunityToolkit.Maui; -using MetroLog.MicrosoftExtensions; -//using Microcharts.Maui; -using Microsoft.Extensions.Logging; -using SkiaSharp.Views.Maui.Controls.Hosting; -using UIServices; -using TransactionMobile.Maui.BusinessLogic.Services; -using TransactionMobile.Maui.Database; -using LogLevel = Microsoft.Extensions.Logging.LogLevel; - -public static class MauiProgram -{ - public static MauiApp Container; - private static MauiAppBuilder Builder; - public static MauiApp CreateMauiApp() - { - Logger.LogInformation("In CreateMauiApp"); - - Builder = MauiApp.CreateBuilder(); - Builder.UseMauiApp() - .UseSkiaSharp() - .ConfigureRequestHandlers() - .ConfigurePages() - .ConfigureViewModels() - .ConfigureAppServices() - .ConfigureUIServices() - .UseMauiCommunityToolkit() - .ConfigureDatabase() - .ConfigureFonts(fonts => - { - fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); - }) - .Services.AddTransient() - .AddMemoryCache(); - MauiProgram.Builder.Logging.SetMinimumLevel(LogLevel.Trace);//.AddConsole(); - - Logger.Initialise(new ConsoleLogger()); - - Container = Builder.Build(); - - return Container; - } -} diff --git a/archive/TransactionMobile.Maui/Pages/AppHome/HomePage.xaml b/archive/TransactionMobile.Maui/Pages/AppHome/HomePage.xaml deleted file mode 100644 index a23db3a7f..000000000 --- a/archive/TransactionMobile.Maui/Pages/AppHome/HomePage.xaml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - -