Merge pull request #1936 from esdrubal/DotNetRelativeOrAbsolute
[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 using System;
29 using System.Collections.Generic;
30 using System.Configuration;
31 using System.Configuration.Provider;
32 using System.IO;
33 using System.Web;
34 using System.Web.Hosting;
35
36 using StandAloneRunnerSupport;
37 using StandAloneTests;
38
39 using NUnit.Framework;
40
41 namespace StandAloneTests.WebFormsRouting
42 {
43         [TestCase ("WebFormsRouting 01", "Web forms routing")]
44         public sealed class WebFormsRouting_01 : ITestCase
45         {
46                 public string PhysicalPath {
47                         get {
48                                 return Path.Combine (Consts.BasePhysicalDir, "WebFormsRouting");
49                         }
50                 }
51                 
52                 public string VirtualPath  {
53                         get { return "/"; }
54                 }
55
56                 public bool SetUp (List <TestRunItem> runItems)
57                 {
58                         runItems.Add (new TestRunItem ("/Default.aspx", Default_Aspx));
59                         runItems.Add (new TestRunItem ("/search/test", Search_Test));
60                         runItems.Add (new TestRunItem ("/search/true", Search_True));
61                         runItems.Add (new TestRunItem ("/search/red", Search_Red));
62                         
63                         return true;
64                 }
65         
66                 void Default_Aspx (string result, TestRunItem runItem)
67                 {
68                         string originalHtml = @"<a href=""/search/test"">Search for 'test'</a>";
69                         
70                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
71                 }
72
73                 void Search_Test (string result, TestRunItem runItem)
74                 {
75                         string originalHtml = @"Search term is: <span id=""label1"">test</span><br />
76         Search term from expression is: <span id=""label2"">test</span><br />
77         <pre id=""testLog"">.: Missing key (key: &#39;SearchTermd&#39;)
78         Returned null.
79 .: Missing property (key: &#39;SearchTerm&#39;)
80         Returned value of type &#39;System.String&#39;: test
81 .: No converter (key: &#39;SearchTerm&#39;)
82         Returned value of type &#39;System.String&#39;: test
83 .: Valid conversion to target (key: &#39;SearchTerm&#39;)
84         Exception &#39;System.FormatException&#39; caught
85 .: Invalid conversion to target (key: &#39;SearchTerm&#39;)
86         Exception &#39;System.Exception&#39; caught
87 .: Complex type converter (key: &#39;SearchTerm&#39;)
88         Exception &#39;System.Exception&#39; caught
89 .: Null controlType (key: &#39;SearchTerm&#39;)
90         Returned value of type &#39;System.String&#39;: test
91 .: Null propertyName (key: &#39;SearchTerm&#39;)
92         Returned value of type &#39;System.String&#39;: test
93 .: Empty propertyName (key: &#39;SearchTerm&#39;)
94         Returned value of type &#39;System.String&#39;: test
95 .: Non-string value (key: &#39;intValue&#39;)
96         Returned value of type &#39;System.Int32&#39;: 123
97 .: Non-string value (key: &#39;boolValue&#39;)
98         Returned value of type &#39;System.Boolean&#39;: False
99 .: Non-string value (key: &#39;doubleValue&#39;)
100         Returned value of type &#39;System.Double&#39;: 1,23
101 </pre>";
102                         
103                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
104                 }
105
106                 void Search_True (string result, TestRunItem runItem)
107                 {
108                         string originalHtml = @"Search term is: <span id=""label1"">true</span><br />
109         Search term from expression is: <span id=""label2"">true</span><br />
110         <pre id=""testLog"">.: Missing key (key: &#39;SearchTermd&#39;)
111         Returned null.
112 .: Missing property (key: &#39;SearchTerm&#39;)
113         Returned value of type &#39;System.String&#39;: true
114 .: No converter (key: &#39;SearchTerm&#39;)
115         Returned value of type &#39;System.String&#39;: true
116 .: Valid conversion to target (key: &#39;SearchTerm&#39;)
117         Returned value of type &#39;System.Boolean&#39;: True
118 .: Invalid conversion to target (key: &#39;SearchTerm&#39;)
119         Exception &#39;System.Exception&#39; caught
120 .: Complex type converter (key: &#39;SearchTerm&#39;)
121         Exception &#39;System.Exception&#39; caught
122 .: Null controlType (key: &#39;SearchTerm&#39;)
123         Returned value of type &#39;System.String&#39;: true
124 .: Null propertyName (key: &#39;SearchTerm&#39;)
125         Returned value of type &#39;System.String&#39;: true
126 .: Empty propertyName (key: &#39;SearchTerm&#39;)
127         Returned value of type &#39;System.String&#39;: true
128 .: Non-string value (key: &#39;intValue&#39;)
129         Returned value of type &#39;System.Int32&#39;: 123
130 .: Non-string value (key: &#39;boolValue&#39;)
131         Returned value of type &#39;System.Boolean&#39;: False
132 .: Non-string value (key: &#39;doubleValue&#39;)
133         Returned value of type &#39;System.Double&#39;: 1,23
134 </pre>";
135                         
136                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
137                 }
138
139                 void Search_Red (string result, TestRunItem runItem)
140                 {
141                         string originalHtml = @"Search term is: <span id=""label1"">red</span><br /> 
142         Search term from expression is: <span id=""label2"">red</span><br /> 
143         <pre id=""testLog"">.: Missing key (key: &#39;SearchTermd&#39;)
144         Returned null.
145 .: Missing property (key: &#39;SearchTerm&#39;)
146         Returned value of type &#39;System.String&#39;: red
147 .: No converter (key: &#39;SearchTerm&#39;)
148         Returned value of type &#39;System.String&#39;: red
149 .: Valid conversion to target (key: &#39;SearchTerm&#39;)
150         Exception &#39;System.FormatException&#39; caught
151 .: Invalid conversion to target (key: &#39;SearchTerm&#39;)
152         Exception &#39;System.Exception&#39; caught
153 .: Complex type converter (key: &#39;SearchTerm&#39;)
154         Returned value of type &#39;System.Drawing.Color&#39;: Color [Red]
155 .: Null controlType (key: &#39;SearchTerm&#39;)
156         Returned value of type &#39;System.String&#39;: red
157 .: Null propertyName (key: &#39;SearchTerm&#39;)
158         Returned value of type &#39;System.String&#39;: red
159 .: Empty propertyName (key: &#39;SearchTerm&#39;)
160         Returned value of type &#39;System.String&#39;: red
161 .: Non-string value (key: &#39;intValue&#39;)
162         Returned value of type &#39;System.Int32&#39;: 123
163 .: Non-string value (key: &#39;boolValue&#39;)
164         Returned value of type &#39;System.Boolean&#39;: False
165 .: Non-string value (key: &#39;doubleValue&#39;)
166         Returned value of type &#39;System.Double&#39;: 1,23
167 </pre>";
168                         
169                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
170                 }
171         }
172 }