From d712d43be3795afe703da2b0258d39a1c34722ef Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Wed, 21 Jul 2021 10:16:57 +0200 Subject: [PATCH 1/4] Use AbsoluteUri in FakeNavigationManager to preserve escpaed uri's --- .../NavigationManager/FakeNavigationManager.cs | 2 +- .../NavigationManager/FakeNavigationManagerTest.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/bunit.web/TestDoubles/NavigationManager/FakeNavigationManager.cs b/src/bunit.web/TestDoubles/NavigationManager/FakeNavigationManager.cs index 271da2ffd..b54e22dca 100644 --- a/src/bunit.web/TestDoubles/NavigationManager/FakeNavigationManager.cs +++ b/src/bunit.web/TestDoubles/NavigationManager/FakeNavigationManager.cs @@ -26,7 +26,7 @@ public FakeNavigationManager(ITestRenderer renderer) /// protected override void NavigateToCore(string uri, bool forceLoad) { - Uri = ToAbsoluteUri(uri).ToString(); + Uri = ToAbsoluteUri(uri).AbsoluteUri; renderer.Dispatcher.InvokeAsync( () => NotifyLocationChanged(isInterceptedLink: false)); diff --git a/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs b/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs index 2b32c8eaf..587c135e0 100644 --- a/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs +++ b/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs @@ -91,5 +91,15 @@ public void Test006() cut.Markup.ShouldBe($"{sut.BaseUri}foo"); } + + [Fact(DisplayName = "Uri should not be unescaped")] + public void Test007() + { + var sut = CreateFakeNavigationMananger(); + + sut.NavigateTo("/with%20whitespace"); + + sut.Uri.ShouldEndWith("with%20whitespace"); + } } } From 140dbedcd547c06ce496c450761fff1d9bb4edcf Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Thu, 22 Jul 2021 07:13:25 +0200 Subject: [PATCH 2/4] Use OriginalString instead of AbsoluteUri Co-authored-by: Egil Hansen --- .../TestDoubles/NavigationManager/FakeNavigationManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bunit.web/TestDoubles/NavigationManager/FakeNavigationManager.cs b/src/bunit.web/TestDoubles/NavigationManager/FakeNavigationManager.cs index b54e22dca..aafb98a3a 100644 --- a/src/bunit.web/TestDoubles/NavigationManager/FakeNavigationManager.cs +++ b/src/bunit.web/TestDoubles/NavigationManager/FakeNavigationManager.cs @@ -26,7 +26,7 @@ public FakeNavigationManager(ITestRenderer renderer) /// protected override void NavigateToCore(string uri, bool forceLoad) { - Uri = ToAbsoluteUri(uri).AbsoluteUri; + Uri = ToAbsoluteUri(uri).OriginalString; renderer.Dispatcher.InvokeAsync( () => NotifyLocationChanged(isInterceptedLink: false)); From c5860edff1db6c1d896faf178a02ad076ad9d0fc Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Thu, 22 Jul 2021 07:19:52 +0200 Subject: [PATCH 3/4] Added changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d22ee6f17..f9ea52245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ List of fixes in this release. - Fixed issue where a registered fall-back service provider was not made available to resolve service dependencies of components under test. Thanks to [@dady8889](https://github.com/dady8889) for the reporting the issue. +- Fixed handling of escaped uri's in FakeNavigationManager. By [@linkdotnet](https://github.com/linkdotnet) in [#460](https://github.com/bUnit-dev/bUnit/pull/460) + ## [1.1.5] - 2021-04-30 ### Added From 2be914ca40026db895ff343ec8e2f74d2aeedc42 Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Thu, 22 Jul 2021 11:44:38 +0200 Subject: [PATCH 4/4] Fix test to use original string --- .../NavigationManager/FakeNavigationManagerTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs b/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs index 587c135e0..cb1ae5335 100644 --- a/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs +++ b/tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs @@ -43,7 +43,7 @@ public void Test003(string uri) sut.Uri.ShouldBe(expectedUri.ToString()); } - [Theory(DisplayName = "NavigateTo with absolute URI sets the Uri property ")] + [Theory(DisplayName = "NavigateTo with absolute URI sets the Uri property")] [InlineData("http://localhost")] [InlineData("http://localhost/")] [InlineData("http://localhost/foo")] @@ -54,7 +54,7 @@ public void Test004(string uri) sut.NavigateTo(uri); - sut.Uri.ShouldBe(expectedUri.ToString()); + sut.Uri.ShouldBe(expectedUri.OriginalString); } [Fact(DisplayName = "NavigateTo raises the NotifyLocationChanged")]