|
|
@@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.TestHost
|
|
|
public async Task StatusCode_DefaultsTo200()
|
|
|
{
|
|
|
// Arrange & Act
|
|
|
- var responseInformation = new ResponseFeature();
|
|
|
+ var responseInformation = CreateResponseFeature();
|
|
|
|
|
|
// Assert
|
|
|
Assert.Equal(200, responseInformation.StatusCode);
|
|
|
@@ -25,11 +25,27 @@ namespace Microsoft.AspNetCore.TestHost
|
|
|
Assert.True(responseInformation.Headers.IsReadOnly);
|
|
|
}
|
|
|
|
|
|
+ [Fact]
|
|
|
+ public async Task StartAsync_StartsResponse()
|
|
|
+ {
|
|
|
+ // Arrange & Act
|
|
|
+ var responseInformation = CreateResponseFeature();
|
|
|
+
|
|
|
+ // Assert
|
|
|
+ Assert.Equal(200, responseInformation.StatusCode);
|
|
|
+ Assert.False(responseInformation.HasStarted);
|
|
|
+
|
|
|
+ await responseInformation.StartAsync();
|
|
|
+
|
|
|
+ Assert.True(responseInformation.HasStarted);
|
|
|
+ Assert.True(responseInformation.Headers.IsReadOnly);
|
|
|
+ }
|
|
|
+
|
|
|
[Fact]
|
|
|
public void OnStarting_ThrowsWhenHasStarted()
|
|
|
{
|
|
|
// Arrange
|
|
|
- var responseInformation = new ResponseFeature();
|
|
|
+ var responseInformation = CreateResponseFeature();
|
|
|
responseInformation.HasStarted = true;
|
|
|
|
|
|
// Act & Assert
|
|
|
@@ -45,7 +61,7 @@ namespace Microsoft.AspNetCore.TestHost
|
|
|
[Fact]
|
|
|
public void StatusCode_ThrowsWhenHasStarted()
|
|
|
{
|
|
|
- var responseInformation = new ResponseFeature();
|
|
|
+ var responseInformation = CreateResponseFeature();
|
|
|
responseInformation.HasStarted = true;
|
|
|
|
|
|
Assert.Throws<InvalidOperationException>(() => responseInformation.StatusCode = 400);
|
|
|
@@ -55,7 +71,7 @@ namespace Microsoft.AspNetCore.TestHost
|
|
|
[Fact]
|
|
|
public void StatusCode_MustBeGreaterThan99()
|
|
|
{
|
|
|
- var responseInformation = new ResponseFeature();
|
|
|
+ var responseInformation = CreateResponseFeature();
|
|
|
|
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => responseInformation.StatusCode = 99);
|
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => responseInformation.StatusCode = 0);
|
|
|
@@ -64,5 +80,10 @@ namespace Microsoft.AspNetCore.TestHost
|
|
|
responseInformation.StatusCode = 200;
|
|
|
responseInformation.StatusCode = 1000;
|
|
|
}
|
|
|
+
|
|
|
+ private ResponseFeature CreateResponseFeature()
|
|
|
+ {
|
|
|
+ return new ResponseFeature(ex => { });
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
+}
|