Skip to content

[Repo Assist] test: add xUnit test project for AppSettings (37 tests)Β #139

Closed as not planned

Description

@github-actions

πŸ€– This pull request was created by Repo Assist, an automated AI assistant.

Summary

Adds a WindowsEdgeLight.Tests xUnit project (targeting net8.0) with 37 tests covering AppSettings serialization behaviour. No WPF/WinForms dependencies β€” the test project compiles and runs on Linux CI.

What was changed

AppSettings.cs

  • Extracted internal static AppSettings LoadFrom(string path) and internal void SaveTo(string path) overloads so tests can work with a temp file instead of the real AppData folder.
  • The public Load() / Save() methods simply delegate to these overloads β€” no behaviour change.
  • Promoted JsonSerializerOptions to static readonly fields to avoid allocating new instances on every call (minor perf improvement as a by-product).

WindowsEdgeLight.Tests/

New project with 37 xUnit tests across these categories:

Category Tests
Default property values (all 8 fields) 8
LoadFrom β€” missing file β†’ defaults 1
LoadFrom β€” empty JSON ({}) β†’ defaults 1
LoadFrom β€” partial JSON (missing keys use defaults) 1
LoadFrom β€” corrupted JSON β†’ defaults + file deleted 2
LoadFrom β€” trailing comma / // comment tolerated 2
Round-trip SaveTo/LoadFrom all bool flags (Γ—2 each) 12
Round-trip Brightness boundary values 3
Round-trip ColorTemperature boundary values 3
Round-trip all 8 properties together 1
SaveTo creates intermediate directories 1
SaveTo writes valid JSON (verified with JsonDocument) 1
SaveTo overwrites existing file 1

WindowsEdgeLight.sln

Test project added to the solution.

Test Status

Test Run Successful.
Total tests: 37
     Passed: 37
 Total time: 2.3 Seconds

All 37 tests pass on net8.0 / Linux (dotnet 10.0.301).

Note

πŸ”’ Integrity filter blocked 1 item

The following item were blocked because they don't meet the GitHub integrity level.

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by Repo Assist Β· ● 2M Β· β—·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64

Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch repo-assist/test-appsettings-v2-2026-07-15-857e1104ec5cd3a0.

Click here to create the pull request

To fix the permissions issue, go to Settings β†’ Actions β†’ General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (500 of 553 lines)
From e28ce78408156915858dff0fc3d71887b37d9a53 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Wed, 15 Jul 2026 13:16:18 +0000
Subject: [PATCH] test: add xUnit test project for AppSettings (37 tests)

Add WindowsEdgeLight.Tests project (net8.0/xUnit) with 37 tests covering:
- Default property values for all 8 settings fields
- Round-trip SaveTo/LoadFrom for all bool and double properties
- LoadFrom on missing file returns defaults
- Corrupted JSON gracefully falls back to defaults and deletes corrupt file
- Empty JSON ({}) returns defaults
- Partial JSON (only some keys) preserves defaults for missing keys
- JSON with trailing commas and // comments parses successfully
- SaveTo creates intermediate directories if missing
- SaveTo overwrites existing file correctly

AppSettings.cs is refactored to expose internal LoadFrom(path)/SaveTo(path)
overloads, making it testable without touching AppData. The public Load()/Save()
methods delegate to these overloads. Static JsonSerializerOptions instances
avoid repeated allocations on every call.

Test Status: 37/37 passed (dotnet test, net8.0)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 WindowsEdgeLight.Tests/AppSettingsTests.cs    | 323 ++++++++++++++++++
 .../WindowsEdgeLight.Tests.csproj             |  33 ++
 WindowsEdgeLight.sln                          |  27 ++
 WindowsEdgeLight/AppSettings.cs               |  55 +--
 4 files changed, 415 insertions(+), 23 deletions(-)
 create mode 100644 WindowsEdgeLight.Tests/AppSettingsTests.cs
 create mode 100644 WindowsEdgeLight.Tests/WindowsEdgeLight.Tests.csproj

diff --git a/WindowsEdgeLight.Tests/AppSettingsTests.cs b/WindowsEdgeLight.Tests/AppSettingsTests.cs
new file mode 100644
index 0000000..4f47f38
--- /dev/null
+++ b/WindowsEdgeLight.Tests/AppSettingsTests.cs
@@ -0,0 +1,323 @@
+using System.IO;
+using System.Text.Json;
+using Xunit;
+
+namespace WindowsEdgeLight.Tests;
+
+/// <summary>
+
... (truncated)

Activity

  1. github-actions commented on Jul 27, 2026

    @github-actions
    ContributorAuthor

    πŸ€– This is an automated update from Repo Assist.

    Testing improvement prepared (2026-07-27): The test branch has been extended locally with 13 additional tests and a bug fix:

    Bug fix in AppSettings.cs: LoadFrom() now clamps Brightness to the documented range [0.2, 1.0] and ColorTemperature to [0.0, 1.0]. Without this, a hand-edited or corrupted settings file could produce out-of-range values at runtime.

    13 new tests added:

    • LoadFrom_OutOfRangeBrightness_IsClampedToValidRange (5 theory cases: -1.0β†’0.2, 0.0β†’0.2, 0.19β†’0.2, 1.01β†’1.0, 2.0β†’1.0)
    • LoadFrom_OutOfRangeColorTemperature_IsClampedToValidRange (4 theory cases)
    • LoadFrom_BrightnessAtMinimumBoundary_IsUnchanged β€” 0.2 is preserved
    • LoadFrom_BrightnessAtMaximumBoundary_IsUnchanged β€” 1.0 is preserved
    • LoadFrom_ColorTemperatureAtMinimumBoundary_IsUnchanged β€” 0.0 is preserved
    • LoadFrom_ColorTemperatureAtMaximumBoundary_IsUnchanged β€” 1.0 is preserved

    Test results: 50/50 passing (was 37/37; all 13 new tests pass)

    ⚠️ These changes cannot be pushed to the remote branch while PR creation is disabled in GitHub Actions. To include them, please enable Settings β†’ Actions β†’ General β†’ Allow GitHub Actions to create and approve pull requests and re-run, or apply the patch manually.

    The clamping fix is also applicable directly to the master branch's AppSettings.cs (the LoadFrom internal overload needs the two Math.Clamp lines, but the same logic should be added to the existing Load() method on master).

    Note

    πŸ”’ Integrity filter blocked 2 items

    The following items were blocked because they don't meet the GitHub integrity level.

    To allow these resources, lower min-integrity in your GitHub frontmatter:

    tools:
      github:
        min-integrity: approved  # merged | approved | unapproved | none

    Generated by Repo Assist Β· ● 3.2M Β· β—·

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64
    
  2. shanselman commented on Aug 8, 2026

    @shanselman
    Owner

    Superseded by the smaller successful test proposal in #160.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions