public void ThrowCorrectExceptionIfSenderIsNull() { var ex = Assert.Throws <ArgumentNullException>(() => CollectionChangedEventHandlers <int, int> .Handle(null, null)); Assert.IsNotNull(ex); Assert.AreEqual("sender", ex.ParamName); }
public void ThrowCorrectExceptionIfEventArgsIsNull() { var sender = new Mock <ICollectionChangedEventSource <int, int> >(); var ex = Assert.Throws <ArgumentNullException>( () => CollectionChangedEventHandlers <int, int> .Handle(sender.Object, null)); Assert.IsNotNull(ex); Assert.AreEqual("e", ex.ParamName); }
public void SenderNullCollectionItemSourceDoesNotThrowExceptionWhenChangeActionIsReset() { var sender = new Mock <ICollectionChangedEventSource <int, int> >(); // ReSharper disable once PossibleNullReferenceException => How Moq initializes expected scenarios, not null. sender.Setup(s => s.CollectionItemSource).Returns((IEnumerable <int>)null); var notifyCollectionChangedEventArgs = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, null); CollectionChangedEventHandlers <int, int> .Handle(sender.Object, notifyCollectionChangedEventArgs); }