Skip to content

Commit ca12203

Browse files
committed
Updated documentation with StringContent of HTTP response message (closes #168)
1 parent 00563ce commit ca12203

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

documentation/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,8 @@ MyWebApi
12901290
.WithResponseModelOfType<ResponseModel>();
12911291

12921292
// tests whether the action returns HttpResponseMessage
1293-
// with content response model object
1293+
// with content response model object deeply equal
1294+
// to the provided one
12941295
MyWebApi
12951296
.Controller<WebApiController>()
12961297
.Calling(c => c.SomeAction())
@@ -1307,6 +1308,15 @@ MyWebApi
13071308
.HttpResponseMessage()
13081309
.WithContentOfType<ObjectContent>();
13091310

1311+
// tests whether the action returns HttpResponseMessage
1312+
// with StringContent and expected string
1313+
MyWebApi
1314+
.Controller<WebApiController>()
1315+
.Calling(c => c.SomeAction())
1316+
.ShouldReturn()
1317+
.HttpResponseMessage()
1318+
.WithStringContent("SomeString");
1319+
13101320
// tests whether the action returns HttpResponseMessage
13111321
// with specific media type formatter
13121322
MyWebApi
@@ -1576,7 +1586,8 @@ MyWebApi
15761586
.AndAlso()
15771587
.ContainingMediaTypeFormatterOfType<SomeMediaTypeFormatter>());
15781588

1579-
// tests whether the action returns OkResult with specific object
1589+
// tests whether the action returns OkResult with object
1590+
// deeply equal to the provided one
15801591
MyWebApi
15811592
.Controller<WebApiController>()
15821593
.Calling(c => c.SomeAction())

src/MyWebApi/Utilities/Validators/HttpResponseMessageValidator.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public static void WithContentOfType<TContentType>(
5151
}
5252
}
5353

54+
/// <summary>
55+
/// Tests whether the content of the HTTP response message contains the provided string.
56+
/// </summary>
57+
/// <param name="actualContent">Actual HTTP content.</param>
58+
/// <param name="expectedContent">Expected string content.</param>
59+
/// <param name="failedValidationAction">Action to call in case of failed validation.</param>
5460
public static void WithStringContent(
5561
HttpContent actualContent,
5662
string expectedContent,

0 commit comments

Comments
 (0)