2013-10-22 77 views
0

的財產我有一個公共接口如下無法設置嘲笑接口

public interface ICommandUIUpdate 
{ 
    bool Enabled { get; set; } 
} 

對於單元測試目的,我在下面的方式

var commandUIUpdate = MockRepository.GenerateMock<ICommandUIUpdate>(); 

嘲笑一樣現在,我當我嘗試設置commandUIUpdate.Enabled = true的值,它不起作用。 它始終設置爲false

任何人有任何想法?

回答

1

您需要關於該屬性使PropertyBehavior

commandUIUpdate.Stub(x => x.Enabled).PropertyBehavior(); 
+1

驚奇當我用VAR commandUIUpdate = MockRepository.GenerateStub ();它一切正常! – AmmaraGafoor

+0

它會這樣做 - 'PropertyBehaviour'是存根的默認值,但不是嘲笑。 –