2 using System.Collections.Generic;
3 using MonoTests.SystemWeb.Framework;
4 using MonoTests.stand_alone.WebHarness;
7 using System.Web.Compilation;
8 using System.Web.UI.WebControls;
9 using System.Reflection;
10 using System.ComponentModel;
11 using System.Threading;
13 namespace MonoTests.System.Web.Compilation {
14 public class ReadOnlyPropertyControl:TextBox {
23 public class BindTestDataItem
31 public BindTestDataItem (int data)
37 public class BindTestDataSource
39 public IList <BindTestDataItem> GetData ()
41 return new List <BindTestDataItem> {new BindTestDataItem (0), new BindTestDataItem (1)};
46 public class TemplateControlCompilerTest
49 public void TemplateControlCompiler_Init ()
51 WebTest.CopyResource (GetType (), "ReadOnlyPropertyBind.aspx", "ReadOnlyPropertyBind.aspx");
52 WebTest.CopyResource (GetType (), "ReadOnlyPropertyControl.ascx", "ReadOnlyPropertyControl.ascx");
53 WebTest.CopyResource (GetType (), "TemplateControlParsingTest.aspx", "TemplateControlParsingTest.aspx");
54 WebTest.CopyResource (GetType (), "ServerSideControlsInScriptBlock.aspx", "ServerSideControlsInScriptBlock.aspx");
55 WebTest.CopyResource (GetType (), "ServerControlInClientSideComment.aspx", "ServerControlInClientSideComment.aspx");
56 WebTest.CopyResource (GetType (), "UnquotedAngleBrackets.aspx", "UnquotedAngleBrackets.aspx");
57 WebTest.CopyResource (GetType (), "FullTagsInText.aspx", "FullTagsInText.aspx");
58 WebTest.CopyResource (GetType (), "TagsExpressionsAndCommentsInText.aspx", "TagsExpressionsAndCommentsInText.aspx");
59 WebTest.CopyResource (GetType (), "NewlineInCodeExpression.aspx", "NewlineInCodeExpression.aspx");
60 WebTest.CopyResource (GetType (), "DuplicateControlsInClientComment.aspx", "DuplicateControlsInClientComment.aspx");
61 WebTest.CopyResource (GetType (), "TagsNestedInClientTag.aspx", "TagsNestedInClientTag.aspx");
62 WebTest.CopyResource (GetType (), "ConditionalClientComments.aspx", "ConditionalClientComments.aspx");
63 WebTest.CopyResource (GetType (), "InvalidPropertyBind1.aspx", "InvalidPropertyBind1.aspx");
64 WebTest.CopyResource (GetType (), "InvalidPropertyBind2.aspx", "InvalidPropertyBind2.aspx");
65 WebTest.CopyResource (GetType (), "InvalidPropertyBind3.aspx", "InvalidPropertyBind3.aspx");
66 WebTest.CopyResource (GetType (), "InvalidPropertyBind4.aspx", "InvalidPropertyBind4.aspx");
67 WebTest.CopyResource (GetType (), "ValidPropertyBind1.aspx", "ValidPropertyBind1.aspx");
68 WebTest.CopyResource (GetType (), "ValidPropertyBind2.aspx", "ValidPropertyBind2.aspx");
69 WebTest.CopyResource (GetType (), "ValidPropertyBind3.aspx", "ValidPropertyBind3.aspx");
70 WebTest.CopyResource (GetType (), "ValidPropertyBind4.aspx", "ValidPropertyBind4.aspx");
71 WebTest.CopyResource (GetType (), "ValidPropertyBind5.aspx", "ValidPropertyBind5.aspx");
72 WebTest.CopyResource (GetType (), "NoBindForMethodsWithBindInName.aspx", "NoBindForMethodsWithBindInName.aspx");
73 WebTest.CopyResource (GetType (), "ReadWritePropertyControl.ascx", "ReadWritePropertyControl.ascx");
74 WebTest.CopyResource (GetType (), "ContentPlaceHolderInTemplate.aspx", "ContentPlaceHolderInTemplate.aspx");
75 WebTest.CopyResource (GetType (), "ContentPlaceHolderInTemplate.master", "ContentPlaceHolderInTemplate.master");
76 WebTest.CopyResource (GetType (), "LinkInHeadWithEmbeddedExpression.aspx", "LinkInHeadWithEmbeddedExpression.aspx");
77 WebTest.CopyResource (GetType (), "ExpressionInListControl.aspx", "ExpressionInListControl.aspx");
78 WebTest.CopyResource (GetType (), "PreprocessorDirectivesInMarkup.aspx", "PreprocessorDirectivesInMarkup.aspx");
79 WebTest.CopyResource (GetType (), "OneLetterIdentifierInCodeRender.aspx", "OneLetterIdentifierInCodeRender.aspx");
80 WebTest.CopyResource (GetType (), "NestedParserFileText.aspx", "NestedParserFileText.aspx");
81 WebTest.CopyResource (GetType (), "TagWithExpressionWithinAttribute.aspx", "TagWithExpressionWithinAttribute.aspx");
82 WebTest.CopyResource (GetType (), "EnumConverter_Bug578586.aspx", "EnumConverter_Bug578586.aspx");
86 [NUnit.Framework.Category ("NunitWeb")]
87 [NUnit.Framework.Category ("NotWorking")]
88 public void ReadOnlyPropertyBindTest ()
90 new WebTest ("ReadOnlyPropertyBind.aspx").Run ();
93 // Test for bug #449970
95 public void MasterPageContentPlaceHolderInTemplate ()
97 new WebTest ("ContentPlaceHolderInTemplate.aspx").Run ();
101 [ExpectedException ("System.Web.Compilation.CompilationException")]
102 public void InvalidPropertyBindTest1 ()
104 new WebTest ("InvalidPropertyBind1.aspx").Run ();
108 [ExpectedException (typeof (HttpParseException))]
109 public void InvalidPropertyBindTest2 ()
111 new WebTest ("InvalidPropertyBind2.aspx").Run ();
115 [ExpectedException ("System.Web.Compilation.CompilationException")]
116 public void InvalidPropertyBindTest3 ()
118 new WebTest ("InvalidPropertyBind3.aspx").Run ();
122 [ExpectedException (typeof (HttpParseException))]
123 public void InvalidPropertyBindTest4 ()
125 new WebTest ("InvalidPropertyBind4.aspx").Run ();
129 public void ValidPropertyBindTest1 ()
131 new WebTest ("ValidPropertyBind1.aspx").Run ();
135 public void ValidPropertyBindTest2 ()
137 new WebTest ("ValidPropertyBind2.aspx").Run ();
141 public void ValidPropertyBindTest3 ()
143 new WebTest ("ValidPropertyBind3.aspx").Run ();
147 public void ValidPropertyBindTest4 ()
149 new WebTest ("ValidPropertyBind4.aspx").Run ();
153 public void ValidPropertyBindTest5 ()
155 new WebTest ("ValidPropertyBind5.aspx").Run ();
160 public void NoBindForMethodsWithBindInNameTest ()
162 string pageHtml = new WebTest ("NoBindForMethodsWithBindInName.aspx").Run ();
163 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
164 string originalHtml = "<span id=\"grid_ctl02_lblTest\">Test</span>";
166 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
171 public void LinkInHeadWithEmbeddedExpression ()
173 string pageHtml = new WebTest ("LinkInHeadWithEmbeddedExpression.aspx").Run ();
174 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
175 string originalHtml = "<link href=\"Themes/Default/Content/Site.css\" rel=\"stylesheet\" type=\"text/css\" />";
177 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
181 public void ExpressionInListControl ()
183 string pageHtml = new WebTest ("ExpressionInListControl.aspx").Run ();
184 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
185 string originalHtml = @"<select name=""DropDown1"" id=""DropDown1"">
186 <option value=""strvalue"">str</option>
189 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
192 [Test (Description="Bug #508888")]
193 public void ServerSideControlsInScriptBlock ()
195 string pageHtml = new WebTest ("ServerSideControlsInScriptBlock.aspx").Run ();
196 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
197 string originalHtml = @"<script type=""text/javascript"">alert (escape(""reporting/location?report=ViewsByDate&minDate=minDate&maxDate=maxDate""));</script>";
198 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
201 [Test (Description="Bug #520024")]
202 public void PreprocessorDirectivesInMarkup ()
204 // Just test if it doesn't throw an exception
205 new WebTest ("PreprocessorDirectivesInMarkup.aspx").Run ();
208 [Test (Description="Bug #526449")]
209 public void NewlineInCodeExpression ()
211 string pageHtml = new WebTest ("NewlineInCodeExpression.aspx").Run ();
212 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
213 string originalHtml = "<a href=\"test\">bla</a>";
214 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
217 [Test (Description="Bug #524358")]
218 public void DuplicateControlsInClientComment ()
220 // Just test if it throws an exception
221 string pageHtml = new WebTest ("DuplicateControlsInClientComment.aspx").Run ();
222 Assert.IsTrue (pageHtml.IndexOf ("[System.Web.Compilation.ParseException]:") != -1, "#A1");
225 [Test (Description="Bug #367723")]
226 public void ConditionalClientComments ()
228 string pageHtml = new WebTest ("ConditionalClientComments.aspx").Run ();
229 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
230 string originalHtml = @"<!--[if IE 6]>
231 <link rel=""styleheet"" type=""text/css"" href=""~/compat-ie6.css""></link>
233 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
236 [Test (Description="Bug #400807")]
237 public void OneLetterIdentifierInCodeRender ()
239 string pageHtml = new WebTest ("OneLetterIdentifierInCodeRender.aspx").Run ();
240 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
241 string originalHtml = @"bDoR called";
243 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
246 [Test (Description="Bug #562286")]
247 public void NestedParserFileText ()
249 // Just test if it doesn't throw an exception
250 new WebTest ("NestedParserFileText.aspx").Run ();
253 [Test (Description="Bug #568631")]
254 public void TagWithExpressionWithinAttribute ()
256 // Just test if it doesn't throw an exception
257 new WebTest ("TagWithExpressionWithinAttribute.aspx").Run ();
260 [Test (Description="Bug #578586")]
261 public void EnumConverter_Bug578586 ()
263 WebTest t = new WebTest ("EnumConverter_Bug578586.aspx");
264 string pageHtml = t.Run ();
265 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
266 string originalHtml = @"<input type=""text"" value=""FlagOne"" name=""test"" id=""test"" />";
268 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
270 [Test (Description="Bug #323719")]
271 public void TagsNestedInClientTag ()
273 string pageHtml = new WebTest ("TagsNestedInClientTag.aspx").Run ();
274 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
275 string originalHtml = @"<script language=""javascript"" src=""/js/test.js"" type=""text/javascript""></script>
276 <sometag language=""javascript"" src=""/js/test.js"" type=""text/javascript""></sometag>";
278 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
281 [Test (Description="Bug #517656")]
282 public void ServerControlInClientSideComment ()
284 string pageHtml = new WebTest ("ServerControlInClientSideComment.aspx").Run ();
285 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
286 string originalHtml = @"<!-- comment start
287 <input id=""testBox"" type=""checkbox"" name=""testBox"" />
289 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
293 public void UnquotedAngleBrackets ()
295 // We just test if it doesn't throw an exception
296 new WebTest ("UnquotedAngleBrackets.aspx").Run ();
300 public void FullTagsInText ()
302 // We just test if it doesn't throw an exception
303 new WebTest ("FullTagsInText.aspx").Run ();
307 public void TagsExpressionsAndCommentsInText ()
309 // We just test if it doesn't throw an exception
310 new WebTest ("TagsExpressionsAndCommentsInText.aspx").Run ();
314 public void ChildTemplatesTest ()
317 WebTest.Host.AppDomain.AssemblyResolve += new ResolveEventHandler (ResolveAssemblyHandler);
318 new WebTest ("TemplateControlParsingTest.aspx").Run ();
320 WebTest.Host.AppDomain.AssemblyResolve -= new ResolveEventHandler (ResolveAssemblyHandler);
324 [TestFixtureTearDown]
325 public void TearDown ()
331 public static Assembly ResolveAssemblyHandler (object sender, ResolveEventArgs e)
333 if (e.Name != "System.Web_test")
336 return Assembly.GetExecutingAssembly ();