1
- using Bunit ;
1
+ using System . Collections . Generic ;
2
+ using System . Linq ;
3
+ using Bunit ;
2
4
using Bunit . TestDoubles ;
5
+ using FluentAssertions ;
3
6
using LinkDotNet . Blog . Web . Pages . Admin ;
4
7
using LinkDotNet . Blog . Web . Shared . Services . Sitemap ;
5
8
using Microsoft . Extensions . DependencyInjection ;
@@ -11,7 +14,7 @@ namespace LinkDotNet.Blog.UnitTests.Web.Pages.Admin
11
14
public class SitemapTests : TestContext
12
15
{
13
16
[ Fact ]
14
- public void ShouldDisplayAndSaveSitemap ( )
17
+ public void ShouldSaveSitemap ( )
15
18
{
16
19
this . AddTestAuthorization ( ) . SetAuthorized ( "steven" ) ;
17
20
var sitemapMock = new Mock < ISitemapService > ( ) ;
@@ -25,5 +28,30 @@ public void ShouldDisplayAndSaveSitemap()
25
28
26
29
sitemapMock . Verify ( s => s . SaveSitemapToFileAsync ( sitemap ) ) ;
27
30
}
31
+
32
+ [ Fact ]
33
+ public void ShouldDisplaySitemap ( )
34
+ {
35
+ this . AddTestAuthorization ( ) . SetAuthorized ( "steven" ) ;
36
+ var sitemapMock = new Mock < ISitemapService > ( ) ;
37
+ Services . AddScoped ( _ => sitemapMock . Object ) ;
38
+ var sitemap = new SitemapUrlSet
39
+ {
40
+ Urls = new List < SitemapUrl >
41
+ {
42
+ new ( ) { Location = "loc" , LastModified = "Now" } ,
43
+ } ,
44
+ } ;
45
+ sitemapMock . Setup ( s => s . CreateSitemapAsync ( ) )
46
+ . ReturnsAsync ( sitemap ) ;
47
+ var cut = RenderComponent < Sitemap > ( ) ;
48
+
49
+ cut . Find ( "button" ) . Click ( ) ;
50
+
51
+ cut . WaitForState ( ( ) => cut . FindAll ( "tr" ) . Count > 1 ) ;
52
+ var row = cut . FindAll ( "tr" ) . Last ( ) ;
53
+ row . Children . First ( ) . InnerHtml . Should ( ) . Be ( "loc" ) ;
54
+ row . Children . Last ( ) . InnerHtml . Should ( ) . Be ( "Now" ) ;
55
+ }
28
56
}
29
57
}
0 commit comments