Merge pull request #1936 from esdrubal/DotNetRelativeOrAbsolute
[mono.git] / mcs / class / System.Web / Test / standalone-tests / PageParserDefaultTypeProperties.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.PageParserDefaultTypeProperties
42 {
43         [TestCase ("PageParserDefaultTypeProperties 01", "Tests for PageParser.Default*Type properties")]
44         public sealed class PageParserDefaultTypeProperties_01 : ITestCase
45         {
46                 static string[] expectedMessages_1 = {
47                         "1: DefaultApplicationBaseType: set",
48                         "1: DefaultPageBaseType: set",
49                         "1: DefaultPageParserFilterType: set",
50                         "1: DefaultUserControlBaseType: set"
51                 };
52
53                 static string[] expectedMessages_2 = {
54                         "2: DefaultApplicationBaseType: exception 'System.ArgumentException' thrown.",
55                         "2: DefaultPageBaseType: exception 'System.ArgumentException' thrown.",
56                         "2: DefaultPageParserFilterType: exception 'System.ArgumentException' thrown.",
57                         "2: DefaultUserControlBaseType: exception 'System.ArgumentException' thrown."
58                 };
59
60                 static string[] expectedMessages_3 = {
61                         "3: DefaultApplicationBaseType: set",
62                         "3: DefaultPageBaseType: set",
63                         "3: DefaultPageParserFilterType: set",
64                         "3: DefaultUserControlBaseType: set"
65                 };
66                 
67                 public string PhysicalPath {
68                         get {
69                                 return Path.Combine (Consts.BasePhysicalDir, "PageParserDefaultTypeProperties");
70                         }
71                 }
72                 
73                 public string VirtualPath  {
74                         get { return "/"; }
75                 }
76
77                 public bool SetUp (List <TestRunItem> runItems)
78                 {
79                         runItems.Add (
80                                 new TestRunItem ("/default.aspx", "Set correct values", Default_Aspx_1) {
81                                         AppDomainData = new object[] { "TestNumber", 1 }
82                                 }
83                         );
84                         runItems.Add (
85                                 new TestRunItem ("/default.aspx", "Set invalid values", Default_Aspx_2) {
86                                         AppDomainData = new object[] { "TestNumber", 2 }
87                                 }
88                         );
89                         runItems.Add (
90                                 new TestRunItem ("/default.aspx", "Set null values", Default_Aspx_3) {
91                                         AppDomainData = new object[] { "TestNumber", 3 }
92                                 }
93                         );
94                         
95                         return true;
96                 }
97
98                 void Default_Aspx_1 (string result, TestRunItem runItem)
99                 {
100                         CheckResults (runItem.TestRunData as List <string>, expectedMessages_1);
101                 }
102
103                 void Default_Aspx_2 (string result, TestRunItem runItem)
104                 {
105                         CheckResults (runItem.TestRunData as List <string>, expectedMessages_2);
106                 }
107
108                 void Default_Aspx_3 (string result, TestRunItem runItem)
109                 {
110                         CheckResults (runItem.TestRunData as List <string>, expectedMessages_3);
111                 }
112                 
113                 void CheckResults (List <string> messages, string[] expectedMessages)
114                 {
115                         Assert.IsNotNull (messages, "#A1");
116
117                         int len = messages.Count;
118                         if (expectedMessages.Length != len)
119                                 Assert.Fail ("Expected {0} messages, found {1}", expectedMessages.Length, len);
120                         
121                         for (int i = 0; i < len; i++)
122                                 Assert.AreEqual (expectedMessages [i], messages [i], "#A2-" + i.ToString ());
123                 }
124         }
125 }