|
1 | 1 | namespace MyTested.AspNetCore.Mvc.Builders.Models
|
2 | 2 | {
|
3 | 3 | using System;
|
| 4 | + using And; |
4 | 5 | using Contracts.And;
|
5 | 6 | using Contracts.Models;
|
6 | 7 | using Exceptions;
|
|
11 | 12 | /// <summary>
|
12 | 13 | /// Used for testing the model members.
|
13 | 14 | /// </summary>
|
14 |
| - /// <typeparam name="TModel">Model from invoked action in ASP.NET Core MVC controller.</typeparam> |
| 15 | + /// <typeparam name="TModel">Model from invoked method in ASP.NET Core MVC.</typeparam> |
15 | 16 | public class ModelDetailsTestBuilder<TModel>
|
16 | 17 | : ModelErrorTestBuilder<TModel>, IAndModelDetailsTestBuilder<TModel>
|
17 | 18 | {
|
18 | 19 | /// <summary>
|
19 | 20 | /// Initializes a new instance of the <see cref="ModelDetailsTestBuilder{TResponseModel}"/> class.
|
20 | 21 | /// </summary>
|
21 |
| - /// <param name="testContext"><see cref="ControllerTestContext"/> containing data about the currently executed assertion chain.</param> |
22 |
| - public ModelDetailsTestBuilder(ControllerTestContext testContext) |
| 22 | + /// <param name="testContext"><see cref="ActionTestContext"/> containing data about the currently executed assertion chain.</param> |
| 23 | + public ModelDetailsTestBuilder(ActionTestContext testContext) |
23 | 24 | : base(testContext)
|
24 | 25 | {
|
25 | 26 | }
|
26 | 27 |
|
27 | 28 | /// <inheritdoc />
|
28 |
| - public IAndTestBuilderWithInvokedAction Passing(Action<TModel> assertions) |
| 29 | + public IAndTestBuilder Passing(Action<TModel> assertions) |
29 | 30 | {
|
30 | 31 | assertions(this.Model);
|
31 |
| - return this.NewAndTestBuilderWithInvokedAction(); |
| 32 | + return new AndTestBuilder(this.TestContext); |
32 | 33 | }
|
33 | 34 |
|
34 | 35 | /// <inheritdoc />
|
35 |
| - public IAndTestBuilderWithInvokedAction Passing(Func<TModel, bool> predicate) |
| 36 | + public IAndTestBuilder Passing(Func<TModel, bool> predicate) |
36 | 37 | {
|
37 | 38 | if (!predicate(this.Model))
|
38 | 39 | {
|
39 | 40 | throw new ResponseModelAssertionException(string.Format(
|
40 | 41 | "When calling {0} action in {1} expected response model {2} to pass the given predicate, but it failed.",
|
41 |
| - this.ActionName, |
42 |
| - this.Controller.GetName(), |
| 42 | + this.TestContext.MethodName, |
| 43 | + this.TestContext.Component.GetName(), |
43 | 44 | typeof(TModel).ToFriendlyTypeName()));
|
44 | 45 | }
|
45 | 46 |
|
46 |
| - return this.NewAndTestBuilderWithInvokedAction(); |
| 47 | + return new AndTestBuilder(this.TestContext); |
47 | 48 | }
|
48 | 49 |
|
49 | 50 | /// <inheritdoc />
|
|
0 commit comments