我有以下 NUnit 测试:
[Test]
public void GetComplexRulesTestContents()
{
var _rule = new RuleViewModel(null, "third rule", "description");
var result = _complexRulesService.GetComplexRules();
Assert.That(result, Has.Member(_rule));
}
从 _complexRulesService.GetComplexRules() 调用的代码是:
public IEnumerable<IRuleViewModel> GetComplexRules()
{
IEnumerable<RuleViewModel> _rules;
_rules = new List<RuleViewModel>
{
new RuleViewModel(null, "first default rule", "description"),
new RuleViewModel(null, "second default rule", "description"),
new RuleViewModel(null, "third rule", "description")
};
return _rules;
}
我得到的错误信息是:
PL.Web.MVC.Rules.Tests.ComplexRulesServiceTests.GetComplexRulesTestContents:
Expected: collection containing <PL.Web.MVC.Models.Rules.RuleViewModel>
But was: < <PL.Web.MVC.Models.Rules.RuleViewModel>, PL.Web.MVC.Models.Rules.RuleViewModel>, <PL.Web.MVC.Models.Rules.RuleViewModel> >
我已经尝试了来自http://www.nunit.org/index.php?p=collectionConstraints&r=2.5.5的测试,它们都通过了。
我做错了什么?
提前感谢您的帮助!