我在build.bat文件中有这个代码
for /R %~dp0 %%A In (*.sln) do (
c:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe %%A /t:rebuild /nologo /verbosity:minimal /flp:Verbosity=detailed;LogFile=%~dp0\Logs.txt;append=true /m /p:Configuration=Debug;Platform="Any CPU" /p:VisualStudioVersion="12.0"
if not %errorlevel%==0 set Failed+=1
pause)
Run Code Online (Sandbox Code Playgroud)
我的问题是%errorlevel%总是0,即使日志文件有错误和警告.
如何在测试控制器动作期间模拟Url.Action?
我正在尝试对我的asp.net核心控制器操作进行单元测试.行动逻辑有Url.Action,我需要模仿它来完成测试,但我找不到正确的解决方案.
谢谢您的帮助!
更新 这是我需要测试的控制器中的方法.
public async Task<IActionResult> Index(EmailConfirmationViewModel model)
{
if (ModelState.IsValid)
{
var user = await _userManager.FindByNameAsync(model.Email);
if (user == null) return RedirectToAction("UserNotFound");
if (await _userManager.IsEmailConfirmedAsync(user)) return RedirectToAction("IsAlreadyConfirmed");
var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.Action("Confirm", "EmailConfirmation", new { userId = user.Id, token }, HttpContext.Request.Scheme);
await _emailService.SendEmailConfirmationTokenAsync(user, callbackUrl);
return RedirectToAction("EmailSent");
}
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
我有嘲笑这部分的问题:
var callbackUrl = Url.Action("Confirm", "EmailConfirmation", new { userId = user.Id, token }, HttpContext.Request.Scheme);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 IdentityServer 4。现在我使用此链接https://github.com/IdentityServer/IdentityServer4.Samples作为示例。
我的问题是,使用 http://localhost:22530/ IdentityServer 加载并工作,但在我的 IIS 上使用它作为托管网站,在http://identity.test.dev下它没有加载。
我已经尝试运行此示例中的代码https://github.com/IdentityServer/IdentityServer4.Samples/tree/dev/Mvc/src/IdSvrHost但它不起作用。
如何通过http://identity.test.dev在 IIS 下启动 IdentityServer ?
我的 RazorEngine 版本 3.6.3 有问题 RazorEngine 无法从“字符串”转换为“RazorEngine.Template.ITemplateKey”
我的代码如下:
var templateServiceConfiguration = new TemplateServiceConfiguration();
templateServiceConfiguration.Namespaces.Add("System.Configuration");
var body = string.Empty;
using (var service = RazorEngineService.Create(templateServiceConfiguration))
{
body = service.RunCompile(emailTemplate.Body, emailTemplate.UniqueName, model: _model, modelType: null, viewBag: null);
}
Run Code Online (Sandbox Code Playgroud)
所以这个方法 service.RunCompile( 作为第一个参数 ITemplateKey ,但是这个方法也有重载必须支持我的版本。
请帮忙。