public static IEventRecorder RaiseCollectionChange <T>(this EventAssertions <T> self, object subject, NotifyCollectionChangedEventArgs args) { var wrappedA = new NColChngEvtArgFix(args); bool AssertEvent(NotifyCollectionChangedEventArgs arg) { return(new NColChngEvtArgFix(arg).IsSameOrEqualTo(wrappedA)); } var eventRecorder = self.Raise(nameof(INotifyCollectionChanged.CollectionChanged)).WithSender(subject); var targetEvents = eventRecorder.First().Parameters.OfType <NotifyCollectionChangedEventArgs>().ToList(); if (!targetEvents.Any()) { throw new ArgumentException("No argument of event " + eventRecorder.EventName + " is of type <" + (object)typeof(NotifyCollectionChangedEventArgs) + ">."); } if (!targetEvents.Any(AssertEvent)) { Execute.Assertion.FailWith("Expected at least one event with arguments matching {0}, but found {1}.", args, eventRecorder.ToList()); } return(eventRecorder); }
public static IEventRecorder RaisePropertyChange <T>(this EventAssertions <T> self, object subject, string propertyName) { return(self.Raise(nameof(INotifyPropertyChanged.PropertyChanged)) .WithSender(subject) .WithArgs <PropertyChangedEventArgs>(a => a.PropertyName == propertyName)); }