예제 #1
0
        public void MySql_ToFirstOrDefaultScalar_Works()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());

            Assert.AreEqual((string)null, repo.ToFirstOrDefaultScalar());
        }
예제 #2
0
        public void MySql_SprocWithSchema_ThrowsException()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());

            Assert.Throws <ArgumentException>(() => repo.SprocWithSchema());
        }
예제 #3
0
        public void MySql_ToScalar_Works()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());

            Assert.AreEqual(142, repo.ToScalar());
        }
예제 #4
0
        public void MySql_InsertRecord_Works()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());
            var result = repo.InsertRecord();

            Assert.AreEqual(1, result);
        }
예제 #5
0
        public void MySql_ManyManyTransactions_DoesntLeak()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            for (int ii = 0; ii < 1000; ii++) {
                var repo = new MySqlIntegrationRepository(GetConnection());
                repo.SprocWithParameter(1);
            }
        }
예제 #6
0
        public void MySql_SprocWithParameter_Works()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());

            Assert.AreEqual(143, repo.SprocWithParameter(143));
        }
예제 #7
0
        public void MySql_InsertRecord_Works()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo   = new MySqlIntegrationRepository(GetConnection());
            var result = repo.InsertRecord();

            Assert.AreEqual(1, result);
        }
예제 #8
0
        public void MySql_ManyManyTransactions_DoesntLeak()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            for (int ii = 0; ii < 1000; ii++)
            {
                var repo = new MySqlIntegrationRepository(GetConnection());
                repo.SprocWithParameter(1);
            }
        }
예제 #9
0
        public void MySql_CommitTransaction_HasSideEffect()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

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

            Assert.AreEqual(1, repo.GetCountOfSideEffects());
        }
예제 #10
0
        public void MySql_ToScalars_Works()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo   = new MySqlIntegrationRepository(GetConnection());
            var result = repo.ToScalars();

            Assert.AreEqual(3, result.Count);
            Assert.AreEqual(142, result[0]);
            Assert.AreEqual(143, result[1]);
            Assert.AreEqual(144, result[2]);
        }
예제 #11
0
        public void MySql_RollbackTransaction_DoesntHaveSideEffect()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());

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

            Assert.AreEqual(0, repo.GetCountOfSideEffects());
        }
예제 #12
0
        public void MySql_CommitTransaction_HasSideEffect()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());

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

            Assert.AreEqual(1, repo.GetCountOfSideEffects());
        }
예제 #13
0
        public void MySql_MultipleResultSets_Work()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(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));
        }
예제 #14
0
        public void MySql_MultipleResultSets_Work()
        {
            IDatabaseConnection connection = GetConnection();

            InitializeDatabase(connection);

            var repo  = new MySqlIntegrationRepository(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));
        }
예제 #15
0
        public void MySql_SprocWithSchema_ThrowsException()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());
            Assert.Throws<ArgumentException>(() => repo.SprocWithSchema());
        }
예제 #16
0
        public void MySql_ToScalars_Works()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());
            var result = repo.ToScalars();

            Assert.AreEqual(3, result.Count);
            Assert.AreEqual(142, result[0]);
            Assert.AreEqual(143, result[1]);
            Assert.AreEqual(144, result[2]);
        }
예제 #17
0
        public void MySql_ToScalar_Works()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());
            Assert.AreEqual(142, repo.ToScalar());
        }
예제 #18
0
        public void MySql_RollbackTransaction_DoesntHaveSideEffect()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

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

            Assert.AreEqual(0, repo.GetCountOfSideEffects());
        }
예제 #19
0
        public void MySql_SprocWithParameter_Works()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());
            Assert.AreEqual(143, repo.SprocWithParameter(143));
        }
예제 #20
0
        public void MySql_ToFirstOrDefaultScalar_Works()
        {
            IDatabaseConnection connection = GetConnection();
            InitializeDatabase(connection);

            var repo = new MySqlIntegrationRepository(GetConnection());
            Assert.AreEqual((string)null, repo.ToFirstOrDefaultScalar());
        }