Exemple #1
0
        public void LinqToEntitiesFunctions_SqlFunctions()
        {
            var query = from c in context.Customers
                        where VfpFunctions.Atc("Simon", c.ContactName) == 1
                        select c;

            ObjectDumper.Write(query);
        }
Exemple #2
0
        public void LinqToEntitiesFunctions_SqlFunctions()
        {
            var query = from c in context.Customers
                        where VfpFunctions.Atc("Simon", c.ContactName) == 1
                        select c;

            var list = query.ToList();
        }
        public void VfpFunctionsTests_Strtran_Default_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Strtran(x.ShipName, "I", "X")).First();

            Assert.AreEqual("Vins et alcools Chevalier", result);
            result = this.GetOrderQuery().Select(x => VfpFunctions.Strtran(x.ShipName, "i", "X")).First();
            Assert.AreEqual("VXns et alcools ChevalXer", result);
        }
        public void VfpFunctionsTests_Strtran_CaseInsensitive_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Strtran(x.ShipName, "I", "X", 1, -1, 1)).First();

            Assert.AreEqual("VXns et alcools ChevalXer", result);
            result = this.GetOrderQuery().Select(x => VfpFunctions.Strtran(x.ShipName, "i", "X", 1, -1, 1)).First();
            Assert.AreEqual("VXns et alcools ChevalXer", result);
        }
        public void VfpFunctionsTests_AT_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.At("I", x.ShipName)).First();

            Assert.AreEqual(0, result);
            result = this.GetOrderQuery().Select(x => VfpFunctions.At("i", x.ShipName)).First();
            Assert.AreEqual(2, result);
        }
        public void VfpFunctionsTests_ATC_IntOccurance_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Atc("I", x.ShipName, 2)).First();

            Assert.AreEqual(23, result);
            result = this.GetOrderQuery().Select(x => VfpFunctions.Atc("i", x.ShipName, 2)).First();
            Assert.AreEqual(23, result);
        }
        public void VfpFunctionsTests_IsDigit_True_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.IsDigit("1")).First();

            Assert.AreEqual(true, result);
            result = this.GetOrderQuery().Select(x => VfpFunctions.IsDigit("A")).First();
            Assert.AreEqual(false, result);
        }
Exemple #8
0
        public void VfpFunctionsTests_AT_LongOccurance_Test() => Execute(context => {
            var result = GetOrderQuery(context).Select(x => VfpFunctions.At("I", x.ShipName, (long)2)).First();
            Assert.Equal(0, result);

            result = GetOrderQuery(context).Select(x => VfpFunctions.At("i", x.ShipName, (long)2)).First();

            Assert.Equal(23, result);
        });
Exemple #9
0
        public void VfpFunctionsTests_ATC_Test() => Execute(context => {
            var result = GetOrderQuery(context).Select(x => VfpFunctions.Atc("I", x.ShipName)).First();

            Assert.Equal(2, result);

            result = GetOrderQuery(context).Select(x => VfpFunctions.Atc("i", x.ShipName)).First();

            Assert.Equal(2, result);
        });
Exemple #10
0
        public void VfpFunctionsTests_Strtran_Default_Test() => Execute(context => {
            var result = GetOrderQuery(context).Select(x => VfpFunctions.Strtran(x.ShipName, "I", "X")).First();

            Assert.Equal("Vins et alcools Chevalier", result);

            result = GetOrderQuery(context).Select(x => VfpFunctions.Strtran(x.ShipName, "i", "X")).First();

            Assert.Equal("VXns et alcools ChevalXer", result);
        });
Exemple #11
0
        public void VfpFunctionsTests_IsDigit_True_Test() => Execute(context => {
            var result = GetOrderQuery(context).Select(x => VfpFunctions.IsDigit(x.ShipAddress.Substring(0, 1))).First();

            Assert.Equal(true, result);

            result = GetOrderQuery(context).Select(x => VfpFunctions.IsDigit(x.ShipCountry.Substring(0, 1))).First();

            Assert.Equal(false, result);
        });
        public void QueryEmptyValues()
        {
            InsertEmptyValues(false);

            using (var context = GetAllTypesDataContext()) {
                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.BinaryChar) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.BinaryChar) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.BinaryMemo) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.BinaryMemo) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.BinaryVarChar) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.BinaryVarChar) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.Char) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.Char) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.Currency) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.Currency) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.Date) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.Date) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.DateTime) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.DateTime) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.Decimal) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.Decimal) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.Double) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.Double) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.Float) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.Float) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.Integer) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.Integer) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.Logical) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.Logical) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.Long) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.Long) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.Memo) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.Memo) == false));

                Assert.AreEqual(1, context.AllTypes.Count(x => VfpFunctions.Empty(x.VarChar) == true));
                Assert.AreEqual(0, context.AllTypes.Count(x => VfpFunctions.Empty(x.VarChar) == false));
            }
        }
        public void VfpFunctionsTests_Sin_Double_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Sin((double).5)).First();

            Assert.AreEqual(0.4794255386042, result);
        }
        public void VfpFunctionsTests_SquareRoot_Decimal_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.SquareRoot((decimal)4)).First();

            Assert.AreEqual(2, result);
        }
        public void VfpFunctionsTests_Asin_Double_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Asin((double).5)).First();

            Assert.AreEqual(0.5235987755983, result);
        }
        public void VfpFunctionsTests_Ascii_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Ascii("A")).First();

            Assert.AreEqual(65, result);
        }
        public void VfpFunctionsTests_Tan_Decimal_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Tan((decimal).5)).First();

            Assert.AreEqual(0.54630248984379, result);
        }
        public void VfpFunctionsTests_Acos_Double_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Acos((double).5)).First();

            Assert.AreEqual(1.0471975511966, result);
        }
        public void VfpFunctionsTests_Chr_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Chr(65)).First();

            Assert.AreEqual("A", result);
        }
        public void VfpFunctionsTests_Stuff_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Stuff(x.ShipName, 6, 2, "xx")).First();

            Assert.AreEqual("Vins xx alcools Chevalier", result);
        }
        public void VfpFunctionsTests_Substr_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Substr(x.ShipName, 9, 7)).First();

            Assert.AreEqual("alcools", result);
        }
        public void VfpFunctionsTests_StringConvert_Double_Length_DecimalPlaces_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.StringConvert((double)12345.67, 15, 1)).First();

            Assert.AreEqual("        12345.7", result);
        }
        public void VfpFunctionsTests_DayOfWeek_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.DayOfWeek(x.OrderDate)).First();

            Assert.AreEqual("Thursday", result);
        }
        public void VfpFunctionsTests_DateTime_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.DateTime()).First();

            Assert.AreEqual(DateTime.Now.ToShortDateString(), result.Value.ToShortDateString());
        }
        public void VfpFunctionsTests_Sign_Long_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Sign((long)0)).First();

            Assert.AreEqual(0, result);
        }
        public void VfpFunctionsTests_Space_Test()
        {
            var result = this.GetOrderQuery().Select(x => "x" + VfpFunctions.Space(3) + "x").First();

            Assert.AreEqual("x   x", result);
        }
        public void VfpFunctionsTests_StringConvert_Double_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.StringConvert((double)12345.67)).First();

            Assert.AreEqual("     12346", result);
        }
        public void VfpFunctionsTests_StringConvert_Decimal_Length_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.StringConvert((decimal)12345.67, 15)).First();

            Assert.AreEqual("          12346", result);
        }
        public void VfpFunctionsTests_AllTrimTest()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.AllTrim("  " + x.Customer.CustomerID)).First();

            Assert.AreEqual("VINET", result);
        }
        public void VfpFunctionsTests_Replicate_Test()
        {
            var result = this.GetOrderQuery().Select(x => VfpFunctions.Replicate("Z", 3)).First();

            Assert.AreEqual("ZZZ", result);
        }