Skip to content

Add Unity GSDK unit tests and CI workflow#193

Merged
dgkanatsios merged 5 commits into
mainfrom
copilot/add-unit-tests-unity-gsdk
Apr 28, 2026
Merged

Add Unity GSDK unit tests and CI workflow#193
dgkanatsios merged 5 commits into
mainfrom
copilot/add-unit-tests-unity-gsdk

Conversation

Copilot AI commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Adds standalone unit tests for the Unity GSDK model/helper classes and a GitHub Actions workflow to run them on PRs, matching the pattern established in #191 (C#) and #192 (C++).

The Unity SDK's model classes (GSDKConfiguration, SessionConfig, HeartbeatRequest/Response, MaintenanceSchedule, etc.) and SimpleJson helpers have no Unity engine dependencies, so they compile and test in a standard .NET project without requiring Unity Editor.

Test project (UnityGsdk/Tests/Tests.csproj):

  • Compiles source files via <Compile Include="..." Link="..." /> — no separate library project needed
  • 34 tests across three files:
    • GSDKConfigurationTests — config parsing, env vars, certificates, ports, round-trip serialization
    • SessionConfigTestsCopyNonNullFields, equality operators, hash code
    • SerializationTests — heartbeat request/response, maintenance schedule V2, connected players, all GameState/GameOperation enum values

CI workflow (.github/workflows/unity-tests.yml):

  • Triggers on PRs touching UnityGsdk/**
  • ubuntu-latest, .NET 10.0.x, dotnet test

Other:

  • UnityGsdk/.gitignore — added !Tests/Tests.csproj exception (existing gitignore excludes *.csproj)
  • UnityGsdk/README.md — added FAQ section clarifying that the Tests/ folder is for development/CI only and does not need to be included when integrating the Unity GSDK; also fixed a pre-existing "scripring" → "scripting" typo

Special notes for your reviewer:

MSTest package versions match csharp/Tests/Tests.csproj for consistency.

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Create test project (UnityGsdk/Tests/Tests.csproj) that compiles model
  and helper source files without Unity engine dependencies
- Add GSDKConfigurationTests: config parsing, env vars, round-trip
- Add SessionConfigTests: CopyNonNullFields, equality, hash code
- Add SerializationTests: heartbeat request/response, maintenance schedule,
  connected players, game state/operation enum serialization
- Add CI workflow (.github/workflows/unity-tests.yml) triggered on PRs
  with changes to UnityGsdk/** paths
- Update UnityGsdk/.gitignore to allow Tests/Tests.csproj

Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests for Unity GSDK and integrate with PR Add Unity GSDK unit tests and CI workflow Mar 3, 2026
@dgkanatsios

Copy link
Copy Markdown
Contributor

@copilot can you amend the Unity GSDK readme to mention that these files don't need to be included when someone uses the Unity GSDK?

@dgkanatsios

Copy link
Copy Markdown
Contributor

@copilot can you retry?

Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>

Copilot AI commented Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot can you retry?

Added a "What is the Tests/ folder?" section to UnityGsdk/README.md clarifying that it's for development/CI only and doesn't need to be included when using the SDK. Also fixed a pre-existing "scripring" → "scripting" typo. See commit 7c97a23.

@dgkanatsios
dgkanatsios requested a review from Copilot April 28, 2026 00:45
@dgkanatsios
dgkanatsios marked this pull request as ready for review April 28, 2026 00:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a standalone .NET unit test project for Unity GSDK model/helper classes (no Unity engine dependency) and introduces a GitHub Actions workflow to run those tests on PRs that touch UnityGsdk/**.

Changes:

  • Added UnityGsdk/Tests/Tests.csproj plus new MSTest test suites covering config parsing, session config behavior, and JSON serialization/deserialization.
  • Added .github/workflows/unity-tests.yml to run Unity GSDK tests on PRs that modify Unity SDK files.
  • Updated UnityGsdk/.gitignore to allow committing the test project file, and updated UnityGsdk/README.md with a Tests folder FAQ + typo fix.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
UnityGsdk/Tests/Tests.csproj New .NET test project compiling Unity GSDK model/helper sources via linked includes.
UnityGsdk/Tests/SessionConfigTests.cs New unit tests for SessionConfig copy/equality/hash behavior.
UnityGsdk/Tests/SerializationTests.cs New unit tests for SimpleJson serialization and model round-trips (heartbeat, maintenance, enums, etc.).
UnityGsdk/Tests/GSDKConfigurationTests.cs New unit tests for GSDKConfiguration parsing and env var capture.
UnityGsdk/README.md Documentation update: adds Tests folder FAQ and fixes a typo.
UnityGsdk/.gitignore Un-ignores the new test project file while keeping Unity’s default ignores.
.github/workflows/unity-tests.yml New CI workflow to build/test the Unity test project on relevant PRs.

Comment thread UnityGsdk/Tests/GSDKConfigurationTests.cs
Comment thread UnityGsdk/README.md Outdated
Comment thread .github/workflows/unity-tests.yml Outdated
dgkanatsios and others added 2 commits April 27, 2026 17:50
- Update integration instructions to use the correct folder name
  'Assets/PlayFabSdk' (the previous 'PlayFabSDK' casing was wrong on
  case-sensitive filesystems like Linux).
- Expand the 'Tests/' section to make clear it refers to the new
  top-level UnityGsdk/Tests/ folder, that it sits outside Assets/ so
  Unity does not import or compile it, and that it does not need to be
  copied when integrating the SDK.
- Disambiguate from the pre-existing in-engine Assets/Tests/ NUnit
  assembly which is gated behind the UNIT_TESTING define.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- GSDKConfigurationTests.ReadConfiguration_EnvironmentVariables_Captured:
  capture original PF_TITLE_ID/PF_BUILD_ID/PF_REGION values before the
  test and restore them in the finally block. The previous version
  unconditionally cleared them, which would wipe any pre-existing values
  set on the developer's machine or on the CI runner for the rest of the
  process.
- unity-tests.yml: add --no-build to the test step. dotnet test builds
  by default, so the explicit Build step was redoing the build; --no-build
  skips that and shaves CI time without removing the two-step structure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dgkanatsios
dgkanatsios merged commit a78e5b9 into main Apr 28, 2026
2 checks passed
@dgkanatsios
dgkanatsios deleted the copilot/add-unit-tests-unity-gsdk branch April 28, 2026 01:02
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.

3 participants