File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -209,15 +209,15 @@ namespace MyApp.Tests.Controllers
209209 {
210210 [Fact ]
211211 public void ReturnOkWithCorrectModelWhenCallingAuthenticatedIndexAction ()
212- => MyMvc
213- .Controller <HomeController >(instance => instance
214- .WithUser (" TestUser" )
215- .WithData (MyTestData .GetData ()))
216- .Calling (c => c .Index ())
217- .ShouldReturn ()
218- .Ok (result => result
219- .WithModelOfType <List <MyResponseModel >>()
220- .Passing (model => model .Count == 10 ));
212+ => MyMvc // Start a test case.
213+ .Controller <HomeController >(instance => instance // Arrange the controller under test.
214+ .WithUser (" TestUser" ) // Set an authenticated user to the request.
215+ .WithData (MyTestData .GetData ())) // Populate the application DbContext with fake data.
216+ .Calling (c => c .Index ()) // Act - invoke the action under test.
217+ .ShouldReturn () // Assert the action behaviour.
218+ .Ok (result => result // Validate the action result type.
219+ .WithModelOfType <List <MyResponseModel >>() // Check the result model type.
220+ .Passing (model => model .Count == 10 )); // Assert specific model properties.
221221 }
222222}
223223```
You can’t perform that action at this time.
0 commit comments