Beispiel #1
0
        public void CloneConnectionDisposed()
        {
            var connection = new TestNoopConnection("");

            connection.Open();

            Assert.AreEqual(ConnectionState.Open, connection.State);

            TestNoopConnection?cloneConnection;

            using (var db = new DataConnection(new TestNoopProvider(), connection, false))
            {
                var c = db.Connection;
                Assert.AreEqual(ConnectionState.Open, c.State);

                using (var db2 = (DataConnection)db.Clone())
                {
                    cloneConnection = db2.Connection as TestNoopConnection;
                    Assert.NotNull(cloneConnection);
                    Assert.AreNotEqual(cloneConnection, connection);
                    Assert.AreEqual(ConnectionState.Open, cloneConnection !.State);
                }
            }

            Assert.AreEqual(ConnectionState.Open, connection.State);
            Assert.AreEqual(false, connection.IsDisposed);

            Assert.IsNotNull(cloneConnection);
            Assert.AreEqual(ConnectionState.Closed, cloneConnection.State);
            Assert.AreEqual(true, cloneConnection.IsDisposed);
        }
Beispiel #2
0
        public void ExternalConnectionNotClosed()
        {
            var connection = new TestNoopConnection("");

            connection.Open();

            Assert.AreEqual(ConnectionState.Open, connection.State);

            using (var db = new DataConnection(new TestNoopProvider(), connection, false))
            {
                var c = db.Connection;
                Assert.AreEqual(ConnectionState.Open, c.State);
            }

            Assert.AreEqual(ConnectionState.Open, connection.State);
            Assert.AreEqual(false, connection.IsDisposed);
        }