Ejemplo n.º 1
0
        public void Operator_NotEqual()
        {
            //Arrange
            var models = new SimpleValuesModel[] {
                new SimpleValuesModel()
                {
                    FloatValue = 2, DecimalValue = 3
                },
                new SimpleValuesModel()
                {
                    FloatValue = 1, DecimalValue = 3
                }
            };
            var query = models.AsQueryable();

            //Act
            var result1 = query.Where("FloatValue != 2").First();
            var result2 = query.Where("FloatValue <> 2").First();
            var result3 = query.Where("FloatValue ne 2").First();

            //Assert
            Assert.AreEqual(models[1], result1);
            Assert.AreEqual(models[1], result2);
            Assert.AreEqual(models[1], result3);
        }
        public void ExpressionTests_Sum2()
        {
            //Arrange
            var initValues = new SimpleValuesModel[]
            {
                new SimpleValuesModel()
                {
                    FloatValue = 1
                },
                new SimpleValuesModel()
                {
                    FloatValue = 2
                },
                new SimpleValuesModel()
                {
                    FloatValue = 3
                },
            };

            var qry = initValues.AsQueryable();

            //Act
            var result  = qry.Select("FloatValue").Sum();
            var result2 = ((IQueryable <float>)qry.Select("FloatValue")).Sum();

            //Assert
            Assert.AreEqual(6.0f, result);
            Assert.AreEqual(6.0f, result2);
        }
Ejemplo n.º 3
0
        public void Operator_Equal_With_Explicit_Convertion_From_String_To_Int32()
        {
            //Arrange
            var models = new SimpleValuesModel[] { new SimpleValuesModel()
                                                   {
                                                       FloatValue = 2, DecimalValue = 3
                                                   } };
            var query = models.AsQueryable();

            //Act
            var result1 = query.Where("FloatValue == int\"2\"").First();
            var result2 = query.Where("FloatValue == Int32\"2\"").First();

            //Assert
            Assert.AreEqual(models[0], result1);
            Assert.AreEqual(models[0], result2);
        }