[corlib] Use ManualResetEvent.WaitOne instead of Thread.Sleep to test Thread.Interrupt
[mono.git] / mcs / class / System.Web / Test / standalone-tests / WebFormsRouting.cs
1 //
2 // Authors:
3 //   Marek Habersack (mhabersack@novell.com)
4 //
5 // (C) 2010 Novell, Inc http://novell.com/
6 //
7
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 #if NET_4_0
29 using System;
30 using System.Collections.Generic;
31 using System.Configuration;
32 using System.Configuration.Provider;
33 using System.IO;
34 using System.Web;
35 using System.Web.Hosting;
36
37 using StandAloneRunnerSupport;
38 using StandAloneTests;
39
40 using NUnit.Framework;
41
42 namespace StandAloneTests.WebFormsRouting
43 {
44         [TestCase ("WebFormsRouting 01", "Web forms routing")]
45         public sealed class WebFormsRouting_01 : ITestCase
46         {
47                 public string PhysicalPath {
48                         get {
49                                 return Path.Combine (Consts.BasePhysicalDir, "WebFormsRouting");
50                         }
51                 }
52                 
53                 public string VirtualPath  {
54                         get { return "/"; }
55                 }
56
57                 public bool SetUp (List <TestRunItem> runItems)
58                 {
59                         runItems.Add (new TestRunItem ("/Default.aspx", Default_Aspx));
60                         runItems.Add (new TestRunItem ("/search/test", Search_Test));
61                         runItems.Add (new TestRunItem ("/search/true", Search_True));
62                         runItems.Add (new TestRunItem ("/search/red", Search_Red));
63                         
64                         return true;
65                 }
66         
67                 void Default_Aspx (string result, TestRunItem runItem)
68                 {
69                         string originalHtml = @"<a href=""/search/test"">Search for 'test'</a>";
70                         
71                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
72                 }
73
74                 void Search_Test (string result, TestRunItem runItem)
75                 {
76                         string originalHtml = @"Search term is: <span id=""label1"">test</span><br />
77         Search term from expression is: <span id=""label2"">test</span><br />
78         <pre id=""testLog"">.: Missing key (key: &#39;SearchTermd&#39;)
79         Returned null.
80 .: Missing property (key: &#39;SearchTerm&#39;)
81         Returned value of type &#39;System.String&#39;: test
82 .: No converter (key: &#39;SearchTerm&#39;)
83         Returned value of type &#39;System.String&#39;: test
84 .: Valid conversion to target (key: &#39;SearchTerm&#39;)
85         Exception &#39;System.FormatException&#39; caught
86 .: Invalid conversion to target (key: &#39;SearchTerm&#39;)
87         Exception &#39;System.Exception&#39; caught
88 .: Complex type converter (key: &#39;SearchTerm&#39;)
89         Exception &#39;System.Exception&#39; caught
90 .: Null controlType (key: &#39;SearchTerm&#39;)
91         Returned value of type &#39;System.String&#39;: test
92 .: Null propertyName (key: &#39;SearchTerm&#39;)
93         Returned value of type &#39;System.String&#39;: test
94 .: Empty propertyName (key: &#39;SearchTerm&#39;)
95         Returned value of type &#39;System.String&#39;: test
96 .: Non-string value (key: &#39;intValue&#39;)
97         Returned value of type &#39;System.Int32&#39;: 123
98 .: Non-string value (key: &#39;boolValue&#39;)
99         Returned value of type &#39;System.Boolean&#39;: False
100 .: Non-string value (key: &#39;doubleValue&#39;)
101         Returned value of type &#39;System.Double&#39;: 1,23
102 </pre>";
103                         
104                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
105                 }
106
107                 void Search_True (string result, TestRunItem runItem)
108                 {
109                         string originalHtml = @"Search term is: <span id=""label1"">true</span><br />
110         Search term from expression is: <span id=""label2"">true</span><br />
111         <pre id=""testLog"">.: Missing key (key: &#39;SearchTermd&#39;)
112         Returned null.
113 .: Missing property (key: &#39;SearchTerm&#39;)
114         Returned value of type &#39;System.String&#39;: true
115 .: No converter (key: &#39;SearchTerm&#39;)
116         Returned value of type &#39;System.String&#39;: true
117 .: Valid conversion to target (key: &#39;SearchTerm&#39;)
118         Returned value of type &#39;System.Boolean&#39;: True
119 .: Invalid conversion to target (key: &#39;SearchTerm&#39;)
120         Exception &#39;System.Exception&#39; caught
121 .: Complex type converter (key: &#39;SearchTerm&#39;)
122         Exception &#39;System.Exception&#39; caught
123 .: Null controlType (key: &#39;SearchTerm&#39;)
124         Returned value of type &#39;System.String&#39;: true
125 .: Null propertyName (key: &#39;SearchTerm&#39;)
126         Returned value of type &#39;System.String&#39;: true
127 .: Empty propertyName (key: &#39;SearchTerm&#39;)
128         Returned value of type &#39;System.String&#39;: true
129 .: Non-string value (key: &#39;intValue&#39;)
130         Returned value of type &#39;System.Int32&#39;: 123
131 .: Non-string value (key: &#39;boolValue&#39;)
132         Returned value of type &#39;System.Boolean&#39;: False
133 .: Non-string value (key: &#39;doubleValue&#39;)
134         Returned value of type &#39;System.Double&#39;: 1,23
135 </pre>";
136                         
137                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
138                 }
139
140                 void Search_Red (string result, TestRunItem runItem)
141                 {
142                         string originalHtml = @"Search term is: <span id=""label1"">red</span><br /> 
143         Search term from expression is: <span id=""label2"">red</span><br /> 
144         <pre id=""testLog"">.: Missing key (key: &#39;SearchTermd&#39;)
145         Returned null.
146 .: Missing property (key: &#39;SearchTerm&#39;)
147         Returned value of type &#39;System.String&#39;: red
148 .: No converter (key: &#39;SearchTerm&#39;)
149         Returned value of type &#39;System.String&#39;: red
150 .: Valid conversion to target (key: &#39;SearchTerm&#39;)
151         Exception &#39;System.FormatException&#39; caught
152 .: Invalid conversion to target (key: &#39;SearchTerm&#39;)
153         Exception &#39;System.Exception&#39; caught
154 .: Complex type converter (key: &#39;SearchTerm&#39;)
155         Returned value of type &#39;System.Drawing.Color&#39;: Color [Red]
156 .: Null controlType (key: &#39;SearchTerm&#39;)
157         Returned value of type &#39;System.String&#39;: red
158 .: Null propertyName (key: &#39;SearchTerm&#39;)
159         Returned value of type &#39;System.String&#39;: red
160 .: Empty propertyName (key: &#39;SearchTerm&#39;)
161         Returned value of type &#39;System.String&#39;: red
162 .: Non-string value (key: &#39;intValue&#39;)
163         Returned value of type &#39;System.Int32&#39;: 123
164 .: Non-string value (key: &#39;boolValue&#39;)
165         Returned value of type &#39;System.Boolean&#39;: False
166 .: Non-string value (key: &#39;doubleValue&#39;)
167         Returned value of type &#39;System.Double&#39;: 1,23
168 </pre>";
169                         
170                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
171                 }
172         }
173 }
174 #endif