2016-11-08 31 views

回答

2

您必须使用函数来代替表达式。

x.ShouldBeEquivalentTo(y, ExcludeProperties); 

private EquivalencyAssertionOptions<xx> ExcludeProperties(EquivalencyAssertionOptions<xx> options) 
    { 
      options.Excluding(t => t.CeOperator); 
      options.Excluding(t => t.CeOperatorName); 
      options.Excluding(t => t.Status); 
      options.Excluding(t => t.IsOperational); 
      return options; 
    } 
3

您不一定需要单独的方法。像这样流畅地连锁多个呼叫。

x.ShouldBeEquivalentTo(y, opts => opts.Excluding(si => !si.PropertyInfo.CanWrite).Excluding(si => si.SomeOtherProperty)); 
相关问题