我正在尝试在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添加到视图界面,但它不起作用。那有什么不对?
答案 0 :(得分:0)
实际上我忘了在我的测试类之上添加一个使用NSubstitude。