[System] UriKind.RelativeOrAbsolute workaround.
[mono.git] / mcs / class / System.Web / Test / standalone-tests / BuildManagerCacheFiles.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.BuildManagerCacheFiles
43 {
44         [TestCase ("BuildManagerCacheFiles 01", "Tests for BuildManager.{Create,Read}CacheFile")]
45         public sealed class BuildManagerCacheFiles_01 : ITestCase
46         {
47                 static string[] expectedMessages = {
48                         "create[1]: codeGen",
49                         "create[1]: fileStream",
50                         "create[1]: can read",
51                         "create[1]: can write",
52                         "create[1]: pathSubdirOfCodeGen",
53                         "create[1]: our file name",
54                         "read[1]: codeGen",
55                         "read[1]: fileStream",
56                         "read[1]: can read",
57                         "read[1]: cannot write",
58                         "read[1]: pathSubdirOfCodeGen",
59                         "read[1]: our file name",
60                         "read[1]: contents ok",
61                         
62                         "create[2]: codeGen",
63
64                         // .NET exception:
65                         //
66                         // System.ArgumentException: Value does not fall within the expected range.
67                         // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
68                         // at System.Web.Compilation.BuildManager.CreateCachedFile(String fileName)
69                         // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 56)
70                         "create[2]: error write (System.ArgumentException)",
71                         "read[2]: codeGen",
72
73                         // .NET exception:
74                         //
75                         // System.ArgumentException: Value does not fall within the expected range.
76                         // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
77                         // at System.Web.Compilation.BuildManager.ReadCachedFile(String fileName)
78                         // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 86)
79                         "read[2]: error read (System.ArgumentException)",
80                         
81                         "read[3]: codeGen",
82                         "read[3]: stream is null",
83
84                         "create[4]: codeGen",
85
86                         // .NET exception
87                         // System.ArgumentNullException: Value cannot be null.
88                         // Parameter name: path2
89                         // at System.IO.Path.Combine(String path1, String path2)
90                         // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
91                         // at System.Web.Compilation.BuildManager.CreateCachedFile(String fileName)
92                         // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 61)
93                         "create[4]: error write (System.ArgumentNullException)",
94                         "read[4]: codeGen",
95
96                         // .NET exception
97                         // System.ArgumentNullException: Value cannot be null.
98                         // Parameter name: path2
99                         // at System.IO.Path.Combine(String path1, String path2)
100                         // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
101                         // at System.Web.Compilation.BuildManager.ReadCachedFile(String fileName)
102                         // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 91)
103                         "read[4]: error read (System.ArgumentNullException)",
104                         
105                         "create[5]: codeGen",
106
107                         // .NET exception
108                         // System.ArgumentException: Value does not fall within the expected range.
109                         // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
110                         // at System.Web.Compilation.BuildManager.CreateCachedFile(String fileName)
111                         // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 61)
112                         "create[5]: error write (System.ArgumentException)",
113                         
114                         "read[5]: codeGen",
115
116                         // .NET exception
117                         // System.ArgumentException: Value does not fall within the expected range.
118                         // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
119                         // at System.Web.Compilation.BuildManager.ReadCachedFile(String fileName)
120                         // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 91)
121                         "read[5]: error read (System.ArgumentException)",
122                 };
123                 
124                 public string PhysicalPath {
125                         get {
126                                 return Path.Combine (
127                                         Consts.BasePhysicalDir,
128                                         "BuildManagerCacheFiles"
129                                 );
130                         }
131                 }
132                 
133                 public string VirtualPath  {
134                         get { return "/"; }
135                 }
136
137                 public bool SetUp (List <TestRunItem> runItems)
138                 {
139                         runItems.Add (new TestRunItem ("/Default.aspx", Default_Aspx));
140                         
141                         return true;
142                 }
143
144                 void Default_Aspx (string result, TestRunItem runItem)
145                 {
146                         var messages = runItem.TestRunData as List <string>;
147
148                         Assert.IsNotNull (messages, "#A1");
149
150                         int len = messages.Count;
151                         int i = 0;
152                         for (; i < len; i++)
153                                 Assert.AreEqual (expectedMessages [i], messages [i], "#A2-" + i.ToString ());
154
155                         if (i != len)
156                                 Assert.Fail ("Expected {0} messages, found {1}", i, len);
157                 }
158         }
159 }
160 #endif