Skip to content

Commit 71b780f

Browse files
committed
test case for SetDefaultAction
1 parent af3b17d commit 71b780f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/TestServer.Tests/TestServerTests.cs

+20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Net.Http;
33
using System.Net.Http.Headers;
44
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Http;
56
using NUnit.Framework;
67

78
namespace Dubstep.TestUtilities.Tests
@@ -341,5 +342,24 @@ public async Task WhenFirstMatchReachedMaxCount_ShouldApplySecond()
341342
AssertOkResponse(first, firstResponse);
342343
AssertOkResponse(second, secondResponse);
343344
}
345+
346+
[Test]
347+
public async Task WhenSetFallbackAction_ShouldApply()
348+
{
349+
// Arrange
350+
_server.CurrentRuleSet
351+
.SetDefaultAction(async (response) =>
352+
{
353+
response.StatusCode = 500;
354+
await response.WriteAsync("Simon says server");
355+
});
356+
var client = _server.CreateClient();
357+
358+
// Act
359+
var actual = await client.GetAsync("/");
360+
361+
// Assert
362+
Assert.AreEqual(HttpStatusCode.InternalServerError, actual.StatusCode);
363+
}
344364
}
345365
}

0 commit comments

Comments
 (0)