Skip to content

Commit 7561a61

Browse files
committed
Unit test.
1 parent 959ec91 commit 7561a61

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Components/Components/test/NavigationManagerTest.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System;
45
using System.Buffers;
56
using System.Diagnostics;
67
using System.Net.Http;
@@ -84,6 +85,21 @@ public void ToBaseRelativePath_ThrowsForInvalidBaseRelativePaths(string baseUri,
8485
ex.Message);
8586
}
8687

88+
[Fact]
89+
public void ToBaseRelativePath_HonorsConfiguredPathBaseComparison()
90+
{
91+
var navigationManager = new TestNavigationManager("https://example.com/dashboard/", "https://example.com/dashboard/");
92+
93+
var ex = Assert.Throws<ArgumentException>(() => navigationManager.ToBaseRelativePath("https://example.com/DaShBoArD"));
94+
Assert.Equal("The URI 'https://example.com/DaShBoArD' is not contained by the base URI 'https://example.com/dashboard/'.", ex.Message);
95+
96+
navigationManager.SetPathBaseComparison(StringComparison.OrdinalIgnoreCase);
97+
98+
var result = navigationManager.ToBaseRelativePath("https://example.com/DaShBoArD");
99+
100+
Assert.Equal(string.Empty, result);
101+
}
102+
87103
[Theory]
88104
[InlineData("scheme://host/?full%20name=Bob%20Joe&age=42", "scheme://host/?full%20name=John%20Doe&age=42")]
89105
[InlineData("scheme://host/?fUlL%20nAmE=Bob%20Joe&AgE=42", "scheme://host/?full%20name=John%20Doe&AgE=42")]
@@ -906,6 +922,11 @@ public TestNavigationManager(string baseUri = null, string uri = null)
906922
public async Task<bool> RunNotifyLocationChangingAsync(string uri, string state, bool isNavigationIntercepted)
907923
=> await NotifyLocationChangingAsync(uri, state, isNavigationIntercepted);
908924

925+
public void SetPathBaseComparison(StringComparison comparison)
926+
{
927+
PathBaseComparison = comparison;
928+
}
929+
909930
protected override void NavigateToCore(string uri, bool forceLoad)
910931
{
911932
throw new System.NotImplementedException();

0 commit comments

Comments
 (0)