Пример #1
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);
            }
        }
Пример #2
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);
                    }
                }
            }
        }