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,12 @@
2009-04-02 Atsushi Enomoto <atsushi@ximian.com>
* ContentTypeTest.cs : add quotation test for especials.
2008-07-01 Marek Safar <marek.safar@gmail.com>
* ContentDispositionTest.cs: Fixed broken test.
2008-02-16 Atsushi Enomoto <atsushi@ximian.com>
* ContentTypeTest.cs : (oops we didn't have ChangeLog here) added
another .ctor() test.

View File

@@ -0,0 +1,152 @@
//
// ContentDispositionTest.cs - NUnit Test Cases for System.Net.Mime.ContentDisposition
//
// Authors:
// John Luke (john.luke@gmail.com)
//
// (C) 2005 John Luke
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Net.Mime;
namespace MonoTests.System.Net.Mime
{
[TestFixture]
public class ContentDispositionTest
{
ContentDisposition cd;
[SetUp]
public void GetReady ()
{
cd = new ContentDisposition ();
cd.FileName = "genome.jpeg";
cd.ModificationDate = DateTime.MaxValue;
}
[Test]
public void DispositionType ()
{
Assert.AreEqual ("attachment", cd.DispositionType);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void DispositionTypeNull ()
{
cd.DispositionType = null;
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void DispositionTypeEmpty ()
{
cd.DispositionType = "";
}
[Test]
public void EqualsHashCode ()
{
ContentDisposition dummy1 = new ContentDisposition ();
dummy1.Inline = true;
ContentDisposition dummy2 = new ContentDisposition ("inline");
Assert.IsTrue (dummy1.Equals (dummy2));
Assert.IsFalse (dummy1 == dummy2);
Assert.IsTrue (dummy1.GetHashCode () == dummy2.GetHashCode ());
}
[Test]
public void Equals ()
{
ContentDisposition dummy1 = new ContentDisposition ();
dummy1.FileName = "genome.jpeg";
ContentDisposition dummy2 = new ContentDisposition ("attachment; filename=genome.jpeg");
Assert.IsTrue (dummy1.Equals (dummy2));
}
[Test]
public void FileName ()
{
Assert.AreEqual ("genome.jpeg", cd.FileName);
}
[Test]
public void Size ()
{
Assert.AreEqual (-1, cd.Size);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ArgumentNullException ()
{
new ContentDisposition (null);
}
[Test]
[ExpectedException (typeof (FormatException))]
public void FormatException ()
{
new ContentDisposition ("");
}
[Test]
public void NoFormatException ()
{
new ContentDisposition ("attachment; foo=bar");
}
[Test]
public void IsInline ()
{
Assert.IsFalse (cd.Inline);
}
[Test]
public void Parameters ()
{
Assert.IsNotNull (cd.Parameters, "is not null");
Assert.AreEqual (2, cd.Parameters.Count);
}
[Test]
public void ToStringTest ()
{
string rfc822 = "dd MMM yyyy HH':'mm':'ss zz00";
string modification_date = DateTime.MaxValue.ToString (rfc822);
string to_string = cd.ToString ();
Assert.IsTrue (to_string.StartsWith ("attachment; "), "#1");
Assert.IsTrue (to_string.Contains ("modification-date=\"" + modification_date + "\""), "#2");
Assert.IsTrue (to_string.Contains ("filename=genome.jpeg"), "#3");
}
[Test]
public void ToStringTest2 ()
{
ContentDisposition dummy = new ContentDisposition ();
Assert.AreEqual ("attachment", dummy.ToString ());
}
[Test]
public void ToStringTest3 ()
{
ContentDisposition dummy = new ContentDisposition ();
dummy.Size = 0;
Assert.AreEqual ("attachment; size=0", dummy.ToString ());
}
[Test]
public void ToStringTest4 ()
{
ContentDisposition dummy = new ContentDisposition ("attachment");
dummy.Parameters.Add ("foo", "bar");
Assert.AreEqual (1, dummy.Parameters.Count);
Assert.AreEqual ("attachment; foo=bar", dummy.ToString ());
}
}
}
#endif

View File

@@ -0,0 +1,174 @@
//
// ContentTypeTest.cs - NUnit Test Cases for System.Net.Mime.ContentType
//
// Authors:
// John Luke (john.luke@gmail.com)
//
// (C) 2005 John Luke
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Net.Mime;
namespace MonoTests.System.Net.Mime
{
[TestFixture]
public class ContentTypeTest
{
ContentType ct;
[SetUp]
public void GetReady ()
{
ct = new ContentType ();
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ArgumentNullException ()
{
new ContentType (null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ArgumentException ()
{
new ContentType ("");
}
[Test]
[ExpectedException (typeof (FormatException))]
public void FormatException ()
{
new ContentType ("attachment; foo=bar"); // missing '/'
}
[Test]
public void ArbitraryParameter ()
{
new ContentType ("application/xml; foo=bar");
}
[Test]
public void Boundary ()
{
Assert.IsNull (ct.Boundary);
}
[Test]
public void CharSet ()
{
Assert.IsNull (ct.CharSet);
}
[Test]
public void Equals ()
{
Assert.IsTrue (ct.Equals (new ContentType ()));
Assert.IsFalse (ct == new ContentType ());
}
[Test]
public void GetHashCodeTest ()
{
Assert.IsTrue (ct.GetHashCode () == new ContentType ().GetHashCode ());
}
[Test]
public void MediaType ()
{
Assert.IsTrue (ct.MediaType == "application/octet-stream");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void MediaTypeNullException ()
{
ct.MediaType = null;
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void MediaTypeEmptyException ()
{
ct.MediaType = "";
}
[Test]
[ExpectedException (typeof (FormatException))]
public void MediaTypeFormatException ()
{
ct.MediaType = "application/x-myType;";
}
[Test]
public void Parameters ()
{
ContentType dummy = new ContentType ();
Assert.IsTrue (dummy.Parameters.Count == 0);
dummy.CharSet = "us-ascii";
dummy.Name = "test";
dummy.Boundary = "-----boundary---0";
dummy.Parameters.Add ("foo", "bar");
Assert.IsTrue (dummy.Parameters.Count == 4);
Assert.IsTrue (dummy.Parameters["charset"] == "us-ascii");
Assert.IsTrue (dummy.Parameters["name"] == "test");
Assert.IsTrue (dummy.Parameters["boundary"] == "-----boundary---0");
Assert.IsTrue (dummy.Parameters["foo"] == "bar");
}
[Test]
public void ToStringTest ()
{
Assert.AreEqual ("application/octet-stream", ct.ToString ());
}
[Test]
public void ToStringTest2 ()
{
ContentType dummy = new ContentType ("text/plain; charset=us-ascii");
Assert.AreEqual ("text/plain; charset=us-ascii", dummy.ToString ());
}
[Test]
public void ToStringTest3 ()
{
ct.Parameters.Add ("foo", "bar");
Assert.AreEqual ("application/octet-stream; foo=bar", ct.ToString ());
}
[Test]
public void ToStringTest4 ()
{
ct.Parameters.Add ("start", "urn:foo");
Assert.AreEqual ("application/octet-stream; start=\"urn:foo\"", ct.ToString ());
}
[Test]
public void ToStringTest5 ()
{
ct.Parameters.Add ("start", "foo_bar");
Assert.AreEqual ("application/octet-stream; start=foo_bar", ct.ToString ());
ct.Parameters.Clear ();
ct.Parameters.Add ("start", "foo@bar");
Assert.AreEqual ("application/octet-stream; start=\"foo@bar\"", ct.ToString ());
}
[Test]
public void ToStringTest6 ()
{
ct.Parameters.Add ("start", "urn:foo\"bar\"");
Assert.AreEqual ("application/octet-stream; start=\"urn:foo\\\"bar\\\"\"", ct.ToString ());
}
[Test]
public void EncodedChars ()
{
ContentType ct = new ContentType ();
ct.Parameters.Add ("ASCII", "This is ASCII");
}
}
}
#endif