Skip to content

Refactor/clean up game application service#257

Merged
xenobiasoft merged 8 commits into
mainfrom
refactor/clean-up-game-application-service
May 2, 2026
Merged

Refactor/clean up game application service#257
xenobiasoft merged 8 commits into
mainfrom
refactor/clean-up-game-application-service

Conversation

@xenobiasoft
Copy link
Copy Markdown
Owner

@xenobiasoft xenobiasoft commented May 2, 2026

Description

Cleans up CosmosDb configuration and refactored game controller code.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Other (please describe):

Changes Made

  • Simplified CosmosClient configuration
  • Refactored game controllers to remove IGameService dependency and changed endpoints to send commands and queries.
  • Added explicit endpoints for game actions

Testing

  • I have tested these changes locally
  • All existing tests pass
  • I have added new tests (if applicable)

Screenshots (if applicable)

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have updated the documentation (if necessary)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-bush-02024e71e-257.westus2.7.azurestaticapps.net

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-bush-02024e71e-257.westus2.7.azurestaticapps.net

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the Sudoku game API/controller layer to use MediatR commands/queries directly (removing the IGameApplicationService abstraction), introduces explicit game status/action endpoints, and adjusts clients/tests/configuration around Cosmos DB and App Configuration.

Changes:

  • Replace IGameApplicationService usage with direct IMediator.Send(...) in API controllers; remove the application service layer.
  • Introduce explicit game status/action endpoints (pause/resume/abandon/complete, actions controller), updating React/Blazor clients and tests.
  • Simplify Cosmos DB/App Configuration setup (incl. optional App Configuration enablement and container auto-create options).

Reviewed changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/frontend/Sudoku.React/src/pages/GamePage.tsx Switches status updates to pauseGame/resumeGame calls.
src/frontend/Sudoku.React/src/pages/GamePage.test.tsx Updates mocks/assertions for pause/resume status calls.
src/frontend/Sudoku.React/src/pages/GamePage.integration.test.tsx Updates integration mocks for pause/resume status calls.
src/frontend/Sudoku.React/src/hooks/useGameService.ts Replaces generic status update with pauseGame/resumeGame helpers.
src/frontend/Sudoku.React/src/api/apiClient.ts Adds pauseGame/resumeGame endpoints (POST).
src/frontend/Sudoku.React/src/api/apiClient.test.ts Adds/updates tests for pause/resume API calls.
src/frontend/Sudoku.Blazor/appsettings.json Moves appconfig endpoint settings into base config.
src/frontend/Sudoku.Blazor/appsettings.Development.json Removes dev-specific appconfig block.
src/frontend/Sudoku.Blazor/Services/HttpClients/IGameApiClient.cs Replaces SaveGameStatusAsync with explicit status action methods.
src/frontend/Sudoku.Blazor/Services/HttpClients/GameApiClient.cs Implements explicit status actions via POST; create-game now follows Location to fetch full game.
src/frontend/Sudoku.Blazor/Services/GameStateManager.cs Maps local GameStatus values to explicit status action calls.
src/frontend/Sudoku.Blazor/Program.cs Only requires Key Vault outside Development.
src/backend/Tests/Mocks/MockGameApiClientExtensions.cs Updates verification to match explicit status action methods.
src/backend/Tests/Application/Services/GameApplicationServiceTests.cs Removes tests for deleted GameApplicationService.
src/backend/Tests/Application/Handlers/CreateGameCommandHandlerTests.cs Updates handler abstraction and asserts returned game id.
src/backend/Tests/API/PossibleValuesControllerTests.cs Switches controller tests to Mediator commands/queries.
src/backend/Tests/API/GamesControllerTests.cs Updates tests for Mediator usage and create-game response semantics.
src/backend/Tests/API/GameStatusControllerTests.cs Expands tests for explicit status endpoints using Mediator.
src/backend/Tests/API/GameActionsControllerTests.cs Updates tests to send MediatR commands.
src/backend/Tests/API/DependencyInjectionTests.cs Updates DI expectations (Mediator instead of app service) and required services list.
src/backend/Tests/API/BaseGameControllerTests.cs Base controller tests now mock IMediator.
src/backend/Sudoku.ServiceDefaults/AzureAppConfigurationExtensions.cs Adds AzureAppConfiguration:Enabled flag to skip App Configuration bootstrap.
src/backend/Sudoku.Infrastructure/Services/CosmosDbService.cs Adds optional auto-create for DB/container (with partition key path).
src/backend/Sudoku.Infrastructure/Repositories/CosmosDbUserProfileRepository.cs Adds optional auto-create for profiles container.
src/backend/Sudoku.Infrastructure/Configuration/InfrastructureServiceCollectionExtensions.cs Removes inline CosmosClient construction; relies on external registration.
src/backend/Sudoku.Infrastructure/Configuration/CosmosDbOptions.cs Adds AutoCreateContainers and ContainerPartitionKeyPath options (defaults preserved).
src/backend/Sudoku.Application/Services/GameApplicationService.cs Deletes application service layer.
src/backend/Sudoku.Application/Interfaces/IGameApplicationService.cs Deletes application service interface.
src/backend/Sudoku.Application/Handlers/CreateGameCommandHandler.cs Create-game now returns a Result<string> game id.
src/backend/Sudoku.Application/Configuration/ApplicationServiceCollectionExtensions.cs Stops registering removed application service; keeps MediatR registration.
src/backend/Sudoku.Application/Commands/CreateGameCommand.cs Updates command to ICommand<string>.
src/backend/Sudoku.AppHost/appsettings.json Sets CosmosDb connection string in base config.
src/backend/Sudoku.AppHost/appsettings.Development.json Removes duplicated connection string section.
src/backend/Sudoku.AppHost/Program.cs Removes Key Vault reference wiring; keeps Cosmos emulator reference.
src/backend/Sudoku.Api/appsettings.json Removes explicit CosmosDb DB/container name block (defaults apply).
src/backend/Sudoku.Api/appsettings.Development.json Adjusts CosmosDb dev settings and enables auto-create.
src/backend/Sudoku.Api/Program.cs Adds user secrets; gates Key Vault to non-Development; registers Cosmos client when enabled.
src/backend/Sudoku.Api/Controllers/PossibleValuesController.cs Uses Mediator commands instead of app service.
src/backend/Sudoku.Api/Controllers/GamesController.cs Uses Mediator; create-game now returns 201 with Location only.
src/backend/Sudoku.Api/Controllers/GameStatusController.cs Replaces PATCH status with explicit POST endpoints (pause/resume/abandon/complete/validate).
src/backend/Sudoku.Api/Controllers/GameActionsController.cs Uses Mediator for move/reset/undo commands.
src/backend/Sudoku.Api/Controllers/BaseGameController.cs Base controller now depends on IMediator; HandleUnitResult uses Result.
scripts/set-app-config.sh Updates App Config keys for CosmosDb auto-create/SSL validation options.
Tests/E2E/fixtures/api-mocks.ts Updates E2E route mocking for status POST endpoints and validate response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/backend/Sudoku.Api/Controllers/GamesController.cs
Comment thread src/backend/Sudoku.AppHost/appsettings.json Outdated
Comment thread src/frontend/Sudoku.Blazor/appsettings.json
Comment thread src/frontend/Sudoku.Blazor/appsettings.Development.json
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-bush-02024e71e-257.westus2.7.azurestaticapps.net

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-bush-02024e71e-257.westus2.7.azurestaticapps.net

@xenobiasoft xenobiasoft merged commit 93ff4d3 into main May 2, 2026
11 checks passed
@xenobiasoft xenobiasoft deleted the refactor/clean-up-game-application-service branch May 2, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants