コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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"));
        }
コード例 #4
0
        public void ApplyTo_RightPropertyName_True()
        {
            IRaisingSubject raising = Substitute.For<IRaisingSubject>();
            raising
                .When(r => r.I = Arg.Any<int>())
                .Do(ci => raising.PropertyChanged += Raise.Event<PropertyChangedEventHandler>(raising, new PropertyChangedEventArgs("I")));

            var subject = new PropertyChangedConstraint<IRaisingSubject>(raising, r => r.I);
            Assert.That(matches(subject, () => raising.I = 3), Is.True);
        }
コード例 #5
0
        public void ApplyTo_RightPropertyName_True()
        {
            IRaisingSubject raising = Substitute.For <IRaisingSubject>();

            raising
            .When(r => r.I = Arg.Any <int>())
            .Do(ci => raising.PropertyChanged += Raise.Event <PropertyChangedEventHandler>(raising, new PropertyChangedEventArgs("I")));

            var subject = new PropertyChangedConstraint <IRaisingSubject>(raising, r => r.I);

            Assert.That(matches(subject, () => raising.I = 3), Is.True);
        }
コード例 #6
0
        public void WriteDescriptionTo_WrongPropertyName_ActualWithOffendingValue()
        {
            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(getMessage(subject, () => raising.I = 3),
                        Does.Contain(TextMessageWriter.Pfx_Actual + "\"Wrong\""));
        }
コード例 #7
0
        public void WriteDescriptionTo_WrongPropertyName_ActualWithOffendingValue()
        {
            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(getMessage(subject, () => raising.I = 3),
                Does.Contain(TextMessageWriter.Pfx_Actual + "\"Wrong\""));
        }
コード例 #8
0
        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"));
        }