| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 
 | using System;
using System.Collections.Generic;
using MonoTests.SystemWeb.Framework;
using MonoTests.stand_alone.WebHarness;
using NUnit.Framework;
using System.Web;
using System.Web.Compilation;
using System.Web.UI.WebControls;
using System.Reflection;
using System.ComponentModel;
using System.Threading;
namespace MonoTests.System.Web.Compilation {
	public class ReadOnlyPropertyControl:TextBox {
		[Bindable (true)]
		public bool MyProp
		{
			get { return true; }
		}
	}
	public class BindTestDataItem
	{
		int data;
		public int Data {
			get { return data; }
			set { data = value; }
		}
		public BindTestDataItem (int data)
		{
			this.data = data;
		}
	}
	
	public class BindTestDataSource 
	{
		public IList <BindTestDataItem> GetData ()
		{
			return new List <BindTestDataItem> {new BindTestDataItem (0), new BindTestDataItem (1)};
		}
	}
	
	[TestFixture]
	public class TemplateControlCompilerTest
	{
		[TestFixtureSetUp]
		public void TemplateControlCompiler_Init ()
		{
			WebTest.CopyResource (GetType (), "ReadOnlyPropertyBind.aspx", "ReadOnlyPropertyBind.aspx");
			WebTest.CopyResource (GetType (), "ReadOnlyPropertyControl.ascx", "ReadOnlyPropertyControl.ascx");
			WebTest.CopyResource (GetType (), "TemplateControlParsingTest.aspx", "TemplateControlParsingTest.aspx");
			WebTest.CopyResource (GetType (), "ServerSideControlsInScriptBlock.aspx", "ServerSideControlsInScriptBlock.aspx");
			WebTest.CopyResource (GetType (), "ServerControlInClientSideComment.aspx", "ServerControlInClientSideComment.aspx");
			WebTest.CopyResource (GetType (), "UnquotedAngleBrackets.aspx", "UnquotedAngleBrackets.aspx");
			WebTest.CopyResource (GetType (), "FullTagsInText.aspx", "FullTagsInText.aspx");
			WebTest.CopyResource (GetType (), "TagsExpressionsAndCommentsInText.aspx", "TagsExpressionsAndCommentsInText.aspx");
			WebTest.CopyResource (GetType (), "NewlineInCodeExpression.aspx", "NewlineInCodeExpression.aspx");
			WebTest.CopyResource (GetType (), "DuplicateControlsInClientComment.aspx", "DuplicateControlsInClientComment.aspx");
			WebTest.CopyResource (GetType (), "TagsNestedInClientTag.aspx", "TagsNestedInClientTag.aspx");
			WebTest.CopyResource (GetType (), "ConditionalClientComments.aspx", "ConditionalClientComments.aspx");
			WebTest.CopyResource (GetType (), "InvalidPropertyBind1.aspx", "InvalidPropertyBind1.aspx");
			WebTest.CopyResource (GetType (), "InvalidPropertyBind2.aspx", "InvalidPropertyBind2.aspx");
			WebTest.CopyResource (GetType (), "InvalidPropertyBind3.aspx", "InvalidPropertyBind3.aspx");
			WebTest.CopyResource (GetType (), "InvalidPropertyBind4.aspx", "InvalidPropertyBind4.aspx");
			WebTest.CopyResource (GetType (), "ValidPropertyBind1.aspx", "ValidPropertyBind1.aspx");
			WebTest.CopyResource (GetType (), "ValidPropertyBind2.aspx", "ValidPropertyBind2.aspx");
			WebTest.CopyResource (GetType (), "ValidPropertyBind3.aspx", "ValidPropertyBind3.aspx");
			WebTest.CopyResource (GetType (), "ValidPropertyBind4.aspx", "ValidPropertyBind4.aspx");
			WebTest.CopyResource (GetType (), "ValidPropertyBind5.aspx", "ValidPropertyBind5.aspx");
			WebTest.CopyResource (GetType (), "NoBindForMethodsWithBindInName.aspx", "NoBindForMethodsWithBindInName.aspx");
			WebTest.CopyResource (GetType (), "ReadWritePropertyControl.ascx", "ReadWritePropertyControl.ascx");
			WebTest.CopyResource (GetType (), "ContentPlaceHolderInTemplate.aspx", "ContentPlaceHolderInTemplate.aspx");
			WebTest.CopyResource (GetType (), "ContentPlaceHolderInTemplate.master", "ContentPlaceHolderInTemplate.master");
			WebTest.CopyResource (GetType (), "LinkInHeadWithEmbeddedExpression.aspx", "LinkInHeadWithEmbeddedExpression.aspx");
			WebTest.CopyResource (GetType (), "ExpressionInListControl.aspx", "ExpressionInListControl.aspx");
			WebTest.CopyResource (GetType (), "PreprocessorDirectivesInMarkup.aspx", "PreprocessorDirectivesInMarkup.aspx");
			WebTest.CopyResource (GetType (), "OneLetterIdentifierInCodeRender.aspx", "OneLetterIdentifierInCodeRender.aspx");
			WebTest.CopyResource (GetType (), "NestedParserFileText.aspx", "NestedParserFileText.aspx");
			WebTest.CopyResource (GetType (), "TagWithExpressionWithinAttribute.aspx", "TagWithExpressionWithinAttribute.aspx");
			WebTest.CopyResource (GetType (), "EnumConverter_Bug578586.aspx", "EnumConverter_Bug578586.aspx");
		}
		
        	[Test]
		[NUnit.Framework.Category ("NunitWeb")]
		[NUnit.Framework.Category ("NotWorking")]
		public void ReadOnlyPropertyBindTest ()
		{
			new WebTest ("ReadOnlyPropertyBind.aspx").Run ();
		}
		// Test for bug #449970
		[Test]
		public void MasterPageContentPlaceHolderInTemplate ()
		{
			new WebTest ("ContentPlaceHolderInTemplate.aspx").Run ();
		}
		
		[Test]
		[ExpectedException ("System.Web.Compilation.CompilationException")]
		public void InvalidPropertyBindTest1 ()
		{
			new WebTest ("InvalidPropertyBind1.aspx").Run ();
		}
		[Test]
		[ExpectedException (typeof (HttpParseException))]
		public void InvalidPropertyBindTest2 ()
		{
			new WebTest ("InvalidPropertyBind2.aspx").Run ();
		}
		[Test]
		[ExpectedException ("System.Web.Compilation.CompilationException")]
		public void InvalidPropertyBindTest3 ()
		{
			new WebTest ("InvalidPropertyBind3.aspx").Run ();
		}
		[Test]
		[ExpectedException (typeof (HttpParseException))]
		public void InvalidPropertyBindTest4 ()
		{
			new WebTest ("InvalidPropertyBind4.aspx").Run ();
		}
		[Test]
		public void ValidPropertyBindTest1 ()
		{
			new WebTest ("ValidPropertyBind1.aspx").Run ();
		}
		[Test]
		public void ValidPropertyBindTest2 ()
		{
			new WebTest ("ValidPropertyBind2.aspx").Run ();
		}
		[Test]
		public void ValidPropertyBindTest3 ()
		{
			new WebTest ("ValidPropertyBind3.aspx").Run ();
		}
		[Test]
		public void ValidPropertyBindTest4 ()
		{
			new WebTest ("ValidPropertyBind4.aspx").Run ();
		}
		[Test]
		public void ValidPropertyBindTest5 ()
		{
			new WebTest ("ValidPropertyBind5.aspx").Run ();
		}
		// bug #493639
		[Test]
		public void NoBindForMethodsWithBindInNameTest ()
		{
			string pageHtml = new WebTest ("NoBindForMethodsWithBindInName.aspx").Run ();
			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
			string originalHtml = "<span id=\"grid_ctl02_lblTest\">Test</span>";
			
			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
		}
		// bug #498637
		[Test]
		public void LinkInHeadWithEmbeddedExpression ()
		{
			string pageHtml = new WebTest ("LinkInHeadWithEmbeddedExpression.aspx").Run ();
			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
			string originalHtml = "<link href=\"Themes/Default/Content/Site.css\" rel=\"stylesheet\" type=\"text/css\" />";
			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
		}
		[Test]
		public void ExpressionInListControl ()
		{
			string pageHtml = new WebTest ("ExpressionInListControl.aspx").Run ();
			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
			string originalHtml = @"<select name=""DropDown1"" id=""DropDown1"">
	<option value=""strvalue"">str</option>
</select>";
			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
		}
		[Test (Description="Bug #508888")]
		public void ServerSideControlsInScriptBlock ()
		{
			string pageHtml = new WebTest ("ServerSideControlsInScriptBlock.aspx").Run ();
			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
			string originalHtml = @"<script type=""text/javascript"">alert (escape(""reporting/location?report=ViewsByDate&minDate=minDate&maxDate=maxDate""));</script>";
			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
		}
		[Test (Description="Bug #520024")]
		public void PreprocessorDirectivesInMarkup ()
		{
			// Just test if it doesn't throw an exception
			new WebTest ("PreprocessorDirectivesInMarkup.aspx").Run ();
		}
		[Test (Description="Bug #526449")]
		public void NewlineInCodeExpression ()
		{
			string pageHtml = new WebTest ("NewlineInCodeExpression.aspx").Run ();
			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
			string originalHtml = "<a href=\"test\">bla</a>";
			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
		}
		[Test (Description="Bug #524358")]
		public void DuplicateControlsInClientComment ()
		{
			// Just test if it throws an exception
			string pageHtml = new WebTest ("DuplicateControlsInClientComment.aspx").Run ();
			Assert.IsTrue (pageHtml.IndexOf ("[System.Web.Compilation.ParseException]:") != -1, "#A1");
		}
		[Test (Description="Bug #367723")]
		public void ConditionalClientComments ()
		{
			string pageHtml = new WebTest ("ConditionalClientComments.aspx").Run ();
			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
			string originalHtml = @"<!--[if IE 6]>
		<link rel=""styleheet"" type=""text/css"" href=""~/compat-ie6.css""></link>
	<![endif]-->";
			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
		}
		
		[Test (Description="Bug #400807")]
		public void OneLetterIdentifierInCodeRender ()
		{
			string pageHtml = new WebTest ("OneLetterIdentifierInCodeRender.aspx").Run ();
			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
			string originalHtml = @"bDoR called";
			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
		}
		[Test (Description="Bug #562286")]
		public void NestedParserFileText ()
		{
			// Just test if it doesn't throw an exception
			new WebTest ("NestedParserFileText.aspx").Run ();
		}
		[Test (Description="Bug #568631")]
		public void TagWithExpressionWithinAttribute ()
		{
			// Just test if it doesn't throw an exception
			new WebTest ("TagWithExpressionWithinAttribute.aspx").Run ();
		}
		[Test (Description="Bug #578586")]
		public void EnumConverter_Bug578586 ()
		{
			WebTest t = new WebTest ("EnumConverter_Bug578586.aspx");
			string pageHtml = t.Run ();
			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
			string originalHtml = @"<input type=""text"" value=""FlagOne"" name=""test"" id=""test"" />";
			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
		}
		[Test (Description="Bug #323719")]
		public void TagsNestedInClientTag ()
		{
			string pageHtml = new WebTest ("TagsNestedInClientTag.aspx").Run ();
			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
			string originalHtml = @"<script language=""javascript"" src=""/js/test.js"" type=""text/javascript""></script>
<sometag language=""javascript"" src=""/js/test.js"" type=""text/javascript""></sometag>";
			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
		}
		
		[Test (Description="Bug #517656")]
		public void ServerControlInClientSideComment ()
		{
			string pageHtml = new WebTest ("ServerControlInClientSideComment.aspx").Run ();
			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
			string originalHtml = @"<!-- comment start
  <input id=""testBox"" type=""checkbox"" name=""testBox"" />
comment end -->";
			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
		}
		[Test]
		public void UnquotedAngleBrackets ()
		{
			// We just test if it doesn't throw an exception
			new WebTest ("UnquotedAngleBrackets.aspx").Run ();
		}
		[Test]
		public void FullTagsInText ()
		{
			// We just test if it doesn't throw an exception
			new WebTest ("FullTagsInText.aspx").Run ();
		}
		[Test]
		public void TagsExpressionsAndCommentsInText ()
		{
			// We just test if it doesn't throw an exception
			new WebTest ("TagsExpressionsAndCommentsInText.aspx").Run ();
		}
		
		[Test]
		public void ChildTemplatesTest ()
		{
			try {
				WebTest.Host.AppDomain.AssemblyResolve += new ResolveEventHandler (ResolveAssemblyHandler);
				new WebTest ("TemplateControlParsingTest.aspx").Run ();
			} finally {
				WebTest.Host.AppDomain.AssemblyResolve -= new ResolveEventHandler (ResolveAssemblyHandler);
			}
		}
		
		[TestFixtureTearDown]
		public void TearDown ()
		{
			Thread.Sleep (100);
			WebTest.Unload ();
		}
		public static Assembly ResolveAssemblyHandler (object sender, ResolveEventArgs e)
		{
			if (e.Name != "System.Web_test")
				return null;
			return Assembly.GetExecutingAssembly ();
		}
	}
}
 |