public void ExecuteDeleteWithOldValuesException () { SqlPoker sql = new SqlPoker (); sql.ConnectionString = "Data Source=fake\\SQLEXPRESS;Initial Catalog=Northwind;User ID=sa"; sql.ProviderName = "System.Data.SqlClient"; CustomSqlDataSourceView view = new CustomSqlDataSourceView (sql, "TestView", null); view.SelectCommandType = SqlDataSourceCommandType.Text; view.SelectCommand = "SELECT * FROM products WHERE ProductID = @ProductID;"; view.DeleteCommandType = SqlDataSourceCommandType.Text; view.DeleteCommand = "DELETE * FROM products WHERE ProductID = @ProductID;"; view.DeleteParameters.Add (new Parameter ("ProductId", TypeCode.Int32, "15")); view.OldValuesParameterFormatString = "origin_{0}"; view.ConflictDetection = ConflictOptions.CompareAllValues; view.Deleting += new SqlDataSourceCommandEventHandler (view_Deleting); Hashtable oldvalue = new Hashtable (); oldvalue.Add ("ProductID", 10); view.Delete (null, null); }
public void ExecuteDeleteException () { SqlPoker sql = new SqlPoker (); sql.ConnectionString = "Data Source=fake\\SQLEXPRESS;Initial Catalog=Northwind;User ID=sa"; sql.ProviderName = "System.Data.SqlClient"; CustomSqlDataSourceView view = new CustomSqlDataSourceView (sql, "TestView", null); view.Delete (null, null); }
public void ExecuteDelete_KeysAndOldValues_OverwriteChanges () { SqlPoker sql = new SqlPoker (); sql.ConnectionString = "Data Source=fake\\SQLEXPRESS;Initial Catalog=Northwind;User ID=sa"; sql.ProviderName = "System.Data.SqlClient"; CustomSqlDataSourceView view = new CustomSqlDataSourceView (sql, "TestView", null); IDictionary keys; IDictionary values; IDictionary oldValues; InitializeView (view, out keys, out values, out oldValues); view.ConflictDetection = ConflictOptions.OverwriteChanges; view.Delete (keys, oldValues); Assert.IsNotNull (CustomEventParameterCollection, "KeysAndOldValues_OverwriteChanges"); Assert.AreEqual ("String:@origin_ProductID=k_10", PassedParameters, "KeysAndOldValues_OverwriteChanges Values"); }
public void ExecuteDelete_KeysAndOldValues_CompareAllValues2 () { SqlPoker sql = new SqlPoker (); sql.ConnectionString = "Data Source=fake\\SQLEXPRESS;Initial Catalog=Northwind;User ID=sa"; sql.ProviderName = "System.Data.SqlClient"; CustomSqlDataSourceView view = new CustomSqlDataSourceView (sql, "TestView", null); IDictionary keys; IDictionary values; IDictionary oldValues; InitializeView (view, out keys, out values, out oldValues); view.DeleteParameters.Add ("origin_ProductID", "po_10"); view.ConflictDetection = ConflictOptions.CompareAllValues; view.Delete (keys, oldValues); Assert.IsNotNull (CustomEventParameterCollection, "ExecuteDelete_KeysAndOldValues_CompareAllValues2"); string [] expectedParams = new string [] { "String:@origin_ProductID=ov_10", "String:@origin_Name=ov_ColorTV", "String:@origin_Description=ov_Beautifull" }; string [] actualValues = PassedParameters.Split (new string [] { ", " }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual (expectedParams.Length, actualValues.Length, "ExecuteDelete_KeysAndOldValues_CompareAllValues2 Params count"); ValidatePassedParams (expectedParams, actualValues, "ExecuteDelete_KeysAndOldValues_CompareAllValues2 expecte '{0}'"); }
public void ExecuteDeleteWithMergedValues () { SqlPoker sql = new SqlPoker (); sql.ConnectionString = "Data Source=fake\\SQLEXPRESS;Initial Catalog=Northwind;User ID=sa"; sql.ProviderName = "System.Data.SqlClient"; CustomSqlDataSourceView view = new CustomSqlDataSourceView (sql, "TestView", null); view.SelectCommandType = SqlDataSourceCommandType.Text; view.SelectCommand = "SELECT * FROM products WHERE ProductID = @ProductID;"; view.DeleteCommandType = SqlDataSourceCommandType.Text; view.DeleteCommand = "DELETE * FROM products WHERE ProductID = @ProductID;"; view.DeleteParameters.Add (new Parameter ("ProductId", TypeCode.Int32, "15")); view.OldValuesParameterFormatString = "origin_{0}"; view.Deleting += new SqlDataSourceCommandEventHandler (view_Deleting); Hashtable value = new Hashtable (); value.Add ("Desc", "Description"); view.Delete (value, null); Assert.IsNotNull (CustomEventParameterCollection, "Delete event not fired"); Assert.AreEqual (2, CustomEventParameterCollection.Count, "Parameter count"); Assert.AreEqual ("@ProductId", CustomEventParameterCollection[0].ParameterName, "Parameter name#1"); Assert.AreEqual (15, CustomEventParameterCollection[0].Value, "Parameter value#1"); Assert.AreEqual ("@origin_Desc", CustomEventParameterCollection[1].ParameterName, "Parameter name#2"); Assert.AreEqual ("Description", CustomEventParameterCollection[1].Value, "Parameter value#2"); }