Added a test to verify ReflectionTypeLoadException
This commit is contained in:
parent
49a48a0a33
commit
4600100695
|
|
@ -115,5 +115,23 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||||
Assert.Contains("/Views/ErrorPageMiddleware/RuntimeError.cshtml", content);
|
Assert.Contains("/Views/ErrorPageMiddleware/RuntimeError.cshtml", content);
|
||||||
Assert.Contains(expectedMessage, content);
|
Assert.Contains(expectedMessage, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task LoaderExceptionsFromReflectionTypeLoadExceptionsAreListed()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var expectedMessage = "Custom Loader Exception.";
|
||||||
|
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var response = await Client.GetAsync("http://localhost/LoaderException");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||||
|
Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
|
||||||
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
|
Assert.Contains("Loader Exceptions:", content);
|
||||||
|
Assert.Contains(expectedMessage, content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace ErrorPageMiddlewareWebSite
|
namespace ErrorPageMiddlewareWebSite
|
||||||
|
|
@ -27,5 +29,17 @@ namespace ErrorPageMiddlewareWebSite
|
||||||
|
|
||||||
[HttpGet("/RuntimeError")]
|
[HttpGet("/RuntimeError")]
|
||||||
public IActionResult RuntimeError() => View();
|
public IActionResult RuntimeError() => View();
|
||||||
|
|
||||||
|
[HttpGet("/LoaderException")]
|
||||||
|
public IActionResult ReflectionTypeLoadException()
|
||||||
|
{
|
||||||
|
throw new ReflectionTypeLoadException(
|
||||||
|
new[] { typeof(SomeType) },
|
||||||
|
new[] { new TypeLoadException("Custom Loader Exception.") });
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SomeType
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue