public void ObjectDisposing () { ObjectViewPoker view = new ObjectViewPoker (new ObjectDataSource (), "", null); view.ObjectDisposing += new ObjectDataSourceDisposingEventHandler (view_ObjectDisposing); view.DoOnObjectDisposing (new ObjectDataSourceDisposingEventArgs (null)); Eventassert ("ObjectDisposing"); }
public void ObjectDataSourceView_DataSourceViewChanged () { ObjectDataSource ds = new ObjectDataSource (); ObjectViewPoker sql = new ObjectViewPoker (ds, "DefaultView", null); sql.DataSourceViewChanged += new EventHandler (sql_DataSourceViewChanged); sql.DoOnDataSourceViewChanged (); eventAssert.IsTrue ("DataSourceViewChanged"); sql.ConflictDetection = ConflictOptions.CompareAllValues; eventAssert.IsTrue ("DataSourceViewChanged"); sql.ConvertNullToDBNull = true; eventAssert.IsFalse ("DataSourceViewChanged"); sql.DataObjectTypeName = "test"; eventAssert.IsTrue ("DataSourceViewChanged"); sql.DeleteMethod = "test"; eventAssert.IsFalse ("DataSourceViewChanged"); sql.EnablePaging = true; eventAssert.IsTrue ("DataSourceViewChanged"); sql.InsertMethod = "test"; eventAssert.IsFalse ("DataSourceViewChanged"); sql.FilterExpression = "test"; eventAssert.IsTrue ("DataSourceViewChanged"); sql.MaximumRowsParameterName = "test"; eventAssert.IsTrue ("DataSourceViewChanged"); sql.SelectCountMethod = "test"; eventAssert.IsTrue ("DataSourceViewChanged"); sql.SelectMethod = "test"; eventAssert.IsTrue ("DataSourceViewChanged"); sql.OldValuesParameterFormatString = "test"; eventAssert.IsTrue ("DataSourceViewChanged"); sql.StartRowIndexParameterName = "test"; eventAssert.IsTrue ("DataSourceViewChanged"); sql.TypeName = "test"; eventAssert.IsTrue ("DataSourceViewChanged"); sql.UpdateMethod = "test"; eventAssert.IsFalse ("DataSourceViewChanged"); }
public void DeleteEvent () { ObjectViewPoker view = new ObjectViewPoker (new ObjectDataSource (), "", null); view.Deleting += new ObjectDataSourceMethodEventHandler (Event); view.DoOnDeleting (new ObjectDataSourceMethodEventArgs (null)); Eventassert ("DeletingEvent"); view.Deleted += new ObjectDataSourceStatusEventHandler (view_Status); view.DoOnDeleted (new ObjectDataSourceStatusEventArgs (null, null)); Eventassert ("DeletedEvent"); }
public void FilterEvent () { ObjectViewPoker view = new ObjectViewPoker (new ObjectDataSource (), "", null); view.Filtering += new ObjectDataSourceFilteringEventHandler (view_Filtering); view.DoOnFiltering (new ObjectDataSourceFilteringEventArgs (null)); Eventassert ("FilterEvent"); }
public void OldValuesParameterFormatString () { ObjectDataSource ds = new ObjectDataSource (); Assert.AreEqual ("{0}", ds.OldValuesParameterFormatString, "A1"); ds.OldValuesParameterFormatString = "hi {0}"; ObjectViewPoker sql = new ObjectViewPoker (ds, "DefaultView", null); Assert.AreEqual ("{0}", sql.OldValuesParameterFormatString, "A2"); ds.OldValuesParameterFormatString = "hi {0}"; Assert.AreEqual ("{0}", sql.OldValuesParameterFormatString, "A3"); ds.OldValuesParameterFormatString = "{0}"; sql.OldValuesParameterFormatString = "hi {0}"; Assert.AreEqual ("{0}", ds.OldValuesParameterFormatString, "A4"); }
public void SelectEvent () { ObjectViewPoker view = new ObjectViewPoker (new ObjectDataSource (), "", null); view.Selecting += new ObjectDataSourceSelectingEventHandler (view_Selecting); view.DoOnSelecting (new ObjectDataSourceSelectingEventArgs (null, new DataSourceSelectArguments (), false)); Eventassert ("SelectingEvent"); view.Selected += new ObjectDataSourceStatusEventHandler (view_Status); view.DoOnSelected (new ObjectDataSourceStatusEventArgs (null, null)); Eventassert ("SelectedEvent"); }
public void DefaultsAssignProperties () { ObjectDataSource ds = new ObjectDataSource (); ObjectViewPoker sql = new ObjectViewPoker (ds, "DefaultView", null); sql.ConflictDetection = ConflictOptions.CompareAllValues; Assert.AreEqual (ConflictOptions.CompareAllValues, sql.ConflictDetection, "ConflictDetection"); sql.ConvertNullToDBNull = true; Assert.IsTrue (sql.ConvertNullToDBNull, "ConvertNullToDBNull"); sql.DataObjectTypeName = "test"; Assert.AreEqual ("test", sql.DataObjectTypeName, "DataObjectTypeName"); sql.DeleteMethod = "test"; Assert.AreEqual ("test", sql.DeleteMethod, "DeleteMethod"); sql.EnablePaging = true; Assert.IsTrue (sql.EnablePaging, "EnablePaging"); sql.InsertMethod = "test"; Assert.AreEqual ("test", sql.InsertMethod, "InsertMethod"); sql.FilterExpression = "test"; Assert.AreEqual ("test", sql.FilterExpression, "FilterExpression"); sql.MaximumRowsParameterName = "test"; Assert.AreEqual ("test", sql.MaximumRowsParameterName, "MaximumRowsParameterName"); sql.SelectCountMethod = "test"; Assert.AreEqual ("test", sql.SelectCountMethod, "SelectCountMethod"); sql.SelectMethod = "test"; Assert.AreEqual ("test", sql.SelectMethod, "SelectMethod"); sql.OldValuesParameterFormatString = "test"; Assert.AreEqual ("test", sql.OldValuesParameterFormatString, "OldValuesParameterFormatString"); sql.StartRowIndexParameterName = "test"; Assert.AreEqual ("test", sql.StartRowIndexParameterName, "StartRowIndexParameterName"); sql.TypeName = "test"; Assert.AreEqual ("test", sql.TypeName, "TypeName"); sql.UpdateMethod = "test"; Assert.AreEqual ("test", sql.UpdateMethod, "UpdateMethod"); Assert.AreEqual ("DefaultView", sql.Name, "Name"); }
public void CanUpdate () { ObjectDataSource ds = new ObjectDataSource (); ObjectViewPoker sql = new ObjectViewPoker (ds, "DefaultView", null); sql.UpdateMethod = "UpdateMethod"; Assert.IsTrue (sql.CanUpdate, "A1"); sql.UpdateMethod = ""; Assert.IsFalse (sql.CanUpdate, "A2"); sql.UpdateMethod = null; Assert.IsFalse (sql.CanUpdate, "A3"); }
public void ParametersAndViewChangedEvent_DontMatchDelete () { ObjectViewPoker view = new ObjectViewPoker (new ObjectDataSource (), "", null); Hashtable keys = null; Hashtable old_values = null; Hashtable new_values = null; InitializeView (view, InitViewType.DontMatchParams, out keys, out old_values, out new_values); view.Delete (keys, old_values); Assert.IsNotNull (eventsCalled, "Events not raized"); Assert.AreEqual (3, eventsCalled.Count, "Events Count"); Assert.AreEqual ("DeleteParameters_ParametersChanged", eventsCalled [0], "DeleteParameters_ParametersChanged"); Assert.AreEqual ("DeleteOther(oldvalue_ID = k_1001, OtherValue = p_OtherValueDelete1)", eventsCalled [1], "DataSource Method params"); Assert.AreEqual ("view_DataSourceViewChanged", eventsCalled [2], "view_DataSourceViewChanged"); }
public void Defaults () { ObjectDataSource ds = new ObjectDataSource (); ObjectViewPoker sql = new ObjectViewPoker (ds, "DefaultView", null); Assert.IsFalse (sql.CanDelete, "CanDelete"); Assert.IsFalse (sql.CanInsert, "CanInsert"); Assert.IsFalse (sql.CanPage, "CanPage"); Assert.IsTrue (sql.CanSort, "CanSort"); Assert.IsFalse (sql.CanUpdate, "CanUpdate"); Assert.AreEqual (ConflictOptions.OverwriteChanges, sql.ConflictDetection, "ConflictDetection"); Assert.IsFalse (sql.ConvertNullToDBNull, "ConvertNullToDBNull"); Assert.AreEqual ("", sql.DataObjectTypeName, "DataObjectTypeName"); Assert.AreEqual ("", sql.DeleteMethod, "DeleteMethod"); Assert.IsNotNull (sql.DeleteParameters, "DeleteParameters"); Assert.AreEqual (0, sql.DeleteParameters.Count, "DeleteParameters.Count"); Assert.IsFalse (sql.EnablePaging, "EnablePaging"); Assert.AreEqual ("", sql.InsertMethod, "InsertMethod"); Assert.IsNotNull (sql.InsertParameters, "InsertParameters"); Assert.AreEqual (0, sql.InsertParameters.Count, "InsertParameters.Count"); Assert.AreEqual ("", sql.FilterExpression, "FilterExpression"); Assert.IsNotNull (sql.FilterParameters, "FilterParameters"); Assert.AreEqual (0, sql.FilterParameters.Count, "FilterParameters.Count"); Assert.AreEqual ("maximumRows", sql.MaximumRowsParameterName, "MaximumRowsParameterName"); Assert.AreEqual ("", sql.SelectCountMethod, "SelectCountMethod"); Assert.AreEqual ("", sql.SelectMethod, "SelectMethod"); Assert.AreEqual ("{0}", sql.OldValuesParameterFormatString, "OldValuesParameterFormatString"); Assert.IsNotNull (sql.SelectParameters, "SelectParameters"); Assert.AreEqual (0, sql.SelectParameters.Count, "SelectParameters.Count"); Assert.AreEqual ("", sql.SortParameterName, "SortParameterName"); Assert.IsNotNull (sql.UpdateParameters, "UpdateParameters"); Assert.AreEqual (0, sql.UpdateParameters.Count, "UpdateParameters.Count"); Assert.AreEqual ("startRowIndex", sql.StartRowIndexParameterName, "StartRowIndexParameterName"); Assert.AreEqual ("", sql.TypeName, "TypeName"); Assert.AreEqual ("", sql.UpdateMethod, "UpdateMethod"); Assert.AreEqual (true, sql.GetIsTrackingViewState (), "IsTrackingViewState"); Assert.IsTrue (sql.CanRetrieveTotalRowCount, "CanRetrieveTotalRowCount"); }
public void ParametersAndViewChangedEvent_MatchOldInsert () { ObjectViewPoker view = new ObjectViewPoker (new ObjectDataSource (), "", null); Hashtable keys = null; Hashtable old_values = null; Hashtable new_values = null; InitializeView (view, InitViewType.MatchParamsToOldValues, out keys, out old_values, out new_values); view.Insert (new_values); Assert.IsNotNull (eventsCalled, "Events not raized"); Assert.AreEqual (3, eventsCalled.Count, "Events Count"); Assert.AreEqual ("InsertParameters_ParametersChanged", eventsCalled [0], "InsertParameters_ParametersChanged"); Assert.AreEqual ("Insert(ID = n_1001, oldvalue_ID = p_OldValueInsert1)", eventsCalled [1], "DataSource Method params"); Assert.AreEqual ("view_DataSourceViewChanged", eventsCalled [2], "view_DataSourceViewChanged"); }
public void ParametersAndViewChangedEvent_Select () { ObjectViewPoker view = new ObjectViewPoker (new ObjectDataSource (), "", null); Hashtable keys = null; Hashtable old_values = null; Hashtable new_values = null; InitializeView (view, InitViewType.MatchParamsToValues, out keys, out old_values, out new_values); view.Select (DataSourceSelectArguments.Empty); Assert.IsNotNull (eventsCalled, "Events not raized"); Assert.AreEqual (3, eventsCalled.Count, "Events Count"); Assert.AreEqual ("view_DataSourceViewChanged", eventsCalled [0], "view_DataSourceViewChanged"); Assert.AreEqual ("SelectParameters_ParametersChanged", eventsCalled [1], "SelectParameters_ParametersChanged"); Assert.AreEqual ("Select(filter = p_ValueSelect1)", eventsCalled [2], "DataSource Method params"); }
private static void InitializeView (ObjectViewPoker view, InitViewType initType, out Hashtable keys, out Hashtable old_value, out Hashtable new_value) { view.TypeName = typeof (DummyDataSourceObject).AssemblyQualifiedName; view.OldValuesParameterFormatString = "oldvalue_{0}"; view.SelectMethod = "Select"; if (initType == InitViewType.DontMatchParams) { view.UpdateMethod = "UpdateOther"; view.InsertMethod = "InsertOther"; view.DeleteMethod = "DeleteOther"; } else { view.UpdateMethod = "Update"; view.InsertMethod = "Insert"; view.DeleteMethod = "Delete"; } Parameter selectParameter = null; Parameter insertParameter = null; Parameter updateParameter = null; Parameter deleteParameter = null; selectParameter = new AlwaysChangingParameter ("filter", TypeCode.String, "p_ValueSelect"); view.SelectParameters.Add (selectParameter); switch (initType) { case InitViewType.MatchParamsToOldValues: insertParameter = new AlwaysChangingParameter ("oldvalue_ID", TypeCode.String, "p_OldValueInsert"); view.InsertParameters.Add (insertParameter); updateParameter = new AlwaysChangingParameter ("oldvalue_ID", TypeCode.String, "p_OldValueUpdate"); view.UpdateParameters.Add (updateParameter); deleteParameter = new AlwaysChangingParameter ("oldvalue_ID", TypeCode.String, "p_OldValueDelete"); view.DeleteParameters.Add (deleteParameter); break; case InitViewType.MatchParamsToValues: insertParameter = new AlwaysChangingParameter ("ID", TypeCode.String, "p_ValueInsert"); view.InsertParameters.Add (insertParameter); updateParameter = new AlwaysChangingParameter ("ID", TypeCode.String, "p_ValueUpdate"); view.UpdateParameters.Add (updateParameter); deleteParameter = new AlwaysChangingParameter ("ID", TypeCode.String, "p_ValueDelete"); view.DeleteParameters.Add (deleteParameter); break; case InitViewType.DontMatchParams: insertParameter = new AlwaysChangingParameter ("OtherValue", TypeCode.String, "p_OtherValueInsert"); view.InsertParameters.Add (insertParameter); updateParameter = new AlwaysChangingParameter ("OtherValue", TypeCode.String, "p_OtherValueUpdate"); view.UpdateParameters.Add (updateParameter); deleteParameter = new AlwaysChangingParameter ("OtherValue", TypeCode.String, "p_OtherValueDelete"); view.DeleteParameters.Add (deleteParameter); break; } view.SelectParameters.ParametersChanged += new EventHandler (SelectParameters_ParametersChanged); view.InsertParameters.ParametersChanged += new EventHandler (InsertParameters_ParametersChanged); view.UpdateParameters.ParametersChanged += new EventHandler (UpdateParameters_ParametersChanged); view.DeleteParameters.ParametersChanged += new EventHandler (DeleteParameters_ParametersChanged); keys = new Hashtable (); keys.Add ("ID", "k_1001"); old_value = new Hashtable (); old_value.Add ("ID", "ov_1001"); new_value = new Hashtable (); new_value.Add ("ID", "n_1001"); view.DataSourceViewChanged += new EventHandler (view_DataSourceViewChanged); }
public void SelectMethod_DataSourceViewChanged1 () { ObjectViewPoker view = new ObjectViewPoker (new ObjectDataSource (), "", null); view.DataSourceViewChanged+=new EventHandler(view_DataSourceViewChanged); view.SelectMethod = "select_1"; Assert.AreEqual (1, eventsCalled.Count); Assert.AreEqual ("view_DataSourceViewChanged", eventsCalled [0]); view.SelectMethod = "select_2"; Assert.AreEqual (2, eventsCalled.Count); Assert.AreEqual ("view_DataSourceViewChanged", eventsCalled [1]); view.SelectMethod = "select_2"; Assert.AreEqual (2, eventsCalled.Count); view.SelectCountMethod = "selectCount_1"; Assert.AreEqual (3, eventsCalled.Count); Assert.AreEqual ("view_DataSourceViewChanged", eventsCalled [2]); view.SelectCountMethod = "selectCount_2"; Assert.AreEqual (4, eventsCalled.Count); Assert.AreEqual ("view_DataSourceViewChanged", eventsCalled [3]); view.SelectCountMethod = "selectCount_2"; Assert.AreEqual (4, eventsCalled.Count); }
public void SelectMethod_DataSourceViewChanged2 () { ObjectViewPoker view = new ObjectViewPoker (new ObjectDataSource (), "", null); view.DataSourceViewChanged += new EventHandler (view_DataSourceViewChanged); Assert.AreEqual ("", view.SelectMethod); view.SelectMethod = null; Assert.AreEqual (1, eventsCalled.Count); Assert.AreEqual ("view_DataSourceViewChanged", eventsCalled [0]); Assert.AreEqual ("", view.SelectMethod); view.SelectMethod = null; Assert.AreEqual (2, eventsCalled.Count); Assert.AreEqual ("view_DataSourceViewChanged", eventsCalled [1]); Assert.AreEqual ("", view.SelectMethod); view.SelectMethod = ""; Assert.AreEqual (2, eventsCalled.Count); }