You can easily publish PropertyChanged events from the Moq.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
|public static class MockExtensions|
|public static IReturnsResult<T> NotifyPropertyChanged<T, TResult>(this Mock<T> mock, Expression<Func<T, TResult>> expression, TResult setupValue) where T : class, INotifyPropertyChanged|
|var memberExpression = expression.Body as MemberExpression;|
|if (memberExpression == null) throw new ArgumentException("expression.Body is not MemberExpression");|
|var returnResult = mock.Setup(expression).Returns(setupValue);|
|mock.Raise(m => m.PropertyChanged += null, new PropertyChangedEventArgs(memberExpression.Member.Name));|