Esempio n. 1
0
        public void SqlServer_DDLStatement_DoesntCrash()
        {
            var repo = new SqlServerIntegrationRepository(GetConnection());

            repo.ExecuteAdHocQuery("CREATE DATABASE datafacetestddl");
            repo.ExecuteAdHocQuery("DROP DATABASE datafacetestddl");
        }
Esempio n. 2
0
        public void SqlServer_ToScalar_Works()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());

            Assert.AreEqual(142, repo.ToScalar());
        }
Esempio n. 3
0
        public void SqlServer_ManyManyTransactions_DoesntLeak()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            for (int ii = 0; ii < 1000; ii++) {
                var repo = new SqlServerIntegrationRepository(GetConnection());
                repo.SprocWithSchema();
            }
        }
Esempio n. 4
0
        public void SqlServer_ToScalarNull_Works()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());

            Assert.IsNull(repo.ToScalarNull());
        }
Esempio n. 5
0
        public void SqlServer_EmptyMultipleResultSets_Work()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());
            var model = repo.EmptyMultipleResultSetModel();

            Assert.IsNotNull(model);
        }
Esempio n. 6
0
        public void SqlServer_ToFirstOrDefault_WithoutValue_Works()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());

            Assert.IsNull(repo.ToFirstOrDefaultScalar2());
        }
Esempio n. 7
0
        public void SqlServer_SprocWithParameter_Works()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());

            Assert.AreEqual(143, repo.SprocWithParameter(143));
        }
Esempio n. 8
0
        public void SqlServer_EmptyMultipleResultSets_Work()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo  = new SqlServerIntegrationRepository(GetConnection());
            var model = repo.EmptyMultipleResultSetModel();

            Assert.IsNotNull(model);
        }
Esempio n. 9
0
        public void SqlServer_ManyManyTransactions_DoesntLeak()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            for (int ii = 0; ii < 1000; ii++)
            {
                var repo = new SqlServerIntegrationRepository(GetConnection());
                repo.SprocWithSchema();
            }
        }
Esempio n. 10
0
        public void SqlServer_CommitTransaction_HasSideEffect()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());
            using (var transaction = repo.WithTransaction()) {
                repo.SprocWithSideEffect();
                transaction.Commit();
            }

            Assert.AreEqual(1, repo.GetCountOfSideEffects());
        }
Esempio n. 11
0
        public void SqlServer_RollbackTransaction_DoesntHaveSideEffect()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());

            using (var transaction = repo.WithTransaction()) {
                repo.SprocWithSideEffect();
                transaction.Rollback();
            }

            Assert.AreEqual(0, repo.GetCountOfSideEffects());
        }
Esempio n. 12
0
        public void SqlServer_CommitTransaction_HasSideEffect()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());

            using (var transaction = repo.WithTransaction()) {
                repo.SprocWithSideEffect();
                transaction.Commit();
            }

            Assert.AreEqual(1, repo.GetCountOfSideEffects());
        }
Esempio n. 13
0
        public void SqlServer_MultipleResultSets_Work()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());
            var model = repo.ToMultipleResultSetModel();

            Assert.AreEqual(model.ResultSet0.Count, 2);
            Assert.AreEqual(model.ResultSet0[0].IntValue, 147);
            Assert.AreEqual(model.ResultSet0[1].IntValue, 192);
            Assert.AreEqual(model.ResultSet0[0].BoolValue, true);
            Assert.AreEqual(model.ResultSet0[1].BoolValue, false);

            Assert.AreEqual(model.ResultSet1.Count, 2);
            Assert.AreEqual(model.ResultSet1[0].StringValue, "abc");
            Assert.AreEqual(model.ResultSet1[1].StringValue, "def");
            Assert.AreEqual(model.ResultSet1[0].DateTimeValue, new DateTime(2001, 2, 3));
            Assert.AreEqual(model.ResultSet1[1].DateTimeValue, new DateTime(2004, 5, 6));
        }
Esempio n. 14
0
        public void SqlServer_MultipleResultSets_Work()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo  = new SqlServerIntegrationRepository(GetConnection());
            var model = repo.ToMultipleResultSetModel();

            Assert.AreEqual(model.ResultSet0.Count, 2);
            Assert.AreEqual(model.ResultSet0[0].IntValue, 147);
            Assert.AreEqual(model.ResultSet0[1].IntValue, 192);
            Assert.AreEqual(model.ResultSet0[0].BoolValue, true);
            Assert.AreEqual(model.ResultSet0[1].BoolValue, false);

            Assert.AreEqual(model.ResultSet1.Count, 2);
            Assert.AreEqual(model.ResultSet1[0].StringValue, "abc");
            Assert.AreEqual(model.ResultSet1[1].StringValue, "def");
            Assert.AreEqual(model.ResultSet1[0].DateTimeValue, new DateTime(2001, 2, 3));
            Assert.AreEqual(model.ResultSet1[1].DateTimeValue, new DateTime(2004, 5, 6));
        }
Esempio n. 15
0
        public void SqlServer_SprocWithSchema_Works()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());
            Assert.AreEqual(123, repo.SprocWithSchema());
        }
Esempio n. 16
0
        public void SqlServer_ToScalarNull_Works()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());
            Assert.IsNull(repo.ToScalarNull());
        }
Esempio n. 17
0
        public void SqlServer_ToScalar_Works()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());
            Assert.AreEqual(142, repo.ToScalar());
        }
Esempio n. 18
0
 public void SqlServer_DDLStatement_DoesntCrash()
 {
     var repo = new SqlServerIntegrationRepository(GetConnection());
     repo.ExecuteAdHocQuery("CREATE DATABASE datafacetestddl");
     repo.ExecuteAdHocQuery("DROP DATABASE datafacetestddl");
 }
Esempio n. 19
0
        public void SqlServer_RollbackTransaction_DoesntHaveSideEffect()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());
            using (var transaction = repo.WithTransaction()) {
                repo.SprocWithSideEffect();
                transaction.Rollback();
            }

            Assert.AreEqual(0, repo.GetCountOfSideEffects());
        }
Esempio n. 20
0
        public void SqlServer_ToFirstOrDefault_WithValue_Works()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new SqlServerIntegrationRepository(GetConnection());
            Assert.AreEqual(1, repo.ToFirstOrDefaultScalar1());
        }