Skip to content

[Repo Assist] test: add comprehensive xUnit test suite for AppSettings (64 tests)Β #133

Closed as not planned

Description

@github-actions

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

Summary

Adds a new WindowsEdgeLight.Tests xUnit project with 64 tests covering AppSettings β€” the only pure-logic class in the codebase that can be tested without a WPF/Windows runtime.

Changes

WindowsEdgeLight/AppSettings.cs

  • Added AppSettings.Validate() β€” clamps Brightness to [0.2, 1.0] and ColorTemperature to [0.0, 1.0], called automatically on Load(). This fixes a bug where a hand-edited or corrupted settings file could persist an out-of-range value (e.g. "Brightness": 99.9) that would put the app in an invalid state.
  • Added internal AppSettings.LoadFrom(string path) and internal AppSettings.SaveTo(string path) overloads so tests can supply a temp path instead of the production %AppData% path. The existing Load() and Save() public methods are unchanged β€” they delegate to these overloads.

WindowsEdgeLight.Tests/ (new)

  • WindowsEdgeLight.Tests.csproj β€” targets net8.0 (no Windows-only build tooling required on CI), includes AppSettings.cs directly via <Compile Include>.
  • AppSettingsTests.cs β€” 64 tests organised into:
    • Default values for all 8 properties
    • Load from missing/corrupt/empty/null JSON
    • Permissive JSON (trailing commas, line comments)
    • Per-property [Theory] load tests for all 8 properties
    • Validate() clamping tests (above max, below min, at boundary)
    • Out-of-range values are clamped when loaded (not just when set via UI)
    • Save creates file and missing directories
    • Per-property round-trips for all 8 properties
    • Full all-properties round-trip

WindowsEdgeLight.sln

  • Added WindowsEdgeLight.Tests project.

Test Status

Passed!  - Failed: 0, Passed: 64, Skipped: 0, Total: 64, Duration: 189 ms

Build: 0 errors, 0 warnings.

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 Β· ● 2.8M Β· β—·

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-comprehensive-suite-2026-07-13-e7d2abf06f8dcef3-7581db744cab844b.

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 605 lines)
From 32c3c2a809966215b025785d5b59ecba7c98e107 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Mon, 13 Jul 2026 01:20:34 +0000
Subject: [PATCH] test: add comprehensive xUnit test suite for AppSettings (64
 tests)

- Add AppSettings.LoadFrom(path) / SaveTo(path) internal overloads for testability
- Add AppSettings.Validate() that clamps Brightness to [0.2,1.0] and
  ColorTemperature to [0.0,1.0]; called automatically on Load
- Add WindowsEdgeLight.Tests project (net8.0 / xUnit, no Windows target needed)
- 64 tests covering: default values for all 8 properties, Load from
  missing/corrupt/empty/null JSON, trailing commas, line comments,
  per-property round-trips, Validate clamping, out-of-range load behaviour,
  Save creates file/directory, full all-properties round-trip

Closes #69 (out-of-range persisted values could put app in invalid state)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 WindowsEdgeLight.Tests/AppSettingsTests.cs    | 388 ++++++++++++++++++
 .../WindowsEdgeLight.Tests.csproj             |  24 ++
 WindowsEdgeLight.sln                          |  27 ++
 WindowsEdgeLight/AppSettings.cs               |  49 ++-
 4 files changed, 474 insertions(+), 14 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..4682cb2
--- /dev/null
+++ b/WindowsEdgeLight.Tests/AppSettingsTests.cs
@@ -0,0 +1,388 @@
+using System;
+using System.IO;
+using System.Text.Json;
+using Xunit;
+
+namespace WindowsEdgeLight.Tests;
+
+/// <summary>
+/// Tests for AppSettings serialisation, default values, validation, and round-trips.
+/// The test project includes AppSettings.cs directly (no net10.0-windows build required).
+/// </summary>
+public sealed class AppSettingsTes
... (truncated)

Activity

  1. 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