File tree Expand file tree Collapse file tree 4 files changed +44
-4
lines changed
src/LinkDotNet.Blog.Web/Shared
LinkDotNet.Blog.IntegrationTests/Web/Shared
LinkDotNet.Blog.UnitTests/Web/Shared Expand file tree Collapse file tree 4 files changed +44
-4
lines changed Original file line number Diff line number Diff line change 14
14
[Parameter ]
15
15
public Introduction Introduction { get ; set ; }
16
16
17
- private string IntroductionClass => Introduction .BackgroundUrl != null ? " introduction-background" : string .Empty ;
17
+ private string IntroductionClass => ! string .IsNullOrEmpty (Introduction .BackgroundUrl )
18
+ ? " introduction-background"
19
+ : string .Empty ;
18
20
}
Original file line number Diff line number Diff line change 4
4
5
5
<nav class =" navbar navbar-expand-lg navbar-light w-100" >
6
6
<div class =" container-fluid" >
7
- @if (configuration .BlogBrandUrl != null )
7
+ @if (! string . IsNullOrEmpty ( configuration .BlogBrandUrl ) )
8
8
{
9
9
<a class =" nav-brand ms-5" href =" /" >
10
10
<img style =" max-height : 70px ;"
Original file line number Diff line number Diff line change @@ -99,9 +99,30 @@ public void ShouldShowBrandImageIfAvailable()
99
99
var cut = RenderComponent < NavMenu > ( ) ;
100
100
101
101
var brandImage = cut . Find ( ".nav-brand img" ) ;
102
-
103
102
var image = brandImage . Unwrap ( ) as IHtmlImageElement ;
104
103
image . Should ( ) . NotBeNull ( ) ;
105
104
image . Source . Should ( ) . Be ( "http://localhost/img.png" ) ;
106
105
}
106
+
107
+ [ Theory ]
108
+ [ InlineData ( null ) ]
109
+ [ InlineData ( "" ) ]
110
+ public void ShouldShowBlogNameWhenNotBrand ( string brandUrl )
111
+ {
112
+ var config = new AppConfiguration
113
+ {
114
+ ProfileInformation = new ProfileInformation ( ) ,
115
+ BlogBrandUrl = brandUrl ,
116
+ BlogName = "Steven" ,
117
+ } ;
118
+ Services . AddScoped ( _ => config ) ;
119
+ this . AddTestAuthorization ( ) ;
120
+
121
+ var cut = RenderComponent < NavMenu > ( ) ;
122
+
123
+ var brandImage = cut . Find ( ".nav-brand" ) ;
124
+ var image = brandImage . Unwrap ( ) as IHtmlAnchorElement ;
125
+ image . Should ( ) . NotBeNull ( ) ;
126
+ image . TextContent . Should ( ) . Be ( "Steven" ) ;
127
+ }
107
128
}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public class IntroductionCardTests : TestContext
11
11
[ Fact ]
12
12
public void ShouldSetBackgroundWhenSet ( )
13
13
{
14
- var introduction = new Introduction ( )
14
+ var introduction = new Introduction
15
15
{
16
16
BackgroundUrl = "something_but_null" ,
17
17
} ;
@@ -24,4 +24,21 @@ public void ShouldSetBackgroundWhenSet()
24
24
background . Should ( ) . HaveCount ( 1 ) ;
25
25
background . Single ( ) . GetStyle ( ) . CssText . Should ( ) . Contain ( introduction . BackgroundUrl ) ;
26
26
}
27
+
28
+ [ Theory ]
29
+ [ InlineData ( null ) ]
30
+ [ InlineData ( "" ) ]
31
+ public void ShouldNotSetBackgroundWhenNotSet ( string url )
32
+ {
33
+ var introduction = new Introduction
34
+ {
35
+ BackgroundUrl = url ,
36
+ } ;
37
+
38
+ var cut = RenderComponent < IntroductionCard > (
39
+ p => p . Add ( s => s . Introduction , introduction ) ) ;
40
+
41
+ var background = cut . FindAll ( ".introduction-background" ) ;
42
+ background . Should ( ) . BeNullOrEmpty ( ) ;
43
+ }
27
44
}
You can’t perform that action at this time.
0 commit comments