public void ApplyTo_SetterDoesNotRaiseEvent_False() { IRaisingSubject raising = Substitute.For <IRaisingSubject>(); var subject = new PropertyChangedConstraint <IRaisingSubject>(raising, r => r.I); Assert.That(matches(subject, () => raising.I = 3), Is.False); }
public void ApplyTo_SetterDoesNotRaiseEvent_True() { IRaisingSubject raising = Substitute.For <IRaisingSubject>(); var subject = new NoPropertyChangingConstraint <IRaisingSubject>(raising); Assert.That(matches(subject, () => raising.I = 3), Is.True); }
public void CanBeCreatedWithExtension() { IRaisingSubject raising = Substitute.For <IRaisingSubject>(); raising.When(r => r.I = Arg.Any <int>()) .Do(i => raising.PropertyChanging += Raise.Event <PropertyChangingEventHandler>(raising, new PropertyChangingEventArgs("I"))); Assert.That(() => raising.I = 3, Must.Raise.PropertyChanging(raising, r => r.I)); }
public void CanBeNewedUp() { IRaisingSubject raising = Substitute.For <IRaisingSubject>(); raising.When(r => r.I = Arg.Any <int>()) .Do(i => raising.PropertyChanging += Raise.Event <PropertyChangingEventHandler>(raising, new PropertyChangingEventArgs("I"))); Assert.That(() => raising.I = 3, new PropertyChangingConstraint <IRaisingSubject>(raising, r => r.I)); }
public void WriteDescriptionTo_SetterDoesNotRaiseEvent_ExpectationWithEvent_PropertyName_ActualWithEventNotRaised() { IRaisingSubject raising = Substitute.For <IRaisingSubject>(); var subject = new PropertyChangedConstraint <IRaisingSubject>(raising, r => r.I); Assert.That(getMessage(subject, () => raising.I = 3), Does.StartWith(TextMessageWriter.Pfx_Expected + "raise event 'PropertyChanged'").And .Contain("PropertyName equal to \"I\"").And .Contain(TextMessageWriter.Pfx_Actual + "event 'PropertyChanged' not raised")); }
public void ApplyTo_RightPropertyName_True() { IRaisingSubject raising = Substitute.For <IRaisingSubject>(); raising.When(r => r.I = Arg.Any <int>()) .Do(i => raising.PropertyChanging += Raise.Event <PropertyChangingEventHandler>(raising, new PropertyChangingEventArgs("I"))); var subject = new PropertyChangingConstraint <IRaisingSubject>(raising, r => r.I); Assert.That(matches(subject, () => raising.I = 3), Is.True); }
public void ApplyTo_WrongPropertyName_False() { IRaisingSubject raising = Substitute.For <IRaisingSubject>(); raising .When(r => r.I = Arg.Any <int>()) .Do(ci => raising.PropertyChanged += Raise.Event <PropertyChangedEventHandler>(raising, new PropertyChangedEventArgs("Wrong"))); var subject = new PropertyChangedConstraint <IRaisingSubject>(raising, r => r.I); Assert.That(matches(subject, () => raising.I = 3), Is.False); }
public void ApplyTo_SetterRaisesEvent_False() { IRaisingSubject raising = Substitute.For <IRaisingSubject>(); raising .When(r => r.I = Arg.Any <int>()) .Do(ci => raising.PropertyChanging += Raise.Event <PropertyChangingEventHandler>(raising, new PropertyChangingEventArgs("anything"))); var subject = new NoPropertyChangingConstraint <IRaisingSubject>(raising); Assert.That(matches(subject, () => raising.I = 3), Is.False); }
public void WriteDescriptionTo_WrongPropertyName_ActualWithOffendingValue() { IRaisingSubject raising = Substitute.For <IRaisingSubject>(); raising.When(r => r.I = Arg.Any <int>()) .Do(i => raising.PropertyChanging += Raise.Event <PropertyChangingEventHandler>(raising, new PropertyChangingEventArgs("Wrong"))); var subject = new PropertyChangingConstraint <IRaisingSubject>(raising, r => r.I); Assert.That(getMessage(subject, () => raising.I = 3), Does .Contain(TextMessageWriter.Pfx_Actual + "\"Wrong\"")); }
public void WriteDescriptionTo_RaisesEvent_ExpectationWithEvent_ActualWithEventNotRaised() { IRaisingSubject raising = Substitute.For <IRaisingSubject>(); raising .When(r => r.I = Arg.Any <int>()) .Do(ci => raising.PropertyChanged += Raise.Event <PropertyChangedEventHandler>(raising, new PropertyChangedEventArgs("anything"))); var subject = new NoPropertyChangedConstraint <IRaisingSubject>(raising); Assert.That(getMessage(subject, () => raising.I = 3), Does.StartWith(TextMessageWriter.Pfx_Expected + "event 'PropertyChanged' not raised").And .Contain(TextMessageWriter.Pfx_Actual + "event 'PropertyChanged' raised")); }