55 using Blog . Controllers . Models ;
66 using Blog . Data . Models ;
77 using Data ;
8- using FluentAssertions ;
98 using MyTested . AspNetCore . Mvc ;
109 using Services ;
1110 using Services . Models ;
1211 using System . Linq ;
1312 using Xunit ;
13+ using Shouldly ;
1414
1515 public class ArticlesControllerTest
1616 {
@@ -28,9 +28,9 @@ public void AllShouldReturnDefaultViewWithCorrectModel(int total, int page, int
2828 . WithModelOfType < ArticleListingViewModel > ( )
2929 . Passing ( articleListing =>
3030 {
31- articleListing . Articles . Should ( ) . HaveCount ( expectedCount ) ;
32- articleListing . Total . Should ( ) . Be ( total ) ;
33- articleListing . Page . Should ( ) . Be ( page ) ;
31+ articleListing . Articles . Count ( ) . ShouldBe ( expectedCount ) ;
32+ articleListing . Total . ShouldBe ( total ) ;
33+ articleListing . Page . ShouldBe ( page ) ;
3434 } ) ) ;
3535
3636 [ Fact ]
@@ -151,15 +151,11 @@ public void CreatePostShouldSaveArticleSetTempDataMessageAndRedirectWhenValidMod
151151 . AndAlso ( )
152152 . ShouldHave ( )
153153 . Data ( data => data
154- . WithSet < Article > ( set => set
155- . Should ( )
156- . NotBeEmpty ( )
157- . And
158- . Subject
159- . SingleOrDefault ( a => a . Title == title )
160- . Should ( )
161- . NotBeNull ( )
162- ) )
154+ . WithSet < Article > ( set =>
155+ {
156+ set . ShouldNotBeEmpty ( ) ;
157+ set . SingleOrDefault ( a => a . Title == title ) . ShouldNotBeNull ( ) ;
158+ } ) )
163159 . AndAlso ( )
164160 . ShouldHave ( )
165161 . TempData ( tempData => tempData
@@ -281,13 +277,13 @@ public void EditPostShouldSaveArticleSetTempDataMessageAndRedirectWhenValidModel
281277 . Data ( data => data
282278 . WithSet < Article > ( set =>
283279 {
284- set . Should ( ) . NotBeEmpty ( ) ;
280+ set . ShouldNotBeEmpty ( ) ;
285281
286282 var article = set . SingleOrDefault ( a => a . Id == articleId ) ;
287283
288- article . Should ( ) . NotBeNull ( ) ;
289- article . Title . Should ( ) . Be ( $ "Edit { title } ") ;
290- article . Content . Should ( ) . Be ( $ "Edit { content } ") ;
284+ article . ShouldNotBeNull ( ) ;
285+ article . Title . ShouldBe ( $ "Edit { title } ") ;
286+ article . Content . ShouldBe ( $ "Edit { content } ") ;
291287 } ) )
292288 . AndAlso ( )
293289 . ShouldHave ( )
@@ -378,7 +374,7 @@ public void ConfirmDeleteShouldDeleteArticleSetTempDataMessageAndRedirectWhenVal
378374 . Calling ( c => c . ConfirmDelete ( articleId ) )
379375 . ShouldHave ( )
380376 . Data ( data => data
381- . WithSet < Article > ( set => set . Should ( ) . NotBeNull ( ) ) )
377+ . WithSet < Article > ( set => set . ShouldBeEmpty ( ) ) )
382378 . AndAlso ( )
383379 . ShouldHave ( )
384380 . TempData ( tempData => tempData
@@ -407,13 +403,10 @@ public void MineShouldReturnViewWithCorrectModel()
407403 . ShouldReturn ( )
408404 . View ( view => view
409405 . WithModelOfType < List < ArticleForUserListingServiceModel > > ( )
410- . Passing ( articles => articles
411- . Should ( )
412- . NotBeEmpty ( )
413- . And
414- . Subject
415- . SingleOrDefault ( a => a . Author == "Author 1" )
416- . Should ( )
417- . NotBeNull ( ) ) ) ;
406+ . Passing ( articles =>
407+ {
408+ articles . ShouldNotBeEmpty ( ) ;
409+ articles . SingleOrDefault ( a => a . Author == "Author 1" ) . ShouldNotBeNull ( ) ;
410+ } ) ) ;
418411 }
419412}
0 commit comments