New test.
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / RadioButtonTest.cs
1 //
2 // RadioRadioButtonTest.cs: Test cases for RadioRadioButton.
3 //
4 // Author:
5 //   Ritvik Mayank (mritvik@novell.com)
6 //
7 // (C) 2005 Novell, Inc. (http://www.novell.com)
8 //
9
10 using System;
11 using System.Windows.Forms;
12 using System.Drawing;
13 using NUnit.Framework;
14
15 namespace MonoTests.System.Windows.Forms
16 {
17         [TestFixture]
18         public class RadioButtonTest
19         {
20                 [Test]
21                 public void RadioButtonPropertyTest ()
22                 {
23                         RadioButton rButton1 = new RadioButton ();
24                         
25                         // A
26                         Assert.AreEqual (Appearance.Normal, rButton1.Appearance, "#A1");
27                         Assert.AreEqual (true, rButton1.AutoCheck, "#A2");
28
29                         // C
30                         Assert.AreEqual (false, rButton1.Checked, "#C1");
31                         Assert.AreEqual (ContentAlignment.MiddleLeft, rButton1.CheckAlign, "#C2");
32                                         
33                         // S
34                         Assert.AreEqual (null, rButton1.Site, "#S1");   
35
36                         // T
37                         rButton1.Text = "New RadioButton";
38                         Assert.AreEqual ("New RadioButton", rButton1.Text, "#T1");
39                         Assert.AreEqual (ContentAlignment.MiddleLeft, rButton1.TextAlign, "#T2");
40                 }
41
42                 [Test]
43                 public void ToStringTest ()
44                 {
45                         RadioButton rButton1 = new RadioButton ();
46                         Assert.AreEqual ("System.Windows.Forms.RadioButton, Checked: False" , rButton1.ToString (), "#9");
47                 }
48         }
49         
50         [TestFixture]
51         public class RadioButtonEventTestClass
52         {
53                 static bool eventhandled = false;
54                 public static void RadioButton_EventHandler (object sender, EventArgs e)
55                 {
56                         eventhandled = true;
57                 }
58
59                 [Test]
60                 public void PanelClickTest ()
61                 {
62                         Form myForm = new Form ();
63                         RadioButton rButton1 = new RadioButton ();
64                         rButton1.Select ();
65                         rButton1.Visible = true;
66                         myForm.Controls.Add (rButton1);
67                         eventhandled = false;
68                         rButton1.Click += new EventHandler (RadioButton_EventHandler);
69                         myForm.Show ();
70                         rButton1.PerformClick ();
71                         Assert.AreEqual (true, eventhandled, "#2");
72                 }
73
74                 [Test]
75                 public void ApperanceChangedTest ()
76                 {
77                         Form myForm = new Form ();
78                         RadioButton rButton1 = new RadioButton ();
79                         rButton1.Select ();
80                         rButton1.Visible = true;
81                         myForm.Controls.Add (rButton1);
82                         rButton1.Appearance = Appearance.Normal;
83                         eventhandled = false;
84                         rButton1.AppearanceChanged += new EventHandler (RadioButton_EventHandler);
85                         rButton1.Appearance = Appearance.Button;
86                         Assert.AreEqual (true, eventhandled, "#2");
87                 }
88         
89                 [Test]
90                 public void CheckedChangedTest ()
91                 {
92                         Form myForm = new Form ();
93                         RadioButton rButton1 = new RadioButton ();
94                         rButton1.Select ();
95                         rButton1.Visible = true;
96                         myForm.Controls.Add (rButton1);
97                         rButton1.Checked = false;
98                         eventhandled = false;
99                         rButton1.CheckedChanged += new EventHandler (RadioButton_EventHandler);
100                         rButton1.Checked = true;
101                         Assert.AreEqual (true, eventhandled, "#3");
102                 }
103         }
104 }