小编dev*_*ife的帖子

MVC2 Binding不适用于Html.DropDownListFor <>

我正在尝试使用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)

我尝试了一些不同的东西,我确信我做的事情很愚蠢......只是不确定它是什么:)

asp.net-mvc viewmodel

7
推荐指数
1
解决办法
6059
查看次数

7
推荐指数
3
解决办法
1459
查看次数

VSCode pytest测试发现失败

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。

python pytest visual-studio-code vscode-settings

7
推荐指数
7
解决办法
4178
查看次数

6
推荐指数
1
解决办法
3539
查看次数

为什么不能转换这种泛型类型?

假设我有以下三个类/接口:

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'"的含义.我只是不明白为什么会这样.这不是协方差吗?

c# generics

6
推荐指数
1
解决办法
135
查看次数

Code Rush三个句点的键盘快捷键是什么?

我知道使用ReSharper,您可以使用键盘快捷键Alt+ Enter打开"快速任务"或其他任何名称.Code Rush有类似的键盘快捷键吗?

devexpress coderush coderush-xpress visual-studio

6
推荐指数
1
解决办法
448
查看次数

无法在Visual Studio 2012 Update 2中查看"打包/发布"Web项目属性中的所有设置

出于某种原因,我无法在VS 2012 Update 2中看到Package/Publish Web项目属性中的所有设置.AFAIK刚刚开始发生.有没有人碰过这个?

这是我目前看到的:

这是我应该看到的:

请注意,我看不到Web部署包设置.

有关如何解决此问题的任何想法?

publish msdeploy visual-studio-2012

6
推荐指数
1
解决办法
5405
查看次数

NUnit异步测试导致AppDomainUnloadedException

我有一个带有异步操作的.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

wcf nunit async-await

6
推荐指数
1
解决办法
3034
查看次数

单元测试,模拟对象和ioc的最佳实践

好的,所以我最近一直试图进入IoC.但是,我一直遇到一个障碍 - 这就是我喜欢使用模拟对象的事实.

它们快速而轻松地进行设置.

但是,如果我在代码中使用IoC,那么它会强制我创建对象的测试实现(和配置),而不是使用模拟对象(即使用moq).

最终结果是我最终得到了大量的配置文件进行测试.

此外,在测试中有许多场景,我需要在测试到测试的基础上从我的类中获得不同的行为.使用moq对象非常容易.你会如何做与IoC类似的事情?

任何帮助将非常感激.

谢谢,
迈克

tdd mocking inversion-of-control

5
推荐指数
1
解决办法
2010
查看次数

如何将Bug添加到TFS 2012任务板

我正在尝试按照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流程模板.

tfs2012

5
推荐指数
1
解决办法
1万
查看次数