我正在尝试使用Html.DropDownListFor <> HtmlHelper并且在发布时遇到一些问题.HTML呈现正确但我在提交时从未获得"选定"值.
<%= Html.DropDownListFor( m => m.TimeZones,
Model.TimeZones,
new { @class = "SecureDropDown",
name = "SelectedTimeZone" } ) %>
Run Code Online (Sandbox Code Playgroud)
[Bind(Exclude = "TimeZones")]
public class SettingsViewModel : ProfileBaseModel
{
public IEnumerable TimeZones { get; set; }
public string TimeZone { get; set; }
public SettingsViewModel()
{
TimeZones = GetTimeZones();
TimeZone = string.Empty;
}
private static IEnumerable GetTimeZones()
{
var timeZones = TimeZoneInfo.GetSystemTimeZones().ToList();
return timeZones.Select(t => new SelectListItem
{
Text = t.DisplayName,
Value = t.Id
} );
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了一些不同的东西,我确信我做的事情很愚蠢......只是不确定它是什么:)
Pytest测试发现失败。UI指出:
Test discovery error, please check the configuration settings for the tests
输出窗口指出:
Test Discovery failed:
Error: Traceback (most recent call last):
File "C:\Users\mikep\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\run_adapter.py", line 16, in <module>
main(tool, cmd, subargs, toolargs)
File "C:\Users\mikep\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\adapter\__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "C:\Users\mikep\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\adapter\pytest.py", line 43, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 3)
Run Code Online (Sandbox Code Playgroud)
这是我的设置:
{
"python.pythonPath": ".venv\\Scripts\\python.exe",
"python.testing.pyTestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pyTestEnabled": true
}
Run Code Online (Sandbox Code Playgroud)
我可以从命令行FWIW成功运行pytest。
假设我有以下三个类/接口:
public interface IImportViewModel
{
}
public class TestImportViewModel : IImportViewModel
{
}
public class ValidationResult<TViewModel> where TViewModel : IImportViewModel
{
}
Run Code Online (Sandbox Code Playgroud)
由于TestImportViewModel实现了IImportViewModel,为什么以下不能编译?
ValidationResult<IImportViewModel> r = new ValidationResult<TestImportViewModel>();
Run Code Online (Sandbox Code Playgroud)
我理解错误消息"无法将类型'ValidationResult'隐式转换为'ValidationResult'"的含义.我只是不明白为什么会这样.这不是协方差吗?
出于某种原因,我无法在VS 2012 Update 2中看到Package/Publish Web项目属性中的所有设置.AFAIK刚刚开始发生.有没有人碰过这个?
请注意,我看不到Web部署包设置.
有关如何解决此问题的任何想法?
我有一个带有异步操作的.NET 4.5 WCF服务.我有集成测试,它使用NetNamedPipeBinding构建服务主机并通过客户端命中操作.
但是,像这样的每个测试总是会导致NUnit报告以下内容:
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.
This can happen if the test(s) started a thread but did not stop it.
Make sure that all the threads started by the test(s) are stopped before completion.
Run Code Online (Sandbox Code Playgroud)
一切看起来都不错.谁能看到可能导致这种情况的原因?我在GitHub上有一个完整的代码示例:https://github.com/devlife/codesamples
好的,所以我最近一直试图进入IoC.但是,我一直遇到一个障碍 - 这就是我喜欢使用模拟对象的事实.
它们快速而轻松地进行设置.
但是,如果我在代码中使用IoC,那么它会强制我创建对象的测试实现(和配置),而不是使用模拟对象(即使用moq).
最终结果是我最终得到了大量的配置文件进行测试.
此外,在测试中有许多场景,我需要在测试到测试的基础上从我的类中获得不同的行为.使用moq对象非常容易.你会如何做与IoC类似的事情?
任何帮助将非常感激.
谢谢,
迈克
我正在尝试按照http://msdn.microsoft.com/en-us/library/hh739066(v=vs.110).aspx上的说明执行"任务板页面上显示的工作项类型".我添加<WORKITEMTYPE name="Bug" />到任务类别.但是,当我导入类别时,我收到一条错误消息,说TF400917: The current configuration is not valid for this feature. 有人对错误有任何想法吗?这是我改变的唯一配置.如果我从配置中删除新行并重新导入它,一切正常.
值得注意的是,我正在使用Scrum 2.0流程模板.
c# ×2
appfabric ×1
asp.net-mvc ×1
async-await ×1
coderush ×1
devexpress ×1
generics ×1
licensing ×1
mocking ×1
msdeploy ×1
nunit ×1
publish ×1
pytest ×1
python ×1
reflection ×1
tdd ×1
tfs2012 ×1
viewmodel ×1
wcf ×1