-Added Newtonsoft.Json.Metro build (whew, what a pain!)

-Added .gitignore file
This commit is contained in:
James Newton-King
2012-03-15 18:34:51 +13:00
parent f9e5745425
commit 5800e97ff3
141 changed files with 3921 additions and 1097 deletions
@@ -1,19 +1,26 @@
using System;
using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
using System.Data.Linq;
#endif
#if !SILVERLIGHT
#if !(SILVERLIGHT || NETFX_CORE)
using System.Data.SqlTypes;
#endif
using System.Linq;
using System.Text;
using Newtonsoft.Json.Converters;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
using Newtonsoft.Json.Tests.TestObjects;
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class BinaryConverterTests : TestFixtureBase
{
private static readonly byte[] TestData = Encoding.UTF8.GetBytes("This is some test data!!!");
@@ -24,7 +31,7 @@ namespace Newtonsoft.Json.Tests.Converters
public byte[] NullByteArray { get; set; }
}
#if !SILVERLIGHT && !PocketPC && !NET20
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
[Test]
public void DeserializeBinaryClass()
{
@@ -90,7 +97,7 @@ namespace Newtonsoft.Json.Tests.Converters
}", json);
}
#if !SILVERLIGHT
#if !(SILVERLIGHT || NETFX_CORE)
public class SqlBinaryClass
{
public SqlBinary SqlBinary { get; set; }
@@ -142,7 +149,7 @@ namespace Newtonsoft.Json.Tests.Converters
ByteArrayClass byteArrayClass = JsonConvert.DeserializeObject<ByteArrayClass>(json, new BinaryConverter());
Assert.AreEqual(TestData, byteArrayClass.ByteArray);
CollectionAssert.AreEquivalent(TestData, byteArrayClass.ByteArray);
Assert.AreEqual(null, byteArrayClass.NullByteArray);
}
@@ -157,7 +164,7 @@ namespace Newtonsoft.Json.Tests.Converters
ByteArrayClass c = JsonConvert.DeserializeObject<ByteArrayClass>(json);
Assert.IsNotNull(c.ByteArray);
Assert.AreEqual(4, c.ByteArray.Length);
Assert.AreEqual(new byte[] { 0, 1, 2, 3 }, c.ByteArray);
CollectionAssert.AreEquivalent(new byte[] { 0, 1, 2, 3 }, c.ByteArray);
}
}
}
@@ -3,10 +3,17 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Converters;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class CustomCreationConverterTests : TestFixtureBase
{
public interface IPerson
@@ -1,10 +1,16 @@
#if !SILVERLIGHT
#if !(SILVERLIGHT || NETFX_CORE)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Converters;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Tests.TestObjects;
using System.Data;
@@ -1,12 +1,20 @@
#if !SILVERLIGHT
#if !(SILVERLIGHT || NETFX_CORE)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Converters;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
using Newtonsoft.Json.Tests.TestObjects;
#if !NETFX_CORE
using System.Data;
#endif
namespace Newtonsoft.Json.Tests.Converters
{
@@ -2,21 +2,28 @@
using System;
using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
using System.Data.Linq;
#endif
#if !SILVERLIGHT
#if !SILVERLIGHT && !NETFX_CORE
using System.Data.SqlTypes;
#endif
using System.Dynamic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Converters;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
using Newtonsoft.Json.Tests.TestObjects;
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class ExpandoObjectConverterTests : TestFixtureBase
{
public class ExpandoContainer
@@ -110,32 +117,32 @@ namespace Newtonsoft.Json.Tests.Converters
Assert.IsNotNull(o.Expando);
dynamic d = o.Expando;
Assert.IsInstanceOfType(typeof(ExpandoObject), d);
CustomAssert.IsInstanceOfType(typeof(ExpandoObject), d);
Assert.AreEqual("String!", d.String);
Assert.IsInstanceOfType(typeof(string), d.String);
CustomAssert.IsInstanceOfType(typeof(string), d.String);
Assert.AreEqual(234, d.Integer);
Assert.IsInstanceOfType(typeof(long), d.Integer);
CustomAssert.IsInstanceOfType(typeof(long), d.Integer);
Assert.AreEqual(1.23, d.Float);
Assert.IsInstanceOfType(typeof(double), d.Float);
CustomAssert.IsInstanceOfType(typeof(double), d.Float);
Assert.IsNotNull(d.List);
Assert.AreEqual(3, d.List.Count);
Assert.IsInstanceOfType(typeof(List<object>), d.List);
CustomAssert.IsInstanceOfType(typeof(List<object>), d.List);
Assert.AreEqual("First", d.List[0]);
Assert.IsInstanceOfType(typeof(string), d.List[0]);
CustomAssert.IsInstanceOfType(typeof(string), d.List[0]);
Assert.AreEqual("Second", d.List[1]);
Assert.AreEqual("Third", d.List[2]);
Assert.IsNotNull(d.Object);
Assert.IsInstanceOfType(typeof(ExpandoObject), d.Object);
CustomAssert.IsInstanceOfType(typeof(ExpandoObject), d.Object);
Assert.AreEqual(1, d.Object.First);
Assert.IsInstanceOfType(typeof(long), d.Object.First);
CustomAssert.IsInstanceOfType(typeof(long), d.Object.First);
}
[Test]
@@ -28,7 +28,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Tests.TestObjects;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Utilities;
using System.Globalization;
@@ -36,6 +42,7 @@ using System.Xml;
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class IsoDateTimeConverterTests : TestFixtureBase
{
[Test]
@@ -112,7 +119,7 @@ namespace Newtonsoft.Json.Tests.Converters
Assert.AreEqual(2006, d.Year);
}
#if !SILVERLIGHT
#if !SILVERLIGHT && !NETFX_CORE
[Test]
public void SerializeFormattedDateTimeNewZealandCulture()
{
@@ -212,11 +219,14 @@ namespace Newtonsoft.Json.Tests.Converters
}
[Test]
[ExpectedException(typeof(Exception), ExpectedMessage = "Cannot convert null value to System.DateTime.")]
public void DeserializeNullToNonNullable()
{
DateTimeTestClass c2 =
JsonConvert.DeserializeObject<DateTimeTestClass>(@"{""PreField"":""Pre"",""DateTimeField"":null,""DateTimeOffsetField"":null,""PostField"":""Post""}", new IsoDateTimeConverter() { DateTimeStyles = DateTimeStyles.AssumeUniversal });
ExceptionAssert.Throws<Exception>("Cannot convert null value to System.DateTime.",
() =>
{
DateTimeTestClass c2 =
JsonConvert.DeserializeObject<DateTimeTestClass>(@"{""PreField"":""Pre"",""DateTimeField"":null,""DateTimeOffsetField"":null,""PostField"":""Post""}", new IsoDateTimeConverter() { DateTimeStyles = DateTimeStyles.AssumeUniversal });
});
}
[Test]
@@ -28,11 +28,18 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Tests.TestObjects;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
using Newtonsoft.Json.Converters;
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class JavaScriptDateTimeConverterTests : TestFixtureBase
{
[Test]
@@ -94,11 +101,14 @@ namespace Newtonsoft.Json.Tests.Converters
}
[Test]
[ExpectedException(typeof(Exception), ExpectedMessage = "Cannot convert null value to System.DateTime.")]
public void DeserializeNullToNonNullable()
{
DateTimeTestClass c2 =
JsonConvert.DeserializeObject<DateTimeTestClass>(@"{""PreField"":""Pre"",""DateTimeField"":null,""DateTimeOffsetField"":null,""PostField"":""Post""}", new JavaScriptDateTimeConverter());
ExceptionAssert.Throws<Exception>("Cannot convert null value to System.DateTime.",
() =>
{
DateTimeTestClass c2 =
JsonConvert.DeserializeObject<DateTimeTestClass>(@"{""PreField"":""Pre"",""DateTimeField"":null,""DateTimeOffsetField"":null,""PostField"":""Post""}", new JavaScriptDateTimeConverter());
});
}
[Test]
@@ -6,10 +6,17 @@ using System.Text;
using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Tests.TestObjects;
using Newtonsoft.Json.Utilities;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class ObjectIdConverterTests : TestFixtureBase
{
public class ObjectIdTestClass
@@ -38,7 +45,7 @@ namespace Newtonsoft.Json.Tests.Converters
byte[] expected = MiscellaneousUtils.HexToBytes("29000000075F6964004ABBED9D1D8B0F02180000010274657374000900000031323334C2A335360000");
Assert.AreEqual(expected, ms.ToArray());
CollectionAssert.AreEquivalent(expected, ms.ToArray());
}
[Test]
@@ -51,7 +58,7 @@ namespace Newtonsoft.Json.Tests.Converters
BsonReader reader = new BsonReader(new MemoryStream(bson));
ObjectIdTestClass c = serializer.Deserialize<ObjectIdTestClass>(reader);
Assert.AreEqual(c.Id.Value, MiscellaneousUtils.HexToBytes("4ABBED9D1D8B0F0218000001"));
CollectionAssert.AreEquivalent(c.Id.Value, MiscellaneousUtils.HexToBytes("4ABBED9D1D8B0F0218000001"));
Assert.AreEqual(c.Test, "1234£56");
}
}
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
using System.Data.Linq;
#endif
#if !SILVERLIGHT
#if !SILVERLIGHT && !NETFX_CORE
using System.Data.SqlTypes;
#endif
using System.IO;
@@ -13,11 +13,18 @@ using System.Text.RegularExpressions;
using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Utilities;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
using Newtonsoft.Json.Tests.TestObjects;
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class RegexConverterTests : TestFixtureBase
{
public class RegexTestClass
@@ -4,11 +4,18 @@ using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using Newtonsoft.Json.Converters;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
using Newtonsoft.Json.Tests.TestObjects;
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class StringEnumConverterTests : TestFixtureBase
{
public class EnumClass
@@ -66,15 +73,18 @@ namespace Newtonsoft.Json.Tests.Converters
#if !NET20
[Test]
[ExpectedException(typeof(Exception), ExpectedMessage = "Enum name 'Third' already exists on enum 'NamedEnumDuplicate'.")]
public void NamedEnumDuplicateTest()
{
EnumContainer<NamedEnumDuplicate> c = new EnumContainer<NamedEnumDuplicate>
ExceptionAssert.Throws<Exception>("Enum name 'Third' already exists on enum 'NamedEnumDuplicate'.",
() =>
{
Enum = NamedEnumDuplicate.First
};
EnumContainer<NamedEnumDuplicate> c = new EnumContainer<NamedEnumDuplicate>
{
Enum = NamedEnumDuplicate.First
};
JsonConvert.SerializeObject(c, Formatting.Indented, new StringEnumConverter());
JsonConvert.SerializeObject(c, Formatting.Indented, new StringEnumConverter());
});
}
[Test]
@@ -28,7 +28,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Converters;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
using Newtonsoft.Json.Tests.TestObjects;
namespace Newtonsoft.Json.Tests.Converters
@@ -53,6 +59,7 @@ namespace Newtonsoft.Json.Tests.Converters
public string StringProperty2 { get; set; }
}
[TestFixture]
public class VersionConverterTests : TestFixtureBase
{
private void SerializeVersionClass(string version1, string version2)
@@ -23,12 +23,18 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !SILVERLIGHT
#if !SILVERLIGHT && !NETFX_CORE
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Tests.Serialization;
using Newtonsoft.Json.Tests.TestObjects;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#endif
using Newtonsoft.Json;
using System.IO;
using System.Xml;
@@ -41,6 +47,7 @@ using System.Xml.Linq;
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class XmlNodeConverterTest : TestFixtureBase
{
private string SerializeXmlNode(XmlNode node)