[SRE] Improved token fixups processing.
[mono.git] / mcs / class / System.Web / Test / standalone-tests / GridViewSortingStyles.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.IO;
32 using System.Web.Util;
33
34 using StandAloneRunnerSupport;
35 using StandAloneTests;
36
37 using NUnit.Framework;
38
39 namespace StandAloneTests.GridViewSortingStyles
40 {
41         [TestCase ("GridViewSortingStyles 01", "GridView supports separate styles for headers/cells when sorting.")]
42         public sealed class Test_01 : ITestCase
43         {
44                 public string PhysicalPath {
45                         get { return Path.Combine (Consts.BasePhysicalDir, "GridViewSortingStyles"); }
46                 }
47                 
48                 public string VirtualPath  {
49                         get { return "/"; }
50                 }
51
52                 public bool SetUp (List <TestRunItem> runItems)
53                 {
54                         runItems.Add (new TestRunItem ("Default.aspx", Default_Aspx));
55                         runItems.Add (new TestRunItem ("Default.aspx", Default_Aspx_Ascending_ProductName) {
56                                         PostValues = new string[] {
57                                                 "__EVENTTARGET", "GridView1",
58                                                 "__EVENTARGUMENT", "Sort$ProductName"
59                                         },
60                                         UrlDescription = "Ascending sorting on ProductName"
61                                 }
62                         );
63                         runItems.Add (new TestRunItem ("Default.aspx", Default_Aspx_Descending_ProductName) {
64                                         PostValues = new string[] {
65                                                 "__EVENTTARGET", "GridView1",
66                                                 "__EVENTARGUMENT", "Sort$ProductName"
67                                         },
68                                         UrlDescription = "Descending sorting on ProductName"
69                                 }
70                         );
71                         runItems.Add (new TestRunItem ("Default.aspx", Default_Aspx_Ascending_ProductID) {
72                                         PostValues = new string[] {
73                                                 "__EVENTTARGET", "GridView1",
74                                                 "__EVENTARGUMENT", "Sort$ProductID"
75                                         },
76                                         UrlDescription = "Ascending sorting on ProductID"
77                                 }
78                         );
79                         runItems.Add (new TestRunItem ("Default.aspx", Default_Aspx_Descending_ProductID) {
80                                         PostValues = new string[] {
81                                                 "__EVENTTARGET", "GridView1",
82                                                 "__EVENTARGUMENT", "Sort$ProductID"
83                                         },
84                                         UrlDescription = "Descending sorting on ProductID"
85                                 }
86                         );
87                         return true;
88                 }
89                 
90                 void Default_Aspx (string result, TestRunItem runItem)
91                 {
92                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"GridView1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\"><a href=\"javascript:__doPostBack(&#39;GridView1&#39;,&#39;Sort$ProductName&#39;)\">Name</a></th><th scope=\"col\"><a href=\"javascript:__doPostBack(&#39;GridView1&#39;,&#39;Sort$ProductID&#39;)\">ID</a></th>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Pear</td><td>1</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Apple</td><td>2</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Orange</td><td>3</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
93                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
94                 }
95
96                 void Default_Aspx_Ascending_ProductName (string result, TestRunItem runItem)
97                 {
98                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"GridView1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\" style=\"background-color:Yellow;\"><a href=\"javascript:__doPostBack(&#39;GridView1&#39;,&#39;Sort$ProductName&#39;)\">Name</a></th><th scope=\"col\"><a href=\"javascript:__doPostBack(&#39;GridView1&#39;,&#39;Sort$ProductID&#39;)\">ID</a></th>\r\n\t\t</tr><tr>\r\n\t\t\t<td style=\"background-color:LightYellow;\">Apple</td><td>2</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td style=\"background-color:LightYellow;\">Orange</td><td>3</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td style=\"background-color:LightYellow;\">Pear</td><td>1</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
99                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
100                 }
101
102                 void Default_Aspx_Descending_ProductName (string result, TestRunItem runItem)
103                 {
104                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"GridView1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\" style=\"background-color:LightBlue;\"><a href=\"javascript:__doPostBack(&#39;GridView1&#39;,&#39;Sort$ProductName&#39;)\">Name</a></th><th scope=\"col\"><a href=\"javascript:__doPostBack(&#39;GridView1&#39;,&#39;Sort$ProductID&#39;)\">ID</a></th>\r\n\t\t</tr><tr>\r\n\t\t\t<td style=\"background-color:AliceBlue;\">Pear</td><td>1</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td style=\"background-color:AliceBlue;\">Orange</td><td>3</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td style=\"background-color:AliceBlue;\">Apple</td><td>2</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
105                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
106                 }
107
108                 void Default_Aspx_Ascending_ProductID (string result, TestRunItem runItem)
109                 {
110                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"GridView1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\"><a href=\"javascript:__doPostBack(&#39;GridView1&#39;,&#39;Sort$ProductName&#39;)\">Name</a></th><th scope=\"col\" style=\"background-color:Yellow;\"><a href=\"javascript:__doPostBack(&#39;GridView1&#39;,&#39;Sort$ProductID&#39;)\">ID</a></th>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Pear</td><td style=\"background-color:LightYellow;\">1</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Apple</td><td style=\"background-color:LightYellow;\">2</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Orange</td><td style=\"background-color:LightYellow;\">3</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
111                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
112                 }
113
114                 void Default_Aspx_Descending_ProductID (string result, TestRunItem runItem)
115                 {
116                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"GridView1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\"><a href=\"javascript:__doPostBack(&#39;GridView1&#39;,&#39;Sort$ProductName&#39;)\">Name</a></th><th scope=\"col\" style=\"background-color:LightBlue;\"><a href=\"javascript:__doPostBack(&#39;GridView1&#39;,&#39;Sort$ProductID&#39;)\">ID</a></th>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Orange</td><td style=\"background-color:AliceBlue;\">3</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Apple</td><td style=\"background-color:AliceBlue;\">2</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Pear</td><td style=\"background-color:AliceBlue;\">1</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
117                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
118                 }
119         }
120 }
121 #endif