test: 增加 HttpHeaderOperation 单元测试
This commit is contained in:
parent
6434cea61c
commit
39c0d4965c
|
@ -38,7 +38,7 @@
|
|||
|
||||
function runUnitTest() {
|
||||
write-host "dotnet test test\UnitTest" -ForegroundColor Cyan
|
||||
dotnet test test\UnitTest --filter "FullyQualifiedName!~MySql" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[Bootstrap*]*" /p:ExcludeByFile="..\..\src\admin\Bootstrap.Admin\Program.cs%2c..\..\src\admin\Bootstrap.Admin\Startup.cs%2c..\..\src\admin\Bootstrap.Admin\HttpHeaderOperation.cs" /p:CoverletOutput=..\..\
|
||||
dotnet test test\UnitTest --filter "FullyQualifiedName!~MySql" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[Bootstrap*]*" /p:ExcludeByFile="..\..\src\admin\Bootstrap.Admin\Program.cs%2c..\..\src\admin\Bootstrap.Admin\Startup.cs" /p:CoverletOutput=..\..\
|
||||
}
|
||||
|
||||
function coverallUnitTest() {
|
||||
|
|
|
@ -17,8 +17,6 @@ namespace Bootstrap.Admin
|
|||
/// <param name="context"></param>
|
||||
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||
{
|
||||
if (operation.Parameters == null) operation.Parameters = new List<OpenApiParameter>();
|
||||
|
||||
if (context.MethodInfo.GetCustomAttributes(typeof(AllowAnonymousAttribute), true).Length == 0)
|
||||
{
|
||||
operation.Parameters.Add(new OpenApiParameter()
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Xunit;
|
||||
|
||||
namespace Bootstrap.Admin.Api
|
||||
{
|
||||
public class HttpHeaderOperationTest
|
||||
{
|
||||
[Fact]
|
||||
public void Apply_Ok()
|
||||
{
|
||||
var oper = new HttpHeaderOperation();
|
||||
var api = new OpenApiOperation();
|
||||
var desc = new ApiDescription();
|
||||
var mi = typeof(HttpHeaderOperationTest).GetMethod("Apply_Ok");
|
||||
var context = new OperationFilterContext(desc, null, null, mi);
|
||||
oper.Apply(api, context);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue