Exemplo n.º 1
0
		public void ObjectDataSource_InsertParametersCaseSensitive ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.SelectMethod = "GetMyData";
			view.InsertMethod = "Insert";

			Parameter p1, p2, p3;
			p1 = new Parameter ("id", TypeCode.String, "1001");
			p2 = new Parameter ("fname", TypeCode.String, "Mahesh");
			p3 = new Parameter ("lname", TypeCode.String, "chand");
			view.InsertParameters.Add (p1);
			view.InsertParameters.Add (p2);
			view.InsertParameters.Add (p3);

			//This hashtable ovveride 
			Hashtable value = new Hashtable ();
			value.Add ("t", "test_id");

			//Merge parameters
			view.ExecuteInsert (value);
			Assert.AreEqual (true, MyTableObject.InsertWithMergedParameters, "InsertParametersCaseSensitive");
		}
Exemplo n.º 2
0
		public void ObjectDataSource_UpdateExecute_DataObjectTypeName ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.DataObjectTypeName = typeof (NewData).AssemblyQualifiedName;
			
			view.SelectMethod = "GetMyData";
			view.UpdateMethod = "Update";
			view.OldValuesParameterFormatString = "oldvalue_{0}";
			view.ExecuteUpdate (null, null, null);
			Assert.AreEqual (true, MyTableObject.UpdateWithDataObjectTypeName, "UpdateExecute_DataObjectTypeName");
			Assert.AreEqual (", , ", MyTableObject.UpdatePassedValues, "UpdateExecute_DataObjectTypeName Values");
		}
Exemplo n.º 3
0
		public void ObjectDataSource_SelectExecuteCaseSensitive ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.SelectMethod = "GetMyData";
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.SelectParameters.Add (new Parameter ("fname", TypeCode.String, "TestSelect"));
			ArrayList ls = (ArrayList) view.ExecuteSelect (new DataSourceSelectArguments (""));
			Assert.AreEqual ("TestSelect", ls[0], "SelectExecuteCaseSensitive");
		}
Exemplo n.º 4
0
		public void ObjectDataSource_DeleteExecuteDataTypeCompareAllValues () 
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.DataObjectTypeName = typeof (NewData).AssemblyQualifiedName;
			view.SelectMethod = "GetMyData";
			view.DeleteMethod = "Delete";
			view.ConflictDetection = ConflictOptions.CompareAllValues;
			Hashtable keys;
			Hashtable old_value;
			Hashtable new_value;
			InitializeView (view, out keys, out old_value, out new_value);

			view.ExecuteDelete (keys, old_value);
			Assert.AreEqual (true, MyTableObject.DeleteWithDataObjectTypeName, "DeleteExecuteDataTypeCompareAllValues");
			Assert.AreEqual ("ov_1001, ov_Mahesh, ov_chand", MyTableObject.UpdatePassedValues, "DeleteExecuteDataTypeCompareAllValues Values");
		}
Exemplo n.º 5
0
		public static void SelectMethodCached (Page p)
		{
			MyTableObject.ds = MyTableObject.CreateDataTable ();
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			ods.EnableCaching = true;
			InitObjectDataSource (ods, "");
			p.Controls.Add (ods);
			ods.Selecting += new ObjectDataSourceSelectingEventHandler (odc_Selecting);

			selecting = false;
			IEnumerable table = (IEnumerable) ods.Select ();
			Assert.AreEqual (true, selecting, "AfterSelectingEvent");

			selecting = false;
			IEnumerable table2 = (IEnumerable) ods.Select ();
			Assert.AreEqual (false, selecting, "AfterSelectingEvent");
		}
Exemplo n.º 6
0
		public static void UpdateMethod (Page p)
		{
			MyTableObject.ds = MyTableObject.CreateDataTable ();  
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "update");
			ods.Updated += new ObjectDataSourceStatusEventHandler (odc_Updated);
			ods.Updating += new ObjectDataSourceMethodEventHandler (odc_Updating);
			p.Controls.Add (ods);
			Assert.AreEqual (3, ((DataView) ods.Select ()).Count, "BeforeUpdate1");
			Assert.AreEqual (1001, ((DataView) ods.Select ())[0].Row.ItemArray[0], "BeforeUpdate2");
			Assert.AreEqual ("Mahesh", ((DataView) ods.Select ())[0].Row.ItemArray[1], "BeforeUpdate3");
			Assert.AreEqual ("Chand", ((DataView) ods.Select ())[0].Row.ItemArray[2], "BeforeUpdate4");
			Assert.AreEqual (false, updated, "BeforeUpdateEvent");
			Assert.AreEqual (false, updating, "BeforeUpdatingEvent");
			ods.Update ();
			Assert.AreEqual (3, ((DataView) ods.Select ()).Count, "AfterUpdate1");
			Assert.AreEqual (1001, ((DataView) ods.Select ())[0].Row.ItemArray[0], "AfterUpdate2");
			Assert.AreEqual ("David", ((DataView) ods.Select ())[0].Row.ItemArray[1], "AfterUpdate3");
			Assert.AreEqual ("Eli", ((DataView) ods.Select ())[0].Row.ItemArray[2], "AfterUpdate4");
			Assert.AreEqual (true, updated, "AfterUpdateEvent");
			Assert.AreEqual (true, updating, "AfterUpdatingEvent");
		}
Exemplo n.º 7
0
		public static void EnableCachingException (Page p)
		{
			MyTableObject.ds = MyTableObject.CreateDataTable ();
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			ods.SelectMethod = "SelectException";
			ods.EnableCaching = true;			
			p.Controls.Add (ods);			
			IEnumerable table = (IEnumerable) ods.Select ();
			
		}
Exemplo n.º 8
0
		public static void DeleteMethod (Page p)
		{
			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
			MyTableObject.ds = MyTableObject.CreateDataTable ();  
			DetailsView dv = new DetailsView ();
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			ods.Deleted += new ObjectDataSourceStatusEventHandler (odc_Deleted);
			ods.Deleting += new ObjectDataSourceMethodEventHandler (odc_Deleting);	
			InitObjectDataSource (ods,"");
			dv.Page = p;
			ods.Page = p;
			dv.DataKeyNames = new string[] { "ID" };
			dv.DataSource = ods;
			p.Controls.Add (lcb); 
			p.Controls.Add (ods);
			p.Controls.Add (dv);
			p.Controls.Add (lce); 
			dv.DataBind ();
			Assert.AreEqual (3, dv.DataItemCount, "BeforeDelete1");
			Assert.AreEqual (1001, dv.SelectedValue, "BeforeDelete2");
			Assert.AreEqual (false, deleting, "BeforeDeletingEvent");
			Assert.AreEqual (false, deleted, "BeforeDeletedEvent");
			ods.Delete ();			
			dv.DataBind ();
			Assert.AreEqual (true, deleting, "AfterDeletingEvent");
			Assert.AreEqual (true, deleted, "AfterDeletedEvent");
			Assert.AreEqual (2, dv.DataItemCount, "BeforeDelete1");
			Assert.AreEqual (1002, dv.SelectedValue, "BeforeDelete2");
		}
Exemplo n.º 9
0
		public void ObjectDataSource_DeleteExecuteMethodParameterException()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.SelectMethod = "GetMyData";
			view.DeleteMethod = "delete";
			Parameter p1, p2, p3;
			p1 = new Parameter ("ID", TypeCode.String, "1001");
			view.DeleteParameters.Add (p1);
			view.OldValuesParameterFormatString = "oldvalue_{0}";
			Hashtable value = new Hashtable ();
			value.Add ("ID", "test_id");
			view.ExecuteDelete (value, null);
		}
Exemplo n.º 10
0
		public void ObjectDataSource_SelectExecuteException_2 ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.SelectMethod = "Fake";
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.SelectParameters.Add (new Parameter ("Fname", TypeCode.String, "TestSelect"));
			IEnumerable res = view.ExecuteSelect (new DataSourceSelectArguments (""));
		}
Exemplo n.º 11
0
		public void ObjectDataSource_UpdateExecute_CompareAllValues_Exception ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.SelectMethod = "GetMyData";
			view.UpdateMethod = "TryUpdate_1";
			Parameter p1, p2, p3;
			p1 = new Parameter ("ID", TypeCode.String, "1001");
			p2 = new Parameter ("FName", TypeCode.String, "Mahesh");
			p3 = new Parameter ("LName", TypeCode.String, "chand");
			view.UpdateParameters.Add (p1);
			view.UpdateParameters.Add (p2);
			view.UpdateParameters.Add (p3);

			view.OldValuesParameterFormatString = "oldvalue_{0}";
			view.ConflictDetection = ConflictOptions.CompareAllValues;
			view.ExecuteUpdate (null, null, null);
		}
Exemplo n.º 12
0
		public void ObjectDataSource_DataSourceChanged ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			((IDataSource) ods).DataSourceChanged += new EventHandler (ObjectDataSourceTest_DataSourceChanged);
			
			// Check if event raised
			ods.DoRaiseDataSourceChangedEvent ();
			Assert.IsTrue (eventChecker, "DataSourceChanged#1");

			eventChecker = false;
			ods.ConflictDetection = ConflictOptions.CompareAllValues;
			Assert.IsFalse (eventChecker, "DataSourceChanged#2");

			eventChecker = false;
			ods.DataObjectTypeName = "MyData";
			Assert.IsFalse (eventChecker, "DataSourceChanged#3");

			eventChecker = false;
			ods.EnablePaging = true;
			Assert.IsFalse (eventChecker, "DataSourceChanged#4");

			eventChecker = false;
			ods.FilterExpression = "ID='{0}'";
			Assert.IsFalse (eventChecker, "DataSourceChanged#5");


			eventChecker = false;
			TextBox TextBox1 = new TextBox ();
			TextBox1.Text = "1001";
			FormParameter p = new FormParameter ("ID", "TextBox1");
			p.DefaultValue = "1002";
			ods.FilterParameters.Add (p);
			Assert.IsFalse (eventChecker, "DataSourceChanged#6");

			eventChecker = false;
			ods.MaximumRowsParameterName = "SelectCount";
			Assert.IsFalse (eventChecker, "DataSourceChanged#7");

			eventChecker = false;
			ods.OldValuesParameterFormatString = "ID";
			Assert.IsFalse (eventChecker, "DataSourceChanged#8");

			eventChecker = false;
			Parameter dummy = new Parameter ();
			dummy.Name = "Test";
			ods.SelectParameters.Add (dummy);
			Assert.IsFalse (eventChecker, "DataSourceChanged#9");

			eventChecker = false;
			ods.SortParameterName = "sortExpression";
			Assert.IsFalse (eventChecker, "DataSourceChanged#10");

			eventChecker = false;
			ods.StartRowIndexParameterName = "ID";
			Assert.IsFalse (eventChecker, "DataSourceChanged#11");

			eventChecker = false; 
			ods.CacheDuration = 1000;
			Assert.IsFalse (eventChecker, "DataSourceChanged#12");

			eventChecker = false;
			ods.CacheExpirationPolicy = DataSourceCacheExpiry.Sliding;
			Assert.IsFalse (eventChecker, "DataSourceChanged#13");

			eventChecker = false;
			ods.CacheKeyDependency = "ID";
			Assert.IsFalse (eventChecker, "DataSourceChanged#14");

			eventChecker = false;
			ods.ConvertNullToDBNull = true;
			Assert.IsFalse (eventChecker, "DataSourceChanged#15");

			eventChecker = false;
			ods.EnableCaching = true;
			Assert.IsFalse (eventChecker, "DataSourceChanged#16");

			eventChecker = false;
			ods.SqlCacheDependency = "Northwind:Employees";
			Assert.IsFalse (eventChecker, "DataSourceChanged#17");
		}
Exemplo n.º 13
0
		public void ObjectDataSource_UpdateExecute_DataObjectTypeName2 () 
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.DataObjectTypeName = typeof (NewData).AssemblyQualifiedName;

			view.SelectMethod = "GetMyData";
			view.UpdateMethod = "Update";
			view.OldValuesParameterFormatString = "oldvalue_{0}";
			view.ConflictDetection = ConflictOptions.OverwriteChanges;
			Hashtable keys;
			Hashtable old_value;
			Hashtable new_value;
			InitializeView (view, out keys, out old_value, out new_value);

			view.ExecuteUpdate (keys, new_value, old_value);
			Assert.AreEqual (true, MyTableObject.UpdateWithDataObjectTypeName, "UpdateExecute_DataObjectTypeName2");
			Assert.AreEqual ("n_1001, n_Mahesh, n_chand", MyTableObject.UpdatePassedValues, "UpdateExecute_DataObjectTypeName Values");
		}
Exemplo n.º 14
0
		public static void FilterParameter (Page p)
		{
			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
			DataGrid dg = new DataGrid ();
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			ods.FilterExpression = "{0}";
			Parameter p1 = new Parameter ("ID", TypeCode.String, "ID=1003");
			ods.FilterParameters.Add (p1); 
			p.Controls.Add (lcb);
			p.Controls.Add (dg);
			p.Controls.Add (ods);
			p.Controls.Add (lce);
			dg.DataSource = ods;
			dg.DataBind ();

		}
Exemplo n.º 15
0
		public static void FilterExpressionException (Page p)
		{
			MyTableObject.ds = MyTableObject.CreateDataTable ();
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			ods.SelectMethod = "SelectException";
			ods.FilterExpression  = "ID='1001'";
			p.Controls.Add (ods);
			IEnumerable table = (IEnumerable) ods.Select ();
		}
Exemplo n.º 16
0
		public static void EnablePaging (Page p)
		{
			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
			GridView  gv = new GridView ();
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			ods.ID = "ObjectDataSource1";
			ods.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			ods.SelectMethod = "SelectForPaging";
			ods.EnablePaging = true;
			ods.SelectCountMethod = "SelectCount";
			ods.MaximumRowsParameterName = "maxRows";
			ods.StartRowIndexParameterName = "startIndex";
			gv.AllowPaging = true;
			gv.PageSize = 5;
			p.Controls.Add (lcb);
			p.Controls.Add (gv);
			p.Controls.Add (ods);
			p.Controls.Add (lce);
			gv.DataSourceID = "ObjectDataSource1";
			gv.DataBind ();	

		}
Exemplo n.º 17
0
		public static void InitObjectDataSource (ObjectDataSourcePoker ds, string action)
		{
			Parameter p1, p2, p3;
			switch (action) {		
				
			case "insert":	p1 = new Parameter ("ID", TypeCode.String, "1004");
					p2 = new Parameter ("fname", TypeCode.String, "David");
					p3 = new Parameter ("LName", TypeCode.String, "Eli");
					break;
				
			case "update": 	p1 = new Parameter ("ID", TypeCode.String, "1001");
					p2 = new Parameter ("FName", TypeCode.String, "David");
					p3 = new Parameter ("LName", TypeCode.String, "Eli");
					break;
			case "DBNull":  p1 = new Parameter ("ID");
					p2 = new Parameter ("FName");
					p3 = new Parameter ("LName");
					break;
				
			default: 	p1 = new Parameter ("ID", TypeCode.String, "1001");
					p2 = new Parameter ("FName", TypeCode.String, "Mahesh");
					p3 = new Parameter ("LName", TypeCode.String, "chand");
					break;
				
			}
			ds.SelectMethod = "GetMyData";
			ds.DeleteMethod = "Delete";
			ds.InsertMethod = "Insert";
			ds.UpdateMethod = "Update";
			ds.SelectCountMethod = "SelectCount";
			ds.DeleteParameters.Add (p1);
			ds.DeleteParameters.Add (p2);
			ds.DeleteParameters.Add (p3);
			ds.InsertParameters.Add (p1);
			ds.InsertParameters.Add (p2);
			ds.InsertParameters.Add (p3);
			ds.UpdateParameters.Add (p1);
			ds.UpdateParameters.Add (p2);
			ds.UpdateParameters.Add (p3);
			ds.ID = "MyObject";
			ds.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
										      

		}
Exemplo n.º 18
0
		public static void SelectMethod (Page p)
		{
			MyTableObject.ds = MyTableObject.CreateDataTable ();  
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods,"");			
			ods.Selected += new ObjectDataSourceStatusEventHandler (odc_Selected);
			ods.Selecting += new ObjectDataSourceSelectingEventHandler (odc_Selecting);
			p.Controls.Add (ods);
			Assert.AreEqual (false, selecting, "BeforeSelectingEvent");
			Assert.AreEqual (false, selected, "BeforeSelectedEvent");			
			IEnumerable table = (IEnumerable) ods.Select ();
			Assert.AreEqual (3,((DataView) table).Count, "ItemsCount");
			Assert.AreEqual ("Mahesh", ((DataView) table)[0].Row.ItemArray[1], "FirstItemData");
			Assert.AreEqual (1002, ((DataView) table)[1].Row.ItemArray[0], "SecondItemData");
			Assert.AreEqual ("Bansal", ((DataView) table)[2].Row.ItemArray[2], "ThirdItemData");			
			Assert.AreEqual (true, selecting, "AfterSelectingEvent");
			Assert.AreEqual (true, selected, "AfterSelectedEvent");
		}
Exemplo n.º 19
0
		public void ObjectDataSource_DefaultProperties ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			
			Assert.AreEqual (ConflictOptions.OverwriteChanges, ods.ConflictDetection, "ConflictDetection");			
			Assert.AreEqual ("",ods.DataObjectTypeName ,"DataObjectTypeName ");
			Assert.AreEqual ("", ods.DeleteMethod, "DeleteMethod");
			Assert.AreEqual (typeof(ParameterCollection),ods.DeleteParameters.GetType (),"DeleteParameters");			
			Assert.AreEqual (false, ods.EnablePaging, "EnablePaging ");
			Assert.AreEqual ("", ods.FilterExpression, "FilterExpression ");
			Assert.AreEqual (typeof (ParameterCollection), ods.FilterParameters.GetType (), "FilterParameters");
			Assert.AreEqual ("", ods.InsertMethod, "InsertMethod ");
			Assert.AreEqual (typeof (ParameterCollection), ods.InsertParameters.GetType (), "InsertParameters ");
			Assert.AreEqual ("maximumRows", ods.MaximumRowsParameterName, "MaximumRowsParameterName");
			Assert.AreEqual ("{0}", ods.OldValuesParameterFormatString, "OldValuesParameterFormatString");
			Assert.AreEqual ("", ods.SelectCountMethod, "SelectCountMethod");
			Assert.AreEqual ("", ods.SelectMethod, "SelectMethod ");
			Assert.AreEqual (typeof (ParameterCollection), ods.SelectParameters.GetType (), "SelectParameters");
			Assert.AreEqual ("", ods.SortParameterName, "SortParameterName");			
			Assert.AreEqual ("startRowIndex", ods.StartRowIndexParameterName, "StartRowIndexParameterName");
			Assert.AreEqual ("", ods.TypeName, "TypeName");
			Assert.AreEqual ("", ods.UpdateMethod, "UpdateMethod ");
			Assert.AreEqual (typeof (ParameterCollection), ods.UpdateParameters.GetType (), "UpdateParameters");
			Assert.AreEqual (0, ods.CacheDuration, "CacheDuration");
			Assert.AreEqual (DataSourceCacheExpiry.Absolute, ods.CacheExpirationPolicy, "CacheExpirationPolicy");
			Assert.AreEqual ("", ods.CacheKeyDependency, "CacheKeyDependency");
			Assert.AreEqual (false, ods.ConvertNullToDBNull, "ConvertNullToDBNull ");
			Assert.AreEqual (false, ods.EnableCaching, "EnableCaching ");
			Assert.AreEqual ("", ods.SqlCacheDependency, "SqlCacheDependency");
			
		}
Exemplo n.º 20
0
		public static void InsertMethod (Page p)
		{
			MyTableObject.ds = MyTableObject.CreateDataTable ();  
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods,"insert");
			ods.Inserted += new ObjectDataSourceStatusEventHandler (odc_Inserted);
			ods.Inserting += new ObjectDataSourceMethodEventHandler (odc_Inserting);
			p.Controls.Add (ods);			
			Assert.AreEqual (3, ((DataView) ods.Select ()).Count, "BeforeInsert");
			Assert.AreEqual (false, inserted , "BeforeInsertedEvent");
			Assert.AreEqual (false, inserting , "BeforeInsertingEvent");
			ods.Insert ();		
			Assert.AreEqual (4, ((DataView) ods.Select ()).Count , "AfterInsert1");
			Assert.AreEqual (1004,((DataView) ods.Select ())[3].Row.ItemArray[0], "AfterInsert2");
			Assert.AreEqual ("David", ((DataView) ods.Select ())[3].Row.ItemArray[1], "AfterInsert3");
			Assert.AreEqual (true, inserted, "AfterInsertedEvent");
			Assert.AreEqual (true, inserting, "AfterInsertingEvent");
			
		}
Exemplo n.º 21
0
		public void ObjectDataSource_AssignToDefaultProperties ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods,"");				
			ods.ConflictDetection = ConflictOptions.CompareAllValues;
			Assert.AreEqual (ConflictOptions.CompareAllValues, ods.ConflictDetection, "ConflictDetection");			
			ods.DataObjectTypeName = "MyData";
			Assert.AreEqual ("MyData", ods.DataObjectTypeName, "DataObjectTypeName ");
			Assert.AreEqual ("Delete", ods.DeleteMethod, "DeleteMethod");
			Assert.AreEqual (3, ods.DeleteParameters.Count, "DeleteParameters");			
			ods.EnablePaging = true;
			Assert.AreEqual (true, ods.EnablePaging, "EnablePaging ");
			ods.FilterExpression = "ID='{0}'";
			Assert.AreEqual ("ID='{0}'", ods.FilterExpression, "FilterExpression ");
			TextBox TextBox1=new TextBox ();
			TextBox1.Text ="1001"; 
			FormParameter p=new FormParameter ("ID","TextBox1");
			p.DefaultValue = "1002";
			ods.FilterParameters.Add (p);  
			Assert.AreEqual ("ID", ods.FilterParameters[0].Name, "FilterParameters1");
			Assert.AreEqual ("1002", ods.FilterParameters[0].DefaultValue , "FilterParameters2");
			Assert.AreEqual ("TextBox1", ((FormParameter )ods.FilterParameters[0]).FormField, "FilterParameters3");
			Assert.AreEqual ("Insert", ods.InsertMethod, "InsertMethod ");
			Assert.AreEqual ("ID", ods.InsertParameters[0].Name , "InsertParameters ");
			ods.MaximumRowsParameterName = "SelectCount";
			Assert.AreEqual ("SelectCount", ods.MaximumRowsParameterName, "MaximumRowsParameterName");
			ods.OldValuesParameterFormatString = "ID";
			Assert.AreEqual ("ID", ods.OldValuesParameterFormatString, "OldValuesParameterFormatString");
			Assert.AreEqual ("SelectCount", ods.SelectCountMethod, "SelectCountMethod");
			Assert.AreEqual ("GetMyData", ods.SelectMethod, "SelectMethod ");
			Parameter dummy = new Parameter ();
			dummy.Name = "Test";
			ods.SelectParameters.Add (dummy);
			Assert.AreEqual ("Test", ods.SelectParameters[0].Name , "SelectParameters");
			ods.SortParameterName = "sortExpression";
			Assert.AreEqual ("sortExpression", ods.SortParameterName, "SortParameterName");			
			ods.StartRowIndexParameterName = "ID";
			Assert.AreEqual ("ID", ods.StartRowIndexParameterName, "StartRowIndexParameterName");
			Assert.AreEqual (typeof (MyTableObject).AssemblyQualifiedName, ods.TypeName, "TypeName");
			Assert.AreEqual ("Update", ods.UpdateMethod, "UpdateMethod ");
			Assert.AreEqual ("FName", ods.UpdateParameters[1].Name, "UpdateParameters");
			ods.CacheDuration = 1000;
			Assert.AreEqual (1000, ods.CacheDuration, "CacheDuration");
			ods.CacheExpirationPolicy = DataSourceCacheExpiry.Sliding;
			Assert.AreEqual (DataSourceCacheExpiry.Sliding, ods.CacheExpirationPolicy, "CacheExpirationPolicy");
			ods.CacheKeyDependency = "ID";
			Assert.AreEqual ("ID", ods.CacheKeyDependency, "CacheKeyDependency");
			ods.ConvertNullToDBNull = true;
			Assert.AreEqual (true, ods.ConvertNullToDBNull, "ConvertNullToDBNull ");
			ods.EnableCaching = true;
			Assert.AreEqual (true, ods.EnableCaching, "EnableCaching ");
			ods.SqlCacheDependency = "Northwind:Employees";
			Assert.AreEqual ("Northwind:Employees", ods.SqlCacheDependency, "SqlCacheDependency");
			
		}
Exemplo n.º 22
0
		public static void EventsTest (Page p)
		{				
			
			MyTableObject.ds = MyTableObject.CreateDataTable ();  
			DetailsView dv = new DetailsView  ();
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			ods.ObjectCreated += new ObjectDataSourceObjectEventHandler (odc_ObjectCreated);
			ods.ObjectCreating += new ObjectDataSourceObjectEventHandler (odc_ObjectCreating);
			InitObjectDataSource (ods,"");
			ods.FilterExpression = "ID='1001'";			
			dv.Page = p;
			ods.Page = p;
			dv.DataKeyNames = new string[] { "ID" };
			dv.DataSource = ods;
			p.Controls.Add (ods);
			p.Controls.Add (dv);
			dv.DataBind ();							
			ods.Filtering += new ObjectDataSourceFilteringEventHandler (odc_Filtering);
			Assert.AreEqual (false, filtering, "BeforeFilteringEvent");
			ods.Select ();
			Assert.AreEqual (true, filtering, "AfterFilteringEvent");
			ods.ObjectDisposing += new ObjectDataSourceDisposingEventHandler (odc_ObjectDisposing);
			//ToDo: Dispose, ObjectCreated and ObjectCreating should be tested.
			
		}
Exemplo n.º 23
0
		public void ObjectDataSource_ViewState ()
		{
			ObjectDataSourcePoker  ods = new ObjectDataSourcePoker ();
			//InitObjectDataSource (ods,"");	

			ods.CacheDuration = 1;
			ods.CacheExpirationPolicy = DataSourceCacheExpiry.Sliding;
			ods.CacheKeyDependency = "key";
			ods.ConflictDetection = ConflictOptions.CompareAllValues;
			ods.ConvertNullToDBNull = true;
			ods.DataObjectTypeName = "DataObjectType";
			ods.DeleteMethod = "deleteMethod";
			ods.EnableCaching = true;
			ods.EnablePaging = true;
			ods.FilterExpression = "filter expression";
			ods.InsertMethod = "insertMethod";
			ods.MaximumRowsParameterName = "maxRows";
			ods.OldValuesParameterFormatString = "old_{0}";
			ods.SelectCountMethod = "selectCountMethod";
			ods.SelectMethod = "selectMethod";
			ods.SortParameterName = "sortParamName";
			ods.SqlCacheDependency = "cacheDependency";
			ods.StartRowIndexParameterName = "startRow";
			ods.TypeName = "TypeName";
			ods.UpdateMethod = "updateMethod";

			object state = ods.SaveState ();
			Assert.IsNull (state, "ViewState is null");

			ObjectDataSourcePoker copy = new ObjectDataSourcePoker ();
			copy.LoadState (state);

		}
Exemplo n.º 24
0
		public void ObjectDataSource_DeleteExecuteMethodCaseSensitive ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.SelectMethod = "GetMyData";
			view.DeleteMethod = "delete";
			Parameter p1, p2, p3;
			p1 = new Parameter ("ID", TypeCode.String, "1001");
			p2 = new Parameter ("FName", TypeCode.String, "Mahesh");
			p3 = new Parameter ("LName", TypeCode.String, "chand");
			view.DeleteParameters.Add (p1);
			view.DeleteParameters.Add (p2);
			view.DeleteParameters.Add (p3);
			view.OldValuesParameterFormatString = "oldvalue_{0}";

			Hashtable value = new Hashtable ();
			value.Add ("ID", "test_id");
			view.ExecuteDelete (value, null);
			Assert.AreEqual (true, MyTableObject.DeleteWithParamsAndKeys, "DeleteExecuteMethodCaseSensitive");
		}
Exemplo n.º 25
0
		public static void ConvertNullToDBNull (Page p)
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods,"DBNull");
			bool dbnull = false;
			ods.ConvertNullToDBNull = true;
			try {
				ods.Delete ();
			}
			catch (Exception ex) {
				Assert.AreEqual (true,
					ex.Message.Contains ("type 'System.DBNull' cannot be converted to type 'System.String'") || // dotnet
					ex.Message.Contains ("type System.DBNull cannot be converted to target type: System.String")); // mono
				dbnull = true;
			}
			Assert.AreEqual (true, dbnull, "ConvertNullToDBNull2");
		}
Exemplo n.º 26
0
		public void ObjectDataSource_InsertExecute_1 ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.SelectMethod = "GetMyData";
			view.InsertMethod = "Insert";

			//This hashtable ovveride 
			Hashtable value = new Hashtable ();
			value.Add ("ID", "test_id");
			view.ExecuteInsert (value);
			Assert.AreEqual (true, MyTableObject.InsertWithParameters, "InsertExecute#1");
		}
Exemplo n.º 27
0
		public static void FilterExpression (Page p)
		{
			LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
			LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
			DataGrid dg = new DataGrid ();			
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			ods.FilterExpression = "ID='1002'";
			p.Controls.Add (lcb); 
			p.Controls.Add (dg);
			p.Controls.Add (ods);
			p.Controls.Add (lce); 
			dg.DataSource = ods;
			dg.DataBind ();
			
		}
Exemplo n.º 28
0
		public void ObjectDataSource_UpdateExecute_2 ()
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.SelectMethod = "GetMyData";
			view.UpdateMethod = "TryUpdate";
			Parameter p1, p2, p3;
			p1 = new Parameter ("ID", TypeCode.String, "1001");
			p2 = new Parameter ("FName", TypeCode.String, "Mahesh");
			p3 = new Parameter ("LName", TypeCode.String, "chand");
			view.UpdateParameters.Add (p1);
			view.UpdateParameters.Add (p2);
			view.UpdateParameters.Add (p3);

			view.OldValuesParameterFormatString = "oldvalue_{0}";
			Hashtable value = new Hashtable ();
			value.Add ("P", "1001");
			
			view.ExecuteUpdate (null, value, null);
			Assert.AreEqual (true, MyTableObject.UpdateWithMergedCollection, "UpdateExecute#2");
		}
Exemplo n.º 29
0
		public void ObjectDataSource_UpdateExecute_OverwriteChanges () 
		{
			ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
			InitObjectDataSource (ods, "");
			CustomObjectDataSourceView view = new CustomObjectDataSourceView (ods, "CustomView", null);
			view.TypeName = typeof (MyTableObject).AssemblyQualifiedName;
			view.SelectMethod = "GetMyData";
			view.UpdateMethod = "UpdateOverwriteChanges";
			view.ConflictDetection = ConflictOptions.OverwriteChanges;
			Hashtable keys;
			Hashtable old_value;
			Hashtable new_value;
			InitializeView (view, out keys, out old_value, out new_value);

			view.ExecuteUpdate (keys, new_value, old_value);
			Assert.AreEqual (true, MyTableObject.UpdateOverwriteChangesCalled, "OverwriteChanges");
			Assert.AreEqual ("n_1001, n_Mahesh, n_chand, k_1001", MyTableObject.UpdatePassedValues, "OverwriteChanges Values");
		}