我正在使用RhinoMocks,我想斷言一個屬性引用的Action沒有被調用,但我並不關心屬性本身。AssertWasNotCalled on Action屬性
實施例:
public class MyClass
{
public Action DoSomething { get; set; }
public void TryDoSomething()
{
if(DoSomething != null)
DoSomething();
}
}
[TestMethod]
public void TestDoSomethingNotCalled()
{
var myclass = new MockRepository.GeneratePartialMock<MyClass>();
myclass.TryDoSomething();
myclass.AssertWasNotCalled(m => m.DoSomething());
}
該測試失敗,因爲上DoSomething的空校驗的。有沒有辦法斷言這個屬性引用的Action沒有被調用,而不是屬性本身?
我跳過槍,沒有看到您的完整回覆。我試圖提出這個問題,但它不會讓我。謝謝! – ConditionRacer