Skip to content

Commit f77e3e9

Browse files
committed
Added documentation summary on various classes
1 parent d39500e commit f77e3e9

21 files changed

+868
-252
lines changed

src/MyTested.Mvc/AuthenticationScheme.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@
66
public class AuthenticationScheme
77
{
88
/// <summary>
9-
/// Anonymous authentication header scheme.
9+
/// "Anonymous" authentication header scheme.
1010
/// </summary>
1111
public const string Anonymous = "Anonymous";
1212

1313
/// <summary>
14-
/// Basic authentication header scheme.
14+
/// "Basic" authentication header scheme.
1515
/// </summary>
1616
public const string Basic = "Basic";
1717

1818
/// <summary>
19-
/// Digest authentication header scheme.
19+
/// "Digest" authentication header scheme.
2020
/// </summary>
2121
public const string Digest = "Digest";
2222

2323
/// <summary>
24-
/// NTLM authentication header scheme.
24+
/// "NTLM" authentication header scheme.
2525
/// </summary>
2626
public const string NTLM = "NTLM";
2727

2828
/// <summary>
29-
/// Negotiate authentication header scheme.
29+
/// "Negotiate" authentication header scheme.
3030
/// </summary>
3131
public const string Negotiate = "Negotiate";
3232
}

src/MyTested.Mvc/Builders/Controllers/ControllerBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public partial class ControllerBuilder<TController> : BaseTestBuilder, IAndControllerBuilder<TController>
2424
where TController : class
2525
{
26-
private readonly IDictionary<Type, object> aggregatedDependencies;
26+
private readonly IDictionary<Type, object> aggregatedServices;
2727

2828
private ControllerTestContext testContext;
2929
private Action<ControllerContext> controllerContextAction;
@@ -44,7 +44,7 @@ public ControllerBuilder(ControllerTestContext testContext)
4444
this.TestContext = testContext;
4545

4646
this.enabledValidation = true;
47-
this.aggregatedDependencies = new Dictionary<Type, object>();
47+
this.aggregatedServices = new Dictionary<Type, object>();
4848

4949
this.ValidateControllerType();
5050
}

src/MyTested.Mvc/Builders/Controllers/ControllerDependencyBuilder.cs

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/MyTested.Mvc/Builders/Controllers/ControllerHttpBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ public IAndControllerBuilder<TController> WithAuthenticatedUser(Action<IClaimsPr
6767
}
6868

6969
/// <inheritdoc />
70-
public IAndControllerBuilder<TController> WithResolvedRouteData()
70+
public IAndControllerBuilder<TController> WithRouteData()
7171
{
72-
return this.WithResolvedRouteData(null);
72+
return this.WithRouteData(null);
7373
}
7474

7575
/// <inheritdoc />
76-
public IAndControllerBuilder<TController> WithResolvedRouteData(object additionalRouteValues)
76+
public IAndControllerBuilder<TController> WithRouteData(object additionalRouteValues)
7777
{
7878
this.resolveRouteValues = true;
7979
this.additionalRouteValues = additionalRouteValues;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
namespace MyTested.Mvc.Builders.Controllers
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using Contracts.Controllers;
6+
using Utilities;
7+
using Utilities.Extensions;
8+
9+
/// <summary>
10+
/// Used for building the controller which will be tested.
11+
/// </summary>
12+
/// <typeparam name="TController">Class representing ASP.NET Core MVC controller.</typeparam>
13+
public partial class ControllerBuilder<TController>
14+
{
15+
/// <inheritdoc />
16+
public IAndControllerBuilder<TController> WithNoServiceFor<TService>()
17+
where TService : class
18+
{
19+
return this.WithServiceFor<TService>(null);
20+
}
21+
22+
/// <inheritdoc />
23+
public IAndControllerBuilder<TController> WithServiceFor<TService>(TService service)
24+
where TService : class
25+
{
26+
var typeOfService = service != null
27+
? service.GetType()
28+
: typeof(TService);
29+
30+
if (this.aggregatedServices.ContainsKey(typeOfService))
31+
{
32+
throw new InvalidOperationException(string.Format(
33+
"Dependency {0} is already registered for {1} controller.",
34+
typeOfService.ToFriendlyTypeName(),
35+
typeof(TController).ToFriendlyTypeName()));
36+
}
37+
38+
this.aggregatedServices.Add(typeOfService, service);
39+
this.TestContext.ControllerConstruction = () => null;
40+
return this;
41+
}
42+
43+
/// <inheritdoc />
44+
public IAndControllerBuilder<TController> WithServices(IEnumerable<object> services)
45+
{
46+
services.ForEach(s => this.WithServiceFor(s));
47+
return this;
48+
}
49+
50+
/// <inheritdoc />
51+
public IAndControllerBuilder<TController> WithServices(params object[] services)
52+
{
53+
services.ForEach(s => this.WithServiceFor(s));
54+
return this;
55+
}
56+
}
57+
}

src/MyTested.Mvc/Builders/Controllers/ControllerSetupBuilder.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ private void BuildControllerIfNotExists()
6565
var controller = this.TestContext.Controller;
6666
if (controller == null)
6767
{
68-
var explicitDependenciesAreSet = this.aggregatedDependencies.Any();
68+
var explicitDependenciesAreSet = this.aggregatedServices.Any();
6969
if (explicitDependenciesAreSet)
7070
{
7171
// custom dependencies are set, try create instance with them
72-
controller = Reflection.TryCreateInstance<TController>(this.aggregatedDependencies);
72+
controller = Reflection.TryCreateInstance<TController>(this.aggregatedServices);
7373
}
7474
else
7575
{
@@ -85,16 +85,16 @@ private void BuildControllerIfNotExists()
8585

8686
if (controller == null)
8787
{
88-
var friendlyDependenciesNames = this.aggregatedDependencies
88+
var friendlyServiceNames = this.aggregatedServices
8989
.Keys
9090
.Select(k => k.ToFriendlyTypeName());
9191

92-
var joinedFriendlyDependencies = string.Join(", ", friendlyDependenciesNames);
92+
var joinedFriendlyServices = string.Join(", ", friendlyServiceNames);
9393

94-
throw new UnresolvedDependenciesException(string.Format(
94+
throw new UnresolvedServicesException(string.Format(
9595
"{0} could not be instantiated because it contains no constructor taking {1} parameters.",
9696
typeof(TController).ToFriendlyTypeName(),
97-
this.aggregatedDependencies.Count == 0 ? "no" : $"{joinedFriendlyDependencies} as"));
97+
this.aggregatedServices.Count == 0 ? "no" : $"{joinedFriendlyServices} as"));
9898
}
9999

100100
this.TestContext.ControllerConstruction = () => controller;
@@ -110,11 +110,7 @@ private void BuildControllerIfNotExists()
110110
private void PrepareControllerContext()
111111
{
112112
var controllerContext = this.TestContext.ControllerContext;
113-
114-
if (this.controllerContextAction != null)
115-
{
116-
this.controllerContextAction(controllerContext);
117-
}
113+
this.controllerContextAction?.Invoke(controllerContext);
118114
}
119115

120116
private void PrepareController()

src/MyTested.Mvc/ContentType.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,92 +6,92 @@
66
public static class ContentType
77
{
88
/// <summary>
9-
/// Represents text/plain (txt).
9+
/// "text/plain" (txt) MIME type value.
1010
/// </summary>
1111
public const string TextPlain = "text/plain";
1212

1313
/// <summary>
14-
/// Represents text/html (html).
14+
/// "text/html" (html) MIME type value.
1515
/// </summary>
1616
public const string TextHtml = "text/html";
1717

1818
/// <summary>
19-
/// Represents text/css (css).
19+
/// "text/css" (css) MIME type value.
2020
/// </summary>
2121
public const string TextCss = "text/css";
2222

2323
/// <summary>
24-
/// Represents image/bmp (bmp).
24+
/// "image/bmp" (bmp) MIME type value.
2525
/// </summary>
2626
public const string ImageBmp = "image/bmp";
2727

2828
/// <summary>
29-
/// Represents image/jpeg (jpeg or jpg).
29+
/// "image/jpeg" (jpeg or jpg) MIME type value.
3030
/// </summary>
3131
public const string ImageJpeg = "image/jpeg";
3232

3333
/// <summary>
34-
/// Represents image/png (png).
34+
/// "image/png" (png) MIME type value.
3535
/// </summary>
3636
public const string ImagePng = "image/png";
3737

3838
/// <summary>
39-
/// Represents image/gif (gif).
39+
/// "image/gif" (gif) MIME type value.
4040
/// </summary>
4141
public const string ImageGif = "image/gif";
4242

4343
/// <summary>
44-
/// Represents "application/x-javascript" (js).
44+
/// "application/x-javascript" (js) MIME type value.
4545
/// </summary>
4646
public const string ApplicationJavaScript = "application/x-javascript";
4747

4848
/// <summary>
49-
/// Represents application/json (json).
49+
/// "application/json" (json) MIME type value.
5050
/// </summary>
5151
public const string ApplicationJson = "application/json";
5252

5353
/// <summary>
54-
/// Represents application/xml (xml).
54+
/// "application/xml" (xml) MIME type value.
5555
/// </summary>
5656
public const string ApplicationXml = "application/xml";
5757

5858
/// <summary>
59-
/// Represents application/x-www-form-urlencoded.
59+
/// "application/x-www-form-urlencoded" MIME type value.
6060
/// </summary>
6161
public const string FormUrlEncoded = "application/x-www-form-urlencoded";
6262

6363
/// <summary>
64-
/// Represents application/octet-stream (exe).
64+
/// "application/octet-stream" (exe) MIME type value.
6565
/// </summary>
6666
public const string ApplicationOctetStream = "application/octet-stream";
6767

6868
/// <summary>
69-
/// Represents application/zip (zip).
69+
/// "application/zip" (zip) MIME type value.
7070
/// </summary>
7171
public const string ApplicationZip = "application/zip";
7272

7373
/// <summary>
74-
/// Represents audio/mpeg (mp3).
74+
/// "audio/mpeg" (mp3) MIME type value.
7575
/// </summary>
7676
public const string AudioMpeg = "audio/mpeg";
7777

7878
/// <summary>
79-
/// Represents audio/vorbis (ogg).
79+
/// "audio/vorbis" (ogg) MIME type value.
8080
/// </summary>
8181
public const string AudioVorbis = "audio/vorbis";
8282

8383
/// <summary>
84-
/// Represents video/avi (avi).
84+
/// "video/avi" (avi) MIME type value.
8585
/// </summary>
8686
public const string VideoAvi = "video/avi";
8787

8888
/// <summary>
89-
/// Represents video/mpeg (mpeg).
89+
/// "video/mpeg" (mpeg) MIME type value.
9090
/// </summary>
9191
public const string VideoMpeg = "video/mpeg";
9292

9393
/// <summary>
94-
/// Represents video/quicktime (qt).
94+
/// "video/quicktime" (qt) MIME type value.
9595
/// </summary>
9696
public const string VideoQuicktime = "video/quicktime";
9797
}

src/MyTested.Mvc/Exceptions/UnresolvedDependenciesException.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
using System;
44

55
/// <summary>
6-
/// <see cref="Exception"/> for controller unresolved dependencies.
6+
/// <see cref="Exception"/> for controller unresolved service dependencies.
77
/// </summary>
8-
public class UnresolvedDependenciesException : Exception
8+
public class UnresolvedServicesException : Exception
99
{
1010
/// <summary>
11-
/// Initializes a new instance of the <see cref="UnresolvedDependenciesException"/> class.
11+
/// Initializes a new instance of the <see cref="UnresolvedServicesException"/> class.
1212
/// </summary>
1313
/// <param name="message">The message that describes the error.</param>
14-
public UnresolvedDependenciesException(string message)
14+
public UnresolvedServicesException(string message)
1515
: base(message)
1616
{
1717
}

src/MyTested.Mvc/From.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
using Internal.Application;
44

55
/// <summary>
6-
/// Provides easy resolving of expression method argument values from the application services.
6+
/// Provides easy resolving of expression method argument values from the application <see cref="System.IServiceProvider"/>.
77
/// </summary>
88
public static class From
99
{
1010
/// <summary>
11-
/// Indicates that a argument should be resolved from the application services in method call lambda expression.
11+
/// Indicates that a argument should be resolved from the application <see cref="System.IServiceProvider"/> in a method call lambda expression.
1212
/// </summary>
1313
/// <typeparam name="TService">Type of service.</typeparam>
1414
/// <returns>Service implementation.</returns>

0 commit comments

Comments
 (0)