public void SerializeObject ()
		{
			Poker p = new Poker ();
			string s = p.Serialize ("hi");

			Assert.IsNull (s, "A1");
		}
		public void SerializeObject ()
		{
			Poker p = new Poker ();
			DateTime dt = new DateTime (2005, 9, 25, 22, 30, 45);
			string s = p.Serialize (dt);
			Assert.AreEqual ("new Date(2005,8,25,22,30,45)", s, "A1");
		}
		public void Properties ()
		{
			Poker p = new Poker ("name", "value");
			ConfigurationPropertyCollection props = p.GetProperties();

			Assert.IsNotNull (props, "A1");
			Assert.AreEqual (2, props.Count, "A2");

			ConfigurationProperty prop;

			prop = props["key"];
			Assert.AreEqual ("key", prop.Name, "A3");
			Assert.IsNull   (prop.Description, "A4");
			Assert.AreEqual (typeof (string), prop.Type, "A5");
			Assert.AreEqual (typeof (StringConverter), prop.Converter.GetType(), "A6");
			Assert.IsNotNull (prop.Validator, "Anull");
			Assert.AreEqual (typeof (DefaultValidator), prop.Validator.GetType(), "A7");
			Assert.AreEqual ("", prop.DefaultValue, "A8");
			Assert.IsTrue   (prop.IsKey, "A9");
			Assert.IsTrue   (prop.IsRequired, "A10");

			Assert.IsFalse  (prop.IsDefaultCollection, "A11");

			prop = props["value"];
			Assert.AreEqual ("value", prop.Name, "A12");
			Assert.IsNull   (prop.Description, "A13");
			Assert.AreEqual (typeof (string), prop.Type, "A14");
			Assert.AreEqual (typeof (StringConverter), prop.Converter.GetType(), "A15");
			Assert.AreEqual (typeof (DefaultValidator), prop.Validator.GetType(), "A16");
			Assert.AreEqual ("", prop.DefaultValue, "A17");
			Assert.IsFalse  (prop.IsKey, "A18");
			Assert.IsFalse  (prop.IsRequired, "A19");

			Assert.IsFalse  (prop.IsDefaultCollection, "A20");
		}
Example #4
0
		public void Properties () {

			Poker p1 = new Poker ();
			Poker p2 = new Poker ();

			Assert.AreEqual (false, p1.GetProperties ().Contains ("myProperty"), "Contains myProperty");
			Assert.AreEqual (false, p1.GetProperties () == p2.GetProperties (), "#");
		}
		public void SupportedTypes ()
		{
			Poker p = new Poker ();

			Type[] ts = p.GetSupportedTypes();

			Assert.IsNull (ts, "A1");
		}
		public void Add ()
		{
			Poker p = new Poker();

			Assert.AreEqual (0, p.Count, "A1");

			p.Add (new PokerElement ("hi"));
		}
Example #7
0
	public void ControlsAccessorTest ()
  	{
		Poker p = new Poker();

		ControlCollection col = p.Controls;

		Assert.AreEqual (col.Count, 1, "Controls accessor causes child control creation.");
	}
		public void SupportedTypes ()
		{
			Poker p = new Poker ();

			Type[] ts = p.GetSupportedTypes();

			Assert.AreEqual (1, ts.Length, "A1");
			Assert.AreEqual (typeof (DateTime), ts[0], "A2");
		}
Example #9
0
		public void TestUseDefaultCredentials () {
			Poker client = new Poker ();
			Assert.IsFalse (client.UseDefaultCredentials, "#1");
			client.UseDefaultCredentials = true;
			Assert.IsTrue (client.Credentials == CredentialCache.DefaultCredentials, "#2");
			client.Credentials = new NetworkCredential ("a", "b");
			Assert.IsFalse (client.UseDefaultCredentials, "#3");
			client.UseDefaultCredentials = false;
			Assert.IsNull (client.Credentials, "#4");
			client.Credentials = CredentialCache.DefaultCredentials;
			Assert.IsTrue (client.UseDefaultCredentials, "#5");
		}
Example #10
0
		public void Label_ViewState ()
		{
			XmlPoker p = new XmlPoker ();

			Assert.AreEqual (p.Text, "", "A1");
			p.Text = "Hello";
			Assert.AreEqual (p.Text, "Hello", "A2");

			object state = p.SaveState ();

			Poker copy = new Poker ();
			copy.LoadState (state);
			Assert.AreEqual (copy.Text, "Hello", "A3");
		}
Example #11
0
	public void Defaults ()
  	{
		Poker p = new Poker ();

		Assert.AreEqual (p.AllowClose, true, "A1");
		Assert.AreEqual (p.AllowConnect, true, "A2");
		Assert.AreEqual (p.AllowEdit, true, "A3");
		Assert.AreEqual (p.AllowHide, true, "A4");
		Assert.AreEqual (p.AllowMinimize, true, "A5");
		Assert.AreEqual (p.AllowZoneChange, true, "A6");
		Assert.AreEqual (p.AuthorizationFilter, String.Empty, "A7");
		Assert.AreEqual (p.CatalogIconImageUrl, String.Empty, "A8");
		Assert.AreEqual (p.ChromeState, PartChromeState.Normal, "A9");
		Assert.AreEqual (p.ChromeType, PartChromeType.Default, "A10");
		Assert.AreEqual (p.ConnectErrorMessage, String.Empty, "A11");
		Assert.AreEqual (p.Description, String.Empty, "A12");
		/* Direction - A13 */
		Assert.AreEqual (p.DisplayTitle, "Untitled", "A14");
		Assert.AreEqual (p.ExportMode, WebPartExportMode.None, "A15");
		Assert.AreEqual (p.HasSharedData, false, "A16");
		Assert.AreEqual (p.HasUserData, false, "A17");
		Assert.AreEqual (p.Height, Unit.Empty, "A18");
		Assert.AreEqual (p.HelpMode, WebPartHelpMode.Navigate, "A19");
		Assert.AreEqual (p.HelpUrl, String.Empty, "A20");
		Assert.AreEqual (p.Hidden, false, "A21");
		Assert.AreEqual (p.ImportErrorMessage, "Cannot import this Web Part.", "A22");
		Assert.AreEqual (p.IsClosed, false, "A23");
		Assert.AreEqual (p.IsShared, false, "A24");
		Assert.AreEqual (p.IsStandalone, true, "A25");
		/* this next isn't really a default - it's true
		 * because the part was created programmatically */
		Assert.AreEqual (p.IsStatic, true, "A26"); 
		Assert.AreEqual (p.Subtitle, String.Empty, "A27");
		Assert.AreEqual (p.Title, String.Empty, "A28");
		Assert.AreEqual (p.TitleIconImageUrl, String.Empty, "A29");
		Assert.AreEqual (p.TitleUrl, String.Empty, "A30");
		Assert.IsNotNull (p.Verbs, "A31");
#if IWebEditableInterface
		Assert.AreEqual (p.WebBrowsableObject, null, "A32");
#endif
#if notyet
		Assert.AreEqual (p.WebPartManager, null, "A33");
#endif		
		Assert.AreEqual (p.Width, Unit.Empty, "A34");
		Assert.AreEqual (p.ZoneIndex, 0, "A35");
	}
		public void FormView_PerformDataBinding ()
		{
			Poker fv = new Poker ();
			fv.Page = new Page ();
			Assert.AreEqual (0,fv.DataItemCount, "BeforePerformDataBinding"); 
			fv.DoPerformDataBinding (myds);
			Assert.AreEqual (6, fv.DataItemCount, "AfterPerformDataBinding"); 
		}
		public void FormView_EnsureDataBound ()
		{
			Poker fv = new Poker ();			
			fv.DataSource = myds;			
			fv.DoOnPreRender (EventArgs.Empty);
			Assert.AreEqual (true, fv.ensureDataBound, "EnsureDataBound");
			
		}
		public void FormView_CreateTable ()
		{
			Poker fv = new Poker ();
			Table tb = fv.DoCreateTable ();
			fv.Page = new Page ();
			Assert.AreEqual ("", tb.BackImageUrl , "CreateTable1");
			Assert.AreEqual (0, tb.Rows.Count, "CreateTable2");
			fv.DataSource = myds;
			fv.DataBind ();			
			fv.ID = "TestFormView";
			tb = fv.DoCreateTable ();
			Assert.AreEqual (-1, tb.CellPadding , "CreateTable3");			

		}
		public void FormView_CreateRow ()
		{
			Poker fv = new Poker ();
			fv.AllowPaging =true;
			fv.DataSource = myds;
			fv.Page = new Page ();
			fv.DataBind ();
			FormViewRow row = fv.DoCreateRow (2,DataControlRowType.DataRow ,DataControlRowState.Normal );
			Assert.AreEqual (2, row.ItemIndex, "CreatedRowItemIndex1");
			Assert.AreEqual (DataControlRowState.Normal , row.RowState, "CreatedRowState1");
			Assert.AreEqual (DataControlRowType.DataRow , row.RowType, "CreatedRowType1");			 
			row = fv.DoCreateRow (4, DataControlRowType.Footer, DataControlRowState.Edit);
			Assert.AreEqual (4, row.ItemIndex, "CreatedRowItemIndex2");
			Assert.AreEqual (DataControlRowState.Edit , row.RowState, "CreatedRowState2");
			Assert.AreEqual (DataControlRowType.Footer , row.RowType, "CreatedRowType2");
			//FormViewPagerRow pagerRow = (FormViewPagerRow)fv.DoCreateRow (3, DataControlRowType.Pager , DataControlRowState.Insert);
			//Assert.AreEqual (3, pagerRow.ItemIndex, "CreatedPageRowItemIndex");
			//Assert.AreEqual (DataControlRowState.Insert, pagerRow.RowState, "CreatedPageRowState");
			//Assert.AreEqual (DataControlRowType.Pager, pagerRow.RowType, "CreatedPageRowType");			 
			
		}
		public void FormView_UpdateItem ()
		{
			Poker fv = new Poker ();
			fv.Page = new Page ();
			fv.DataSource = myds;
			fv.DataBind ();
			fv.ChangeMode (FormViewMode.Edit);
			fv.ItemUpdating += new FormViewUpdateEventHandler (update_item);
			Assert.AreEqual (false, updateItem, "BeforeUpdateItem");
			fv.UpdateItem (false);
			Assert.AreEqual (true, updateItem, "AfterUpdateItem");

		}
		public void FormView_DeleteItem ()
		{
			Poker fv = new Poker ();
			fv.Page = new Page ();
			fv.DataSource = myds;
			fv.DataBind ();
			Assert.AreEqual (false, isDeleted, "BeforeDeleteItem");
			fv.ItemDeleting += new FormViewDeleteEventHandler (fv_DeleteingHandler);
			fv.DeleteItem ();
			Assert.AreEqual (true, isDeleted, "BeforeDeleteItem");

		}
		public void FormView_DataKey ()
		{
			Page p = new Page ();

			Poker fv = new Poker ();
			p.Controls.Add (fv);

			ObjectDataSource data = new ObjectDataSource ();
			data.TypeName = typeof (FormViewDataObject).AssemblyQualifiedName;
			data.SelectMethod = "Select";
			p.Controls.Add (data);

			fv.DataSource = data;
			fv.DataKeyNames = new string [] { "ID", "FName" };

			DataKey key1 = fv.DataKey;

			Assert.AreEqual (null, key1.Value, "DataKey.Value before binding");
			Assert.AreEqual (0, key1.Values.Count, "DataKey.Values count before binding");

			fv.DataBind ();

			DataKey key2 = fv.DataKey;
			DataKey key3 = fv.DataKey;

			Assert.IsFalse (Object.ReferenceEquals (key1, key2), "DataKey returns the same instans");
			Assert.IsTrue (Object.ReferenceEquals (key2, key3), "DataKey returns the same instans");
			
			Assert.AreEqual (1001, key1.Value, "DataKey.Value after binding");
			Assert.AreEqual (2, key1.Values.Count, "DataKey.Values count after binding");
			Assert.AreEqual (1001, key1.Values [0], "DataKey.Values[0] after binding");
			Assert.AreEqual ("Mahesh", key1.Values [1], "DataKey.Values[1] after binding");

			Poker copy = new Poker ();
			object state = fv.DoSaveControlState ();
			copy.DoLoadControlState (state);

			DataKey key4 = copy.DataKey;

			Assert.AreEqual (1001, key4.Value, "DataKey.Value from ViewState");
			Assert.AreEqual (2, key4.Values.Count, "DataKey.Values count from ViewState");
			Assert.AreEqual (1001, key4.Values [0], "DataKey.Values[0] from ViewState");
			Assert.AreEqual ("Mahesh", key4.Values [1], "DataKey.Values[1] from ViewState");
		}
		public void FormView_ChangeMode ()
		{
			Poker fv = new Poker ();
			Assert.AreEqual (FormViewMode.ReadOnly, fv.CurrentMode, "ChangeModeDefault");
			fv.ChangeMode (FormViewMode.Insert);
			Assert.AreEqual (FormViewMode.Insert, fv.CurrentMode, "ChangeModeInsert");
			fv.ChangeMode (FormViewMode.Edit);
			Assert.AreEqual (FormViewMode.Edit, fv.CurrentMode, "ChangeModeEdit");
			fv.ChangeMode (FormViewMode.ReadOnly);
			Assert.AreEqual (FormViewMode.ReadOnly, fv.CurrentMode, "ChangeModeReadOnly");
		}
		public void FormView_ExtractRowValues ()
		{
			Poker fv=new Poker ();
			fv.ItemTemplate = new MyTemplate ();
			fv.DataKeyNames = new string[] { "ID", "FName", "LName" };
			//IOrderedDictionary dict = (IOrderedDictionary) new OrderedDictionary (0x19);
			//fv.DoExtractRowValues (dict, true);			
			//DataTable ds = CreateDataTable ();
			//fv.DataSource = ds;
			//fv.DataBind ();
			//OrderedDictionary fieldsValues = new OrderedDictionary ();
			//fv.DoExtractRowValues (fieldsValues, true);
			//Assert.AreEqual (3, fieldsValues.Count, "ExtractRowValues1");
			//Assert.AreEqual (3, fieldsValues.Keys.Count, "ExtractRowValues2");
			//Assert.AreEqual (3, fieldsValues.Values.Count, "ExtractRowValues3");
			//Assert.AreEqual (true, fieldsValues.Contains ("ID"), "ExtractRowValues4");
			//IDictionaryEnumerator enumerator = fieldsValues.GetEnumerator ();
			//enumerator.MoveNext ();
			//Assert.AreEqual ("ID", enumerator.Key, "FieldValue1");
			//Assert.AreEqual ("1001", enumerator.Value, "FieldValue2");
			//enumerator.MoveNext ();
			//Assert.AreEqual ("FName", enumerator.Key, "FieldValue3");
			//Assert.AreEqual ("Mahesh", enumerator.Value, "FieldValue4");
			//enumerator.MoveNext ();
			//Assert.AreEqual ("LName", enumerator.Key, "FieldValue5");
			//Assert.AreEqual ("Chand", enumerator.Value, "FieldValue6");		
  
		}
		public void FormView_PrepareControlHierarchy ()
		{
			Poker fv = new Poker ();
			fv.Page = new Page ();
			fv.controlHierarchy = false;
			fv.Render ();
			Assert.AreEqual (0, fv.Controls.Count, "ControlHierarchy1");
			Assert.AreEqual (true, fv.controlHierarchy, "ControlHierarchy2");
			fv.AllowPaging = true;
			fv.DataSource = myds;
			fv.DataBind ();
			fv.controlHierarchy = false;
			fv.Render ();
			Assert.AreEqual (1, fv.Controls.Count, "ControlHierarchy3");
			Assert.AreEqual (true, fv.controlHierarchy, "ControlHierarchy4");


		}
		public void FormView_CreateChildControls ()
		{
			Poker fv = new Poker ();
			fv.DataSource = myds;
			fv.Page = new Page ();
			Assert.AreEqual (6, fv.DoCreateChildControls (myds, true), "CreateChildControlFromDS");
			myds.Add ("item7");
			Assert.AreEqual (7, fv.DoCreateChildControls (myds, false), "CreateChildControlFromViewState");
			myds.Remove ("item7");

		}
		public void FormView_PageCount () {
			Page p = new Page ();

			Poker fv = new Poker ();
			p.Controls.Add (fv);

			ObjectDataSource data = new ObjectDataSource ();
			data.TypeName = typeof (FormViewDataObject).AssemblyQualifiedName;
			data.SelectMethod = "Select";
			p.Controls.Add (data);

			fv.DataSource = data;

			Assert.AreEqual (0, fv.PageCount, "PageCount before binding");

			fv.DataBind ();
			
			Assert.AreEqual (3, fv.PageCount, "PageCount after binding");
		}
		public void FormView_CreateChildControls2 ()
		{
			Poker fv = new Poker ();
			fv.Page = new Page ();
			fv.DataSource = new MyEnumSource (20);
			fv.DataBind ();
			
			Assert.AreEqual (20, fv.PageCount, "CreateChildControls#0");

			Assert.AreEqual (0, fv.DoCreateChildControls (new MyEnumSource (0), true), "CreateChildControls#1");
			Assert.AreEqual (20, fv.DoCreateChildControls (new MyEnumSource (20), true), "CreateChildControls#2");

			Assert.AreEqual (0, fv.DoCreateChildControls (new object [0], false), "CreateChildControls#3");
			Assert.AreEqual (5, fv.DoCreateChildControls (new object [5], false), "CreateChildControls#4");
		}
		public void FormView_DataBind ()
		{
			Poker fv = new Poker ();
			fv.AllowPaging = true;
			fv.DataSource = myds;
			fv.Page = new Page ();
			Assert.AreEqual (0, fv.PageCount, "BeforeDataBind1");
			Assert.AreEqual (null, fv.DataItem, "BeforeDataBind2");
			fv.DataBind ();
			Assert.AreEqual (6, fv.PageCount, "AfterDataBind1");
			Assert.AreEqual (6, fv.DataItemCount, "AfterDataBind2");
			Assert.AreEqual ("Item1", fv.DataItem, "AfterDataBind3");
		}
		public void FormView_CreateDataSourceSelectArguments ()
		{
			//Checks the default DataSourceSelectArgument object returned.
			Poker fv = new Poker ();
			DataSourceSelectArguments selectArgs = fv.DoCreateDataSourceSelectArguments ();
			Assert.AreEqual (0, selectArgs.MaximumRows, "CreateDataSourceSelectArguments1");
			Assert.AreEqual (false, selectArgs.RetrieveTotalRowCount, "CreateDataSourceSelectArguments2");						

		}
		public void FormView_InsertItem ()
		{
			Poker fv = new Poker ();
			fv.Page = new Page ();
			fv.ChangeMode (FormViewMode.Insert);
			fv.ItemInserting += new FormViewInsertEventHandler (insert_item);
			Assert.AreEqual (false, insertItem, "BeforeInsertItem");
			fv.InsertItem (false);
			Assert.AreEqual (true, insertItem, "AfterInsertItem");

		}
		public void FormView_CreateControlStyle ()
		{
			Poker fv = new Poker ();
			Style s = fv.DoCreateControlStyle ();
			Assert.AreEqual (typeof (TableStyle), s.GetType (), "CreateControlStyle1");
			Assert.AreEqual (GridLines.None, ((TableStyle) s).GridLines, "CreateControlStyle2");
			Assert.AreEqual ("", ((TableStyle) s).BackImageUrl, "CreateControlStyle3");
			Assert.AreEqual (0, ((TableStyle) s).CellSpacing, "CreateControlStyle4");
			Assert.AreEqual (-1, ((TableStyle) s).CellPadding, "CreateControlStyle5");

		}
		public void FormView_IsBindableType ()
		{
			bool isBindable = false;
			Poker fv = new Poker ();
			isBindable = fv.IsBindableType (typeof (Decimal));
			Assert.AreEqual (true, isBindable, "IsBindableTypeDecimal");
			isBindable = fv.IsBindableType (typeof (Int32));
			Assert.AreEqual (true, isBindable, "IsBindableTypeInt32");
			isBindable = fv.IsBindableType (typeof (String));
			Assert.AreEqual (true, isBindable, "IsBindableTypeString");
			isBindable = fv.IsBindableType (typeof (Boolean));
			Assert.AreEqual (true, isBindable, "IsBindableTypeBoolean");
			isBindable = fv.IsBindableType (typeof (DateTime));
			Assert.AreEqual (true, isBindable, "IsBindableTypeDateTime");
			isBindable = fv.IsBindableType (typeof (Byte));
			Assert.AreEqual (true, isBindable, "IsBindableTypeByte");
			isBindable = fv.IsBindableType (typeof (Guid));
			Assert.AreEqual (true, isBindable, "IsBindableTypeGuid");
			isBindable = fv.IsBindableType (typeof (MyTemplate));
			Assert.AreEqual (false, isBindable, "IsBindableTypeMyTemplate");
		}
		public void FormView_InitializePager ()
		{
			Poker fv = new Poker ();
			Page page = new Page ();
			page.Controls.Add (fv);
			fv.AllowPaging = true;
			fv.DataSource = myds;
			Assert.AreEqual (false, fv.isInitializePager, "BeforeInitializePager");
			Assert.AreEqual (0, fv.PageCount, "BeforeInitializePagerPageCount");
			fv.DataBind ();
			Assert.AreEqual (true, fv.isInitializePager, "AfterInitializePager");
			Assert.AreEqual (6, fv.PageCount, "AfterInitializePagerPageCount");
		}