bag
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
namespace Yh.SchClass.OpenApi.Tests;
|
||||
|
||||
public class SchClassOpenApiOptionsTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("", null)]
|
||||
[InlineData(" ", null)]
|
||||
[InlineData("/base.yunhaixingtong.com", "/base.yunhaixingtong.com")]
|
||||
[InlineData("/base.yunhaixingtong.com/", "/base.yunhaixingtong.com")]
|
||||
[InlineData("base.yunhaixingtong.com", "/base.yunhaixingtong.com")]
|
||||
[InlineData(" /base.yunhaixingtong.com/ ", "/base.yunhaixingtong.com")]
|
||||
public void NormalizeBasePath_归一化规则(string? input, string? expected)
|
||||
{
|
||||
Assert.Equal(expected, SchClassOpenApiOptions.NormalizeBasePath(input));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveBaseUrl_拼接host与path并去尾斜杠()
|
||||
{
|
||||
var options = new SchClassOpenApiOptions
|
||||
{
|
||||
BaseHost = "http://base.yunhaixingtong.com/",
|
||||
BasePath = "/base.yunhaixingtong.com/",
|
||||
};
|
||||
|
||||
Assert.Equal("http://base.yunhaixingtong.com/base.yunhaixingtong.com", options.ResolveBaseUrl());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveBaseUrl_path为空时挂根路径()
|
||||
{
|
||||
var options = new SchClassOpenApiOptions { BaseHost = "http://base.yunhaixingtong.com", BasePath = "" };
|
||||
|
||||
Assert.Equal("http://base.yunhaixingtong.com", options.ResolveBaseUrl());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveBaseUrl_host为空时返回空串()
|
||||
{
|
||||
Assert.Equal("", new SchClassOpenApiOptions().ResolveBaseUrl());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void 默认值_对齐Java客户端()
|
||||
{
|
||||
var options = new SchClassOpenApiOptions();
|
||||
|
||||
Assert.True(options.Enabled);
|
||||
Assert.Null(options.BaseHost);
|
||||
Assert.Null(options.BasePath);
|
||||
Assert.Equal(1500, options.ConnectTimeoutMs);
|
||||
Assert.Equal(5000, options.ReadTimeoutMs);
|
||||
Assert.Equal(5000, options.WriteTimeoutMs);
|
||||
Assert.Null(options.AppKey);
|
||||
Assert.Null(options.AppSecret);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void 配置节名_独立于用户中心()
|
||||
{
|
||||
Assert.Equal("yh:schclass:open", SchClassOpenApiOptions.SectionName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user