Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using MonoTests.SystemWeb.Framework;
using MonoTests.Common;
[assembly: WebTestResourcesSetup (typeof (TestsSetup), "CopyResources")]
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle ("System.Web.DynamicData_tests_net_2_0")]
[assembly: AssemblyDescription ("System.Web.DynamicData tests_net_2_0")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("Novell, Inc")]
[assembly: AssemblyProduct ("System.Web.DynamicData_tests_net_2_0")]
[assembly: AssemblyCopyright ("Copyright © 2009 Novell, Inc")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible (false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid ("ad6fbbb5-3518-439f-987e-c930d83e7acf")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion ("1.0.0.0")]
//[assembly: AssemblyFileVersion ("1.0.0.0")]
#if !TARGET_DOTNET
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile ("../winfx.pub")]
#endif

View File

@@ -0,0 +1,6 @@
2009-07-03 Marek Habersack <mhabersack@novell.com>
* AssemblyInfo.cs: added. Necessary, because we need to set up
WebTest environment and it is done via an assembly-level custom
attribute.

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
namespace MonoTests.Common
{
class AFieldTemplate : ITemplate
{
public List <Control> Controls { get; private set; }
public AFieldTemplate ()
{
Controls = new List<Control> ();
}
public void InstantiateIn (Control container)
{
if (container == null)
return;
List <Control> controls = Controls;
if (controls.Count == 0)
return;
foreach (Control c in controls)
container.Controls.Add (c);
}
}
}

View File

@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
namespace MonoTests.Common
{
delegate void AssertThrowsDelegate();
static class AssertExtensions
{
public static void AreEqual (byte[] expected, byte[] data, string message)
{
if (expected == null) {
if (data == null)
return;
Assert.Fail ("{0}{1}Expected: null{1}Got: byte array with {2} elements and of rank {3}{1}",
message, Environment.NewLine, data.Length, data.Rank);
}
if (data == null)
Assert.Fail ("{0}{1}Expected: byte array with {2} elements and rank {3}{1}Got: null{1}",
message, Environment.NewLine, expected.Length, expected.Rank);
if (expected.Rank > 1)
Assert.Fail ("Only single-dimensional arrays are supported.");
if (expected.Rank != data.Rank || expected.Length != data.Length)
Assert.Fail ("{0}{1}Expected: byte array with {2} elements and rank {3}{1}Got: byte array with {4} elements and rank {5}{1}",
message, Environment.NewLine, expected.Length, expected.Rank, data.Length, data.Rank);
int max = expected.Length;
for (int i = 0; i < max; i++) {
if (expected[i] != data[i])
Assert.Fail ("{0}{1}Arrays differ at index {2}.{1}Expected 0x{3:X} got 0x{4:X}{1}",
message, Environment.NewLine, i, expected[i], data[i]);
}
}
public static void Throws<ET> (AssertThrowsDelegate code, string message)
{
Throws(typeof(ET), code, message);
}
public static void Throws(Type exceptionType, AssertThrowsDelegate code, string message)
{
if (code == null)
Assert.Fail("No code provided for the test.");
Exception exception = null;
try
{
code();
}
catch (Exception ex)
{
exception = ex;
}
if (exceptionType == null)
{
if (exception == null)
Assert.Fail("{0}{1}Expected: any exception thrown{1}But was: no exception thrown{1}",
message, Environment.NewLine);
return;
}
if (exception == null || exception.GetType() != exceptionType)
Assert.Fail("{0}{1}Expected: {2}{1}But was: {3}{1}{4}{1}",
message,
Environment.NewLine,
exceptionType,
exception == null ? "no exception" : exception.GetType().ToString(),
exception == null ? "no exception" : exception.ToString());
}
public static void Throws(AssertThrowsDelegate code, string message)
{
Throws(null, code, message);
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MonoTests.Common
{
public class AssociatedBar
{
public string Column1 { get; set; }
public int Column2 { get; set; }
public string Column3 { get; set; }
public int Column4 { get; set; }
public AssociatedBar ()
{
Column1 = "Column 1";
Column2 = 123;
Column3 = "Column 3";
}
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.DynamicData.ModelProviders;
using MonoTests.ModelProviders;
namespace MonoTests.Common
{
public class AssociatedFoo
{
[DynamicDataAssociation ("AssociatedBarTable.Column1", AssociationDirection.OneToOne)]
public string ForeignKeyColumn1 { get; set; }
[DynamicDataAssociation ("AssociatedBarTable.Column4", AssociationDirection.OneToOne)]
public int ForeignKeyColumn2 { get; set; }
[DynamicDataAssociation ("AssociatedBarTable.Column3", AssociationDirection.ManyToOne)]
public string PrimaryKeyColumn1 { get; set; }
[DynamicDataAssociation ("AssociatedBarTable.Column2", AssociationDirection.OneToMany)]
public int PrimaryKeyColumn2 { get; set; }
public int Column1 { get; set; }
}
}

View File

@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using MonoTests.ModelProviders;
namespace MonoTests.Common
{
class Baz
{
// DO NOT change the order of properties - tests depend on it
// DO NOT change the column types - tests depend on it
public int Column1 { get; set; }
public int PrimaryKeyColumn1 { get; set; }
public string PrimaryKeyColumn2 { get; set; }
public bool PrimaryKeyColumn3 { get; set; }
public string CustomPropertyColumn1 { get; set; }
[UIHint ("UI Hint")]
public string CustomPropertyColumn2 { get; set; }
public int GeneratedColumn1 { get; set; }
[UIHint ("UI Hint")]
public int GeneratedColumn2 { get; set; }
[ReadOnly (true)]
public int ReadOnlyColumn { get; private set; }
[ReadOnly (false)]
public int ReadWriteColumn { get; private set; }
[DisplayFormat (NullDisplayText="Text")]
public DateTime NullDisplayTextColumn { get; set; }
[Required (ErrorMessage = "Custom error message")]
public int ErrorMessageColumn1 { get; set; }
[Required (ErrorMessage = "s")]
public int ErrorMessageColumn2 { get; set; }
[UIHint ("")]
public int EmptyHintColumn { get; set; }
[DynamicDataSortable (true)]
public int SortableColumn1 { get; set; }
[UIHint ("MyCustomUIHintTemplate")]
public string CustomUIHintColumn { get; set; }
public Baz ()
{
Column1 = 123;
PrimaryKeyColumn1 = 456;
PrimaryKeyColumn2 = "primary key value";
PrimaryKeyColumn3 = true;
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
namespace MonoTests.Common
{
class BazColumnAttributes
{
public string ColumnNoAttributes { get; set; }
[DisplayFormat (
ApplyFormatInEditMode=true,
ConvertEmptyStringToNull=true,
DataFormatString="Item: {0}"
)]
public string ColumnFormatInEditMode { get; set; }
[DataType (DataType.EmailAddress)]
public string ColumnWithDataType { get; set; }
[DefaultValue (12345L)]
public long ColumnWithDefaultLongValue { get; set; }
[DefaultValue ("Value")]
public string ColumnWithDefaultStringValue { get; set; }
[Description ("Description")]
public string ColumnWithDescription { get; set; }
[DisplayName ("Display Name")]
public string ColumnWithDisplayName { get; set; }
[ScaffoldColumn (false)]
public string NoScaffoldColumn { get; set; }
[ScaffoldColumn (true)]
public string ScaffoldAttributeColumn { get; set; }
[UIHint ("UI Hint")]
public string UIHintColumn { get; set; }
}
}

View File

@@ -0,0 +1,74 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using MonoTests.ModelProviders;
namespace MonoTests.Common
{
public class BazDataTypeDefaultTypes
{
public char Char_Column { get; set; }
public byte Byte_Column { get; set; }
public int Int_Column { get; set; }
public long Long_Column { get; set; }
public bool Bool_Column { get; set; }
public string String_Column { get; set; }
public float Float_Column { get; set; }
public Single Single_Column { get; set; }
public double Double_Column { get; set; }
public decimal Decimal_Column { get; set; }
public sbyte SByte_Column { get; set; }
public uint UInt_Column { get; set; }
public ulong ULong_Column { get; set; }
public short Short_Column { get; set; }
public ushort UShort_Column { get; set; }
public DateTime DateTime_Column { get; set; }
public FooEmpty FooEmpty_Column { get; set; }
public object Object_Column { get; set; }
public byte[] ByteArray_Column { get; set; }
public int[] IntArray_Column { get; set; }
public string[] StringArray_Column { get; set; }
public object[] ObjectArray_Column { get; set; }
public List<string> StringList_Column { get; set; }
public Dictionary<string, object> Dictionary_Column { get; set; }
public ICollection ICollection_Column { get; set; }
public IEnumerable IEnumerable_Column { get; set; }
public ICollection<byte> ICollectionByte_Column { get; set; }
public IEnumerable<byte> IEnumerableByte_Column { get; set; }
public byte[,] ByteMultiArray_Column { get; set; }
public bool[] BoolArray_Column { get; set; }
[DynamicDataStringLength (Int32.MaxValue)]
public string MaximumLength_Column1 { get; set; }
[DynamicDataStringLength (Int32.MinValue)]
public string MaximumLength_Column2 { get; set; }
// This is the highest length at which string is considered to be short
[DynamicDataStringLength ((Int32.MaxValue / 2) - 5)]
public string MaximumLength_Column3 { get; set; }
// This is the lowest length at which string is considered to be long
[DynamicDataStringLength ((Int32.MaxValue / 2) - 4)]
public string MaximumLength_Column4 { get; set; }
[StringLength (255)]
[DynamicDataStringLength (512)]
public string MaximumLength_Column5 { get; set; }
public BazDataTypeDefaultTypes () : this (false)
{}
public BazDataTypeDefaultTypes (bool fillValues)
{
if (fillValues) {
Char_Column = 'a';
String_Column = "string";
}
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MonoTests.Common
{
class BazNoStrings
{
// DO NOT change the order of properties - tests depend on it
public int Column1 { get; set; }
public int PrimaryKeyColumn1 { get; set; }
public long PrimaryKeyColumn2 { get; set; }
public bool PrimaryKeyColumn3 { get; set; }
public BazNoStrings ()
{
Column1 = 123;
PrimaryKeyColumn1 = 456;
PrimaryKeyColumn2 = 789;
PrimaryKeyColumn3 = true;
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MonoTests.Common
{
class BazNoStringsNoPrimary
{
// DO NOT change the order of properties - tests depend on it
public int Column1 { get; set; }
public int Column2 { get; set; }
public BazNoStringsNoPrimary ()
{
Column1 = 123;
Column2 = 456;
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
namespace MonoTests.Common
{
public class BazValidationAttributes
{
[Range (-5, 5)]
public int Column1 { get; set; }
}
}

View File

@@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace MonoTests.Common
{
public class BazWithDataTypeAttribute
{
[DataType (DataType.Custom)]
public string CustomColumn1 { get; set; }
[DataType (DataType.Custom)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string CustomColumn2 { get; set; }
[DataType ("MyCustomType")]
public string CustomColumn3 { get; set; }
[DataType ("MyCustomType")]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string CustomColumn4 { get; set; }
[DataType (DataType.DateTime)]
public string DateTimeColumn1 { get; set; }
[DataType (DataType.DateTime)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string DateTimeColumn2 { get; set; }
[DataType (DataType.Date)]
public string DateColumn1 { get; set; }
[DataType (DataType.Date)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string DateColumn2 { get; set; }
[DataType (DataType.Date)]
public long DateColumn3 { get; set; }
[DataType (DataType.Date)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public long DateColumn4 { get; set; }
[DataType (DataType.Time)]
public string TimeColumn1 { get; set; }
[DataType (DataType.Time)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string TimeColumn2 { get; set; }
[DataType (DataType.Duration)]
public string DurationColumn1 { get; set; }
[DataType (DataType.Duration)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string DurationColumn2 { get; set; }
[DataType (DataType.PhoneNumber)]
public string PhoneNumberColumn1 { get; set; }
[DataType (DataType.PhoneNumber)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string PhoneNumberColumn2 { get; set; }
[DataType (DataType.Currency)]
public string CurrencyColumn1 { get; set; }
[DataType (DataType.Currency)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string CurrencyColumn2 { get; set; }
[DataType (DataType.Text)]
public long TextColumn1 { get; set; }
[DataType (DataType.Text)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public long TextColumn2 { get; set; }
[DataType (DataType.Html)]
public string HtmlColumn1 { get; set; }
[DataType (DataType.Html)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string HtmlColumn2 { get; set; }
[DataType (DataType.MultilineText)]
public string MultilineTextColumn1 { get; set; }
[DataType (DataType.MultilineText)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string MultilineTextColumn2 { get; set; }
[DataType (DataType.EmailAddress)]
public string EmailAddressColumn1 { get; set; }
[DataType (DataType.EmailAddress)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string EmailAddressColumn2 { get; set; }
[DataType (DataType.Password)]
public string PasswordColumn1 { get; set; }
[DataType (DataType.Password)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string PasswordColumn2 { get; set; }
[DataType (DataType.Url)]
public string UrlColumn1 { get; set; }
[DataType (DataType.Url)]
[UIHint ("MyCustomUIHintTemplate_Text")]
public string UrlColumn2 { get; set; }
}
}

View File

@@ -0,0 +1,95 @@
2010-01-22 Marek Habersack <mhabersack@novell.com>
* AssertExtensions.cs: added AreEqual method for comparing byte
arrays.
2009-09-18 Marek Habersack <mhabersack@novell.com>
* TestsBasePage.cs: added an event ItemDataBinding, invoked
whenever an item is data bound.
2009-07-14 Marek Habersack <mhabersack@novell.com>
* AssertExtensions.cs: include full exception trace in the Fail
message
2009-07-08 Marek Habersack <mhabersack@novell.com>
* TestsSetup.cs: added the BuildPath helper method which converts
unix-style filesystem paths to the os-specific format.
2009-07-03 Marek Habersack <mhabersack@novell.com>
* TestsSetup.cs: custom WebTest setup for DynamicData
* TestsBasePage.cs: a base class for all the web pages used by the
tests.
* MiscExtensions.cs: added some helper extensions for fishing out
controls from control trees.
* ITestDataContext.cs: GetTableData gets full set of query
arguments.
2009-06-18 Marek Habersack <mhabersack@novell.com>
* TestDataColumn.cs: mark the column as sortable based on value of
the DynamicDataSortable attribute.
* Baz.cs: added a sortable column.
2009-06-15 Marek Habersack <mhabersack@novell.com>
* TestDataContext.cs: added new tables
* BazColumnAttributes.cs, BazDataTypeDefaultTypes.cs,
FooWithMetadataType.cs: added
2009-06-12 Marek Habersack <mhabersack@novell.com>
* TestDataContainer.cs: GetTables uses an object of the associated
data type to create table collection.
* TestDataColumn.cs: foreign key columns are determined using a
custom attribute instead of a name now. This makes it possible to
specify which table.column they are associated with.
* FooDisplayColumnAttribute.cs: changed sortDescending to true in
class attributes.
* AssociatedBar.cs, AssociatedFoo.cs, FooEmptySortColumn.cs,
FooMisnamedSortColumn.cs, FooNoScaffold.cs, FooReadOnly.cs,
ITestDataContext.cs, TestDataContext.cs: added
2009-06-10 Marek Habersack <mhabersack@novell.com>
* TestDataColumn.cs: added detection of foreign key columns.
* FooWithDefaults.cs: added foreign key columns
* FooDisplayName.cs, FooDisplayNameEmptyName.cs,
FooSettableDefaults.cs: added
2009-06-09 Marek Habersack <mhabersack@novell.com>
* Baz.cs, BazNoStrings.cs, BazNoStringsNoPrimary.cs,
FooDisplayColumnAttribute.cs, FooEmpty.cs,
FooEmptyDisplayColumnAttribute.cs,
FooInvalidDisplayColumnAttribute.cs, FooWithToString.cs,
TestDataColumn.cs, TestDataContainer.cs, TestDataTable.cs: added
* Utils.cs: added two BuildActionName methods to make building
action paths for testing more compact.
* FooNoPrimaryColumns.cs, FooNoDefaultsWithPrimaryKey.cs: added
2009-06-08 Marek Habersack <mhabersack@novell.com>
* Utils.cs: added.
Moved GetModel here from MetaModelTest.cs
Added RegisterContext methods.
* FooWithDefaultsContainer.cs,
FooWithDefaultsColumn.cs,FooWithDefaultsTable.cs,
FooWithDefaults.cs: added

View File

@@ -0,0 +1,76 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Web.DynamicData;
using System.Web.DynamicData.ModelProviders;
using System.Web.UI;
using System.Web.UI.WebControls;
using MonoTests.System.Web.DynamicData;
using MonoTests.ModelProviders;
using MonoTests.DataSource;
using MonoTests.DataObjects;
namespace MonoTests.Common
{
public class EmployeesDataContext : ITestDataContext
{
List<Employee> employees;
List<SeasonalEmployee> seasonalEmployees;
List<BazDataTypeDefaultTypes> defaultDataTypes;
public List<Employee> Employees {
get {
if (employees == null)
employees = new List<Employee> ();
return employees;
}
}
public List<SeasonalEmployee> SeasonalEmployees {
get
{
if (seasonalEmployees == null)
seasonalEmployees = new List<SeasonalEmployee> ();
return seasonalEmployees;
}
}
public List<BazDataTypeDefaultTypes> DefaultDataTypes {
get {
if (defaultDataTypes == null)
defaultDataTypes = new List<BazDataTypeDefaultTypes> ();
return defaultDataTypes;
}
}
public IList GetTableData (string tableName, DataSourceSelectArguments args, string where, ParameterCollection whereParams)
{
if (String.Compare (tableName, "EmployeeTable", StringComparison.OrdinalIgnoreCase) == 0)
return Employees;
if (String.Compare (tableName, "SeasonalEmployeeTable", StringComparison.OrdinalIgnoreCase) == 0)
return SeasonalEmployees;
if (String.Compare (tableName, "BazDataTypeDefaultTypesTable", StringComparison.OrdinalIgnoreCase) == 0)
return DefaultDataTypes;
return null;
}
public List<DynamicDataTable> GetTables ()
{
var ret = new List<DynamicDataTable> ();
ret.Add (new TestDataTable<Employee> ());
ret.Add (new TestDataTable<SeasonalEmployee> ());
ret.Add (new TestDataTable<BazDataTypeDefaultTypes> ());
return ret;
}
}
}

View File

@@ -0,0 +1,223 @@
//
// System.Web.HttpResponseTest.cs - Unit tests for System.Web.HttpResponse
//
// Author:
// Miguel de Icaza <miguel@ximian.com>
//
// Copyright (C) 2005-2009 Novell, Inc (http://www.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.Text;
using System.Web;
using System;
using System.Collections;
using System.Collections.Specialized;
using NUnit.Framework;
namespace MonoTests.Common
{
public class FakeHttpWorkerRequest : HttpWorkerRequest
{
const string appPath = "/";
string queryString;
public Hashtable KnownResponseHeaders;
public Hashtable UnknownResponseHeaders;
public int return_kind;
public FakeHttpWorkerRequest ()
: this (1)
{
// for Mono
AppDomain.CurrentDomain.SetData (".appVPath", appPath);
}
public FakeHttpWorkerRequest (int re)
{
KnownResponseHeaders = CollectionsUtil.CreateCaseInsensitiveHashtable ();
UnknownResponseHeaders = CollectionsUtil.CreateCaseInsensitiveHashtable ();
return_kind = re;
queryString = String.Empty;
}
public override string GetUriPath ()
{
return appPath;
}
public override string GetFilePath ()
{
return GetUriPath ();
}
public override string GetQueryString ()
{
return queryString;
}
public void SetQueryString (string queryString)
{
this.queryString = queryString;
}
public override string GetRawUrl ()
{
return "GetRawUrl";
}
public override string GetHttpVerbName ()
{
return "GET";
}
public override string GetHttpVersion ()
{
if (return_kind == 1)
return "HTTP/1.0";
else
return "HTTP/1.1";
}
public override string GetRemoteAddress ()
{
return "__GetRemoteAddress";
}
public override int GetRemotePort ()
{
return 1010;
}
public override string GetLocalAddress ()
{
return "GetLocalAddress";
}
public override string GetAppPath ()
{
return appPath;
}
public override int GetLocalPort ()
{
return 2020;
}
public override string MapPath (string virtualPath)
{
#if TARGET_DOTNET
return "c:\\fakefile";
#else
return "/fakefile";
#endif
}
public bool status_sent;
public int status_code;
public string status_string;
public override void SendStatus (int s, string x)
{
status_sent = true;
status_code = s;
status_string = x;
}
void AddHeader (Hashtable table, string header_name, object header)
{
object o = table[header_name];
if (o == null)
table.Add (header_name, header);
else {
ArrayList al = o as ArrayList;
if (al == null) {
al = new ArrayList ();
al.Add (o);
table[header_name] = al;
} else
al = o as ArrayList;
al.Add (header);
}
}
bool headers_sent;
public override void SendKnownResponseHeader (int x, string j)
{
string header_name = HttpWorkerRequest.GetKnownRequestHeaderName (x);
AddHeader (KnownResponseHeaders, header_name, new KnownResponseHeader (x, j));
headers_sent = true;
}
public override void SendUnknownResponseHeader (string a, string b)
{
AddHeader (UnknownResponseHeaders, a, new UnknownResponseHeader (a, b));
headers_sent = true;
}
bool data_sent;
public byte[] data;
public int data_len;
public int total = 0;
public override void SendResponseFromMemory (byte[] arr, int x)
{
data_sent = true;
data = new byte[x];
for (int i = 0; i < x; i++)
data[i] = arr[i];
data_len = x;
total += data_len;
}
public override void SendResponseFromFile (string a, long b, long c)
{
data_sent = true;
}
public override void SendResponseFromFile (IntPtr a, long b, long c)
{
data_sent = true;
}
public override void FlushResponse (bool x)
{
}
public override void EndOfRequest ()
{
}
public override string GetKnownRequestHeader (int index)
{
return null;
}
public bool OutputProduced
{
get
{
return headers_sent || data_sent;
}
}
}
}

View File

@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.DynamicData;
namespace MonoTests.Common
{
class FieldFormattingOptions : IFieldFormattingOptions
{
Dictionary<string, object> propertyValues = new Dictionary<string, object> ();
public bool ApplyFormatInEditMode
{
get { return GetProperty <bool> ("ApplyFormatInEditMode"); }
}
public bool ConvertEmptyStringToNull
{
get { return GetProperty <bool> ("ConvertEmptyStringToNull"); }
}
public string DataFormatString
{
get { return GetProperty <string> ("DataFormatString"); }
}
public bool HtmlEncode
{
get { return GetProperty <bool> ("HtmlEncode"); }
}
public string NullDisplayText
{
get { return GetProperty <string> ("NullDisplayText"); }
}
T GetProperty<T> (string name)
{
if (String.IsNullOrEmpty (name))
throw new ArgumentNullException ("name");
object v;
if (propertyValues.TryGetValue (name, out v)) {
if (v == null)
return default (T);
if (typeof (T).IsAssignableFrom (v.GetType ())) {
return (T) v;
}
throw new InvalidOperationException ("Invalid value type. Expected '" + typeof (T) + "' and got '" + v.GetType () + "'");
}
return default (T);
}
public void SetProperty (string name, object value)
{
if (String.IsNullOrEmpty (name))
return;
if (propertyValues.ContainsKey (name))
propertyValues[name] = value;
else
propertyValues.Add (name, value);
}
}
}

View File

@@ -0,0 +1,278 @@
using System;
using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using MonoTests.stand_alone.WebHarness;
using MonoTests.SystemWeb.Framework;
using MonoTests.Common;
using MonoTests.DataSource;
using MonoTests.DataObjects;
namespace MonoTests.Common
{
sealed class FieldTemplatePathTables
{
public static readonly List<FieldTemplateTestDescription> FieldTemplateReadOnlyColumns = new List<FieldTemplateTestDescription> ()
{
new FieldTemplateTestDescription ("Char_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("Byte_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("Int_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("Long_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("Bool_Column", "~/DynamicData/FieldTemplates/Boolean.ascx"),
new FieldTemplateTestDescription ("String_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("Float_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("Single_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("Double_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("Decimal_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("SByte_Column"),
new FieldTemplateTestDescription ("UInt_Column"),
new FieldTemplateTestDescription ("ULong_Column"),
new FieldTemplateTestDescription ("Short_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("UShort_Column"),
new FieldTemplateTestDescription ("DateTime_Column", "~/DynamicData/FieldTemplates/DateTime.ascx"),
new FieldTemplateTestDescription ("FooEmpty_Column"),
new FieldTemplateTestDescription ("Object_Column"),
new FieldTemplateTestDescription ("ByteArray_Column"),
new FieldTemplateTestDescription ("IntArray_Column"),
new FieldTemplateTestDescription ("StringArray_Column"),
new FieldTemplateTestDescription ("ObjectArray_Column"),
new FieldTemplateTestDescription ("StringList_Column"),
new FieldTemplateTestDescription ("Dictionary_Column"),
new FieldTemplateTestDescription ("ICollection_Column"),
new FieldTemplateTestDescription ("IEnumerable_Column"),
new FieldTemplateTestDescription ("ICollectionByte_Column"),
new FieldTemplateTestDescription ("IEnumerableByte_Column"),
new FieldTemplateTestDescription ("ByteMultiArray_Column"),
new FieldTemplateTestDescription ("BoolArray_Column"),
new FieldTemplateTestDescription ("MaximumLength_Column4", "~/DynamicData/FieldTemplates/Text.ascx"),
};
public static readonly List<FieldTemplateTestDescription> FieldTemplateEditColumns = new List<FieldTemplateTestDescription> ()
{
new FieldTemplateTestDescription ("Char_Column", "~/DynamicData/FieldTemplates/Text_Edit.ascx"),
new FieldTemplateTestDescription ("Byte_Column", "~/DynamicData/FieldTemplates/Integer_Edit.ascx"),
new FieldTemplateTestDescription ("Int_Column", "~/DynamicData/FieldTemplates/Integer_Edit.ascx"),
new FieldTemplateTestDescription ("Long_Column", "~/DynamicData/FieldTemplates/Integer_Edit.ascx"),
new FieldTemplateTestDescription ("Bool_Column", "~/DynamicData/FieldTemplates/Boolean_Edit.ascx"),
new FieldTemplateTestDescription ("String_Column", "~/DynamicData/FieldTemplates/Text_Edit.ascx"),
new FieldTemplateTestDescription ("Float_Column", "~/DynamicData/FieldTemplates/Decimal_Edit.ascx"),
new FieldTemplateTestDescription ("Single_Column", "~/DynamicData/FieldTemplates/Decimal_Edit.ascx"),
new FieldTemplateTestDescription ("Double_Column", "~/DynamicData/FieldTemplates/Decimal_Edit.ascx"),
new FieldTemplateTestDescription ("Decimal_Column", "~/DynamicData/FieldTemplates/Decimal_Edit.ascx"),
new FieldTemplateTestDescription ("SByte_Column"),
new FieldTemplateTestDescription ("UInt_Column"),
new FieldTemplateTestDescription ("ULong_Column"),
new FieldTemplateTestDescription ("Short_Column", "~/DynamicData/FieldTemplates/Integer_Edit.ascx"),
new FieldTemplateTestDescription ("UShort_Column"),
new FieldTemplateTestDescription ("DateTime_Column", "~/DynamicData/FieldTemplates/DateTime_Edit.ascx"),
new FieldTemplateTestDescription ("FooEmpty_Column"),
new FieldTemplateTestDescription ("Object_Column"),
new FieldTemplateTestDescription ("ByteArray_Column"),
new FieldTemplateTestDescription ("IntArray_Column"),
new FieldTemplateTestDescription ("StringArray_Column"),
new FieldTemplateTestDescription ("ObjectArray_Column"),
new FieldTemplateTestDescription ("StringList_Column"),
new FieldTemplateTestDescription ("Dictionary_Column"),
new FieldTemplateTestDescription ("ICollection_Column"),
new FieldTemplateTestDescription ("IEnumerable_Column"),
new FieldTemplateTestDescription ("ICollectionByte_Column"),
new FieldTemplateTestDescription ("IEnumerableByte_Column"),
new FieldTemplateTestDescription ("ByteMultiArray_Column"),
new FieldTemplateTestDescription ("BoolArray_Column"),
new FieldTemplateTestDescription ("MaximumLength_Column4", "~/DynamicData/FieldTemplates/MultilineText_Edit.ascx"),
};
public static readonly List<string> NonDefaultFullTypeNameTemplates = new List<string> () {
"System.Char.ascx",
"System.Char.ascx.cs",
"System.Byte.ascx",
"System.Byte.ascx.cs",
"System.Boolean.ascx",
"System.Boolean.ascx.cs",
"System.Int16.ascx",
"System.Int16.ascx.cs",
"System.Int32.ascx",
"System.Int32.ascx.cs",
"System.Int64.ascx",
"System.Int64.ascx.cs",
"System.String.ascx",
"System.String.ascx.cs",
"System.UInt16.ascx",
"System.UInt16.ascx.cs",
"System.UInt32.ascx",
"System.UInt32.ascx.cs",
"System.UInt64.ascx",
"System.UInt64.ascx.cs",
"System.SByte.ascx",
"System.SByte.ascx.cs",
"System.Object.ascx",
"System.Object.ascx.cs",
"System.Byte[].ascx",
"System.Byte[].ascx.cs",
"System.Collections.Generic.List`1[System.String].ascx",
"System.Collections.Generic.List`1[System.String].ascx.cs",
"MonoTests.Common.FooEmpty.ascx",
"MonoTests.Common.FooEmpty.ascx.cs",
"System.Collections.ICollection.ascx",
"System.Collections.ICollection.ascx.cs",
};
public static readonly List<FieldTemplateTestDescription> FieldTemplateNonDefaultColumns = new List<FieldTemplateTestDescription> ()
{
new FieldTemplateTestDescription ("Char_Column", "~/DynamicData/FieldTemplates/System.Char.ascx"),
new FieldTemplateTestDescription ("Byte_Column", "~/DynamicData/FieldTemplates/System.Byte.ascx"),
new FieldTemplateTestDescription ("Int_Column", "~/DynamicData/FieldTemplates/System.Int32.ascx"),
new FieldTemplateTestDescription ("Long_Column", "~/DynamicData/FieldTemplates/System.Int64.ascx"),
new FieldTemplateTestDescription ("Bool_Column", "~/DynamicData/FieldTemplates/System.Boolean.ascx"),
new FieldTemplateTestDescription ("String_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("Float_Column", "~/DynamicData/FieldTemplates/System.String.ascx"),
new FieldTemplateTestDescription ("Single_Column", "~/DynamicData/FieldTemplates/System.String.ascx"),
new FieldTemplateTestDescription ("Double_Column", "~/DynamicData/FieldTemplates/System.String.ascx"),
new FieldTemplateTestDescription ("Decimal_Column", "~/DynamicData/FieldTemplates/System.String.ascx"),
new FieldTemplateTestDescription ("SByte_Column", "~/DynamicData/FieldTemplates/System.SByte.ascx"),
new FieldTemplateTestDescription ("UInt_Column", "~/DynamicData/FieldTemplates/System.UInt32.ascx"),
new FieldTemplateTestDescription ("ULong_Column", "~/DynamicData/FieldTemplates/System.UInt64.ascx"),
new FieldTemplateTestDescription ("Short_Column", "~/DynamicData/FieldTemplates/System.Int16.ascx"),
new FieldTemplateTestDescription ("UShort_Column", "~/DynamicData/FieldTemplates/System.UInt16.ascx"),
new FieldTemplateTestDescription ("DateTime_Column", "~/DynamicData/FieldTemplates/DateTime.ascx"),
new FieldTemplateTestDescription ("FooEmpty_Column", "~/DynamicData/FieldTemplates/MonoTests.Common.FooEmpty.ascx"),
new FieldTemplateTestDescription ("Object_Column", "~/DynamicData/FieldTemplates/System.Object.ascx"),
new FieldTemplateTestDescription ("ByteArray_Column", "~/DynamicData/FieldTemplates/System.Byte[].ascx"),
new FieldTemplateTestDescription ("IntArray_Column"),
new FieldTemplateTestDescription ("StringArray_Column"),
new FieldTemplateTestDescription ("ObjectArray_Column"),
new FieldTemplateTestDescription ("StringList_Column"),
// Doesn't work for some reason
//new FieldTemplateTestDescription ("StringList_Column", "~/DynamicData/FieldTemplates/System.Collections.Generic.List`1[System.String].ascx"),
new FieldTemplateTestDescription ("Dictionary_Column"),
new FieldTemplateTestDescription ("ICollection_Column", "~/DynamicData/FieldTemplates/System.Collections.ICollection.ascx"),
new FieldTemplateTestDescription ("IEnumerable_Column"),
new FieldTemplateTestDescription ("ICollectionByte_Column"),
new FieldTemplateTestDescription ("IEnumerableByte_Column"),
new FieldTemplateTestDescription ("ByteMultiArray_Column"),
new FieldTemplateTestDescription ("BoolArray_Column"),
new FieldTemplateTestDescription ("MaximumLength_Column4", "~/DynamicData/FieldTemplates/System.String.ascx"),
};
public static readonly List<string> NonDefaultShortTypeNameTemplates = new List<string> () {
"Char.ascx",
"Char.ascx.cs",
"Byte.ascx",
"Byte.ascx.cs",
"Int16.ascx",
"Int16.ascx.cs",
"Int32.ascx",
"Int32.ascx.cs",
"Int64.ascx",
"Int64.ascx.cs",
"String.ascx",
"String.ascx.cs",
"UInt16.ascx",
"UInt16.ascx.cs",
"UInt32.ascx",
"UInt32.ascx.cs",
"UInt64.ascx",
"UInt64.ascx.cs",
"SByte.ascx",
"SByte.ascx.cs",
"Object.ascx",
"Object.ascx.cs",
"Byte[].ascx",
"Byte[].ascx.cs",
"FooEmpty.ascx",
"FooEmpty.ascx.cs",
"ICollection.ascx",
"ICollection.ascx.cs",
};
public static readonly List<FieldTemplateTestDescription> FieldTemplateNonDefaultShortColumns = new List<FieldTemplateTestDescription> ()
{
new FieldTemplateTestDescription ("FooEmpty_Column", "~/DynamicData/FieldTemplates/FooEmpty.ascx"),
new FieldTemplateTestDescription ("Char_Column", "~/DynamicData/FieldTemplates/Char.ascx"),
new FieldTemplateTestDescription ("Byte_Column", "~/DynamicData/FieldTemplates/Byte.ascx"),
new FieldTemplateTestDescription ("Int_Column", "~/DynamicData/FieldTemplates/Int32.ascx"),
new FieldTemplateTestDescription ("Long_Column", "~/DynamicData/FieldTemplates/Int64.ascx"),
new FieldTemplateTestDescription ("Bool_Column", "~/DynamicData/FieldTemplates/Boolean.ascx"),
new FieldTemplateTestDescription ("String_Column", "~/DynamicData/FieldTemplates/Text.ascx"),
new FieldTemplateTestDescription ("Float_Column", "~/DynamicData/FieldTemplates/String.ascx"),
new FieldTemplateTestDescription ("Single_Column", "~/DynamicData/FieldTemplates/String.ascx"),
new FieldTemplateTestDescription ("Double_Column", "~/DynamicData/FieldTemplates/String.ascx"),
new FieldTemplateTestDescription ("Decimal_Column", "~/DynamicData/FieldTemplates/String.ascx"),
new FieldTemplateTestDescription ("SByte_Column", "~/DynamicData/FieldTemplates/SByte.ascx"),
new FieldTemplateTestDescription ("UInt_Column", "~/DynamicData/FieldTemplates/UInt32.ascx"),
new FieldTemplateTestDescription ("ULong_Column", "~/DynamicData/FieldTemplates/UInt64.ascx"),
new FieldTemplateTestDescription ("Short_Column", "~/DynamicData/FieldTemplates/Int16.ascx"),
new FieldTemplateTestDescription ("UShort_Column", "~/DynamicData/FieldTemplates/UInt16.ascx"),
new FieldTemplateTestDescription ("DateTime_Column", "~/DynamicData/FieldTemplates/DateTime.ascx"),
new FieldTemplateTestDescription ("Object_Column", "~/DynamicData/FieldTemplates/Object.ascx"),
new FieldTemplateTestDescription ("ByteArray_Column", "~/DynamicData/FieldTemplates/Byte[].ascx"),
new FieldTemplateTestDescription ("IntArray_Column"),
new FieldTemplateTestDescription ("StringArray_Column"),
new FieldTemplateTestDescription ("ObjectArray_Column"),
new FieldTemplateTestDescription ("StringList_Column"),
// Doesn't work for some reason
//new FieldTemplateTestDescription ("StringList_Column", "~/DynamicData/FieldTemplates/List`1[System.String].ascx"),
new FieldTemplateTestDescription ("Dictionary_Column"),
new FieldTemplateTestDescription ("ICollection_Column", "~/DynamicData/FieldTemplates/ICollection.ascx"),
new FieldTemplateTestDescription ("IEnumerable_Column"),
new FieldTemplateTestDescription ("ICollectionByte_Column"),
new FieldTemplateTestDescription ("IEnumerableByte_Column"),
new FieldTemplateTestDescription ("ByteMultiArray_Column"),
new FieldTemplateTestDescription ("BoolArray_Column"),
new FieldTemplateTestDescription ("MaximumLength_Column4", "~/DynamicData/FieldTemplates/String.ascx"),
};
public static void SetUp_ShortTypeNameTemplates (object caller)
{
if (caller == null)
throw new ArgumentNullException ("caller");
Type type = caller.GetType ();
foreach (string tname in NonDefaultShortTypeNameTemplates)
WebTest.CopyResource (type, "MonoTests.WebPages.DynamicData.FieldTemplates_NonDefault." + tname, TestsSetup.BuildPath ("DynamicData/FieldTemplates/" + tname));
}
public static void CleanUp_ShortTypeNameTemplates ()
{
string baseDir = WebTest.TestBaseDir;
string filePath;
foreach (string tname in NonDefaultShortTypeNameTemplates) {
filePath = Path.Combine (baseDir, TestsSetup.BuildPath ("DynamicData/FieldTemplates/" + tname));
try {
if (File.Exists (filePath))
File.Delete (filePath);
} catch {
// ignore
}
}
}
public static void SetUp_FullTypeNameTemplates (object caller)
{
if (caller == null)
throw new ArgumentNullException ("caller");
Type type = caller.GetType ();
foreach (string tname in NonDefaultFullTypeNameTemplates)
WebTest.CopyResource (type, "MonoTests.WebPages.DynamicData.FieldTemplates_NonDefault." + tname, TestsSetup.BuildPath ("DynamicData/FieldTemplates/" + tname));
}
public static void CleanUp_FullTypeNameTemplates ()
{
string baseDir = WebTest.TestBaseDir;
string filePath;
foreach (string tname in NonDefaultFullTypeNameTemplates) {
filePath = Path.Combine (baseDir, TestsSetup.BuildPath ("DynamicData/FieldTemplates/" + tname));
try {
if (File.Exists (filePath))
File.Delete (filePath);
} catch {
// ignore
}
}
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
namespace MonoTests.Common
{
sealed class FieldTemplateTestDescription
{
public string ColumnName { get; private set; }
public string ControlVirtualPath { get; private set; }
public bool IsNull { get; private set; }
public FieldTemplateTestDescription (string columnName)
: this (columnName, String.Empty, true) { }
public FieldTemplateTestDescription (string columnName, string virtualPath)
: this (columnName, virtualPath, false) { }
public FieldTemplateTestDescription (string columnName, string virtualPath, bool isNull)
{
ColumnName = columnName;
ControlVirtualPath = virtualPath;
IsNull = isNull;
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Web.DynamicData.ModelProviders;
using MonoTests.ModelProviders;
namespace MonoTests.Common
{
[ScaffoldTable (false)]
class FooBarNoScaffold
{
public string Column1 { get; set; }
public string CustomPropertyColumn1 { get; set; }
[UIHint ("UI Hint")]
public string CustomPropertyColumn2 { get; set; }
public int GeneratedColumn1 { get; set; }
[UIHint ("UI Hint")]
public int GeneratedColumn2 { get; set; }
[DynamicDataAssociation ("AssociatedBarTable.Column1", AssociationDirection.OneToOne)]
public string ForeignKeyColumn1 { get; set; }
}
}

Some files were not shown because too many files have changed in this diff Show More