SmtpConfig包含我想在测试类中使用的凭据.appsettings.development.json
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"SmtpConfig": {
"credentials": "username:password"
}
}
Run Code Online (Sandbox Code Playgroud)
在这里我配置要在类中注入的smtpConfig(在控制器类中工作得非常好!)Startup.cs
public IConfigurationRoot Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.Configure<SmtpConfig(
Configuration.GetSection(nameof(SmtpConfig)
));
}
Run Code Online (Sandbox Code Playgroud)
我想在测试中从appsettings.development.json访问凭据,因为在另一台服务器上我将有另一个配置文件.
//important usings
using Microsoft.Extensions.Options;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class SomeControllerAPITest
{
private SmtpConfig _smtpConfig;
public SomeControllerAPITest(IOptions<SmtpConfig> smtpConfig)
{
_smtpConfig = smtpConfig.Value;
}
[TestMethod]
public void Post_ReturnsCreatedInstance()
{
var credentials = _smtpConfig.credentials;
//use that credentials
...
//call remote server
...
} …Run Code Online (Sandbox Code Playgroud) 我想版本化我的asp.net核心应用程序.
我按照以下链接:http://www.matthiaseinig.de/2013/05/20/auto-generate-fileversion-for-all-projects-in-a-solution-with-t4/,但我想删除项目装配信息,但我没有找到它.
如何删除重复的程序集信息?我想用另一个文件覆盖asp核心程序集.
过了一会儿,我意识到最好的解决方案是使用T4文件,每次构建后版本会自动递增.
看这里:
auto-versioning assembly-attributes .net-assembly .net-core asp.net-core
我想将集成分支合并到主分支中,但我不想仅仅为了看起来不错而更改任何内容。
积分分支是灰色的。这个分支包含了很多改动,我想搞一招。要重置它,当与主服务器分离时,因为我可以看到最后的更改并将它们与主服务器上的一次提交一起放置。因此,master 将包含来自集成分支的文件的最新版本,但集成将保持与 master 分离。
我想将集成合并到 master 中,仅在视觉上(不进行更改),以便在历史记录中看起来不错,因为我已经通过该单一提交进行了更改。
最后一个问题是:如何合并 master 中的集成而不对 master 进行更改,而仅影响历史记录(视觉上)?
我想这样做是因为:
.net ×2
.net-core ×1
appsettings ×1
asp.net-core ×1
c# ×1
git ×1
git-branch ×1
json ×1
smtp ×1
testing ×1
unit-testing ×1
wix ×1
wpf ×1