Skip to content

Separate the route and pipeline testing and their action invoking #350

@ivaylokenov

Description

@ivaylokenov

Route tests should not execute the action and its action filters. A route test should only assert whether ASP.NET Core has the correct mapping of the URL and whether the model binding is working.

A pipeline test should execute both the action and its action filters - the whole MVC pipeline.

This breaking change is required because currently, the route tests mock the actual action call for performance reasons but action filters may need the actual data but unfortunately, they receive mocks, which leads to unexpected behavior.

// Does not execute action and action filters by default.
MyRouting
    .Configuration()
    .ShouldMap("/My/Action/5")
    .To<MyController>(c => c.Action(5));
// Executes action and action filters by default.
MyPipeline
    .Configuration()
    .ShouldMap("/My/Action/5")
    .To<MyController>(c => c.Action(5));

Optional methods should be provided - WithActionExecution and WithoutActionExecution for overriding the default behaviour.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions