2012-03-29 6 views
0

MVPアプリケーションでプレゼンターをユニットテストしようとしています。 NSsiteを使って模擬しようとしている私のビューインターフェイスはここにあります:なぜNSubstituteを使用してMVPのビュープロパティをモックできないのですか?

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 
    } 
} 

私はビューインタフェースにmodiferを追加して動作しませんでした。何が間違っているのですか?

+1

これは 'ICategoriesView':' CategoryId'ではなく 'CategorId'の誤植ですか? –

答えて

0

実際に私のテストクラスの上にNSubstitudeを使って追加するのを忘れてしまった。

関連する問題