Ejemplo n.º 1
0
 public void TestCreateConnection([DataSources(false)] string context)
 {
     using (var db = new NewDataContext(context))
     {
         Assert.AreEqual(0, db.CreateCalled);
         using (db.GetDataConnection())
         {
             Assert.AreEqual(1, db.CreateCalled);
             using (db.GetDataConnection())
             {
                 Assert.AreEqual(1, db.CreateCalled);
             }
         }
     }
 }
Ejemplo n.º 2
0
        public void TestCreateConnection([DataSources(false)] string context)
        {
            using (var db = new NewDataContext(context))
            {
                Assert.AreEqual(0, db.CreateCalled);

                db.KeepConnectionAlive = true;
                db.GetTable <Person>().ToList();
                Assert.AreEqual(1, db.CreateCalled);
                db.GetTable <Person>().ToList();
                Assert.AreEqual(1, db.CreateCalled);
                db.KeepConnectionAlive = false;
                db.GetTable <Person>().ToList();
                Assert.AreEqual(2, db.CreateCalled);
            }
        }
Ejemplo n.º 3
0
        public void TestCloneConnection([DataSources(false)] string context)
        {
            using (var db = new NewDataContext(context))
            {
                Assert.AreEqual(0, db.CloneCalled);
                using (new NewDataContext(context))
                {
                    using (((IDataContext)db).Clone(true))
                    {
                        Assert.False(db.IsMarsEnabled);
                        Assert.AreEqual(0, db.CloneCalled);

                        using (db.GetDataConnection())
                        {
                            using (((IDataContext)db).Clone(true))
                                Assert.AreEqual(db.IsMarsEnabled ? 1 : 0, db.CloneCalled);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void TestCloneConnection([DataSources(false)] string context)
        {
            using (var db = new NewDataContext(context))
            {
                Assert.AreEqual(0, db.CloneCalled);
                using (new NewDataContext(context))
                {
                    using (((IDataContext)db).Clone(true))
                    {
                        Assert.False(db.IsMarsEnabled);
                        Assert.AreEqual(0, db.CloneCalled);

                        // create and preserve underlying dataconnection
                        db.KeepConnectionAlive = true;
                        db.GetTable <Person>().ToList();

                        using (((IDataContext)db).Clone(true))
                            Assert.AreEqual(db.IsMarsEnabled ? 1 : 0, db.CloneCalled);
                    }
                }
            }
        }