Skip to content

[tests] Fix UrlEscaping_Bug43411 to actually run and assert correctly#11523

Open
jonathanpeppers wants to merge 1 commit into
mainfrom
jonathanpeppers/fix-urlescaping-bug43411
Open

[tests] Fix UrlEscaping_Bug43411 to actually run and assert correctly#11523
jonathanpeppers wants to merge 1 commit into
mainfrom
jonathanpeppers/fix-urlescaping-bug43411

Conversation

@jonathanpeppers
Copy link
Copy Markdown
Member

Two issues with UrlEscaping_Bug43411 in AndroidMessageHandlerIntegrationTests on main:

  1. The test has been silently dead for years. The method was declared void UrlEscaping_Bug43411 () (non-public). NUnitLite — the legacy in-process runner used by the device test suite — silently skipped non-public [Test] methods, so this test never ran. Nobody noticed because the failure mode was "silently never runs."

    Discovered while migrating to stock NUnit 3 via dotnet test in [WIP] Dogfood dotnet test for device tests #11224, where NUnit 3 actually surfaces the method and it fails.

  2. The assertion was wrong. It compared the request URL against request.RequestUri.ToString (), but per the .NET docs Uri.ToString () returns the "human-readable" form and unescapes safe characters like %20 → literal space. So Assert.AreEqual ("http://localhost:8810/?example=value%20_value", request.RequestUri.ToString ()) fails because the actual value contains value _value with a space.

    The correct property is Uri.AbsoluteUri, which returns the canonical encoded form and preserves percent-encoding.

Changes

  • Make UrlEscaping_Bug43411 public so NUnit discovers it. The helper UrlEscaping_TestUrl stays non-public.
  • In UrlEscaping_TestUrl, switch from request.RequestUri.ToString () to request.RequestUri.AbsoluteUri, with a brief comment explaining why.

See #11224 for context on the NUnit 3 migration that surfaced this.

Two issues with this test on main:

1. The method was declared `void UrlEscaping_Bug43411 ()` (non-public). NUnitLite silently skipped non-public `[Test]` methods, so the test has been effectively dead for years. Discovered while migrating to stock NUnit 3 via `dotnet test` in PR #11224, where NUnit 3 surfaces the method and it fails.

2. The assertion compared the request URL against `Uri.ToString ()`, which returns the human-readable form and unescapes safe characters like `%20` to a literal space. The canonical, encoded form is `Uri.AbsoluteUri` — switch to that so percent-encoding is preserved.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 27, 2026 21:12
Copy link
Copy Markdown
Contributor

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

This PR fixes a previously undiscovered AndroidMessageHandler integration test so it is run by NUnit and validates URL escaping using the encoded URI representation.

Changes:

  • Makes UrlEscaping_Bug43411 public so the test runner discovers it.
  • Updates the assertion to compare against Uri.AbsoluteUri instead of Uri.ToString().
  • Adds a short comment explaining the ToString() vs AbsoluteUri distinction.

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