2 // Tests for System.Web.UI.WebControls.CommandFieldTest.cs
5 // Yoni Klein (yonik@mainsoft.com)
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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.
33 using System.Collections.Generic;
37 using System.Web.UI.WebControls;
40 using System.Collections;
41 using System.Collections.Specialized;
42 using NUnit.Framework;
44 namespace MonoTests.System.Web.UI.WebControls
46 class PokerCommandField : CommandField
49 public PokerCommandField ()
55 public object SaveState ()
57 return SaveViewState ();
60 public void LoadState (object o)
65 public StateBag StateBag
67 get { return base.ViewState; }
70 public void DoCopyProperties (DataControlField newField)
72 base.CopyProperties (newField);
75 public DataControlField DoCreateField ()
77 return base.CreateField ();
83 public class CommandFieldTest
86 public void CommandField_DefaultProperty ()
88 PokerCommandField field = new PokerCommandField ();
89 Assert.AreEqual ("", field.CancelImageUrl, "CancelImageUrl");
90 Assert.AreEqual ("Cancel", field.CancelText, "CancelText");
91 Assert.AreEqual (true, field.CausesValidation, "CausesValidation");
92 Assert.AreEqual ("", field.DeleteImageUrl, "DeleteImageUrl");
93 Assert.AreEqual ("Delete", field.DeleteText, "DeleteText");
94 Assert.AreEqual ("", field.EditImageUrl, "EditImageUrl");
95 Assert.AreEqual ("Edit", field.EditText, "EditText");
96 Assert.AreEqual ("", field.InsertImageUrl, "InsertImageUrl");
97 Assert.AreEqual ("Insert", field.InsertText, "InsertText");
98 Assert.AreEqual ("", field.NewImageUrl, "NewImageUrl");
99 Assert.AreEqual ("New", field.NewText, "NewText");
100 Assert.AreEqual ("", field.SelectImageUrl, "SelectImageUrl");
101 Assert.AreEqual ("Select", field.SelectText, "SelectText");
102 Assert.AreEqual (true, field.ShowCancelButton, "ShowCancelButton ");
103 Assert.AreEqual (false, field.ShowDeleteButton, "ShowDeleteButton");
104 Assert.AreEqual (false, field.ShowEditButton, "ShowEditButton");
105 Assert.AreEqual (false, field.ShowInsertButton, "ShowInsertButton");
106 Assert.AreEqual (false, field.ShowSelectButton , "ShowSelectButton");
107 Assert.AreEqual ("", field.UpdateImageUrl, "UpdateImageUrl");
108 Assert.AreEqual ("Update", field.UpdateText, "UpdateText");
114 public void CommandField_AssignProperty ()
116 PokerCommandField field = new PokerCommandField ();
117 field.CancelImageUrl = "test";
118 Assert.AreEqual ("test", field.CancelImageUrl, "CancelImageUrl");
119 field.CancelText = "test";
120 Assert.AreEqual ("test", field.CancelText, "CancelText");
121 field.CausesValidation = false;
122 Assert.AreEqual (false, field.CausesValidation, "CausesValidation");
123 field.DeleteImageUrl = "test";
124 Assert.AreEqual ("test", field.DeleteImageUrl, "DeleteImageUrl");
125 field.DeleteText = "test";
126 Assert.AreEqual ("test", field.DeleteText, "DeleteText");
127 field.EditImageUrl = "test";
128 Assert.AreEqual ("test", field.EditImageUrl, "EditImageUrl");
129 field.EditText = "test";
130 Assert.AreEqual ("test", field.EditText, "EditText");
131 field.InsertImageUrl = "test";
132 Assert.AreEqual ("test", field.InsertImageUrl, "InsertImageUrl");
133 field.InsertText = "test";
134 Assert.AreEqual ("test", field.InsertText, "InsertText");
135 field.NewImageUrl = "test";
136 Assert.AreEqual ("test", field.NewImageUrl, "NewImageUrl");
137 field.NewText = "test";
138 Assert.AreEqual ("test", field.NewText, "NewText");
139 field.SelectImageUrl = "test";
140 Assert.AreEqual ("test", field.SelectImageUrl, "SelectImageUrl");
141 field.SelectText = "test";
142 Assert.AreEqual ("test", field.SelectText, "SelectText");
143 field.ShowCancelButton = false;
144 Assert.AreEqual (false, field.ShowCancelButton, "ShowCancelButton ");
145 field.ShowDeleteButton = true;
146 Assert.AreEqual (true, field.ShowDeleteButton, "ShowDeleteButton");
147 field.ShowEditButton = true;
148 Assert.AreEqual (true, field.ShowEditButton, "ShowEditButton");
149 field.ShowInsertButton = true;
150 Assert.AreEqual (true, field.ShowInsertButton, "ShowInsertButton");
151 field.ShowSelectButton = true;
152 Assert.AreEqual (true, field.ShowSelectButton, "ShowSelectButton");
153 field.UpdateImageUrl = "test";
154 Assert.AreEqual ("test", field.UpdateImageUrl, "UpdateImageUrl");
155 field.UpdateText = "test";
156 Assert.AreEqual ("test", field.UpdateText, "UpdateText");
160 public void CommandField_CopyProperty ()
162 PokerCommandField field = new PokerCommandField ();
163 CommandField copy = new CommandField ();
164 field.CancelImageUrl = "test";
165 field.CancelText = "test";
166 field.CausesValidation = false;
167 field.DeleteImageUrl = "test";
168 field.DeleteText = "test";
169 field.EditImageUrl = "test";
170 field.EditText = "test";
171 field.InsertImageUrl = "test";
172 field.InsertText = "test";
173 field.NewImageUrl = "test";
174 field.NewText = "test";
175 field.SelectImageUrl = "test";
176 field.SelectText = "test";
177 field.ShowCancelButton = false;
178 field.ShowDeleteButton = true;
179 field.ShowEditButton = true;
180 field.ShowInsertButton = true;
181 field.ShowSelectButton = true;
182 field.UpdateImageUrl = "test";
183 field.UpdateText = "test";
185 field.DoCopyProperties (copy);
186 Assert.AreEqual (false, copy.CausesValidation, "CausesValidation");
187 Assert.AreEqual ("test", copy.DeleteImageUrl, "DeleteImageUrl");
188 Assert.AreEqual ("test", copy.DeleteText, "DeleteText");
189 Assert.AreEqual ("test", copy.EditImageUrl, "EditImageUrl");
190 Assert.AreEqual ("test", copy.EditText, "EditText");
191 Assert.AreEqual ("test", copy.InsertImageUrl, "InsertImageUrl");
192 Assert.AreEqual ("test", copy.InsertText, "InsertText");
193 Assert.AreEqual ("test", copy.NewImageUrl, "NewImageUrl");
194 Assert.AreEqual ("test", copy.NewText, "NewText");
195 Assert.AreEqual ("test", copy.SelectImageUrl, "SelectImageUrl");
196 Assert.AreEqual ("test", copy.SelectText, "SelectText");
197 Assert.AreEqual (false, copy.ShowCancelButton, "ShowCancelButton ");
198 Assert.AreEqual (true, copy.ShowDeleteButton, "ShowDeleteButton");
199 Assert.AreEqual (true, copy.ShowEditButton, "ShowEditButton");
200 Assert.AreEqual (true, copy.ShowInsertButton, "ShowInsertButton");
201 Assert.AreEqual (true, copy.ShowSelectButton, "ShowSelectButton");
202 Assert.AreEqual ("test", copy.UpdateImageUrl, "UpdateImageUrl");
203 Assert.AreEqual ("test", copy.UpdateText, "UpdateText");
204 Assert.AreEqual ("test", copy.CancelImageUrl, "CancelImageUrl");
205 Assert.AreEqual ("test", copy.CancelText, "CancelText");
210 public void CommandField_CreateField ()
212 PokerCommandField field = new PokerCommandField ();
213 DataControlField newfield = field.DoCreateField ();
214 if (!(newfield is CommandField)) {
215 Assert.Fail ("New CommandField was not created");
221 [Category ("NotWorking")]
222 [ExpectedException (typeof (NotSupportedException))]
223 public void CommandField_ValidateSupportsCallback ()
225 PokerCommandField field = new PokerCommandField ();
226 field.ShowSelectButton = true;
227 field.Initialize (true, new Control());
228 field.ValidateSupportsCallback ();
233 public void CommandField_ValidateSupportsCallback_pass ()
\r
235 PokerCommandField field = new PokerCommandField ();
\r
236 field.ShowSelectButton = false;
\r
237 field.Initialize (true, new Control ());
\r
238 field.ValidateSupportsCallback ();
\r