1
1
using System . Threading . Tasks ;
2
+ using Blazored . Toast . Services ;
2
3
using Bunit ;
4
+ using Bunit . TestDoubles ;
3
5
using LinkDotNet . Blog . Domain ;
4
6
using LinkDotNet . Blog . Infrastructure . Persistence ;
5
7
using LinkDotNet . Blog . TestUtilities ;
8
+ using LinkDotNet . Blog . Web ;
6
9
using LinkDotNet . Blog . Web . Pages ;
7
10
using LinkDotNet . Blog . Web . Shared ;
8
11
using LinkDotNet . Blog . Web . Shared . Services ;
12
+ using Microsoft . AspNetCore . Components . Web ;
9
13
using Microsoft . Extensions . DependencyInjection ;
10
14
11
15
namespace LinkDotNet . Blog . UnitTests . Web . Pages ;
@@ -32,4 +36,28 @@ public void ShouldShowLoadingAnimation()
32
36
33
37
cut . FindComponents < Loading > ( ) . Count . Should ( ) . Be ( 1 ) ;
34
38
}
39
+
40
+ [ Fact ]
41
+ public void ShouldSetTitleToTag ( )
42
+ {
43
+ JSInterop . Mode = JSRuntimeMode . Loose ;
44
+ var repositoryMock = new Mock < IRepository < BlogPost > > ( ) ;
45
+ var blogPost = new BlogPostBuilder ( ) . WithTitle ( "Title" ) . Build ( ) ;
46
+ repositoryMock . Setup ( r => r . GetByIdAsync ( "1" ) ) . ReturnsAsync ( blogPost ) ;
47
+ Services . AddScoped ( _ => repositoryMock . Object ) ;
48
+ Services . AddScoped ( _ => Mock . Of < IUserRecordService > ( ) ) ;
49
+ Services . AddScoped ( _ => Mock . Of < IToastService > ( ) ) ;
50
+ Services . AddScoped ( _ => Mock . Of < AppConfiguration > ( ) ) ;
51
+ this . AddTestAuthorization ( ) ;
52
+ ComponentFactories . AddStub < PageTitle > ( ) ;
53
+ ComponentFactories . AddStub < Like > ( ) ;
54
+ ComponentFactories . AddStub < CommentSection > ( ) ;
55
+
56
+ var cut = RenderComponent < BlogPostPage > (
57
+ p => p . Add ( s => s . BlogPostId , "1" ) ) ;
58
+
59
+ var pageTitleStub = cut . FindComponent < Stub < PageTitle > > ( ) ;
60
+ var pageTitle = Render ( pageTitleStub . Instance . Parameters . Get ( p => p . ChildContent ) ) ;
61
+ pageTitle . Markup . Should ( ) . Be ( "Title" ) ;
62
+ }
35
63
}
0 commit comments