Esempio n. 1
0
 public static InclusionClause Matcher(this InclusionClause self)
 {
     return(Match.Create <InclusionClause>(ic =>
                                           ReferenceEquals(ic.LHS.Field, self.LHS.Field) &&
                                           ic.LHS.Field == self.LHS.Field &&
                                           ic.Operator == self.Operator &&
                                           ic.RHS.OrderBy(v => v.ToString()).SequenceEqual(self.RHS.OrderBy(v => v.ToString()))
                                           ));
 }
Esempio n. 2
0
        public void InclusionClauseNotNegated()
        {
            // Arrange
            var mockField = new Mock <IField>();
            var expr      = new FieldExpression(mockField.Object);
            var op        = InclusionOperator.In;
            var values    = new DBValue[] { DBValue.Create(100), DBValue.Create(200), DBValue.Create(300) };

            mockField.Setup(field => field.DataType).Returns(DBType.Int32);

            // Act
            var clause = new InclusionClause(expr, op, values);
            var fields = clause.GetDependentFields();

            // Assert
            clause.LHS.Should().Be(expr);
            clause.Operator.Should().Be(op);
            clause.RHS.Should().BeEquivalentTo(values);
            fields.Should().BeEquivalentTo(new IField[] { mockField.Object });
        }
Esempio n. 3
0
        public void InclusionClauseNegated_NotIn()
        {
            // Arrange
            var mockField = new Mock <IField>();
            var expr      = new FieldExpression(mockField.Object);
            var op        = InclusionOperator.NotIn;
            var values    = new DBValue[] { DBValue.Create(100), DBValue.Create(200), DBValue.Create(300) };

            mockField.Setup(field => field.DataType).Returns(DBType.Int32);
            var clause      = new InclusionClause(expr, op, values);
            var mockBuilder = new Mock <IConstraintDeclBuilder>();

            // Act
            var negation = clause.Negation();

            negation.AddDeclarationTo(mockBuilder.Object);

            // Assert
            var expected = new InclusionClause(expr, InclusionOperator.In, values);

            mockBuilder.Verify(builder => builder.AddClause(expected.Matcher()));
            mockBuilder.VerifyNoOtherCalls();
        }