2 // RadioRadioButtonTest.cs: Test cases for RadioRadioButton.
5 // Ritvik Mayank (mritvik@novell.com)
7 // (C) 2005 Novell, Inc. (http://www.novell.com)
11 using System.Windows.Forms;
13 using NUnit.Framework;
15 namespace MonoTests.System.Windows.Forms
18 public class RadioButtonTest
21 public void RadioButtonPropertyTest ()
23 RadioButton rButton1 = new RadioButton ();
26 Assert.AreEqual (Appearance.Normal, rButton1.Appearance, "#A1");
27 Assert.AreEqual (true, rButton1.AutoCheck, "#A2");
30 Assert.AreEqual (false, rButton1.Checked, "#C1");
31 Assert.AreEqual (ContentAlignment.MiddleLeft, rButton1.CheckAlign, "#C2");
34 Assert.AreEqual (null, rButton1.Site, "#S1");
37 rButton1.Text = "New RadioButton";
38 Assert.AreEqual ("New RadioButton", rButton1.Text, "#T1");
39 Assert.AreEqual (ContentAlignment.MiddleLeft, rButton1.TextAlign, "#T2");
40 Assert.IsFalse (rButton1.TabStop, "#T3");
43 bool event_received = false;
44 void rb_tabstop_changed (object sender, EventArgs e)
46 event_received = true;
50 public void TabStopEventTest ()
52 RadioButton rb = new RadioButton ();
54 rb.TabStopChanged += new EventHandler (rb_tabstop_changed);
58 Assert.IsTrue (event_received);
62 public void ToStringTest ()
64 RadioButton rButton1 = new RadioButton ();
65 Assert.AreEqual ("System.Windows.Forms.RadioButton, Checked: False" , rButton1.ToString (), "#9");
70 public class RadioButtonEventTestClass
72 static bool eventhandled = false;
73 public static void RadioButton_EventHandler (object sender, EventArgs e)
79 public void PanelClickTest ()
81 Form myForm = new Form ();
82 myForm.ShowInTaskbar = false;
83 RadioButton rButton1 = new RadioButton ();
85 rButton1.Visible = true;
86 myForm.Controls.Add (rButton1);
88 rButton1.Click += new EventHandler (RadioButton_EventHandler);
90 rButton1.PerformClick ();
91 Assert.AreEqual (true, eventhandled, "#2");
96 public void ApperanceChangedTest ()
98 Form myForm = new Form ();
99 myForm.ShowInTaskbar = false;
100 RadioButton rButton1 = new RadioButton ();
102 rButton1.Visible = true;
103 myForm.Controls.Add (rButton1);
104 rButton1.Appearance = Appearance.Normal;
105 eventhandled = false;
106 rButton1.AppearanceChanged += new EventHandler (RadioButton_EventHandler);
107 rButton1.Appearance = Appearance.Button;
108 Assert.AreEqual (true, eventhandled, "#2");
113 public void CheckedChangedTest ()
115 Form myForm = new Form ();
116 myForm.ShowInTaskbar = false;
117 RadioButton rButton1 = new RadioButton ();
119 rButton1.Visible = true;
120 myForm.Controls.Add (rButton1);
121 rButton1.Checked = false;
122 eventhandled = false;
123 rButton1.CheckedChanged += new EventHandler (RadioButton_EventHandler);
124 rButton1.Checked = true;
125 Assert.AreEqual (true, eventhandled, "#3");