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