Ejemplo n.º 1
0
        protected IEnumerable <LinqDataTypes2> AdjustExpectedData(ITestDataContext db, IEnumerable <LinqDataTypes2> data)
        {
            if (db.ProviderNeedsTimeFix(db.ContextID))
            {
                var adjusted = new List <LinqDataTypes2>();
                foreach (var record in data)
                {
                    var copy = new LinqDataTypes2()
                    {
                        ID             = record.ID,
                        MoneyValue     = record.MoneyValue,
                        DateTimeValue  = record.DateTimeValue,
                        DateTimeValue2 = record.DateTimeValue2,
                        BoolValue      = record.BoolValue,
                        GuidValue      = record.GuidValue,
                        SmallIntValue  = record.SmallIntValue,
                        IntValue       = record.IntValue,
                        BigIntValue    = record.BigIntValue,
                        StringValue    = record.StringValue
                    };

                    if (copy.DateTimeValue != null)
                    {
                        copy.DateTimeValue = copy.DateTimeValue.Value.AddMilliseconds(-copy.DateTimeValue.Value.Millisecond);
                    }

                    adjusted.Add(copy);
                }

                return(adjusted);
            }

            return(data);
        }
Ejemplo n.º 2
0
        public void SelectNullableTest2([DataSources] string context)
        {
            using (var db = GetDataContext(context))
            {
                try
                {
                    var en = new LinqDataTypes2()
                    {
                        ID = 1000, BoolValue = false
                    };
                    db.Insert(en);

                    var e = new LinqDataTypes()
                    {
                        ID = 1000, BoolValue = false
                    };

                    var e2 = db.Types.First(_ => _.ID == 1000);

                    Assert.AreEqual(e, e2);
                }
                finally
                {
                    db.Types2.Where(_ => _.ID == 1000).Delete();
                }
            }
        }
Ejemplo n.º 3
0
        protected IEnumerable <LinqDataTypes2> AdjustExpectedData(ITestDataContext db, IEnumerable <LinqDataTypes2> data)
        {
            if (db.ContextID == "MySql" || db.ContextID == "MySql.LinqService")
            {
                // MySql versions prior to 5.6.4 do not store fractional seconds so we need to trim
                // them from expected data too
                var version = db.Types.Select(_ => MySqlVersion()).First();
                var match   = new Regex(@"^\d+\.\d+.\d+").Match(version);
                if (match.Success)
                {
                    var versionParts = match.Value.Split('.').Select(_ => int.Parse(_)).ToArray();

                    if (versionParts[0] * 10000 + versionParts[1] * 100 + versionParts[2] < 50604)
                    {
                        var adjusted = new List <LinqDataTypes2>();
                        foreach (var record in data)
                        {
                            var copy = new LinqDataTypes2()
                            {
                                ID             = record.ID,
                                MoneyValue     = record.MoneyValue,
                                DateTimeValue  = record.DateTimeValue,
                                DateTimeValue2 = record.DateTimeValue2,
                                BoolValue      = record.BoolValue,
                                GuidValue      = record.GuidValue,
                                SmallIntValue  = record.SmallIntValue,
                                IntValue       = record.IntValue,
                                BigIntValue    = record.BigIntValue,
                                StringValue    = record.StringValue
                            };

                            if (copy.DateTimeValue != null)
                            {
                                copy.DateTimeValue = copy.DateTimeValue.Value.AddMilliseconds(-copy.DateTimeValue.Value.Millisecond);
                            }

                            adjusted.Add(copy);
                        }

                        return(adjusted);
                    }
                }
            }

            return(data);
        }
Ejemplo n.º 4
0
 static LinqDataTypes2 FixData(LinqDataTypes2 data)
 {
     data.StringValue = null;
     return(data);
 }