Ejemplo n.º 1
0
        public void ORA_ParamTestUpdate()
        {
            using (var db = OpenDbConnection())
            {
                DropAndCreateTables(db);

                var bo1 = new ParamTestBo {
                    Id = 1, Double = 0.001, Int = 100, Info = "One", NullableBool = true
                };
                var bo2 = new ParamTestBo {
                    Id = 2, Double = 0.002, Int = 200, Info = "Two", NullableBool = true, DateTime = DateTime.Now
                };
                db.Insert(bo1);
                db.Insert(bo2);

                bo1.Double       = 0.01;
                bo1.Int          = 10000;
                bo1.Info         = "OneUpdated";
                bo1.NullableBool = null;
                bo1.DateTime     = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

                db.Update(bo1);

                var bo1Check = db.SingleById <ParamTestBo>(1);

                Assert.AreEqual(bo1.Double, bo1Check.Double);
                Assert.AreEqual(bo1.Int, bo1Check.Int);
                Assert.AreEqual(bo1.Info, bo1Check.Info);
                Assert.AreEqual(bo1.DateTime, bo1Check.DateTime);


                Assert.GreaterOrEqual(DateTime.Now, bo2.DateTime);

                bo2.Info         = "TwoUpdated";
                bo2.Int          = 9923;
                bo2.NullableBool = false;
                bo2.DateTime     = DateTime.Now.AddDays(10);

                db.Update(bo2);

                var bo2Check = db.SingleById <ParamTestBo>(2);

                Assert.Less(DateTime.Now, bo2.DateTime);
                Assert.AreEqual("TwoUpdated", bo2Check.Info);
                Assert.AreEqual(9923, bo2Check.Int);
                Assert.AreEqual(false, bo2Check.NullableBool);
            }
        }
        public void ORA_ParamTestUpdate()
        {
            using (var db = OpenDbConnection())
            {
                DropAndCreateTables(db);

                var bo1 = new ParamTestBo { Id = 1, Double = 0.001, Int = 100, Info = "One", NullableBool = true };
                var bo2 = new ParamTestBo { Id = 2, Double = 0.002, Int = 200, Info = "Two", NullableBool = true, DateTime = DateTime.Now };
                db.Insert(bo1);
                db.Insert(bo2);

                bo1.Double = 0.01;
                bo1.Int = 10000;
                bo1.Info = "OneUpdated";
                bo1.NullableBool = null;
                bo1.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

                db.Update(bo1);

                var bo1Check = db.SingleById<ParamTestBo>(1);

                Assert.AreEqual(bo1.Double, bo1Check.Double);
                Assert.AreEqual(bo1.Int, bo1Check.Int);
                Assert.AreEqual(bo1.Info, bo1Check.Info);
                Assert.AreEqual(bo1.DateTime, bo1Check.DateTime);


                Assert.GreaterOrEqual(DateTime.Now, bo2.DateTime);

                bo2.Info = "TwoUpdated";
                bo2.Int = 9923;
                bo2.NullableBool = false;
                bo2.DateTime = DateTime.Now.AddDays(10);

                db.Update(bo2);

                var bo2Check = db.SingleById<ParamTestBo>(2);

                Assert.Less(DateTime.Now, bo2.DateTime);
                Assert.AreEqual("TwoUpdated", bo2Check.Info);
                Assert.AreEqual(9923, bo2Check.Int);
                Assert.AreEqual(false, bo2Check.NullableBool);
            }
        }