Ejemplo n.º 1
0
        public void SQL_Compact_always_truncates_money_on_insert_or_update()
        {
            using (var context = new ArubaCeContext("Scenario_Use_SqlCe_AppConfig_connection_string"))
            {
                context.Database.Initialize(force: false);

                using (context.Database.BeginTransaction())
                {
                    // Insert
                    var allTypes = context.AllTypes.Add(
                        new ArubaAllCeTypes
                    {
                        c11_money   = 9.88888888888888888888888888888888m,
                        c5_datetime = DateTime.Now,
                    });
                    context.SaveChanges();

                    Assert.Equal(9.8888m, context.AllTypes.AsNoTracking().Single(t => t.c1_int == allTypes.c1_int).c11_money);

                    // Update
                    allTypes.c11_money = 11.88888888888888888888888888888888m;
                    context.SaveChanges();

                    Assert.Equal(11.8888m, context.AllTypes.AsNoTracking().Single(t => t.c1_int == allTypes.c1_int).c11_money);
                }
            }
        }
Ejemplo n.º 2
0
        public void SQL_Compact_does_not_truncate_decimals_on_insert_or_update()
        {
            using (var context = new ArubaCeContext("Scenario_Use_SqlCe_AppConfig_connection_string"))
            {
                context.Database.Initialize(force: false);

                using (context.Database.BeginTransaction())
                {
                    // Insert
                    var allTypes = context.AllTypes.Add(
                        new ArubaAllCeTypes
                    {
                        c7_decimal_28_4 = 9.88888888888888888888888888888888m,
                        c8_numeric_28_4 = 9.88888888888888888888888888888888m,
                        c5_datetime     = DateTime.Now,
                    });
                    context.SaveChanges();

                    ValidateSavedValues(context, allTypes, 9.8889m);

                    // Update
                    allTypes.c7_decimal_28_4 = 11.88888888888888888888888888888888m;
                    allTypes.c8_numeric_28_4 = 11.88888888888888888888888888888888m;
                    context.SaveChanges();

                    ValidateSavedValues(context, allTypes, 11.8889m);
                }
            }
        }