我正在尝试在 MVP 应用程序中对我的演示者进行单元测试。这是我尝试使用 NSubstitude 模拟的视图界面:
public interface ICategoriesView : IBaseViewInterface
{
string CategoryName { get; }
long CategorId { get; }
long CategoryParent { get; }
IEnumerable<EntityObject> CategoryDataSource { set; }
}
这是我的单元测试课。我正在使用 NUnit 框架:
[TestFixture]
public class CategoriesTests
{
[Test(Description="this is used for testing the behavior of presenter if we pass empty name.")]
public void Add_EmptyName_Fails()
{
var _view = NSubstitute.Substitute.For<ICategoriesView>();
//now here i'm supposed to get something like _view.CategoryId.Returns(2) but i don't!
//the error message says that _view.CategoryId doesn't have an extension method
//named Returns. and it's true since intellisence doesn't list it after period
}
}
我在视图界面中添加了 set modifer,但它不起作用。那么有什么问题呢?