Browse Source

[asp.net] Added first test for Menu list rendering in 4.0

Marek Habersack 15 years ago
parent
commit
a2d4e011e0

+ 1 - 0
mcs/class/System.Web/System.Web_standalone_test.dll.sources

@@ -21,3 +21,4 @@ Test/standalone-tests/GridViewSortingStyles.cs
 Test/standalone-tests/SiteMapPathRendering.cs
 Test/standalone-tests/PageParserDefaultTypeProperties.cs
 Test/standalone-tests/ChildrenAsProperties.cs
+Test/standalone-tests/Menu_4.0_List.cs

+ 65 - 0
mcs/class/System.Web/Test/standalone-tests/Menu_4.0_List.cs

@@ -0,0 +1,65 @@
+//
+// Authors:
+//   Marek Habersack ([email protected])
+//
+// (C) 2010 Novell, Inc http://novell.com/
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_4_0
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Web.Util;
+
+using StandAloneRunnerSupport;
+using StandAloneTests;
+
+using NUnit.Framework;
+
+namespace StandAloneTests.Menu_40_List
+{
+	[TestCase ("Menu_40_List", "Menu control List rendering mode for 4.0")]
+	public sealed class Test_01 : ITestCase
+	{
+		public string PhysicalPath {
+			get { return Path.Combine (Consts.BasePhysicalDir, "Menu_4.0_List"); }
+		}
+		
+		public string VirtualPath  {
+			get { return "/"; }
+		}
+
+		public bool SetUp (List <TestRunItem> runItems)
+		{
+			runItems.Add (new TestRunItem ("test_01.aspx", Test_01_Aspx));
+			return true;
+		}
+		
+		void Test_01_Aspx (string result, TestRunItem runItem)
+		{
+			string originalHtml = "<a href=\"#MyMenu1_SkipLink\"><img alt=\"Skip Navigation Links\" src=\"/WebResource.axd\" width=\"0\" height=\"0\" style=\"border-width:0px;\" /></a><div id=\"MyMenu1\">\r\n\t<ul class=\"level1\">\r\n\t\t<li><a title=\"Root description\" class=\"popout level1\" href=\"./\">Root</a><ul class=\"level2\">\r\n\t\t\t<li><a title=\"Mono Project Home Page\" class=\"popout level2\" href=\"http://mono-project.com/\">Mono</a><ul class=\"level3\">\r\n\t\t\t\t<li><a title=\"How to report Mono bugs\" class=\"popout level3\" href=\"http://mono-project.com/Bugs\">Mono Bugs</a><ul class=\"level4\">\r\n\t\t\t\t\t<li><a title=\"Includes Mono bugs interface\" class=\"level4\" href=\"http://bugzilla.novell.com\">Novell Bugzilla</a></li>\r\n\t\t\t\t</ul></li>\r\n\t\t\t</ul></li><li><a title=\"Main page of the Google search engine\" class=\"popout level2\" href=\"http://google.com\">Google</a><ul class=\"level3\">\r\n\t\t\t\t<li><a title=\"Google language translation interface\" class=\"level3\" href=\"http://translate.google.com\">Translator</a></li><li><a title=\"Google code search engine\" class=\"level3\" href=\"http://google.com/codesearch\">Code Search</a></li>\r\n\t\t\t</ul></li>\r\n\t\t</ul></li>\r\n\t</ul>\r\n</div><a id=\"MyMenu1_SkipLink\"></a>";
+			Helpers.ExtractAndCompareCodeFromHtml (Helpers.StripWebResourceAxdQuery (result), originalHtml, "#A1");
+		}
+	}
+}
+#endif

+ 12 - 0
mcs/class/System.Web/Test/standalone/Menu_4.0_List/App_Data/MenuData.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<MenuRoot url="~/" title="Root" description="Root description">
+	<MenuNode url="http://mono-project.com/" title="Mono" description="Mono Project Home Page">
+		<MenuNode url="http://mono-project.com/Bugs" title="Mono Bugs" description="How to report Mono bugs">
+			<MenuNode url="http://bugzilla.novell.com" title="Novell Bugzilla" description="Includes Mono bugs interface"/>
+		</MenuNode>
+	</MenuNode>
+	<MenuNode url="http://google.com" title="Google" description="Main page of the Google search engine">
+		<MenuNode url="http://translate.google.com" title="Translator" description="Google language translation interface"/>
+		<MenuNode url="http://google.com/codesearch" title="Code Search" description="Google code search engine"/>
+	</MenuNode>
+</MenuRoot>

+ 25 - 0
mcs/class/System.Web/Test/standalone/Menu_4.0_List/test_01.aspx

@@ -0,0 +1,25 @@
+<%@ Page Language="C#" AutoEventWireup="true" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+    <title></title>
+</head>
+<body>
+    <form id="form1" runat="server">
+    <div>
+	
+	    <!-- START --><%= AppDomain.CurrentDomain.GetData ("BEGIN_CODE_MARKER") %><asp:Menu ID="MyMenu1" runat="server" RenderingMode="List" DataSourceID="MenuDataSource" StaticDisplayLevels="1">
+	    <DataBindings>
+	    <asp:MenuItemBinding DataMember="MenuRoot" Depth="0" TextField="title" NavigateUrlField="url" ToolTipField="description" />
+	    <asp:MenuItemBinding DataMember="MenuNode" Depth="1" TextField="title" NavigateUrlField="url" ToolTipField="description" />
+	    <asp:MenuItemBinding DataMember="MenuNode" Depth="2" TextField="title" NavigateUrlField="url" ToolTipField="description" />
+	    <asp:MenuItemBinding DataMember="MenuNode" Depth="3" TextField="title" NavigateUrlField="url" ToolTipField="description" />
+	    </DataBindings>
+	    </asp:Menu><%= AppDomain.CurrentDomain.GetData ("END_CODE_MARKER") %><!-- END -->
+	    <asp:XmlDataSource ID="MenuDataSource" runat="server" DataFile="~/App_Data/MenuData.xml" />
+    </div>
+    </form>
+</body>
+</html>

+ 7 - 0
mcs/class/System.Web/Test/standalone/Menu_4.0_List/web.config

@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<configuration>
+	<system.web>
+		<compilation debug="true" targetFramework="4.0" />
+		<customErrors mode="Off"/>
+	</system.web>
+</configuration>