Esempio n. 1
0
            public void SingleValue_MatchesOnlyThatValue()
            {
                var sieve = new EqualitySieve<ABusinessObject>().ForProperty(x => x.AnInt).ForValue(1);

                var sut = sieve.ToExpression();

                sut.Compile().Invoke(ABusinessObjectWithAnIntOf1).Should().BeTrue();
                sut.Compile().Invoke(ABusinessObjectWithAnIntOf2).Should().BeFalse();
                sut.Compile().Invoke(ABusinessObjectWithAnIntOf3).Should().BeFalse();
            }
Esempio n. 2
0
                    WithInvalidValue_AndInvalidValueBehaviorSetToThrowException_ExceptionIsThrownWhenToExpressionIsCalled
                    ()
                {
                    var sieve =
                        new EqualitySieve<ABusinessObject>().ForProperty(x => x.AnInt)
                            .WithInvalidValueBehavior(InvalidValueBehavior.ThrowInvalidSieveValueException)
                            .ForValue("2abc");

                    // ReSharper disable once UnusedVariable -- used for purposes of this action only
                    Action act = () => { var sut = sieve.ToExpression(); };

                    act.ShouldThrow<InvalidSieveValueException>().And.Message.Should().ContainEquivalentOf("2abc");

                }
Esempio n. 3
0
            public void WithoutPropertySet_ThrowsSievePropertyNotSetException()
            {
                var sieve = new EqualitySieve<ABusinessObject, int>().ForValue(1);

                Action act = () => sieve.ToExpression();

                act.ShouldThrow<SievePropertyNotSetException>()
                    .And.Message.Should()
                    .ContainEquivalentOf("try calling ForProperty");
            }
Esempio n. 4
0
                WhenSpecifyingAnExceptionBeThrown_InvalidValueThrowsInvalidSieveValueExceptionWhenCallingToExpression
                ()
            {
                const string STRING_VALUES = "7/25/2010, 12/1abc/2012";

                var sieve =
                    new EqualitySieve<ABusinessObject>().ForProperty(x => x.ADateTime)
                        .WithInvalidValueBehavior(InvalidValueBehavior.ThrowInvalidSieveValueException)
                        .ForValue(STRING_VALUES);

                // ReSharper disable once UnusedVariable -- used for purposes of this action only
                Action act = () => { var sut = sieve.ToExpression(); };

                act.ShouldThrow<InvalidSieveValueException>()
                    .And.Message.Should()
                    .ContainEquivalentOf("12/1abc/2012");
            }