+2010-06-16 Marek Habersack <mhabersack@novell.com>
+
+ * FormView.cs: row values must be retrieved with inclusion of
+ keys. Fixes bug #607722
+
2010-06-03 Marek Habersack <mhabersack@novell.com>
* Parameter.cs, ControlParameter.cs, SessionParameter.cs,
currentEditOldValues = OldEditValues.Values;
currentEditRowKeys = DataKey.Values;
- currentEditNewValues = GetRowValues (false);
+ currentEditNewValues = GetRowValues (true);
FormViewUpdateEventArgs args = new FormViewUpdateEventArgs (param, currentEditRowKeys, currentEditOldValues, currentEditNewValues);
OnItemUpdating (args);
Test/standalone-tests/Control_GetUniqueIDRelativeTo.cs
Test/standalone-tests/RegisterBuildProvider.cs
Test/standalone-tests/PageMetaAttributes.cs
+Test/standalone-tests/FormViewUpdateParameters_Bug607722.cs
--- /dev/null
+//
+// Authors:
+// Marek Habersack (mhabersack@novell.com)
+//
+// (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.
+//
+using System;
+using System.Collections.Generic;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace StandAloneRunnerSupport
+{
+ [Serializable]
+ public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, IXmlSerializable
+ {
+ public System.Xml.Schema.XmlSchema GetSchema ()
+ {
+ return null;
+ }
+
+ public void ReadXml (XmlReader reader)
+ {
+ XmlSerializer keySerializer = new XmlSerializer (typeof (TKey));
+ XmlSerializer valueSerializer = new XmlSerializer (typeof (TValue));
+
+ bool wasEmpty = reader.IsEmptyElement;
+ reader.Read ();
+
+ if (wasEmpty)
+ return;
+
+ while (reader.NodeType != System.Xml.XmlNodeType.EndElement) {
+ reader.ReadStartElement ("item");
+
+ reader.ReadStartElement ("key");
+ TKey key = (TKey) keySerializer.Deserialize (reader);
+ reader.ReadEndElement ();
+
+ reader.ReadStartElement ("value");
+ TValue value = (TValue) valueSerializer.Deserialize (reader);
+ reader.ReadEndElement ();
+
+ this.Add (key, value);
+
+ reader.ReadEndElement ();
+ reader.MoveToContent ();
+ }
+ reader.ReadEndElement ();
+ }
+
+ public void WriteXml (XmlWriter writer)
+ {
+ XmlSerializer keySerializer = new XmlSerializer (typeof (TKey));
+ XmlSerializer valueSerializer = new XmlSerializer (typeof (TValue));
+
+ foreach (TKey key in this.Keys) {
+ writer.WriteStartElement ("item");
+
+ writer.WriteStartElement ("key");
+ keySerializer.Serialize (writer, key);
+ writer.WriteEndElement ();
+
+ writer.WriteStartElement ("value");
+ TValue value = this [key];
+ valueSerializer.Serialize (writer, value);
+ writer.WriteEndElement ();
+
+ writer.WriteEndElement ();
+ }
+ }
+ }
+}
\ No newline at end of file
using System.Web;
using System.Web.Hosting;
+using MonoTests.SystemWeb.Framework;
using NUnit.Framework;
namespace StandAloneRunnerSupport
return;
}
- string result;
+ Response response;
TestRunner runner;
try {
Console.Write ('[');
Success = false;
throw new InvalidOperationException ("runner must not be null.");
}
- result = runner.Run (tri.Url, tri.PathInfo);
+ response = runner.Run (tri.Url, tri.PathInfo, tri.PostValues);
if (tri.Callback == null)
continue;
tri.TestRunData = runner.TestRunData;
- tri.Callback (result, tri);
+ tri.Callback (response.Body, tri);
Console.Write ('.');
} catch (Exception) {
FailedUrl = tri.Url;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
+using System.Collections.Generic;
using System.Web;
using System.Web.Hosting;
get; set;
}
+ public SerializableDictionary <string, string> PostValues {
+ get; set;
+ }
+
public TestRunItem ()
: this (null, null, null)
{}
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
+using System.Collections.Generic;
using System.IO;
+using System.Net;
using System.Text;
using System.Web;
using System.Web.Hosting;
+using MonoTests.SystemWeb.Framework;
+
namespace StandAloneRunnerSupport
{
public sealed class TestRunner : MarshalByRefObject, IRegisteredObject, ITestRunner
public TestRunner ()
{
}
-
- public string Run (string url)
- {
- return Run (url, null);
- }
- public string Run (string url, string pathInfo)
+ public Response Run (string url, string pathInfo, SerializableDictionary <string, string> postValues)
{
+ if (String.IsNullOrEmpty (url))
+ throw new ArgumentNullException ("url");
+
+ bool isPost = postValues != null;
+
ResetState ();
if (String.IsNullOrEmpty (url))
wr = new TestWorkerRequest (uri.AbsolutePath, query, pathInfo, output);
else
wr = new TestWorkerRequest (uri.AbsolutePath, query, output);
+ wr.IsPost = isPost;
HttpRuntime.ProcessRequest (wr);
- return output.ToString ();
+ return new Response {
+ Body = output.ToString (),
+ StatusCode = wr.StatusCode,
+ StatusDescription = wr.StatusDescription
+ };
} finally {
output.Close ();
}
//
using System;
using System.IO;
+using System.Net;
using System.Web;
using System.Web.Hosting;
string query;
string appVirtualDir;
string pathInfo;
-
+
+ public bool IsPost { get; set; }
+ public HttpStatusCode StatusCode { get; set; }
+ public string StatusDescription { get; set; }
+
public TestWorkerRequest (string page, string query, TextWriter output)
: this (page, query, null, output)
{
return page;
}
+ public override string GetHttpVerbName ()
+ {
+ if (IsPost)
+ return "POST";
+
+ return base.GetHttpVerbName ();
+ }
+
public override string GetPathInfo ()
{
if (pathInfo == null)
return TrimLeadingSlash (base.GetUriPath ());
}
+ public override void SendStatus (int code, string description)
+ {
+ StatusCode = (HttpStatusCode) code;
+ StatusDescription = description;
+
+ base.SendStatus (code, description);
+ }
+
static string TrimLeadingSlash (string input)
{
if (String.IsNullOrEmpty (input))
--- /dev/null
+//
+// Authors:
+// Marek Habersack (mhabersack@novell.com)
+//
+// (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.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Web.Util;
+
+using StandAloneRunnerSupport;
+using StandAloneTests;
+
+using NUnit.Framework;
+
+namespace StandAloneTests.Control_GetUniqueIDRelativeTo
+{
+ [TestCase ("FormViewUpdateParameters_Bug607722", "FormView update parameters should include keys")]
+ public sealed class FormViewUpdateParameters_Bug607722 : ITestCase
+ {
+ public string PhysicalPath {
+ get { return Path.Combine (Consts.BasePhysicalDir, "FormViewUpdateParameters_Bug607722"); }
+ }
+
+ public string VirtualPath {
+ get { return "/"; }
+ }
+
+ public bool SetUp (List <TestRunItem> runItems)
+ {
+ runItems.Add (new TestRunItem ("Default.aspx", Default_Aspx));
+#if BUG_IN_THE_RUNTIME
+ runItems.Add (new TestRunItem ("Default.aspx", Default_Aspx_POST) {
+ PostValues = new SerializableDictionary <string, string> {
+ {"FormView1$M1TextBox", "12"},
+ {"FormView1$M2TextBox", "12"}
+ }
+ }
+ );
+#endif
+
+ return true;
+ }
+
+ void Default_Aspx (string result, TestRunItem runItem)
+ {
+ string originalHtml = @"M1: <span id=""FormView1_M1Label"">0</span><br />M2: <span id=""FormView1_M2Label"">0</span>";
+ Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
+ }
+
+ void Default_Aspx_POST (string result, TestRunItem runItem)
+ {
+ string originalHtml = @"M1: <span id=""FormView1_M1Label"">12</span><br />M2: <span id=""FormView1_M2Label"">12</span>";
+ Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
+ }
+ }
+}
+
--- /dev/null
+using System;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Web;
+using System.ComponentModel;
+
+namespace Prueba {
+ public class Data {
+ public int M1 { get; set; }
+ public string M2 { get; set; }
+ public Data(int m1, string m2) {
+ M1 = m1;
+ M2 = m2;
+ }
+ }
+ public class DataCollection : Collection<Data> { }
+ [DataObject(true)]
+ public class DataSource {
+ private static DataCollection data = new DataCollection();
+ static DataSource(){
+ for(int i = 0; i < 2; i++) {
+ data.Add(new Data(i, i.ToString()));
+ }
+ }
+ public DataCollection Retrieve() {
+ return data;
+ }
+ public void insert(int m1, string m2) {
+ foreach(Data i in data) {
+ if(i.M1 == m1)
+ return;
+ }
+ data.Add(new Data(m1, m2));
+ }
+ public void Update(int m1, string m2, int oldM1) {
+ foreach(Data i in data) {
+ if(i.M1 == oldM1) {
+ i.M1 = m1;
+ i.M2 = m2;
+ }
+ }
+ }
+ public void Delete(int oldM1) {
+ Data deleting = null;
+ foreach(Data i in data) {
+ if(i.M1 == oldM1) {
+ deleting = i;
+ }
+ }
+ if(deleting != null)
+ data.Remove(deleting);
+ }
+ }
+}
--- /dev/null
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Prueba._Default" Title="<%$ Resources:Labels, Contact %>" %>
+<!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>Bug #6077722 test</title>
+</head>
+<body>
+ <form id="form1" runat="server">
+ <div>
+ <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1" DataKeyNames="M1">
+ <EditItemTemplate>
+ M1:
+ <asp:TextBox ID="M1TextBox" runat="server" Text='<%# Bind("M1") %>' />
+ <br />
+ M2:
+ <asp:TextBox ID="M2TextBox" runat="server" Text='<%# Bind("M2") %>' />
+ <br />
+ <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
+ <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
+ </EditItemTemplate>
+ <InsertItemTemplate>
+ M1:
+ <asp:TextBox ID="M1TextBox" runat="server" Text='<%# Bind("M1") %>' />
+ <br />
+ M2:
+ <asp:TextBox ID="M2TextBox" runat="server" Text='<%# Bind("M2") %>' />
+ <br />
+ <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
+ <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
+ </InsertItemTemplate>
+ <ItemTemplate>
+ <%= AppDomain.CurrentDomain.GetData ("BEGIN_CODE_MARKER") %>M1: <asp:Label ID="M1Label" runat="server" Text='<%# Bind("M1") %>' /><br />M2: <asp:Label ID="M2Label" runat="server" Text='<%# Bind("M2") %>' /><%= AppDomain.CurrentDomain.GetData ("END_CODE_MARKER") %>
+ <br />
+ <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
+ <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" />
+ <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New" />
+ </ItemTemplate>
+ </asp:FormView>
+ <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" onselectedindexchanged="GridView1_SelectedIndexChanged" DataKeyNames="M1">
+ <Columns>
+ <asp:CommandField ShowSelectButton="True" />
+ <asp:BoundField DataField="M1" HeaderText="M1" SortExpression="M1" />
+ <asp:BoundField DataField="M2" HeaderText="M2" SortExpression="M2" />
+ </Columns>
+ </asp:GridView>
+ <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="insert" OldValuesParameterFormatString="old{0}" SelectMethod="Retrieve"
+ TypeName="Prueba.DataSource" UpdateMethod="Update">
+ <DeleteParameters>
+ <asp:Parameter Name="oldM1" Type="Int32" />
+ </DeleteParameters>
+ <UpdateParameters>
+ <asp:Parameter Name="m1" Type="Int32" />
+ <asp:Parameter Name="m2" Type="String" />
+ <asp:Parameter Name="oldM1" Type="Int32" />
+ </UpdateParameters>
+ <InsertParameters>
+ <asp:Parameter Name="m1" Type="Int32" />
+ <asp:Parameter Name="m2" Type="String" />
+ </InsertParameters>
+ </asp:ObjectDataSource>
+ </div>
+ </form>
+</body>
+</html>
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace Prueba {
+ public partial class _Default : System.Web.UI.Page {
+ protected void Page_Load(object sender, EventArgs e) {
+ }
+
+ protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) {
+ FormView1.PageIndex = GridView1.SelectedIndex;
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <system.web>
+ <compilation debug="true" />
+ <customErrors mode="RemoteOnly" />
+ </system.web>
+ <system.codedom>
+ <compilers>
+ <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <providerOption name="CompilerVersion" value="v3.5"/>
+ <providerOption name="WarnAsError" value="false"/>
+ </compiler>
+ </compilers>
+ </system.codedom>
+</configuration>
\ No newline at end of file
Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/tools.cs
Test/mainsoft/MainsoftWebTest/NunitWebTest.cs
Test/mainsoft/MainsoftWebTest/XmlComparer.cs
+
+Test/mainsoft/NunitWeb/NunitWeb/Response.cs
+
Test/standalone-runner-support/Helpers.cs
Test/standalone-runner-support/ITestCase.cs
Test/standalone-runner-support/ITestRunner.cs
Test/standalone-runner-support/TestRunItem.cs
Test/standalone-runner-support/TestRunner.cs
Test/standalone-runner-support/TestWorkerRequest.cs
+Test/standalone-runner-support/SerializableDictionary.cs