New tests.
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / ButtonFieldBaseTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.ButtonFieldBaseTest.cs
3 //
4 // Author:
5 //      Yoni Klein (yonik@mainsoft.com)
6 //
7 //
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29
30 #if NET_2_0
31
32
33 using System;
34 using System.Collections.Generic;
35 using System.Text;
36 using System.Web;
37 using System.Web.UI;
38 using System.Web.UI.WebControls;
39 using System.IO;
40 using System.Drawing;
41 using System.Collections;
42 using System.Collections.Specialized;
43 using NUnit.Framework;
44 using System.Data;
45
46
47
48
49 namespace MonoTests.System.Web.UI.WebControls
50 {
51         class PokerButtonFieldBase : ButtonFieldBase
52         {
53                 // View state Stuff
54                 public PokerButtonFieldBase ()
55                         : base ()
56                 {
57                         TrackViewState ();
58                 }
59
60                 public object SaveState ()
61                 {
62                         return SaveViewState ();
63                 }
64
65                 public void LoadState (object o)
66                 {
67                         LoadViewState (o);
68                 }
69
70                 public StateBag StateBag
71                 {
72                         get { return base.ViewState; }
73                 }
74
75                 protected override DataControlField CreateField ()
76                 {
77                         throw new Exception ("The method or operation is not implemented.");
78                 }
79
80                 public void DoCopyProperties (DataControlField newField)
81                 {
82                         base.CopyProperties (newField);
83                 }
84         }
85
86         [TestFixture]
87         public class ButtonFieldBaseTest
88         {
89                 [Test]
90                 public void ButtonFieldBase_DefaultProperty ()
91                 {
92                         PokerButtonFieldBase button = new PokerButtonFieldBase ();
93                         Assert.AreEqual (ButtonType.Link, button.ButtonType, "ButtonType");
94                         Assert.AreEqual (false, button.CausesValidation, "CausesValidation");
95                         Assert.AreEqual (false, button.ShowHeader, "ShowHeader");
96                         Assert.AreEqual ("", button.ValidationGroup, "ValidationGroup"); 
97                 }
98
99                 [Test]
100                 public void ButtonFieldBase_AssignProperty ()
101                 {
102                         PokerButtonFieldBase button = new PokerButtonFieldBase ();
103                         button.ButtonType = ButtonType.Image;
104                         Assert.AreEqual (ButtonType.Image, button.ButtonType, "ButtonType");
105                         button.CausesValidation = true;
106                         Assert.AreEqual (true, button.CausesValidation, "CausesValidation");
107                         button.ShowHeader = true;
108                         Assert.AreEqual (true, button.ShowHeader, "ShowHeader");
109                         button.ValidationGroup = "test";
110                         Assert.AreEqual ("test", button.ValidationGroup, "ValidationGroup"); 
111                 }
112
113                 [Test]
114                 public void ButtonFieldBase_CopyProperties ()
115                 {
116                         PokerButtonFieldBase button = new PokerButtonFieldBase ();
117                         PokerButtonFieldBase copy = new PokerButtonFieldBase ();
118                         button.ButtonType = ButtonType.Image;
119                         button.CausesValidation = true;
120                         button.ShowHeader = true;
121                         button.ValidationGroup = "test";
122                         button.DoCopyProperties (copy);
123                         Assert.AreEqual ("test", copy.ValidationGroup, "ValidationGroup"); 
124                         Assert.AreEqual (ButtonType.Image, copy.ButtonType, "ButtonType");
125                         Assert.AreEqual (true, copy.CausesValidation, "CausesValidation");
126                         Assert.AreEqual (true, copy.ShowHeader, "ShowHeader");
127                 }
128         }
129 }
130 #endif