public async Task ThrowsWhenStatusCodeIsSetAfterResponseStarted() { // Act await _http1Connection.WriteAsync(new ArraySegment <byte>(new byte[1])); // Assert Assert.True(_http1Connection.HasResponseStarted); Assert.Throws <InvalidOperationException>(() => ((IHttpResponseFeature)_http1Connection).StatusCode = StatusCodes.Status404NotFound); }