Skip to content

Commit 6996392

Browse files
committed
Merge branch 'fix-45654' into fix-58815
2 parents fa320e2 + d8751ab commit 6996392

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Mvc/Mvc.TagHelpers/test/ComponentTagHelperTest.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ private static TagHelperOutput GetTagHelperOutput()
7777

7878
private ViewContext GetViewContext()
7979
{
80-
var navManager = new Mock<NavigationManager>();
81-
navManager.As<IHostEnvironmentNavigationManager>();
82-
8380
var httpContext = new DefaultHttpContext
8481
{
8582
RequestServices = new ServiceCollection()
@@ -89,7 +86,7 @@ private ViewContext GetViewContext()
8986
x => x.CreateProtector(It.IsAny<string>()) == Mock.Of<IDataProtector>()))
9087
.AddLogging()
9188
.AddScoped<ComponentStatePersistenceManager>()
92-
.AddScoped(_ => navManager.Object)
89+
.AddScoped<NavigationManager, MockNavigationManager>()
9390
.AddScoped<HttpContextFormDataProvider>()
9491
.BuildServiceProvider(),
9592
};
@@ -104,4 +101,16 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
104101
builder.AddContent(0, "Hello from the component");
105102
}
106103
}
104+
105+
class MockNavigationManager : NavigationManager, IHostEnvironmentNavigationManager
106+
{
107+
public MockNavigationManager()
108+
{
109+
Initialize("https://localhost:85/subdir/", "https://localhost:85/subdir/path?query=value#hash");
110+
}
111+
112+
void IHostEnvironmentNavigationManager.Initialize(string baseUri, string uri)
113+
{
114+
}
115+
}
107116
}

0 commit comments

Comments
 (0)