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 : TestHelper
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 void AutoSizeText ()
73 f.ShowInTaskbar = false;
75 RadioButton rb = new RadioButton ();
82 rb.Text = "Some text that is surely longer than 100 pixels.";
84 if (rb.Width == width)
85 Assert.Fail ("RadioButton did not autosize, actual: {0}", rb.Width);
91 public class RadioButtonEventTestClass : TestHelper
93 static bool eventhandled = false;
94 public static void RadioButton_EventHandler (object sender, EventArgs e)
100 public void PanelClickTest ()
102 Form myForm = new Form ();
103 myForm.ShowInTaskbar = false;
104 RadioButton rButton1 = new RadioButton ();
106 rButton1.Visible = true;
107 myForm.Controls.Add (rButton1);
108 eventhandled = false;
109 rButton1.Click += new EventHandler (RadioButton_EventHandler);
111 rButton1.PerformClick ();
112 Assert.AreEqual (true, eventhandled, "#2");
117 public void ApperanceChangedTest ()
119 Form myForm = new Form ();
120 myForm.ShowInTaskbar = false;
121 RadioButton rButton1 = new RadioButton ();
123 rButton1.Visible = true;
124 myForm.Controls.Add (rButton1);
125 rButton1.Appearance = Appearance.Normal;
126 eventhandled = false;
127 rButton1.AppearanceChanged += new EventHandler (RadioButton_EventHandler);
128 rButton1.Appearance = Appearance.Button;
129 Assert.AreEqual (true, eventhandled, "#2");
134 public void CheckedChangedTest ()
136 Form myForm = new Form ();
137 myForm.ShowInTaskbar = false;
138 RadioButton rButton1 = new RadioButton ();
140 rButton1.Visible = true;
141 myForm.Controls.Add (rButton1);
142 rButton1.Checked = false;
143 eventhandled = false;
144 rButton1.CheckedChanged += new EventHandler (RadioButton_EventHandler);
145 rButton1.Checked = true;
146 Assert.AreEqual (true, eventhandled, "#3");