鑑於以下示例代碼,我如何配置Pex來尊重我的代碼合同?如何配置Pex以遵守代碼合同?
public static IEnumerable<User> Administrators(this UserGroup userGroup)
{
Contract.Requires(userGroup != null);
Contract.Requires(userGroup.UserList != null);
return userGroup.UserList.Where(ul => ul.IsAdmin == true);
}
當前問題:當我運行Pex時,它仍然生成違反指定代碼合同的測試用例。
FYI:Here are the 'Code Contracts' settings在我的csproj文件中。
編輯:做了
break in SP1?
你試過給他們發郵件嗎? [email protected] – porges 2011-05-26 22:51:14
我認爲這是一個錯誤。約翰尼古拉斯的解決方案有效,但對PEX來說仍然不正確。與PEX使用代碼合同的關鍵在於PEX自動提取代碼合同,並將其作爲預期行爲或合格測試進行處理。 – 2011-07-01 22:24:04