Merge pull request #4570 from lateralusX/jlorenss/visual_studio_msbuild_fix
[mono.git] / mcs / class / System.Web.Extensions / Test / standalone-tests / DataPager_NumericPagerField_Bug615315.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.IO;
31 using System.Web.Util;
32
33 using StandAloneRunnerSupport;
34 using StandAloneTests;
35
36 using NUnit.Framework;
37
38 namespace StandAloneTests.DataPager_NumericPagerField_Bug615315
39 {
40         [TestCase ("DataPager_NumericPagerField_Bug615315, Test 01", "Page numbers must be sequential (Query Mode)")]
41         public sealed class Test_01 : ITestCase
42         {
43                 public string PhysicalPath {
44                         get { return Path.Combine (Consts.BasePhysicalDir, "DataPager_NumericPagerField_Bug615315"); }
45                 }
46                 
47                 public string VirtualPath  {
48                         get { return "/"; }
49                 }
50
51                 public bool SetUp (List <TestRunItem> runItems)
52                 {
53                         runItems.Add (new TestRunItem ("Test_QueryMode.aspx", TestQueryMode_Aspx_Start));
54                         runItems.Add (new TestRunItem ("Test_QueryMode.aspx?pageNumber=2", TestQueryMode_Aspx_Page2));
55                         return true;
56                 }
57                 
58                 void TestQueryMode_Aspx_Start (string result, TestRunItem runItem)
59                 {
60                         string originalHtml = @"<span id=""ctl00_ContentPlaceHolder1_ListView1_DataPager1""><a class=""aspNetDisabled"">First</a>&nbsp;<span>1</span>&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=2"">2</a>&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=3"">3</a>&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=4"">4</a>&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=5"">5</a>&nbsp;&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=6"">...</a>&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=10"">Last</a>&nbsp;</span>";
61                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
62                 }
63
64                 void TestQueryMode_Aspx_Page2 (string result, TestRunItem runItem)
65                 {
66                         string originalHtml = @"<span id=""ctl00_ContentPlaceHolder1_ListView1_DataPager1""><a href=""/Test_QueryMode.aspx?pageNumber=1"">First</a>&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=1"">1</a>&nbsp;<span>2</span>&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=3"">3</a>&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=4"">4</a>&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=5"">5</a>&nbsp;&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=6"">...</a>&nbsp;<a href=""/Test_QueryMode.aspx?pageNumber=10"">Last</a>&nbsp;</span>";
67                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
68                 }
69         }
70
71         [TestCase ("DataPager_NumericPagerField_Bug615315, Test 02", "Page numbers must be sequential (PostBack Mode)")]
72         public sealed class Test_02 : ITestCase
73         {
74                 public string PhysicalPath {
75                         get { return Path.Combine (Consts.BasePhysicalDir, "DataPager_NumericPagerField_Bug615315"); }
76                 }
77                 
78                 public string VirtualPath  {
79                         get { return "/"; }
80                 }
81
82                 public bool SetUp (List <TestRunItem> runItems)
83                 {
84                         runItems.Add (new TestRunItem ("Test_PostBackMode.aspx", TestPostBackMode_Aspx_Start));
85 #if BUG_IN_THE_RUNTIME_IS_FIXED
86                         // With this version of code, the runtime segfaults. Until this is fixed,
87                         // we'll be using an alternative version of the code
88                         runItems.Add (new TestRunItem ("Default.aspx", TestPostBackMode_Aspx_Page2) {
89                                         PostValues = new SerializableDictionary <string, string> {
90                                                 {"__EVENTTARGET", "ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl01"},
91                                                 {"__EVENTARGUMENT", String.Empty}
92                                         },
93                                         UrlDescription = "Page 2"
94                                 }
95                         );
96 #else
97                         runItems.Add (new TestRunItem ("Test_PostBackMode.aspx", TestPostBackMode_Aspx_Page2) {
98                                         PostValues = new string[] {
99                                                 "__EVENTTARGET", "ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl01",
100                                                 "__EVENTARGUMENT", String.Empty
101                                         },
102                                         UrlDescription = "Page 2"
103                                 }
104                         );
105                         
106                         runItems.Add (new TestRunItem ("Test_PostBackMode.aspx", TestPostBackMode_Aspx_PageNext) {
107                                         PostValues = new string[] {
108                                                 "__EVENTTARGET", "ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl05",
109                                                 "__EVENTARGUMENT", String.Empty
110                                         },
111                                         UrlDescription = "Page 6 (next)"
112                                 }
113                         );
114
115                         runItems.Add (new TestRunItem ("Test_PostBackMode.aspx", TestPostBackMode_Aspx_PagePrev) {
116                                         PostValues = new string[] {
117                                                 "__EVENTTARGET", "ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl00",
118                                                 "__EVENTARGUMENT", String.Empty
119                                         },
120                                         UrlDescription = "Page 5 (prev)"
121                                 }
122                         );
123 #endif
124
125                         return true;
126                 }
127                 
128                 void TestPostBackMode_Aspx_Start (string result, TestRunItem runItem)
129                 {
130                         string originalHtml = @"<span id=""ctl00_ContentPlaceHolder1_ListView1_DataPager1""><input type=""submit"" name=""ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl00$ctl00"" value=""First"" disabled=""disabled"" />&nbsp;<span>1</span>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl01&#39;,&#39;&#39;)"">2</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl02&#39;,&#39;&#39;)"">3</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl03&#39;,&#39;&#39;)"">4</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl04&#39;,&#39;&#39;)"">5</a>&nbsp;&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl05&#39;,&#39;&#39;)"">...</a>&nbsp;<input type=""submit"" name=""ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl02$ctl00"" value=""Last"" />&nbsp;</span>";
131                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
132                 }
133
134                 void TestPostBackMode_Aspx_Page2 (string result, TestRunItem runItem)
135                 {
136                         string originalHtml = @"<span id=""ctl00_ContentPlaceHolder1_ListView1_DataPager1""><input type=""submit"" name=""ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl00$ctl00"" value=""First"" />&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl00&#39;,&#39;&#39;)"">1</a>&nbsp;<span>2</span>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl02&#39;,&#39;&#39;)"">3</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl03&#39;,&#39;&#39;)"">4</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl04&#39;,&#39;&#39;)"">5</a>&nbsp;&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl05&#39;,&#39;&#39;)"">...</a>&nbsp;<input type=""submit"" name=""ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl02$ctl00"" value=""Last"" />&nbsp;</span>";
137                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
138                 }
139
140                 void TestPostBackMode_Aspx_PageNext (string result, TestRunItem runItem)
141                 {
142                         string originalHtml = @"<span id=""ctl00_ContentPlaceHolder1_ListView1_DataPager1""><input type=""submit"" name=""ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl00$ctl00"" value=""First"" />&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl00&#39;,&#39;&#39;)"">...</a>&nbsp;<span>6</span>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl02&#39;,&#39;&#39;)"">7</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl03&#39;,&#39;&#39;)"">8</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl04&#39;,&#39;&#39;)"">9</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl05&#39;,&#39;&#39;)"">10</a>&nbsp;<input type=""submit"" name=""ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl02$ctl00"" value=""Last"" />&nbsp;</span>";
143                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
144                 }
145
146                 void TestPostBackMode_Aspx_PagePrev (string result, TestRunItem runItem)
147                 {
148                         string originalHtml = @"<span id=""ctl00_ContentPlaceHolder1_ListView1_DataPager1""><input type=""submit"" name=""ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl00$ctl00"" value=""First"" />&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl00&#39;,&#39;&#39;)"">1</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl01&#39;,&#39;&#39;)"">2</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl02&#39;,&#39;&#39;)"">3</a>&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl03&#39;,&#39;&#39;)"">4</a>&nbsp;<span>5</span>&nbsp;&nbsp;<a href=""javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl01$ctl05&#39;,&#39;&#39;)"">...</a>&nbsp;<input type=""submit"" name=""ctl00$ContentPlaceHolder1$ListView1$DataPager1$ctl02$ctl00"" value=""Last"" />&nbsp;</span>";
149                         Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
150                 }
151         }
152 }
153