public void DeclaringASieveForSubTypeAndPassingBusinessObject_Works() { var businessObj1 = new ABusinessObject { AComplexProperty =new ComplexProperty { AnInt = 1, AString = "Hello" }}; var businessObj2 = new ABusinessObject { AComplexProperty = new ComplexProperty { AnInt = 2, AString = "Hello" } }; var sieve = new EqualitySieve<ComplexProperty>().ForProperty(x => x.AnInt).ForValue(1).ToCompiledExpression(); sieve.Invoke(businessObj1.AComplexProperty).Should().BeTrue(); sieve.Invoke(businessObj2.AComplexProperty).Should().BeFalse(); }
public void DefaultBehaviorIsToLetAllThrough() { //no values defined var sut = new EqualitySieve<ABusinessObject>().ForProperty(x => x.AnInt).ToCompiledExpression(); sut.Invoke(ABusinessObjectWithAnIntOf1).Should().BeTrue(); sut.Invoke(ABusinessObjectWithAnIntOf2).Should().BeTrue(); sut.Invoke(ABusinessObjectWithAnIntOf3).Should().BeTrue(); }
public void WithLetNoneThroughOption_DoesNotAllowAnyThrough() { //no values defined var sut = new EqualitySieve<ABusinessObject>().ForProperty(x => x.AnInt) .WithEmptyValuesListBehavior(EmptyValuesListBehavior.LetNoObjectsThrough) .ToCompiledExpression(); sut.Invoke(ABusinessObjectWithAnIntOf1).Should().BeFalse(); sut.Invoke(ABusinessObjectWithAnIntOf2).Should().BeFalse(); sut.Invoke(ABusinessObjectWithAnIntOf3).Should().BeFalse(); }
public void ToCompiledExpression_ReturnsCompiledExpression() { var sut = new EqualitySieve<ABusinessObject>().ForProperty(x => x.AnInt).ForValue(1).ToCompiledExpression(); sut.Invoke(ABusinessObjectWithAnIntOf1).Should().BeTrue(); sut.Invoke(ABusinessObjectWithAnIntOf2).Should().BeFalse(); sut.Invoke(ABusinessObjectWithAnIntOf3).Should().BeFalse(); }