0

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 を追加しましたが、機能しませんでした。それで何が悪いの?

4

1 に答える 1

0

実際、テスト クラスの上に using NSubstitude を追加するのを忘れていました。

于 2012-03-30T13:42:54.597 に答える