Exemple #1
0
        public void Assert_Nullable_Integer_Collection_Contains_Single_Value_Expression_Is_Generated_Correctly()
        {
            // Arrange
            var randomInteger = Utilities.GetRandomItem(HydraArmy.Select(t => t.NullableIntegerCollection)).FirstOrDefault();
            var expression    = ExpressionBuilder.CreateBinary <Hydra>(nameof(Hydra.NullableIntegerCollection), randomInteger, ExpressionOperator.Contains);

            // Act
            var result = HydraArmy.Where(expression.Compile()).ToList();

            // Assert
            Assert.NotEmpty(result);
            Assert.Contains(result, t => t.NullableIntegerCollection.Contains(randomInteger));
            Assert.DoesNotContain(result, t => t.NullableIntegerCollection.Contains(randomInteger) == false);
        }
        public void Assert_Decimal_Collection_Contains_Single_Value_Dynamic_Query_Expression_Is_Generated_Correctly()
        {
            // Arrange
            var randomDecimal = Utilities.GetRandomItem(HydraArmy.Select(t => t.DecimalCollection)).FirstOrDefault();
            var expression    = ExpressionBuilder.CreateBinaryFromQuery <Hydra>(BuildQueryText(nameof(Hydra.DecimalCollection), randomDecimal, ExpressionOperator.Contains));

            // Act
            var result = HydraArmy.Where(expression.Compile()).ToList();

            // Assert
            Assert.NotEmpty(result);
            Assert.Contains(result, t => t.DecimalCollection.Contains(randomDecimal));
            Assert.DoesNotContain(result, t => t.DecimalCollection.Contains(randomDecimal) == false);
        }
Exemple #3
0
        public void Assert_Nullable_Boolean_Contains_On_Value_Expression_Is_Generated_Correctly()
        {
            // Arrange
            var randomBooleans = Utilities.GetRandomItems(HydraArmy.Select(t => t.NullableBoolean));
            var expression     = ExpressionBuilder.CreateBinary <Hydra>(nameof(Hydra.NullableBoolean), randomBooleans, ExpressionOperator.ContainsOnValue);

            // Act
            var result = HydraArmy.Where(expression.Compile()).ToList();

            // Assert
            Assert.NotEmpty(result);
            Assert.Contains(result, t => randomBooleans.Contains(t.NullableBoolean));
            Assert.DoesNotContain(result, t => !randomBooleans.Contains(t.NullableBoolean));
        }
        public void Assert_Char_Array_Contains_Single_Value_Expression_Is_Generated_Correctly()
        {
            // Arrange
            var randomChar = Utilities.GetRandomItem(HydraArmy.Select(t => t.CharArray)).FirstOrDefault();
            var expression = ExpressionBuilder.CreateBinary <Hydra>(nameof(Hydra.CharArray), randomChar, ExpressionOperator.Contains);

            // Act
            var result = HydraArmy.Where(expression.Compile()).ToList();

            // Assert
            Assert.NotEmpty(result);
            Assert.Contains(result, t => t.CharArray.Contains(randomChar));
            Assert.DoesNotContain(result, t => !t.CharArray.Contains(randomChar));
        }
Exemple #5
0
        public void Assert_Char_Contains_On_Value_Dynamic_Query_Expression_Is_Generated_Correctly()
        {
            // Arrange
            var randomChars = Utilities.GetRandomItems(HydraArmy.Select(t => t.Char));
            var expression  = ExpressionBuilder.CreateBinaryFromQuery <Hydra>(BuildQueryText(nameof(Hydra.Char), randomChars, ExpressionOperator.ContainsOnValue));

            // Act
            var result = HydraArmy.Where(expression.Compile()).ToList();

            // Assert
            Assert.NotEmpty(result);
            Assert.Contains(result, t => randomChars.Contains(t.Char));
            Assert.DoesNotContain(result, t => randomChars.Contains(t.Char) == false);
        }
Exemple #6
0
        public void Assert_Nullable_Guid_Array_Contains_Single_Value_Dynamic_Query_Expression_Is_Generated_Correctly()
        {
            // Arrange
            var randomGuid = Utilities.GetRandomItem(HydraArmy.Select(t => t.NullableGuidArray)).FirstOrDefault();
            var expression = ExpressionBuilder.CreateBinaryFromQuery <Hydra>(BuildQueryText(nameof(Hydra.NullableGuidArray), randomGuid, ExpressionOperator.Contains));

            // Act
            var result = HydraArmy.Where(expression.Compile()).ToList();

            // Assert
            Assert.NotEmpty(result);
            Assert.Contains(result, t => t.NullableGuidArray.Contains(randomGuid));
            Assert.DoesNotContain(result, t => !t.NullableGuidArray.Contains(randomGuid));
        }
Exemple #7
0
        public void Assert_String_Contains_Dynamic_Query_Expression_Is_Generated_Correctly()
        {
            // Arrange
            var randomString = Utilities.GetRandomItem(HydraArmy.Select(t => string.Concat(t.FirstName, " ")));
            var expression   = ExpressionBuilder.CreateBinaryFromQuery <Hydra>(BuildQueryText(nameof(Hydra.FullName), randomString, ExpressionOperator.Contains));

            // Act
            var result = HydraArmy.Where(expression.Compile()).ToList();

            // Assert
            Assert.NotEmpty(result);
            Assert.Contains(result, t => randomString.Contains(t.FirstName));
            Assert.DoesNotContain(result, t => randomString.Contains(t.FirstName) == false);
        }
Exemple #8
0
        public void Assert_String_Ends_With_Expression_Is_Generated_Correctly()
        {
            // Arrange
            var randomString = Utilities.GetRandomItem(HydraArmy.Select(t => string.Concat(" ", t.LastName)));
            var expression   = ExpressionBuilder.CreateBinary <Hydra>(nameof(Hydra.FullName), randomString, ExpressionOperator.EndsWith);

            // Act
            var result = HydraArmy.Where(expression.Compile()).ToList();

            // Assert
            Assert.NotEmpty(result);
            Assert.Contains(result, t => t.FullName.EndsWith(randomString));
            Assert.DoesNotContain(result, t => t.FullName.EndsWith(randomString) == false);
        }