代码拉取完成,页面将自动刷新
using Microsoft.Extensions.Configuration;
namespace Extensions.Configuration.GitRepository.TestProject
{
[TestClass]
public sealed class TestGitRepositoryProvides
{
[TestInitialize]
public void TestInit()
{
}
[TestCleanup]
public void TestCleanup()
{
// This method is called after each test method.
}
[TestMethod]
[DataRow("GitLab", "https://gitlab.com/", "maikebing/gitcfg", "WithGitLab", typeof(GitLabProviderExtensions), null, DisplayName = "GitLabProvider")]
[DataRow("GitHub", "https://github.com/", "maikebing/gitcfg", "WithGitHub", typeof(GitHubProviderExtensions), "http://127.0.0.1:7890", DisplayName = "GitHubProvider")]
[DataRow("GitHub", "https://github.com/", "8f00a80b168022dbfec1769c3ae8145c", "WithGitHubGist", typeof(GitHubProviderExtensions), "http://127.0.0.1:7890", DisplayName = "GitHubProvider")]
[DataRow("Gitee", "https://gitee.com/", "maikebing/gitcfg", "WithGitee", typeof(GiteeProviderExtensions), null, DisplayName = "GiteeProvider")]
[DataRow("Gitea", "https://gitea.com/", "maikebing/gitcfg", "WithGitea", typeof(GiteaProviderExtensions), null, DisplayName = "GiteaProvider")]
[DataRow("Gitee", "https://gitee.com/", "r6bhzi1y90av2qtslgmwe86", "WithGiteeGists", typeof(GiteeProviderExtensions), null, DisplayName = "GiteeGistsProvider")]
public void TestProvider(string _proveiderName, string hosturl, string repoPath, string setProveiderMethodName, Type extType, string proxy)
{
IConfigurationBuilder _builder;
IConfigurationRoot config;
var cfgfilename = Path.GetTempFileName();
_builder = new ConfigurationBuilder()
.AddUserSecrets<TestGitRepositoryProvides>();
config = _builder.Build();
System.IO.File.WriteAllText(cfgfilename, $"{{\"{_proveiderName}\":\"{_proveiderName}\"}}");
_builder.AddGitRepository(cfg =>
{
extType.GetMethod(setProveiderMethodName)?.Invoke(null, [cfg]);
cfg = cfg.WithHostUrl(hosturl)
.WithRepositoryPath(repoPath)
.WithAuthenticationToken(config.GetValue<string>(_proveiderName))
.WithFileName($"{_proveiderName}.json")
.WithCache(cfgfilename)
.WithProxy(proxy);
});
var cfg = _builder.Build();
Assert.IsNotNull(cfg);
Assert.AreEqual(cfg.GetValue<string>(_proveiderName), _proveiderName);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。