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,95 @@
//
// AnonymousIdentificationSectionTest.cs
// - unit tests for System.Web.Configuration.AnonymousIdentificationSection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class AnonymousIdentificationSectionTest {
[Test]
public void Defaults()
{
AnonymousIdentificationSection a = new AnonymousIdentificationSection();
Assert.AreEqual (HttpCookieMode.UseCookies, a.Cookieless, "A1");
Assert.AreEqual (".ASPXANONYMOUS", a.CookieName, "A2");
Assert.AreEqual ("/", a.CookiePath, "A3");
Assert.AreEqual (CookieProtection.Validation, a.CookieProtection, "A4");
Assert.AreEqual (false, a.CookieRequireSSL, "A5");
Assert.AreEqual (true, a.CookieSlidingExpiration, "A6");
Assert.AreEqual (TimeSpan.Parse ("69.10:40:00"), a.CookieTimeout, "A7");
Assert.AreEqual (null, a.Domain, "A8");
Assert.AreEqual (false, a.Enabled, "A9");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void CookieName_validationFailure ()
{
AnonymousIdentificationSection a = new AnonymousIdentificationSection();
a.CookieName = "";
Assert.AreEqual ("", a.CookieName, "A1");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void CookiePath_validationFailure ()
{
AnonymousIdentificationSection a = new AnonymousIdentificationSection();
a.CookiePath = "";
Assert.AreEqual ("", a.CookiePath, "A1");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void CookieTimeout_validationFailure ()
{
AnonymousIdentificationSection a = new AnonymousIdentificationSection();
a.CookieTimeout = TimeSpan.FromSeconds (-30);
Assert.AreEqual (TimeSpan.FromSeconds (-30), a.CookieTimeout, "A1");
}
}
}
#endif

View File

@@ -0,0 +1,73 @@
//
// AssemblyCollectionTest.cs
// - unit tests for System.Web.Configuration.AssemblyCollection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class AssemblyCollectionTest {
[Test]
public void DuplicateKey ()
{
AssemblyCollection c = new AssemblyCollection ();
c.Add (new AssemblyInfo ("System.Web.dll"));
c.Add (new AssemblyInfo ("System.Web.dll"));
}
[Test]
public void GetByName ()
{
AssemblyCollection c = new AssemblyCollection ();
AssemblyInfo a = new AssemblyInfo ("System.Web.dll");
c.Add (a);
Assert.AreEqual (a, c["System.Web.dll"]);
}
[Test]
public void GetByNameFailure ()
{
AssemblyCollection c = new AssemblyCollection ();
AssemblyInfo a = new AssemblyInfo ("System.Web.dll");
c.Add (a);
Assert.IsNull (c["System.Net.dll"]);
}
}
}
#endif

View File

@@ -0,0 +1,72 @@
//
// AssemblyInfoTest.cs
// - unit tests for System.Web.Configuration.AssemblyInfo
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class AssemblyInfoTest {
[Test]
public void Defaults()
{
AssemblyInfo a = new AssemblyInfo("hi");
Assert.AreEqual ("hi", a.Assembly, "A1");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void Assembly_validationFailure ()
{
AssemblyInfo a = new AssemblyInfo ("");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void Assembly_validationFailure2 ()
{
AssemblyInfo a = new AssemblyInfo ("hi");
a.Assembly = "";
}
}
}
#endif

View File

@@ -0,0 +1,60 @@
//
// AuthenticationSectionTest.cs
// - unit tests for System.Web.Configuration.AuthenticationSection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class AuthenticationSectionTest {
[Test]
public void Defaults()
{
AuthenticationSection a = new AuthenticationSection();
Assert.IsNotNull (a.Forms, "A1");
Assert.AreEqual (typeof (FormsAuthenticationConfiguration), a.Forms.GetType(), "A2");
Assert.IsNotNull (a.Passport, "A3");
Assert.AreEqual (typeof (PassportAuthentication), a.Passport.GetType(), "A4");
Assert.AreEqual (AuthenticationMode.Windows, a.Mode, "A5");
}
}
}
#endif

View File

@@ -0,0 +1,109 @@
//
// AuthorizationRuleCollectionTest.cs
// - unit tests for System.Web.Configuration.AuthorizationRuleCollection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
using System.IO;
using System.Xml;
using System.Reflection;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class AuthorizationRuleCollectionTest {
[Test]
public void AddDuplicate ()
{
AuthorizationRuleCollection col = new AuthorizationRuleCollection ();
AuthorizationRule rule = new AuthorizationRule (AuthorizationRuleAction.Deny);
rule.Users.Add ("toshok");
rule.Verbs.Add ("GET");
col.Add (rule);
col.Add (rule);
Assert.AreEqual (2, col.Count, "A1");
Assert.AreEqual ("toshok", col[0].Users.ToString(), "A2");
}
[Test]
public void AddDuplicate2 ()
{
AuthorizationRuleCollection col = new AuthorizationRuleCollection ();
AuthorizationRule rule1 = new AuthorizationRule (AuthorizationRuleAction.Deny);
AuthorizationRule rule2 = new AuthorizationRule (AuthorizationRuleAction.Allow);
rule1.Users.Add ("toshok");
rule1.Verbs.Add ("GET");
rule2.Users.Add ("toshok");
rule2.Verbs.Add ("GET");
col.Add (rule1);
col.Add (rule2);
Assert.AreEqual (2, col.Count, "A1");
Assert.AreEqual ("toshok", col[0].Users.ToString(), "A2");
Assert.AreEqual (AuthorizationRuleAction.Deny, col[0].Action, "A3");
Assert.AreEqual (AuthorizationRuleAction.Allow, col[1].Action, "A4");
}
[Test]
public void GetElementKey ()
{
MethodInfo minfo = typeof (AuthorizationRuleCollection).GetMethod ("GetElementKey", BindingFlags.Instance | BindingFlags.NonPublic);
AuthorizationRuleCollection col = new AuthorizationRuleCollection ();
AuthorizationRule rule = new AuthorizationRule (AuthorizationRuleAction.Deny);
rule.Users.Add ("toshok");
rule.Verbs.Add ("GET");
col.Add (rule);
object[] args = new object[1];
args[0] = rule;
string key = (string)minfo.Invoke (col, args);
Assert.AreEqual ("Deny", key, "A1");
}
}
}
#endif

View File

@@ -0,0 +1,190 @@
//
// AuthorizationRuleTest.cs
// - unit tests for System.Web.Configuration.AuthorizationRule
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
using System.IO;
using System.Xml;
using System.Reflection;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class AuthorizationRuleTest {
[Test]
public void Defaults()
{
AuthorizationRule a = new AuthorizationRule(AuthorizationRuleAction.Deny);
Assert.AreEqual (AuthorizationRuleAction.Deny, a.Action, "A1");
Assert.IsNotNull (a.Roles, "A2");
Assert.IsNotNull (a.Users, "A3");
Assert.IsNotNull (a.Verbs, "A4");
}
[Test]
public void Test_EqualsAndHashCode ()
{
AuthorizationRule a = new AuthorizationRule (AuthorizationRuleAction.Deny);
AuthorizationRule b = new AuthorizationRule (AuthorizationRuleAction.Deny);
a.Users.Add ("toshok");
a.Roles.Add ("Admin");
a.Verbs.Add ("reboot");
b.Users.Add ("toshok");
b.Roles.Add ("Admin");
b.Verbs.Add ("reboot");
Assert.AreEqual (a, b, "A1");
Assert.AreEqual (a.GetHashCode (), b.GetHashCode (), "A2");
}
[Test]
public void SerializeElement ()
{
StringWriter sw;
XmlWriter writer;
AuthorizationRule rule;
MethodInfo mi = typeof (AuthorizationRule).GetMethod ("SerializeElement", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
object[] parms = new object[2];
bool failed;
/* 1 */
failed = true;
try {
sw = new StringWriter ();
writer = new XmlTextWriter (sw);
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
parms[0] = writer;
parms[1] = false;
mi.Invoke (rule, parms);
}
catch (TargetInvocationException e) {
Assert.AreEqual (typeof (ConfigurationErrorsException), e.InnerException.GetType (), "A1");
failed = false;
}
Assert.IsFalse (failed, "A1");
/* 2 */
sw = new StringWriter ();
writer = new XmlTextWriter (sw);
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
rule.Users.Add ("toshok");
parms[0] = writer;
parms[1] = false;
mi.Invoke (rule, parms);
Assert.AreEqual ("<allow users=\"toshok\" />", sw.ToString(), "A2");
/* 2 */
sw = new StringWriter ();
writer = new XmlTextWriter (sw);
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
rule.Users.Add ("toshok");
parms[0] = writer;
parms[1] = true;
mi.Invoke (rule, parms);
Assert.AreEqual ("<allow users=\"toshok\" />", sw.ToString(), "A2");
/* 3-4 */
sw = new StringWriter ();
writer = new XmlTextWriter (sw);
rule = new AuthorizationRule (AuthorizationRuleAction.Deny);
rule.Users.Add ("toshok");
rule.Users.Add ("chris");
rule.Roles.Add ("admin");
rule.Roles.Add ("wheel");
rule.Verbs.Add ("GET");
rule.Verbs.Add ("PUT");
parms[0] = writer;
parms[1] = true;
bool b = (bool)mi.Invoke (rule, parms);
Assert.AreEqual ("<deny roles=\"admin,wheel\" users=\"toshok,chris\" verbs=\"GET,PUT\" />", sw.ToString(), "A3");
Assert.IsTrue (b, "A4");
}
[Test]
public void PostDeserialize ()
{
AuthorizationRule rule;
MethodInfo mi = typeof (AuthorizationRule).GetMethod ("PostDeserialize", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
object[] parms = new object[0];
bool failed;
/* 1 */
failed = true;
try {
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
mi.Invoke (rule, parms);
}
catch (TargetInvocationException e) {
Assert.AreEqual (typeof (ConfigurationErrorsException), e.InnerException.GetType (), "A1");
failed = false;
}
Assert.IsFalse (failed, "A1");
/* 2 */
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
rule.Users.Add ("toshok");
mi.Invoke (rule, parms);
/* 2 */
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
rule.Users.Add ("toshok");
mi.Invoke (rule, parms);
/* 3-4 */
rule = new AuthorizationRule (AuthorizationRuleAction.Deny);
rule.Users.Add ("toshok");
rule.Users.Add ("chris");
rule.Roles.Add ("admin");
rule.Roles.Add ("wheel");
rule.Verbs.Add ("GET");
rule.Verbs.Add ("PUT");
mi.Invoke (rule, parms);
}
}
}
#endif

View File

@@ -0,0 +1,57 @@
//
// AuthorizationSectionTest.cs
// - unit tests for System.Web.Configuration.AuthorizationSection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class AuthorizationSectionTest {
[Test]
public void Defaults()
{
AuthorizationSection a = new AuthorizationSection ();
Assert.IsNotNull (a.Rules, "A1");
Assert.AreEqual (0, a.Rules.Count, "A2");
}
}
}
#endif

View File

@@ -0,0 +1,102 @@
//
// BufferModeSettingsTest.cs
// - unit tests for System.Web.Configuration.BufferModeSettings
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class BufferModeSettingsTest {
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void MaxBufferSize_validationFailure ()
{
BufferModeSettings b = new BufferModeSettings ("hi", Int32.MaxValue, 1, Int32.MaxValue, TimeSpan.FromSeconds (1), TimeSpan.Zero, Int32.MaxValue);
b.MaxBufferSize = 0;
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void MaxBufferThreads_validationFailure ()
{
BufferModeSettings b = new BufferModeSettings ("hi", Int32.MaxValue, 1, Int32.MaxValue, TimeSpan.FromSeconds (1), TimeSpan.Zero, Int32.MaxValue);
b.MaxBufferThreads = 0;
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void MaxFlushSize_validationFailure ()
{
BufferModeSettings b = new BufferModeSettings ("hi", Int32.MaxValue, 1, Int32.MaxValue, TimeSpan.FromSeconds (1), TimeSpan.Zero, Int32.MaxValue);
b.MaxFlushSize = 0;
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void Name_validationFailure ()
{
BufferModeSettings b = new BufferModeSettings ("hi", Int32.MaxValue, 1, Int32.MaxValue, TimeSpan.FromSeconds (1), TimeSpan.Zero, Int32.MaxValue);
b.Name = "";
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void RegularFlushInterval_validationFailure ()
{
BufferModeSettings b = new BufferModeSettings ("hi", Int32.MaxValue, 1, Int32.MaxValue, TimeSpan.FromSeconds (1), TimeSpan.Zero, Int32.MaxValue);
b.RegularFlushInterval = TimeSpan.FromSeconds (-30);
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void UrgentFlushThreshold_validationFailure ()
{
BufferModeSettings b = new BufferModeSettings ("hi", Int32.MaxValue, 1, Int32.MaxValue, TimeSpan.FromSeconds (1), TimeSpan.Zero, Int32.MaxValue);
b.UrgentFlushThreshold = 0;
}
}
}
#endif

View File

@@ -0,0 +1,91 @@
//
// BuildProviderTest.cs
// - unit tests for System.Web.Configuration.BuildProvider
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class BuildProviderTest {
[Test]
public void EqualsAndHashCode ()
{
BuildProvider b1, b2;
b1 = new BuildProvider (".hi", "System.Bye");
b2 = new BuildProvider (".hi", "System.Bye");
Assert.IsTrue (b1.Equals (b2), "A1");
Assert.AreEqual (b1.GetHashCode (), b2.GetHashCode (), "A2");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void ctor_validationFailure1 ()
{
BuildProvider b = new BuildProvider ("", "hi");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void ctor_validationFailure2 ()
{
BuildProvider b = new BuildProvider ("hi", "");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void Extension_validationFailure ()
{
BuildProvider b = new BuildProvider ("hi", "bye");
b.Extension = "";
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void Type_validationFailure ()
{
BuildProvider b = new BuildProvider ("hi", "bye");
b.Type = "";
}
}
}
#endif

View File

@@ -0,0 +1,74 @@
//
// CacheSectionTest.cs
// - unit tests for System.Web.Configuration.CacheSection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class CacheSectionTest {
[Test]
public void Defaults ()
{
CacheSection c = new CacheSection ();
Assert.AreEqual (false, c.DisableExpiration, "A1");
Assert.AreEqual (false, c.DisableMemoryCollection, "A2");
Assert.AreEqual (0, c.PercentagePhysicalMemoryUsedLimit, "A3");
Assert.AreEqual (0, c.PrivateBytesLimit, "A4");
Assert.AreEqual (TimeSpan.FromMinutes (2), c.PrivateBytesPollTime, "A4");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void PercentagePhysicalMemoryUsedLimit_validationFailure()
{
CacheSection c = new CacheSection ();
c.PercentagePhysicalMemoryUsedLimit = -1;
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void PrivateBytesLimit_validationFailure ()
{
CacheSection c = new CacheSection ();
c.PrivateBytesLimit = -1L;
}
}
}
#endif

View File

@@ -0,0 +1,94 @@
2008-12-23 Marek Habersack <mhabersack@novell.com>
* WebConfigurationManagerTest.cs: added new test.
2007-11-23 Marek Habersack <mhabersack@novell.com>
* CacheSectionTest.cs: modified to match the new MS.NET defaults.
2007-03-24 Marek Habersack <mhabersack@novell.com>
* WebConfigurationManagerTest.cs: the tests don't work because of
the way the test suite is set up. In a normal application, the
three test would work just fine.
2006-06-26 Atsushi Enomoto <atsushi@ximian.com>
* NullableStringValidatorTest.cs : new aggregated tests for
properties that use PropertyHelper.EmptyStringValidator.
2006-03-08 Chris Toshok <toshok@ximian.com>
* SiteMapSectionTest.cs: test defaults.
2005-12-06 Chris Toshok <toshok@ximian.com>
* AuthorizationRuleCollectionTest.cs (GetElementKey): new test.
* AuthorizationRuleTest.cs (PostDeserialize): PostDeserialize
doesn't return a value.
2005-12-05 Chris Toshok <toshok@ximian.com>
* ClientTargetTest.cs: new tests.
* AssemblyCollectionTest.cs: new tests.
* CustomErrorCollectionTest.cs: new tests.
* AuthorizationRuleCollectionTest.cs: new tests.
* CodeSubDirectoryTest.cs: new tests.
2005-12-02 Chris Toshok <toshok@ximian.com>
* ProfilePropertySettingsTest.cs: new tests.
* GlobalizationSectionTest.cs: add PostDeserialize test.
* AuthorizationRuleTest.cs: add PostDeserialize test.
2005-12-01 Chris Toshok <toshok@ximian.com>
* GlobalizationSectionTest.cs: Add a test for PreSerialize.
* AuthorizationRuleTest.cs: Add a test for
Preserialize/SerializeElement.
2005-11-23 Chris Toshok <toshok@ximian.com>
* MachineKeyValidationConverterTest.cs: new test.
2005-11-18 Chris Toshok <toshok@ximian.com>
* GlobalizationSectionTest.cs, HostingEnvironmentSectionTest.cs,
CacheSectionTest.cs, CustomErrorsSectionTest.cs,
HealthMonitoringSectionTest.cs, CompilationSectionTest.cs,
DeploymentSectionTest.cs, ClientTargetSectionTest.cs: new tests.
2005-11-14 Chris Toshok <toshok@ximian.com>
* AnonymousIdentificationSectionTest.cs: remove MS stacktrace
comment.
* BuildProviderTest.cs: new tests.
* AuthorizationRuleTest.cs: new tests.
* AuthorizationSectionTest.cs: new tests.
* AuthenticationSectionTest.cs: new tests.
* BufferModeSettingsTest.cs: new tests.
2005-11-13 Chris Toshok <toshok@ximian.com>
* AssemblyInfoTest.cs: programmatic property access tests.
* AnonymousIdentificationSectionTest.cs: same.
2005-09-02 Sebastien Pouliot <sebastien@ximian.com>
* HttpCapabilitiesBaseCas.cs: New. CAS unit tests for
HttpCapabilitiesBase class.

View File

@@ -0,0 +1,56 @@
//
// ClientTargetSectionTest.cs
// - unit tests for System.Web.Configuration.ClientTargetSection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class ClientTargetSectionTest {
[Test]
public void Defaults ()
{
ClientTargetSection c = new ClientTargetSection ();
Assert.IsNotNull (c.ClientTargets, "A1");
Assert.AreEqual (typeof (ClientTargetCollection), c.ClientTargets.GetType(), "A2");
}
}
}
#endif

View File

@@ -0,0 +1,77 @@
//
// ClientTargetTest.cs
// - unit tests for System.Web.Configuration.ClientTarget
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
using System.IO;
using System.Xml;
using System.Reflection;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class ClientTargetTest {
[Test]
public void EqualsAndHashCode ()
{
ClientTarget c1, c2;
c1 = new ClientTarget ("alias", "userAgent");
c2 = new ClientTarget ("alias", "userAgent");
Assert.IsTrue (c1.Equals (c2), "A1");
Assert.AreEqual (c1.GetHashCode (), c2.GetHashCode (), "A2");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void ctor_validationFailure1 ()
{
ClientTarget c = new ClientTarget ("", "hi");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void ctor_validationFailure2 ()
{
ClientTarget c = new ClientTarget ("hi", "");
}
}
}
#endif

View File

@@ -0,0 +1,79 @@
//
// CodeSubDirectoryTest.cs
// - unit tests for System.Web.Configuration.CodeSubDirectory
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
using System.IO;
using System.Xml;
using System.Reflection;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class CodeSubDirectoryTest {
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void ctor_validationFailure ()
{
CodeSubDirectory c = new CodeSubDirectory ("");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void setter_validationFailure ()
{
CodeSubDirectory c = new CodeSubDirectory ("hi");
c.DirectoryName = "";
}
[Test]
public void WhiteSpaceTrimTest ()
{
CodeSubDirectory c = new CodeSubDirectory (" /this/is/a/path/with-spaces ");
Assert.AreEqual (" /this/is/a/path/with-spaces ", c.DirectoryName, "A1");
c.DirectoryName = " /another/one";
Assert.AreEqual (" /another/one", c.DirectoryName, "A2");
c.DirectoryName = "/one/more ";
Assert.AreEqual ("/one/more ", c.DirectoryName, "A3");
}
}
}
#endif

View File

@@ -0,0 +1,74 @@
//
// CompilationSectionTest.cs
// - unit tests for System.Web.Configuration.CompilationSection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class CompilationSectionTest {
[Test]
public void Defaults ()
{
CompilationSection c = new CompilationSection ();
Assert.IsNotNull (c.Assemblies, "A1");
Assert.AreEqual ("", c.AssemblyPostProcessorType, "A2");
Assert.IsTrue (c.Batch, "A3");
Assert.AreEqual (TimeSpan.FromMinutes (15), c.BatchTimeout, "A4");
Assert.IsNotNull (c.BuildProviders, "A5");
Assert.IsNotNull (c.CodeSubDirectories, "A6");
Assert.IsNotNull (c.Compilers, "A7");
Assert.IsFalse (c.Debug, "A8");
Assert.AreEqual ("vb", c.DefaultLanguage, "A9");
Assert.IsTrue (c.Explicit, "A10");
Assert.IsNotNull (c.ExpressionBuilders, "A11");
Assert.AreEqual (1000, c.MaxBatchSize, "A12");
Assert.AreEqual (15, c.NumRecompilesBeforeAppRestart, "A13");
Assert.IsFalse (c.Strict, "A14");
Assert.AreEqual ("", c.TempDirectory, "A15");
Assert.IsFalse (c.UrlLinePragmas, "A16");
}
}
}
#endif

View File

@@ -0,0 +1,132 @@
//
// CustomErrorCollectionTest.cs
// - unit tests for System.Web.Configuration.CustomErrorCollection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class CustomErrorCollectionTest
{
[Test]
public void GetKey ()
{
CustomErrorCollection col = new CustomErrorCollection ();
col.Add (new CustomError (404, "http://404-error.com/"));
Assert.AreEqual ("404", col.GetKey (0), "A1");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void GetKey_OutOfRange ()
{
CustomErrorCollection col = new CustomErrorCollection ();
Assert.IsNull (col.GetKey(0), "A1");
}
[Test]
public void Set ()
{
CustomErrorCollection col = new CustomErrorCollection ();
col.Add (new CustomError (404, "http://404-error.com/"));
col.Add (new CustomError (403, "http://403-error.com/"));
col.Add (new CustomError (999, "http://403-error.com/"));
col.Set (new CustomError (403, "http://403-error2.com/"));
Assert.AreEqual (3, col.Count, "A1");
Assert.AreEqual (3, col.AllKeys.Length, "A2");
Assert.AreEqual ("http://403-error2.com/", col[1].Redirect, "A3");
}
[Test]
public void SetToDuplicate ()
{
CustomErrorCollection col = new CustomErrorCollection ();
col.Add (new CustomError (404, "http://404-error.com/"));
col.Add (new CustomError (403, "http://403-error.com/"));
col.Add (new CustomError (999, "http://403-error.com/"));
/* override the 999 entry with a duplicate 403 */
col[2] = new CustomError (403, "http://403-error2.com/");
Assert.AreEqual (3, col.Count, "A1");
Assert.AreEqual (3, col.AllKeys.Length, "A2");
Assert.AreEqual (403, col[1].StatusCode, "A3");
Assert.AreEqual ("http://403-error.com/", col[1].Redirect, "A4");
Assert.AreEqual (403, col[2].StatusCode, "A5");
Assert.AreEqual ("http://403-error2.com/", col[2].Redirect, "A6");
}
[Test]
public void DuplicateKeyInAdd ()
{
CustomErrorCollection col = new CustomErrorCollection ();
col.Add (new CustomError (404, "http://404-error.com/"));
col.Add (new CustomError (404, "http://403-error.com/"));
Assert.AreEqual (1, col.Count, "A1");
Assert.AreEqual (1, col.AllKeys.Length, "A2");
Assert.AreEqual ("http://403-error.com/", col[0].Redirect, "A3");
}
[Test]
public void AllKeys ()
{
CustomErrorCollection col = new CustomErrorCollection ();
col.Add (new CustomError (404, "http://404-error.com/"));
col.Add (new CustomError (403, "http://403-error.com/"));
col.Add (new CustomError (999, "http://403-error.com/"));
Assert.AreEqual (3, col.AllKeys.Length, "A1");
Assert.AreEqual ("404", col.AllKeys[0], "A2");
Assert.AreEqual ("403", col.AllKeys[1], "A3");
Assert.AreEqual ("999", col.AllKeys[2], "A4");
}
}
}
#endif

View File

@@ -0,0 +1,57 @@
//
// CustomErrorsSectionTest.cs
// - unit tests for System.Web.Configuration.CustomErrorsSection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class CustomErrorsSectionTest {
[Test]
public void Defaults ()
{
CustomErrorsSection c = new CustomErrorsSection ();
Assert.IsNull (c.DefaultRedirect, "A1");
Assert.IsNotNull (c.Errors, "A2");
Assert.AreEqual (CustomErrorsMode.RemoteOnly, c.Mode, "A3");
}
}
}
#endif

View File

@@ -0,0 +1,55 @@
//
// DeploymentSectionTest.cs
// - unit tests for System.Web.Configuration.DeploymentSection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class DeploymentSectionTest {
[Test]
public void Defaults ()
{
DeploymentSection d = new DeploymentSection ();
Assert.IsFalse (d.Retail, "A1");
}
}
}
#endif

View File

@@ -0,0 +1,185 @@
//
// GlobalizationSectionTest.cs
// - unit tests for System.Web.Configuration.GlobalizationSection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Reflection;
using System.Text;
using System.IO;
using System.Xml;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
using MonoTests.SystemWeb.Framework;
using MonoTests.stand_alone.WebHarness;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class GlobalizationSectionTest {
[TestFixtureSetUp]
public void SetUp ()
{
WebTest.CopyResource (GetType (), "GlobalizationEncodingName.aspx", "GlobalizationEncodingName.aspx");
}
[Test]
public void Defaults ()
{
GlobalizationSection g = new GlobalizationSection ();
Assert.AreEqual ("", g.Culture, "A1");
Assert.IsFalse (g.EnableBestFitResponseEncoding, "A2");
Assert.IsFalse (g.EnableClientBasedCulture, "A3");
// XXX FileEncoding?
Assert.AreEqual (Encoding.UTF8, g.RequestEncoding, "A5");
Assert.AreEqual ("", g.ResourceProviderFactoryType, "A6");
Assert.AreEqual (Encoding.UTF8, g.ResponseHeaderEncoding, "A7");
Assert.AreEqual ("", g.UICulture, "A8");
}
[Test]
public void PreSerialize ()
{
StringWriter sw;
XmlWriter writer;
MethodInfo mi = typeof (GlobalizationSection).GetMethod ("PreSerialize", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
GlobalizationSection s;
object[] parms = new object[1];
bool failed;
sw = new StringWriter ();
writer = new XmlTextWriter (sw);
s = new GlobalizationSection();
parms[0] = writer;
/* 1 */
mi.Invoke (s, parms);
/* 2 */
failed = true;
try {
s.Culture = "illegal-culture";
mi.Invoke (s, parms);
}
catch (TargetInvocationException e) {
Assert.AreEqual (typeof (ConfigurationErrorsException), e.InnerException.GetType (), "A2");
failed = false;
}
Assert.IsFalse (failed, "A2");
/* 3 */
failed = true;
try {
s.Culture = "";
s.UICulture = "illegal-culture";
mi.Invoke (s, parms);
}
catch (TargetInvocationException e) {
Assert.AreEqual (typeof (ConfigurationErrorsException), e.InnerException.GetType (), "A3");
failed = false;
}
Assert.IsFalse (failed, "A3");
/* 4 */
s.Culture = "";
s.UICulture = "";
s.ResourceProviderFactoryType = "invalid-type";
mi.Invoke (s, parms);
/* 5 (null writer) */
parms[0] =null;
mi.Invoke (s, parms);
}
[Test]
public void PostDeserialize ()
{
MethodInfo mi = typeof (GlobalizationSection).GetMethod ("PostDeserialize", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
GlobalizationSection s;
object[] parms = new object[0];
bool failed;
s = new GlobalizationSection();
/* 1 */
mi.Invoke (s, parms);
/* 2 */
failed = true;
try {
s.Culture = "illegal-culture";
mi.Invoke (s, parms);
}
catch (TargetInvocationException e) {
Assert.AreEqual (typeof (ConfigurationErrorsException), e.InnerException.GetType (), "A2");
failed = false;
}
Assert.IsFalse (failed, "A2");
failed = true;
try {
s.Culture = "";
s.UICulture = "illegal-culture";
mi.Invoke (s, parms);
}
catch (TargetInvocationException e) {
Assert.AreEqual (typeof (ConfigurationErrorsException), e.InnerException.GetType (), "A3");
failed = false;
}
Assert.IsFalse (failed, "A3");
s.Culture = "";
s.UICulture = "";
s.ResourceProviderFactoryType = "invalid-type";
mi.Invoke (s, parms);
}
[Test]
public void GlobalizationEncodingName ()
{
string pageHtml = new WebTest ("GlobalizationEncodingName.aspx").Run ();
string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
string originalHtml = "GOOD";
Assert.AreEqual (originalHtml, renderedHtml, "#A1");
}
}
}
#endif

View File

@@ -0,0 +1,73 @@
//
// HostingEnvironmentSectionTest.cs
// - unit tests for System.Web.Configuration.HostingEnvironmentSection
//
// Author:
// Chris Toshok <toshok@ximian.com>
//
// Copyright (C) 2005 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.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class HostingEnvironmentSectionTest {
[Test]
public void Defaults ()
{
HostingEnvironmentSection s = new HostingEnvironmentSection ();
Assert.AreEqual (TimeSpan.MaxValue, s.IdleTimeout, "A1");
Assert.IsTrue (s.ShadowCopyBinAssemblies, "A2");
Assert.AreEqual (TimeSpan.FromSeconds (30), s.ShutdownTimeout, "A3");
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void IdleTimeout_validationFailure ()
{
HostingEnvironmentSection s = new HostingEnvironmentSection ();
s.IdleTimeout = TimeSpan.FromSeconds (-1);
}
[Test]
[ExpectedException (typeof (ConfigurationErrorsException))]
public void ShutdownTimeout_validationFailure ()
{
HostingEnvironmentSection s = new HostingEnvironmentSection ();
s.ShutdownTimeout = TimeSpan.FromSeconds (-1);
}
}
}
#endif

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