Ai
4 Star 24 Fork 2

IoTSharp/Extensions.Configuration.GitRepository

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
TestGitRepositoryProvides.cs 2.62 KB
一键复制 编辑 原始数据 按行查看 历史
麦壳饼 提交于 2025-04-17 12:14 +08:00 . 加入GitHub的Gist 支持
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);
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/IoTSharp/Extensions.Configuration.GitRepository.git
git@gitee.com:IoTSharp/Extensions.Configuration.GitRepository.git
IoTSharp
Extensions.Configuration.GitRepository
Extensions.Configuration.GitRepository
main

搜索帮助