[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / ValidatedControlConverterTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.ValidatedControlConverterTest.cs 
3 //
4 // Author:
5 //      Peter Dennis Bartok (pbartok@novell.com)
6 //
7
8 //
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using NUnit.Framework;
32 using System;
33 using System.Collections;
34 using System.ComponentModel;
35 using System.IO;
36 using System.Globalization;
37 using System.Web;
38 using ComponentSpace = System.ComponentModel;
39 using System.Web.UI;
40 using System.Web.UI.WebControls;
41
42 namespace MonoTests.System.Web.UI.WebControls
43 {
44         [TestFixture]   
45         public class ValidatedControlConverterTest {
46                 public class ControlContainer : IContainer {
47                         ComponentCollection     col;
48
49                         public ControlContainer(ICollection collection) {
50                                 Control[] controls = new Control[collection.Count];
51                                 int i;
52
53                                 i = 0;
54                                 foreach(Control c in collection) {
55                                         controls[i++] = c;
56                                 }
57
58                                 col = new ComponentCollection(controls);
59                         }
60
61                         public ComponentCollection Components {
62                                 get { return col; }
63                         }
64
65                         public void Remove(IComponent component) { }
66                         public void Add(IComponent component, string name) { }
67                         void ComponentSpace.IContainer.Add(IComponent component) { }
68                         public void Dispose() { }
69                 }
70
71                 public class ControlTypeDescriptorContext : ITypeDescriptorContext {
72                         ControlContainer        cc;
73
74                         public ControlTypeDescriptorContext (ICollection collection) {
75                                 cc = new ControlContainer(collection);
76                         }
77
78
79                         public IContainer Container {
80                                 get {
81                                         return cc;
82                                 }
83                         }
84
85                         public void OnComponentChanged() { }
86                         public bool OnComponentChanging() { return false; }
87                         public object Instance { get { return null; } }
88                         public PropertyDescriptor PropertyDescriptor { get { return null; } }
89                         public object GetService(Type serviceType) {  return null; }
90                 }
91
92                 public class NamingContainer : WebControl, INamingContainer {
93
94                 }
95
96                 [Test]
97         [NUnit.Framework.Category("NotWorking")]
98                 public void Basic () {
99                         string[]                                result;
100                         int                                     i;
101                         ValidatedControlConverter               conv;
102                         TypeConverter.StandardValuesCollection  values;
103                         NamingContainer                         container;
104                         TextBox                 ctl1, ctl2;
105                         DropDownList                            ddl;
106                         Button                                  btn;
107                         ControlTypeDescriptorContext            context;
108
109                         container = new NamingContainer ();
110                         ctl1 = new TextBox ();
111                         ctl2 = new TextBox ();
112                         ddl = new DropDownList();
113
114                         // Button has no ValidationProperty and will not show in the list
115                         btn = new Button();
116
117                         container.Controls.Add (ctl1);
118                         container.Controls.Add (ctl2);
119                         container.Controls.Add (btn);
120                         container.Controls.Add (ddl);
121                         
122                         container.ID = "naming";
123                         ctl1.ID = "fooid";
124                         ctl2.ID = "blahid";
125                         ddl.ID = "ddlid";
126                         btn.ID = "buttonid";
127
128                         context = new ControlTypeDescriptorContext(container.Controls);
129                         conv = new ValidatedControlConverter();
130
131                         values = conv.GetStandardValues(context);
132                         Assert.IsNull (values, "B1");
133                 }
134         }
135 }