Esempio n. 1
0
        public void TestQueryFunctionsWithInvalidQueries()
        {
            wrapper = new MySQLWrapper("s403g01.cpsc.ucalgary.ca", "ismacaul_HospiPalTestDB", "ismacaul_seng403", "seng403");
            string query = "INSERT INTO table VALUES (1);";
            Assert.False(wrapper.Insert(query));

            query = "UPDATE table SET TestColumn = 2 WHERE TestColumn = 1";
            Assert.False(wrapper.Update(query));

            query = "SELECT * FROM table";
            List<object[]> returnList = wrapper.Select(query);
            Assert.True(returnList == null);

            query = "DELETE FROM table WHERE TestColumn = 2;";
            Assert.False(wrapper.Delete(query));
        }
Esempio n. 2
0
        public void TestQueryFunctionWithValidQueries()
        {
            wrapper = new MySQLWrapper("s403g01.cpsc.ucalgary.ca", "ismacaul_HospiPalTestDB", "ismacaul_seng403", "seng403");
            string query = "INSERT INTO TestTable VALUES (1);";
            Assert.True(wrapper.Insert(query));

            query = "UPDATE TestTable SET TestColumn = 2 WHERE TestColumn = 1";
            Assert.True(wrapper.Update(query));

            query = "SELECT * FROM TestTable";
            List<object[]> returnList = wrapper.Select(query);
            object[] row = returnList[0];
            int value = (int)row[0];
            Assert.True(value == 2);

            query = "DELETE FROM TestTable WHERE TestColumn = 2;";
            Assert.True(wrapper.Delete(query));
        }