Skip to content

Commit ba1ab4b

Browse files
committed
Updated README with pipeline tests (#282)
1 parent bab8066 commit ba1ab4b

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ To add **MyTested.AspNetCore.Mvc** to your solution, you must follow these simpl
119119
namespace MyApp.Tests
120120
{
121121
using MyTested.AspNetCore.Mvc;
122-
122+
123123
using Microsoft.Extensions.DependencyInjection;
124124

125125
public class TestStartup : Startup
126126
{
127127
public void ConfigureTestServices(IServiceCollection services)
128128
{
129129
base.ConfigureServices(services);
130-
130+
131131
// Replace only your own custom services. The ASP.NET Core ones
132132
// are already replaced by MyTested.AspNetCore.Mvc.
133133
services.Replace<IService, MockedService>();
@@ -142,7 +142,7 @@ namespace MyApp.Tests
142142
namespace MyApp.Tests.Controllers
143143
{
144144
using MyTested.AspNetCore.Mvc;
145-
145+
146146
using MyApp.Controllers;
147147
using Xunit;
148148

@@ -185,7 +185,7 @@ A controller integration test uses the globally registered services from the `Te
185185
// and tests for view result and model with specific assertions.
186186
MyController<MyMvcController>
187187
.Instance(instance => instance
188-
.WithUser(user => user
188+
.WithUser(user => user
189189
.WithUsername("MyUserName")))
190190
.Calling(c => c.MyAction(myRequestModel))
191191
.ShouldHave()
@@ -274,14 +274,14 @@ A controller unit test uses service mocks explicitly provided in each separate a
274274
// and tests for view result.
275275
MyController<MyMvcController>
276276
.Instance(instance => instance
277-
.WithDependencies(
277+
.WithDependencies(
278278
serviceMock,
279279
anotherServiceMock,
280280
From.Services<IYetAnotherService>())) // Provides a global service.
281281
.Calling(c => c.MyAction())
282282
.ShouldReturn()
283283
.View();
284-
284+
285285
// Instantiates controller with the provided service mocks,
286286
// and tests for view result.
287287
MyController<MyMvcController>
@@ -367,7 +367,7 @@ MyMvc
367367
.ShouldMap("/My/Action/1")
368368
.To<MyController>(c => c.Action(1))
369369
.Which(controller => controller
370-
.WithUser()
370+
.WithUser()
371371
.WithData(MyDataProvider.GetMyModels()))
372372
.ShouldReturn()
373373
.Redirect(redirect => redirect
@@ -383,9 +383,9 @@ MyMvc
383383
.ShouldMap("/My/Action/1")
384384
.To<MyController>(c => c.Action(1))
385385
.Which(controller => controller
386-
.WithUser()
386+
.WithUser()
387387
.WithData(MyDataProvider.GetMyModels())
388-
.WithDependencies(
388+
.WithDependencies(
389389
serviceMock,
390390
anotherServiceMock))
391391
.ShouldReturn()
@@ -442,7 +442,7 @@ MyViewComponent<MyMvcController>
442442
.ShouldReturn()
443443
.View()
444444
.WithModelOfType<MyResponseModel>();
445-
445+
446446
// View component unit test.
447447
MyViewComponent<MyMvcController>
448448
.Instance(instance => instance
@@ -475,28 +475,28 @@ MyMvc
475475
.WithData(data => data
476476
.WithEntities(entities =>
477477
AddData(sessionId, entities)))
478-
478+
479479
// Act
480480
.Calling(c => c.MyAction(
481481
From.Services<MyDataContext>(), // Action injected services can be populated with this call.
482482
new MyModel { Id = id },
483483
CancellationToken.None))
484-
484+
485485
// Assert
486486
.ShouldReturn()
487487
.Redirect(redirect => redirect
488488
.To<AnotherController>(c => c.AnotherAction(
489489
With.No<MyDataContext>(),
490490
id)));
491-
491+
492492
// With variables.
493493
494494
// Arrange
495495
var controller = MyController<MyMvcController>
496496
.Instance()
497497
.WithUser(username, new[] { role })
498498
.WithData(MyTestData.GetData());
499-
499+
500500
// Act
501501
var call = controller.Calling(c => c.MyAction(id));
502502

@@ -560,7 +560,7 @@ MyMvc
560560
.WithDomain("mydomain.com")
561561
.WithExpiration(myDateTimeOffset)
562562
.WithPath("/")))
563-
.AndAlso()
563+
.AndAlso()
564564
.ShouldReturn()
565565
.Ok();
566566
```
@@ -581,9 +581,10 @@ This package will include all available assertion methods in your test project,
581581
- `MyTested.AspNetCore.Mvc.Controllers.ActionResults` - Contains setup and assertion methods for controller API action results
582582
- `MyTested.AspNetCore.Mvc.Controllers.Views` - Contains setup and assertion methods for controller view features
583583
- `MyTested.AspNetCore.Mvc.Controllers.Views.ActionResults` - Contains setup and assertion methods for controller view action results
584-
- `MyTested.AspNetCore.Mvc.Models` - Contains setup and assertion methods for response and view models
584+
- `MyTested.AspNetCore.Mvc.Models` - Contains setup and assertion methods for responses and view models
585585
- `MyTested.AspNetCore.Mvc.Routing` - Contains setup and assertion methods for routes
586586
- `MyTested.AspNetCore.Mvc.Core` - Contains setup and assertion methods for MVC core features
587+
- `MyTested.AspNetCore.Mvc.Pipeline` - Contains setup methods for pipeline tests
587588
- `MyTested.AspNetCore.Mvc.TempData` - Contains setup and assertion methods for `ITempDataDictionary`
588589
- `MyTested.AspNetCore.Mvc.ViewData` - Contains assertion methods for `ViewDataDictionary` and dynamic `ViewBag`
589590
- `MyTested.AspNetCore.Mvc.ViewComponents` - Contains setup and assertion methods for view components
@@ -604,7 +605,7 @@ This package will include all available assertion methods in your test project,
604605

605606
After the downloading is complete, just add `using MyTested.AspNetCore.Mvc;` to your source code and you are ready to test in the most elegant and developer friendly way.
606607

607-
```c#
608+
```c#
608609
using MyTested.AspNetCore.Mvc;
609610
```
610611

src/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ MyTested.AspNetCore.Mvc Packages
1212
- `MyTested.AspNetCore.Mvc.Models` - Contains setup and assertion methods for response and view models
1313
- `MyTested.AspNetCore.Mvc.Routing` - Contains setup and assertion methods for routes
1414
- `MyTested.AspNetCore.Mvc.Core` - Contains setup and assertion methods for MVC core features
15+
- `MyTested.AspNetCore.Mvc.Pipeline` - Contains setup methods for pipeline tests
1516
- `MyTested.AspNetCore.Mvc.TempData` - Contains setup and assertion methods for `ITempDataDictionary`
1617
- `MyTested.AspNetCore.Mvc.ViewData` - Contains assertion methods for `ViewDataDictionary` and dynamic `ViewBag`
1718
- `MyTested.AspNetCore.Mvc.ViewComponents` - Contains setup and assertion methods for view components

0 commit comments

Comments
 (0)