Skip to content

Commit 1333c08

Browse files
committed
Documentation and cleaner API (closes #101)
1 parent 9fdd1c4 commit 1333c08

8 files changed

+95
-117
lines changed

docs/api/MyTested.AspNetCore.Mvc.Builders.Contracts.Invocations.IViewComponentShouldReturnTestBuilder-1.html

Lines changed: 37 additions & 58 deletions
Large diffs are not rendered by default.

docs/manifest.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,98 @@
11
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Invocations
22
{
33
using System;
4-
using Base;
4+
using And;
55
using ViewComponentResults;
66

77
/// <summary>
88
/// Used for testing returned view component result.
99
/// </summary>
1010
/// <typeparam name="TInvocationResult">Result from invoked view component in ASP.NET Core MVC.</typeparam>
1111
public interface IViewComponentShouldReturnTestBuilder<TInvocationResult>
12-
: IBaseShouldReturnTestBuilder<TInvocationResult, IBaseTestBuilderWithViewComponentResult<TInvocationResult>>
12+
: IBaseShouldReturnTestBuilder<TInvocationResult, IAndTestBuilder>
1313
{
1414
/// <summary>
1515
/// Tests whether the view component result is <see cref="Microsoft.AspNetCore.Mvc.ViewComponents.ContentViewComponentResult"/>.
1616
/// </summary>
17-
/// <returns>Test builder of <see cref="IBaseTestBuilderWithViewComponentResult{TInvocationResult}"/> type.</returns>
18-
IBaseTestBuilderWithViewComponentResult<TInvocationResult> Content();
17+
/// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns>
18+
IAndTestBuilder Content();
1919

2020
/// <summary>
2121
/// Tests whether the view component result is <see cref="Microsoft.AspNetCore.Mvc.ViewComponents.ContentViewComponentResult"/> with expected content.
2222
/// </summary>
2323
/// <param name="content">Expected content as string.</param>
24-
/// <returns>Test builder of <see cref="IBaseTestBuilderWithViewComponentResult{TInvocationResult}"/> type.</returns>
25-
IBaseTestBuilderWithViewComponentResult<TInvocationResult> Content(string content);
24+
/// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns>
25+
IAndTestBuilder Content(string content);
2626

2727
/// <summary>
2828
/// Tests whether <see cref="Microsoft.AspNetCore.Mvc.ViewComponents.ContentViewComponentResult"/> passes the given assertions.
2929
/// </summary>
3030
/// <param name="assertions">Action containing all assertions on the content.</param>
31-
/// <returns>Test builder of <see cref="IBaseTestBuilderWithViewComponentResult{TInvocationResult}"/> type.</returns>
32-
IBaseTestBuilderWithViewComponentResult<TInvocationResult> Content(Action<string> assertions);
31+
/// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns>
32+
IAndTestBuilder Content(Action<string> assertions);
3333

3434
/// <summary>
3535
/// Tests whether <see cref="Microsoft.AspNetCore.Mvc.ViewComponents.ContentViewComponentResult"/> passes the given predicate.
3636
/// </summary>
3737
/// <param name="predicate">Predicate testing the content.</param>
38-
/// <returns>Test builder of <see cref="IBaseTestBuilderWithViewComponentResult{TInvocationResult}"/> type.</returns>
39-
IBaseTestBuilderWithViewComponentResult<TInvocationResult> Content(Func<string, bool> predicate);
38+
/// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns>
39+
IAndTestBuilder Content(Func<string, bool> predicate);
4040

4141
/// <summary>
4242
/// Tests whether the view component result is <see cref="Microsoft.AspNetCore.Html.IHtmlContent"/>.
4343
/// </summary>
44-
/// <returns>Test builder of <see cref="IBaseTestBuilderWithViewComponentResult{TInvocationResult}"/> type.</returns>
45-
IBaseTestBuilderWithViewComponentResult<TInvocationResult> HtmlContent();
44+
/// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns>
45+
IAndTestBuilder HtmlContent();
4646

4747
/// <summary>
4848
/// Tests whether the view component result is <see cref="Microsoft.AspNetCore.Html.IHtmlContent"/> with expected content.
4949
/// </summary>
5050
/// <param name="htmlContent">Expected HTML content as string.</param>
51-
/// <returns>Test builder of <see cref="IBaseTestBuilderWithViewComponentResult{TInvocationResult}"/> type.</returns>
52-
IBaseTestBuilderWithViewComponentResult<TInvocationResult> HtmlContent(string htmlContent);
51+
/// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns>
52+
IAndTestBuilder HtmlContent(string htmlContent);
5353

5454
/// <summary>
5555
/// Tests whether <see cref="Microsoft.AspNetCore.Html.IHtmlContent"/> passes the given assertions.
5656
/// </summary>
5757
/// <param name="assertions">Action containing all assertions on the HTML content.</param>
58-
/// <returns>Test builder of <see cref="IBaseTestBuilderWithViewComponentResult{TInvocationResult}"/> type.</returns>
59-
IBaseTestBuilderWithViewComponentResult<TInvocationResult> HtmlContent(Action<string> assertions);
58+
/// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns>
59+
IAndTestBuilder HtmlContent(Action<string> assertions);
6060

6161
/// <summary>
6262
/// Tests whether <see cref="Microsoft.AspNetCore.Html.IHtmlContent"/> passes the given predicate.
6363
/// </summary>
6464
/// <param name="predicate">Predicate testing the HTML content.</param>
65-
/// <returns>Test builder of <see cref="IBaseTestBuilderWithViewComponentResult{TInvocationResult}"/> type.</returns>
66-
IBaseTestBuilderWithViewComponentResult<TInvocationResult> HtmlContent(Func<string, bool> predicate);
65+
/// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns>
66+
IAndTestBuilder HtmlContent(Func<string, bool> predicate);
6767

6868
/// <summary>
6969
/// Tests whether the view component result is <see cref="Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult"/> with the default view name.
7070
/// </summary>
71-
/// <returns>Test builder of <see cref="IViewTestBuilder"/> type.</returns>
72-
IViewTestBuilder View();
71+
/// <returns>Test builder of <see cref="IAndViewTestBuilder"/> type.</returns>
72+
IAndViewTestBuilder View();
7373

7474
/// <summary>
7575
/// Tests whether the view component result is <see cref="Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult"/> with the provided view name.
7676
/// </summary>
7777
/// <param name="viewName">Expected view name.</param>
78-
/// <returns>Test builder of <see cref="IViewTestBuilder"/> type.</returns>
79-
IViewTestBuilder View(string viewName);
78+
/// <returns>Test builder of <see cref="IAndViewTestBuilder"/> type.</returns>
79+
IAndViewTestBuilder View(string viewName);
8080

8181
/// <summary>
8282
/// Tests whether the view component result is <see cref="Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult"/> with the provided deeply equal model object.
8383
/// </summary>
8484
/// <typeparam name="TModel">Expected model type.</typeparam>
8585
/// <param name="model">Expected model object.</param>
86-
/// <returns>Test builder of <see cref="IViewTestBuilder"/> type.</returns>
87-
IViewTestBuilder View<TModel>(TModel model);
86+
/// <returns>Test builder of <see cref="IAndViewTestBuilder"/> type.</returns>
87+
IAndViewTestBuilder View<TModel>(TModel model);
8888

8989
/// <summary>
9090
/// Tests whether the view component result is <see cref="Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult"/> with the provided view name and deeply equal model object.
9191
/// </summary>
9292
/// <typeparam name="TModel">Expected model type.</typeparam>
9393
/// <param name="viewName">Expected view name.</param>
9494
/// <param name="model">Expected model object.</param>
95-
/// <returns>Test builder of <see cref="IViewTestBuilder"/> type.</returns>
96-
IViewTestBuilder View<TModel>(string viewName, TModel model);
95+
/// <returns>Test builder of <see cref="IAndViewTestBuilder"/> type.</returns>
96+
IAndViewTestBuilder View<TModel>(string viewName, TModel model);
9797
}
9898
}

src/MyTested.AspNetCore.Mvc.ViewComponents/Builders/Invocations/ShouldReturn/ViewComponentShouldReturnContent.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
namespace MyTested.AspNetCore.Mvc.Builders.Invocations.ShouldReturn
22
{
33
using System;
4-
using Contracts.Base;
4+
using And;
5+
using Contracts.And;
56
using Microsoft.AspNetCore.Mvc.ViewComponents;
67
using Utilities.Validators;
78
using Exceptions;
89

910
public partial class ViewComponentShouldReturnTestBuilder<TInvocationResult>
1011
{
1112
/// <inheritdoc />
12-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> Content()
13+
public IAndTestBuilder Content()
1314
{
1415
InvocationResultValidator.ValidateInvocationResultType<ContentViewComponentResult>(this.TestContext);
15-
return this.NewAndTestBuilderWithViewComponentResult();
16+
return new AndTestBuilder(this.TestContext);
1617
}
1718

1819
/// <inheritdoc />
19-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> Content(string content)
20+
public IAndTestBuilder Content(string content)
2021
{
2122
var actualContent = this.GetActualContent();
2223

@@ -28,21 +29,21 @@ public IBaseTestBuilderWithViewComponentResult<TInvocationResult> Content(string
2829
actualContent);
2930
}
3031

31-
return this.NewAndTestBuilderWithViewComponentResult();
32+
return new AndTestBuilder(this.TestContext);
3233
}
3334

3435
/// <inheritdoc />
35-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> Content(Action<string> assertions)
36+
public IAndTestBuilder Content(Action<string> assertions)
3637
{
3738
var actualContent = this.GetActualContent();
3839

3940
assertions(actualContent);
4041

41-
return this.NewAndTestBuilderWithViewComponentResult();
42+
return new AndTestBuilder(this.TestContext);
4243
}
4344

4445
/// <inheritdoc />
45-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> Content(Func<string, bool> predicate)
46+
public IAndTestBuilder Content(Func<string, bool> predicate)
4647
{
4748
var actualContent = this.GetActualContent();
4849

@@ -53,7 +54,7 @@ public IBaseTestBuilderWithViewComponentResult<TInvocationResult> Content(Func<s
5354
actualContent);
5455
}
5556

56-
return this.NewAndTestBuilderWithViewComponentResult();
57+
return new AndTestBuilder(this.TestContext);
5758
}
5859

5960
private string GetActualContent()

src/MyTested.AspNetCore.Mvc.ViewComponents/Builders/Invocations/ShouldReturn/ViewComponentShouldReturnHtmlContent.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
namespace MyTested.AspNetCore.Mvc.Builders.Invocations.ShouldReturn
22
{
33
using System;
4-
using Contracts.Base;
4+
using And;
5+
using Contracts.And;
56
using Exceptions;
67
using Utilities.Validators;
78
using Microsoft.AspNetCore.Html;
@@ -11,16 +12,16 @@
1112
public partial class ViewComponentShouldReturnTestBuilder<TInvocationResult>
1213
{
1314
/// <inheritdoc />
14-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> HtmlContent()
15+
public IAndTestBuilder HtmlContent()
1516
{
1617
InvocationResultValidator
1718
.ValidateInvocationResultType<IHtmlContent>(this.TestContext, canBeAssignable: true);
1819

19-
return this.NewAndTestBuilderWithViewComponentResult();
20+
return new AndTestBuilder(this.TestContext);
2021
}
2122

2223
/// <inheritdoc />
23-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> HtmlContent(string htmlContent)
24+
public IAndTestBuilder HtmlContent(string htmlContent)
2425
{
2526
var actualContent = this.GetHtmlContentAsString();
2627

@@ -32,21 +33,21 @@ public IBaseTestBuilderWithViewComponentResult<TInvocationResult> HtmlContent(st
3233
actualContent);
3334
}
3435

35-
return this.NewAndTestBuilderWithViewComponentResult();
36+
return new AndTestBuilder(this.TestContext);
3637
}
3738

3839
/// <inheritdoc />
39-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> HtmlContent(Action<string> assertions)
40+
public IAndTestBuilder HtmlContent(Action<string> assertions)
4041
{
4142
var actualContent = this.GetHtmlContentAsString();
4243

4344
assertions(actualContent);
4445

45-
return this.NewAndTestBuilderWithViewComponentResult();
46+
return new AndTestBuilder(this.TestContext);
4647
}
4748

4849
/// <inheritdoc />
49-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> HtmlContent(Func<string, bool> predicate)
50+
public IAndTestBuilder HtmlContent(Func<string, bool> predicate)
5051
{
5152
var actualContent = this.GetHtmlContentAsString();
5253

@@ -57,7 +58,7 @@ public IBaseTestBuilderWithViewComponentResult<TInvocationResult> HtmlContent(Fu
5758
actualContent);
5859
}
5960

60-
return this.NewAndTestBuilderWithViewComponentResult();
61+
return new AndTestBuilder(this.TestContext);
6162
}
6263

6364
private string GetHtmlContentAsString()

src/MyTested.AspNetCore.Mvc.ViewComponents/Builders/Invocations/ShouldReturn/ViewComponentShouldReturnNullOrDefault.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
namespace MyTested.AspNetCore.Mvc.Builders.Invocations.ShouldReturn
22
{
33
using And;
4-
using Contracts.Base;
4+
using Contracts.And;
55
using Exceptions;
66
using Utilities;
77
using Utilities.Validators;
88

99
public partial class ViewComponentShouldReturnTestBuilder<TInvocationResult>
1010
{
1111
/// <inheritdoc />
12-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> DefaultValue()
12+
public IAndTestBuilder DefaultValue()
1313
{
1414
if (!this.CheckValidDefaultValue())
1515
{
@@ -18,11 +18,11 @@ public IBaseTestBuilderWithViewComponentResult<TInvocationResult> DefaultValue()
1818
typeof(TInvocationResult).ToFriendlyTypeName()));
1919
}
2020

21-
return this.NewAndTestBuilderWithViewComponentResult();
21+
return new AndTestBuilder(this.TestContext);
2222
}
2323

2424
/// <inheritdoc />
25-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> Null()
25+
public IAndTestBuilder Null()
2626
{
2727
CommonValidator.CheckIfTypeCanBeNull(typeof(TInvocationResult));
2828
if (!this.CheckValidDefaultValue())
@@ -32,11 +32,11 @@ public IBaseTestBuilderWithViewComponentResult<TInvocationResult> Null()
3232
typeof(TInvocationResult).ToFriendlyTypeName()));
3333
}
3434

35-
return this.NewAndTestBuilderWithViewComponentResult();
35+
return new AndTestBuilder(this.TestContext);
3636
}
3737

3838
/// <inheritdoc />
39-
public IBaseTestBuilderWithViewComponentResult<TInvocationResult> NotNull()
39+
public IAndTestBuilder NotNull()
4040
{
4141
CommonValidator.CheckIfTypeCanBeNull(typeof(TInvocationResult));
4242
if (this.CheckValidDefaultValue())
@@ -46,7 +46,7 @@ public IBaseTestBuilderWithViewComponentResult<TInvocationResult> NotNull()
4646
typeof(TInvocationResult).ToFriendlyTypeName()));
4747
}
4848

49-
return this.NewAndTestBuilderWithViewComponentResult();
49+
return new AndTestBuilder(this.TestContext);
5050
}
5151

5252
private bool CheckValidDefaultValue()

src/MyTested.AspNetCore.Mvc.ViewComponents/Builders/Invocations/ShouldReturn/ViewComponentShouldReturnTestBuilder.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,5 @@ public ViewComponentShouldReturnTestBuilder(ViewComponentTestContext testContext
1313
: base(testContext)
1414
{
1515
}
16-
17-
private IBaseTestBuilderWithViewComponentResult<TInvocationResult> NewAndTestBuilderWithViewComponentResult()
18-
=> new AndTestBuilderWithViewComponentResult<TInvocationResult>(this.TestContext);
1916
}
2017
}

src/MyTested.AspNetCore.Mvc.ViewComponents/Builders/Invocations/ShouldReturn/ViewComponentShouldReturnView.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
public partial class ViewComponentShouldReturnTestBuilder<TInvocationResult>
1010
{
1111
/// <inheritdoc />
12-
public IViewTestBuilder View()
12+
public IAndViewTestBuilder View()
1313
{
1414
return this.View(null);
1515
}
1616

1717
/// <inheritdoc />
18-
public IViewTestBuilder View(string viewName)
18+
public IAndViewTestBuilder View(string viewName)
1919
{
2020
var viewResult = InvocationResultValidator
2121
.GetInvocationResult<ViewViewComponentResult>(this.TestContext);
@@ -33,13 +33,13 @@ public IViewTestBuilder View(string viewName)
3333
}
3434

3535
/// <inheritdoc />
36-
public IViewTestBuilder View<TModel>(TModel model)
36+
public IAndViewTestBuilder View<TModel>(TModel model)
3737
{
3838
return this.View(null, model);
3939
}
4040

4141
/// <inheritdoc />
42-
public IViewTestBuilder View<TModel>(string viewName, TModel model)
42+
public IAndViewTestBuilder View<TModel>(string viewName, TModel model)
4343
{
4444
var viewTestBuilder = this.View(viewName);
4545
viewTestBuilder.WithModel(model);

0 commit comments

Comments
 (0)