This repository was archived by the owner on Dec 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 523
Refactored some functional tests. #1561
Closed
MaherJendoubi
wants to merge
2
commits into
aspnet:dev
from
MaherJendoubi:maher/refactoring-functional-tests
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,7 +131,7 @@ public async Task DoesNotHangOnConnectionCloseRequest() | |
{ | ||
var builder = new WebHostBuilder() | ||
.UseKestrel() | ||
.UseUrls($"http://127.0.0.1:0") | ||
.UseUrls("http://127.0.0.1:0") | ||
.Configure(app => | ||
{ | ||
app.Run(async context => | ||
|
@@ -161,7 +161,7 @@ public async Task StreamsAreNotPersistedAcrossRequests() | |
|
||
var builder = new WebHostBuilder() | ||
.UseKestrel() | ||
.UseUrls($"http://127.0.0.1:0") | ||
.UseUrls("http://127.0.0.1:0") | ||
.Configure(app => | ||
{ | ||
app.Run(async context => | ||
|
@@ -204,7 +204,7 @@ public void CanUpgradeRequestWithConnectionKeepAliveUpgradeHeader() | |
var dataRead = false; | ||
var builder = new WebHostBuilder() | ||
.UseKestrel() | ||
.UseUrls($"http://127.0.0.1:0") | ||
.UseUrls("http://127.0.0.1:0") | ||
.Configure(app => | ||
{ | ||
app.Run(async context => | ||
|
@@ -251,29 +251,23 @@ public async Task ConnectionResetPriorToRequestIsLoggedAsDebug() | |
.Returns(true); | ||
mockLogger | ||
.Setup(logger => logger.Log(LogLevel.Debug, _connectionStartedEventId, It.IsAny<object>(), null, It.IsAny<Func<object, Exception, string>>())) | ||
.Callback(() => | ||
{ | ||
connectionStarted.Release(); | ||
}); | ||
.Callback(() => connectionStarted.Release()); | ||
mockLogger | ||
.Setup(logger => logger.Log(LogLevel.Debug, _connectionResetEventId, It.IsAny<object>(), null, It.IsAny<Func<object, Exception, string>>())) | ||
.Callback(() => | ||
{ | ||
connectionReset.Release(); | ||
}); | ||
.Callback(() => connectionReset.Release()); | ||
|
||
var mockLoggerFactory = new Mock<ILoggerFactory>(); | ||
mockLoggerFactory | ||
.Setup(factory => factory.CreateLogger("Microsoft.AspNetCore.Server.Kestrel")) | ||
.Returns(mockLogger.Object); | ||
mockLoggerFactory | ||
.Setup(factory => factory.CreateLogger(It.IsNotIn(new[] { "Microsoft.AspNetCore.Server.Kestrel" }))) | ||
.Setup(factory => factory.CreateLogger(It.IsNotIn("Microsoft.AspNetCore.Server.Kestrel"))) | ||
.Returns(Mock.Of<ILogger>()); | ||
|
||
var builder = new WebHostBuilder() | ||
.UseLoggerFactory(mockLoggerFactory.Object) | ||
.UseKestrel() | ||
.UseUrls($"http://127.0.0.1:0") | ||
.UseUrls("http://127.0.0.1:0") | ||
.Configure(app => app.Run(context => TaskCache.CompletedTask)); | ||
|
||
using (var host = builder.Build()) | ||
|
@@ -311,30 +305,24 @@ public async Task ConnectionResetBetweenRequestsIsLoggedAsDebug() | |
.Returns(true); | ||
mockLogger | ||
.Setup(logger => logger.Log(LogLevel.Debug, _connectionKeepAliveEventId, It.IsAny<object>(), null, It.IsAny<Func<object, Exception, string>>())) | ||
.Callback(() => | ||
{ | ||
requestDone.Release(); | ||
}); | ||
.Callback(() => requestDone.Release()); | ||
mockLogger | ||
.Setup(logger => logger.Log(LogLevel.Debug, _connectionResetEventId, It.IsAny<object>(), null, It.IsAny<Func<object, Exception, string>>())) | ||
.Callback(() => | ||
{ | ||
connectionReset.Release(); | ||
}); | ||
.Callback(() => connectionReset.Release()); | ||
|
||
var mockLoggerFactory = new Mock<ILoggerFactory>(); | ||
mockLoggerFactory | ||
.Setup(factory => factory.CreateLogger("Microsoft.AspNetCore.Server.Kestrel")) | ||
.Returns(mockLogger.Object); | ||
mockLoggerFactory | ||
.Setup(factory => factory.CreateLogger(It.IsNotIn(new[] { "Microsoft.AspNetCore.Server.Kestrel" }))) | ||
.Setup(factory => factory.CreateLogger(It.IsNotIn("Microsoft.AspNetCore.Server.Kestrel"))) | ||
.Returns(Mock.Of<ILogger>()); | ||
|
||
|
||
var builder = new WebHostBuilder() | ||
.UseLoggerFactory(mockLoggerFactory.Object) | ||
.UseKestrel() | ||
.UseUrls($"http://127.0.0.1:0") | ||
.UseUrls("http://127.0.0.1:0") | ||
.Configure(app => app.Run(context => TaskCache.CompletedTask)); | ||
|
||
using (var host = builder.Build()) | ||
|
@@ -372,25 +360,22 @@ public async Task ConnectionResetMidRequestIsLoggedAsDebug() | |
.Returns(true); | ||
mockLogger | ||
.Setup(logger => logger.Log(LogLevel.Debug, _connectionResetEventId, It.IsAny<object>(), null, It.IsAny<Func<object, Exception, string>>())) | ||
.Callback(() => | ||
{ | ||
connectionReset.Release(); | ||
}); | ||
.Callback(() => connectionReset.Release()); | ||
|
||
var mockLoggerFactory = new Mock<ILoggerFactory>(); | ||
mockLoggerFactory | ||
.Setup(factory => factory.CreateLogger("Microsoft.AspNetCore.Server.Kestrel")) | ||
.Returns(mockLogger.Object); | ||
mockLoggerFactory | ||
.Setup(factory => factory.CreateLogger(It.IsNotIn(new[] { "Microsoft.AspNetCore.Server.Kestrel" }))) | ||
.Setup(factory => factory.CreateLogger(It.IsNotIn("Microsoft.AspNetCore.Server.Kestrel"))) | ||
.Returns(Mock.Of<ILogger>()); | ||
|
||
var requestStarted = new SemaphoreSlim(0); | ||
|
||
var builder = new WebHostBuilder() | ||
.UseLoggerFactory(mockLoggerFactory.Object) | ||
.UseKestrel() | ||
.UseUrls($"http://127.0.0.1:0") | ||
.UseUrls("http://127.0.0.1:0") | ||
.Configure(app => app.Run(async context => | ||
{ | ||
requestStarted.Release(); | ||
|
@@ -431,7 +416,7 @@ public async Task ThrowsOnReadAfterConnectionError() | |
|
||
var builder = new WebHostBuilder() | ||
.UseKestrel() | ||
.UseUrls($"http://127.0.0.1:0") | ||
.UseUrls("http://127.0.0.1:0") | ||
.Configure(app => app.Run(async context => | ||
{ | ||
requestStarted.Release(); | ||
|
@@ -475,14 +460,14 @@ public async Task RequestAbortedTokenFiredOnClientFIN() | |
var requestAborted = new SemaphoreSlim(0); | ||
var builder = new WebHostBuilder() | ||
.UseKestrel() | ||
.UseUrls($"http://127.0.0.1:0") | ||
.UseUrls("http://127.0.0.1:0") | ||
.Configure(app => app.Run(async context => | ||
{ | ||
appStarted.Release(); | ||
|
||
var token = context.RequestAborted; | ||
token.Register(() => requestAborted.Release(2)); | ||
await requestAborted.WaitAsync().TimeoutAfter(TimeSpan.FromSeconds(10)); | ||
await requestAborted.WaitAsync(token).TimeoutAfter(TimeSpan.FromSeconds(10)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't tie the semaphore to the cancellation token. |
||
})); | ||
|
||
using (var host = builder.Build()) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
?
is unnecessary sinceAssert.Single
will fail if it can't find the stop event.