Treat all SQL exceptions the same in DatabaseErrorPageMiddlewareTest

Fixes #366
This commit is contained in:
AndriySvyryd 2017-04-26 16:08:32 -07:00
parent 9680560aae
commit 979107493e
1 changed files with 21 additions and 3 deletions

View File

@ -322,7 +322,16 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests
var server = new TestServer(builder);
var ex = await Assert.ThrowsAsync<SqlException>(async () =>
await server.CreateClient().GetAsync("http://localhost/"));
{
try
{
await server.CreateClient().GetAsync("http://localhost/");
}
catch (InvalidOperationException exception) when (exception.InnerException != null)
{
throw exception.InnerException;
}
});
Assert.True(logProvider.Logger.Messages.Any(m =>
m.StartsWith(StringsHelpers.GetResourceString("FormatDatabaseErrorPageMiddleware_ContextNotRegistered", typeof(BloggingContext)))));
@ -368,7 +377,16 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests
var server = SetupTestServer<BloggingContextWithSnapshotThatThrows, ExceptionInLogicMiddleware>(database, logProvider);
var ex = await Assert.ThrowsAsync<SqlException>(async () =>
await server.CreateClient().GetAsync("http://localhost/"));
{
try
{
await server.CreateClient().GetAsync("http://localhost/");
}
catch (InvalidOperationException exception) when (exception.InnerException != null)
{
throw exception.InnerException;
}
});
Assert.True(logProvider.Logger.Messages.ToList().Any(m =>
m.StartsWith(StringsHelpers.GetResourceString("FormatDatabaseErrorPageMiddleware_Exception"))));
@ -448,7 +466,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests
{
if (!PlatformHelper.IsMono)
{
optionsBuilder.UseSqlServer(database.ConnectionString);
optionsBuilder.UseSqlServer(database.ConnectionString, b => b.CommandTimeout(600));
}
else
{