File tree Expand file tree Collapse file tree 2 files changed +39
-4
lines changed
LinkDotNet.Blog.UnitTests/Web/Pages/Admin
LinkDotNet.Blog.Web/Pages/Admin Expand file tree Collapse file tree 2 files changed +39
-4
lines changed Original file line number Diff line number Diff line change
1
+ using Bunit ;
2
+ using Bunit . TestDoubles ;
3
+ using LinkDotNet . Blog . Web . Pages . Admin ;
4
+ using LinkDotNet . Blog . Web . Shared . Services . Sitemap ;
5
+ using Microsoft . Extensions . DependencyInjection ;
6
+ using Moq ;
7
+ using Xunit ;
8
+
9
+ namespace LinkDotNet . Blog . UnitTests . Web . Pages . Admin
10
+ {
11
+ public class SitemapTests : TestContext
12
+ {
13
+ [ Fact ]
14
+ public void ShouldDisplayAndSaveSitemap ( )
15
+ {
16
+ this . AddTestAuthorization ( ) . SetAuthorized ( "steven" ) ;
17
+ var sitemapMock = new Mock < ISitemapService > ( ) ;
18
+ Services . AddScoped ( _ => sitemapMock . Object ) ;
19
+ var sitemap = new SitemapUrlSet ( ) ;
20
+ sitemapMock . Setup ( s => s . CreateSitemapAsync ( ) )
21
+ . ReturnsAsync ( sitemap ) ;
22
+ var cut = RenderComponent < Sitemap > ( ) ;
23
+
24
+ cut . Find ( "button" ) . Click ( ) ;
25
+
26
+ sitemapMock . Verify ( s => s . SaveSitemapToFileAsync ( sitemap ) ) ;
27
+ }
28
+ }
29
+ }
Original file line number Diff line number Diff line change 2
2
@using LinkDotNet .Blog .Web .Shared .Services .Sitemap
3
3
@inject ISitemapService sitemapService
4
4
@attribute [Authorize]
5
-
6
- <div class =" row" >
5
+ <h3 xmlns =" http://www.w3.org/1999/html" >Sitemap</h3 >
6
+ <div class =" row px-2" >
7
+ <p >A sitemap is a file which lists all important links in a webpage. It helps crawler to find all of the
8
+ important pages. Especially newer sites benefit from having a sitemap.xml.
9
+ The file will be created at the root of the site. To see the sitemap.xml go here: <a href =" /sitemap.xml" >sitemap.xml</a >.<br />
10
+ If you get a 404 there is currently no sitemap.xml</p >
7
11
<button class =" btn btn-primary" @onclick =" CreateSitemap" >Create Sitemap</button >
8
12
9
13
@if (sitemapUrlSet != null )
10
14
{
11
- <table class =" table table-striped table-hover" >
12
- <tbody >
15
+ <table class =" table table-striped table-hover h-50 " >
16
+ <thead >
13
17
<tr >
14
18
<th >Url </th >
15
19
<th >Last Changed </th >
16
20
</tr >
21
+ </thead >
22
+ <tbody >
17
23
@foreach ( var url in sitemapUrlSet .Urls )
18
24
{
19
25
<tr >
You can’t perform that action at this time.
0 commit comments