我正在尝试使用Nspec。我遵循了以下说明:http://nspec.org/
using NSpec;
using FluentAssertions;
class my_first_spec : nspec
{
string name;
void before_each()
{
name = "NSpec";
}
void it_asserts_at_the_method_level()
{
name.ShouldBeEquivalentTo("NSpec");
}
void describe_nesting()
{
before = () => name += " Add Some Other Stuff";
it["asserts in a method"] = () =>
{
name.ShouldBeEquivalentTo("NSpec Add Some Other Stuff");
};
context["more nesting"] = () =>
{
before = () => name += ", And Even More";
it["also asserts in a lambda"] = () =>
{
name.ShouldBeEquivalentTo("NSpec Add Some Other Stuff, And Even More");
};
};
}
}编辑器识别名称空间和nspec类,但是我看到一个编译器错误,它说:
‘'string不包含ShouldBeEquivalentTo的定义’。
有什么问题吗?
我正在使用.NET 4.7.1和VisualStudio2017。
我花了一段时间在谷歌上搜索这个,我在这里查看过,例如:https://github.com/fluentassertions/fluentassertions/issues/234
发布于 2018-03-06 10:52:59
FluentAssertions已经删除了ShouldBeEquivalentTo扩展,这是最近版本中的一项重大更改。
有关建议的备选方案,请参阅最近的FluentAssertions文档。
https://fluentassertions.com/introduction
name.Should().BeEquivalentTo(...);您的示例代码需要更新为
class my_first_spec : nspec {
string name;
void before_each() {
name = "NSpec";
}
void it_asserts_at_the_method_level() {
name.Should().BeEquivalentTo("NSpec");
}
void describe_nesting() {
before = () => name += " Add Some Other Stuff";
it["asserts in a method"] = () => {
name.Should().BeEquivalentTo("NSpec Add Some Other Stuff");
};
context["more nesting"] = () => {
before = () => name += ", And Even More";
it["also asserts in a lambda"] = () => {
name.Should().BeEquivalentTo("NSpec Add Some Other Stuff, And Even More");
};
};
}
}https://stackoverflow.com/questions/49128388
复制相似问题