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 {
24 public class BindTestDataItem
32 public BindTestDataItem (int data)
38 public class BindTestDataSource
40 public IList <BindTestDataItem> GetData ()
42 return new List <BindTestDataItem> {new BindTestDataItem (0), new BindTestDataItem (1)};
48 public class TemplateControlCompilerTest
51 public void TemplateControlCompiler_Init ()
53 WebTest.CopyResource (GetType (), "ReadOnlyPropertyBind.aspx", "ReadOnlyPropertyBind.aspx");
54 WebTest.CopyResource (GetType (), "ReadOnlyPropertyControl.ascx", "ReadOnlyPropertyControl.ascx");
55 WebTest.CopyResource (GetType (), "TemplateControlParsingTest.aspx", "TemplateControlParsingTest.aspx");
56 WebTest.CopyResource (GetType (), "ServerSideControlsInScriptBlock.aspx", "ServerSideControlsInScriptBlock.aspx");
57 WebTest.CopyResource (GetType (), "ServerControlInClientSideComment.aspx", "ServerControlInClientSideComment.aspx");
58 WebTest.CopyResource (GetType (), "UnquotedAngleBrackets.aspx", "UnquotedAngleBrackets.aspx");
59 WebTest.CopyResource (GetType (), "FullTagsInText.aspx", "FullTagsInText.aspx");
60 WebTest.CopyResource (GetType (), "TagsExpressionsAndCommentsInText.aspx", "TagsExpressionsAndCommentsInText.aspx");
61 WebTest.CopyResource (GetType (), "NewlineInCodeExpression.aspx", "NewlineInCodeExpression.aspx");
62 WebTest.CopyResource (GetType (), "DuplicateControlsInClientComment.aspx", "DuplicateControlsInClientComment.aspx");
64 WebTest.CopyResource (GetType (), "InvalidPropertyBind1.aspx", "InvalidPropertyBind1.aspx");
65 WebTest.CopyResource (GetType (), "InvalidPropertyBind2.aspx", "InvalidPropertyBind2.aspx");
66 WebTest.CopyResource (GetType (), "InvalidPropertyBind3.aspx", "InvalidPropertyBind3.aspx");
67 WebTest.CopyResource (GetType (), "InvalidPropertyBind4.aspx", "InvalidPropertyBind4.aspx");
68 WebTest.CopyResource (GetType (), "ValidPropertyBind1.aspx", "ValidPropertyBind1.aspx");
69 WebTest.CopyResource (GetType (), "ValidPropertyBind2.aspx", "ValidPropertyBind2.aspx");
70 WebTest.CopyResource (GetType (), "ValidPropertyBind3.aspx", "ValidPropertyBind3.aspx");
71 WebTest.CopyResource (GetType (), "ValidPropertyBind4.aspx", "ValidPropertyBind4.aspx");
72 WebTest.CopyResource (GetType (), "ValidPropertyBind5.aspx", "ValidPropertyBind5.aspx");
73 WebTest.CopyResource (GetType (), "NoBindForMethodsWithBindInName.aspx", "NoBindForMethodsWithBindInName.aspx");
74 WebTest.CopyResource (GetType (), "ReadWritePropertyControl.ascx", "ReadWritePropertyControl.ascx");
75 WebTest.CopyResource (GetType (), "ContentPlaceHolderInTemplate.aspx", "ContentPlaceHolderInTemplate.aspx");
76 WebTest.CopyResource (GetType (), "ContentPlaceHolderInTemplate.master", "ContentPlaceHolderInTemplate.master");
77 WebTest.CopyResource (GetType (), "LinkInHeadWithEmbeddedExpression.aspx", "LinkInHeadWithEmbeddedExpression.aspx");
78 WebTest.CopyResource (GetType (), "ExpressionInListControl.aspx", "ExpressionInListControl.aspx");
79 WebTest.CopyResource (GetType (), "PreprocessorDirectivesInMarkup.aspx", "PreprocessorDirectivesInMarkup.aspx");
84 [NUnit.Framework.Category ("NunitWeb")]
86 [NUnit.Framework.Category ("NotWorking")]
88 public void ReadOnlyPropertyBindTest ()
90 new WebTest ("ReadOnlyPropertyBind.aspx").Run ();
94 // Test for bug #449970
96 public void MasterPageContentPlaceHolderInTemplate ()
98 new WebTest ("ContentPlaceHolderInTemplate.aspx").Run ();
102 [ExpectedException ("System.Web.Compilation.CompilationException")]
103 public void InvalidPropertyBindTest1 ()
105 new WebTest ("InvalidPropertyBind1.aspx").Run ();
109 [ExpectedException (typeof (HttpParseException))]
110 public void InvalidPropertyBindTest2 ()
112 new WebTest ("InvalidPropertyBind2.aspx").Run ();
116 [ExpectedException ("System.Web.Compilation.CompilationException")]
117 public void InvalidPropertyBindTest3 ()
119 new WebTest ("InvalidPropertyBind3.aspx").Run ();
123 [ExpectedException (typeof (HttpParseException))]
124 public void InvalidPropertyBindTest4 ()
126 new WebTest ("InvalidPropertyBind4.aspx").Run ();
130 public void ValidPropertyBindTest1 ()
132 new WebTest ("ValidPropertyBind1.aspx").Run ();
136 public void ValidPropertyBindTest2 ()
138 new WebTest ("ValidPropertyBind2.aspx").Run ();
142 public void ValidPropertyBindTest3 ()
144 new WebTest ("ValidPropertyBind3.aspx").Run ();
148 public void ValidPropertyBindTest4 ()
150 new WebTest ("ValidPropertyBind4.aspx").Run ();
154 public void ValidPropertyBindTest5 ()
156 new WebTest ("ValidPropertyBind5.aspx").Run ();
161 public void NoBindForMethodsWithBindInNameTest ()
163 string pageHtml = new WebTest ("NoBindForMethodsWithBindInName.aspx").Run ();
164 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
165 string originalHtml = "<span id=\"grid_ctl02_lblTest\">Test</span>";
167 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
172 public void LinkInHeadWithEmbeddedExpression ()
174 string pageHtml = new WebTest ("LinkInHeadWithEmbeddedExpression.aspx").Run ();
175 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
176 string originalHtml = "<link href=\"Themes/Default/Content/Site.css\" rel=\"stylesheet\" type=\"text/css\" />";
178 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
182 public void ExpressionInListControl ()
184 string pageHtml = new WebTest ("ExpressionInListControl.aspx").Run ();
185 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
186 string originalHtml = @"<select name=""DropDown1"" id=""DropDown1"">
187 <option value=""strvalue"">str</option>
190 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
193 [Test (Description="Bug #508888")]
194 public void ServerSideControlsInScriptBlock ()
196 string pageHtml = new WebTest ("ServerSideControlsInScriptBlock.aspx").Run ();
197 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
198 string originalHtml = @"<script type=""text/javascript"">alert (escape(""reporting/location?report=ViewsByDate&minDate=minDate&maxDate=maxDate""));</script>";
199 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
202 [Test (Description="Bug #520024")]
203 public void PreprocessorDirectivesInMarkup ()
205 // Just test if it doesn't throw an exception
206 new WebTest ("PreprocessorDirectivesInMarkup.aspx").Run ();
209 [Test (Description="Bug #526449")]
210 public void NewlineInCodeExpression ()
212 string pageHtml = new WebTest ("NewlineInCodeExpression.aspx").Run ();
213 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
214 string originalHtml = "<a href=\"test\">bla</a>";
215 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
219 [Test (Description="Bug #525104")]
220 [ExpectedException (typeof (HttpException))]
221 public void DuplicateControlsInClientComment ()
223 // Just test if it throws an exception
224 new WebTest ("DuplicateControlsInClientCommment.aspx").Run ();
227 [Test (Description="Bug #517656")]
228 public void ServerControlInClientSideComment ()
230 string pageHtml = new WebTest ("ServerControlInClientSideComment.aspx").Run ();
231 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
232 string originalHtml = @"<!-- comment start
233 <input id=""testBox"" type=""checkbox"" name=""testBox"" />
235 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
239 public void UnquotedAngleBrackets ()
241 // We just test if it doesn't throw an exception
242 new WebTest ("UnquotedAngleBrackets.aspx").Run ();
246 public void FullTagsInText ()
248 // We just test if it doesn't throw an exception
249 new WebTest ("FullTagsInText.aspx").Run ();
253 public void TagsExpressionsAndCommentsInText ()
255 // We just test if it doesn't throw an exception
256 new WebTest ("TagsExpressionsAndCommentsInText.aspx").Run ();
260 public void ChildTemplatesTest ()
263 WebTest.Host.AppDomain.AssemblyResolve += new ResolveEventHandler (ResolveAssemblyHandler);
264 new WebTest ("TemplateControlParsingTest.aspx").Run ();
266 WebTest.Host.AppDomain.AssemblyResolve -= new ResolveEventHandler (ResolveAssemblyHandler);
270 [TestFixtureTearDown]
271 public void TearDown ()
277 public static Assembly ResolveAssemblyHandler (object sender, ResolveEventArgs e)
279 if (e.Name != "System.Web_test")
282 return Assembly.GetExecutingAssembly ();