public void TestMethodInsertIntoUserData() { Boolean expectedInsert = true; Boolean expectedDelete = true; string expectedUserName = "******"; string expectedPassword = "******"; string expectedFullName = "John Sampleson"; string expectedType = "SA"; List <object> bookstore = new List <object>( new object[] { expectedUserName, expectedPassword, expectedType, 0, expectedFullName } ); Boolean actualInsert = dbQ.INSERT_INTO_TABLE("UserData", bookstore); //Insert method for database Assert.AreEqual(expectedInsert, actualInsert); ds = dbQ.SELECT_FROM_TABLE("SELECT * FROM UserData WHERE UserName = '******'"); string actualUserName = ds.Tables[0].Rows[0]["UserName"].ToString(); string actualPassword = ds.Tables[0].Rows[0]["Password"].ToString(); string actualFullName = ds.Tables[0].Rows[0]["FullName"].ToString(); string actualType = ds.Tables[0].Rows[0]["Type"].ToString(); Assert.AreEqual(expectedUserName, actualUserName); Assert.AreEqual(expectedPassword, actualPassword); Assert.AreEqual(expectedFullName, actualFullName); Assert.AreEqual(expectedType, actualType); Boolean actualDelete = dbQ.DELETE_FROM_TABLE("DELETE FROM UserData WHERE UserName = '******'"); Assert.AreEqual(expectedDelete, actualDelete); }
public void TestMethodDeleteFromSupplier() { var c = new SqlConnection(Properties.Settings.Default.dbConnectionString); Boolean expectedInsert = true; Boolean expectedDelete = true; string expectedName = "Google"; int expectedSupplierID = dbG.GetID("Supplier", c); List <object> bookstore = new List <object>( new object[] { expectedName } ); Boolean actualInsert = dbQ.INSERT_INTO_TABLE("Supplier", bookstore); Assert.AreEqual(expectedInsert, actualInsert); ds = dbQ.SELECT_FROM_TABLE("SELECT * FROM Supplier WHERE Name = '" + expectedName + "'"); int actualSupplierID = Int32.Parse(ds.Tables[0].Rows[0]["SupplierId"].ToString()); string actualName = ds.Tables[0].Rows[0]["Name"].ToString(); Assert.AreEqual(expectedSupplierID, actualSupplierID); Assert.AreEqual(expectedName, actualName); //Delete from Database Boolean actualDelete = dbQ.DELETE_FROM_TABLE("DELETE FROM Supplier WHERE Name = '" + expectedName + "'"); Assert.AreEqual(expectedDelete, actualDelete); Boolean expectedFinalDeleteReturn = true; Boolean finalDeleteReturn = false; ds = dbQ.SELECT_FROM_TABLE("SELECT * FROM Supplier WHERE Name = '" + expectedName + "'"); if (ds.Tables[0].Rows.Count == 0) { finalDeleteReturn = true; } Assert.AreEqual(expectedFinalDeleteReturn, finalDeleteReturn); c.Close(); }