Moq - How to verify that a property value is set via the setter

前端 未结 5 1876
梦如初夏
梦如初夏 2020-12-16 09:22

Consider this class:

public class Content
{      
   public virtual bool IsCheckedOut {get; private set;}
   public virtual void CheckOut()
   {
      IsChec         


        
5条回答
  •  -上瘾入骨i
    2020-12-16 09:34

    Mock mockContect = new Mock(); 
    mockContent.VerifySet(x => x.IsCheckedOut, Times.Once());
    

    Will that do the trick? Not sure how the private setter comes in to play as havent tested that. but works for my public setter.

    Got this from: http://www.codethinked.com/post/2009/03/10/Beginning-Mocking-With-Moq-3-Part-2.aspx

提交回复
热议问题