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 1414 [Parameter ]
1515 public Introduction Introduction { get ; set ; }
1616
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 ;
1820}
Original file line number Diff line number Diff line change 44
55<nav class =" navbar navbar-expand-lg navbar-light w-100" >
66 <div class =" container-fluid" >
7- @if (configuration .BlogBrandUrl != null )
7+ @if (! string . IsNullOrEmpty ( configuration .BlogBrandUrl ) )
88 {
99 <a class =" nav-brand ms-5" href =" /" >
1010 <img style =" max-height : 70px ;"
Original file line number Diff line number Diff line change @@ -99,9 +99,30 @@ public void ShouldShowBrandImageIfAvailable()
9999 var cut = RenderComponent < NavMenu > ( ) ;
100100
101101 var brandImage = cut . Find ( ".nav-brand img" ) ;
102-
103102 var image = brandImage . Unwrap ( ) as IHtmlImageElement ;
104103 image . Should ( ) . NotBeNull ( ) ;
105104 image . Source . Should ( ) . Be ( "http://localhost/img.png" ) ;
106105 }
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+ }
107128}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public class IntroductionCardTests : TestContext
1111 [ Fact ]
1212 public void ShouldSetBackgroundWhenSet ( )
1313 {
14- var introduction = new Introduction ( )
14+ var introduction = new Introduction
1515 {
1616 BackgroundUrl = "something_but_null" ,
1717 } ;
@@ -24,4 +24,21 @@ public void ShouldSetBackgroundWhenSet()
2424 background . Should ( ) . HaveCount ( 1 ) ;
2525 background . Single ( ) . GetStyle ( ) . CssText . Should ( ) . Contain ( introduction . BackgroundUrl ) ;
2626 }
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+ }
2744}
You can’t perform that action at this time.
0 commit comments