Moved all UnitTests to a single project. Implemented parts of AspNetCore UnitTests.
This commit is contained in:
@@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Builder
|
||||
/// <summary>
|
||||
/// Extensions for the <see cref="IApplicationBuilder"/>.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
public static class ApplicationBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace AMWD.Common.AspNetCore.Extensions
|
||||
/// <summary>
|
||||
/// Extensions for the HTML (e.g. <see cref="IHtmlHelper"/>).
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
public static class HtmlExtensions
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -30,13 +30,11 @@ namespace Microsoft.AspNetCore.Http
|
||||
/// <returns>The ip address of the client.</returns>
|
||||
public static IPAddress GetRemoteIpAddress(this HttpContext httpContext, string headerName = "X-Forwarded-For")
|
||||
{
|
||||
var remote = httpContext.Connection.RemoteIpAddress;
|
||||
|
||||
string forwardedHeader = httpContext.Request.Headers[headerName].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(forwardedHeader) && IPAddress.TryParse(forwardedHeader, out var forwarded))
|
||||
return forwarded;
|
||||
|
||||
return remote;
|
||||
return httpContext.Connection.RemoteIpAddress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,11 +56,13 @@ namespace Microsoft.AspNetCore.Http
|
||||
/// <returns></returns>
|
||||
public static string GetReturnUrl(this HttpContext httpContext)
|
||||
{
|
||||
string url = httpContext.Items["OriginalRequest"]?.ToString();
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
url = httpContext.Request.Query["ReturnUrl"].ToString();
|
||||
if (httpContext.Items.ContainsKey("OriginalRequest"))
|
||||
return httpContext.Items["OriginalRequest"].ToString();
|
||||
|
||||
return url;
|
||||
if (httpContext.Request.Query.ContainsKey("ReturnUrl"))
|
||||
return httpContext.Request.Query["ReturnUrl"].ToString();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -70,6 +70,6 @@ namespace Microsoft.AspNetCore.Http
|
||||
/// </summary>
|
||||
/// <param name="httpContext">The current <see cref="HttpContext"/>.</param>
|
||||
public static void ClearSession(this HttpContext httpContext)
|
||||
=> httpContext?.Session?.Clear();
|
||||
=> httpContext.Session?.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Microsoft.Extensions.Logging
|
||||
/// <summary>
|
||||
/// Extensions for the <see cref="ILogger"/>.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
internal static class LoggerExtensions
|
||||
{
|
||||
// Found here:
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
/// <summary>
|
||||
/// Extensions for the <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user