Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/Newtonsoft.Json.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamesNK <james@newtonking.com>2012-02-10 15:33:45 +0400
committerJamesNK <james@newtonking.com>2012-02-10 15:33:45 +0400
commit49328ddeb0e58a7419c25b69d4932b9886886073 (patch)
treedf69cca9be3d8e751963768402f360cf1e7d493d /Src/Newtonsoft.Json.Tests
parent3bebf5c7659c6d092ee06bbd2de9aa6aa5ba452e (diff)
-Incremented version to 4.0.8
-Added VersionConverter -Fixed converting XML to JSON with a default namespace -Changed Silverlight/Windows Phone assemblies to not be signed
Diffstat (limited to 'Src/Newtonsoft.Json.Tests')
-rw-r--r--Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs114
-rw-r--r--Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs490
-rw-r--r--Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs10
-rw-r--r--Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj1
-rw-r--r--Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net35.csproj1
-rw-r--r--Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj1
-rw-r--r--Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WindowsPhone.csproj1
-rw-r--r--Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj1
-rw-r--r--Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs24
9 files changed, 633 insertions, 10 deletions
diff --git a/Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs
new file mode 100644
index 0000000..eaaaf94
--- /dev/null
+++ b/Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs
@@ -0,0 +1,114 @@
+#region License
+// Copyright (c) 2007 James Newton-King
+//
+// 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.
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Newtonsoft.Json.Converters;
+using NUnit.Framework;
+using Newtonsoft.Json.Tests.TestObjects;
+
+namespace Newtonsoft.Json.Tests.Converters
+{
+ public class VersionClass
+ {
+ public VersionClass(string version1, string version2)
+ {
+ this.StringProperty1 = "StringProperty1";
+ this.Version1 = new Version(version1);
+ this.Version2 = new Version(version2);
+ this.StringProperty2 = "StringProperty2";
+ }
+
+ public VersionClass()
+ {
+ }
+
+ public string StringProperty1 { get; set; }
+ public Version Version1 { get; set; }
+ public Version Version2 { get; set; }
+ public string StringProperty2 { get; set; }
+ }
+
+ public class VersionConverterTests : TestFixtureBase
+ {
+ private void SerializeVersionClass(string version1, string version2)
+ {
+ VersionClass versionClass = new VersionClass(version1, version2);
+
+ string json = JsonConvert.SerializeObject(versionClass, Formatting.Indented, new VersionConverter());
+
+ string expectedJson = string.Format(@"{{
+ ""StringProperty1"": ""StringProperty1"",
+ ""Version1"": ""{0}"",
+ ""Version2"": ""{1}"",
+ ""StringProperty2"": ""StringProperty2""
+}}", version1, version2);
+
+ Assert.AreEqual(expectedJson, json);
+ }
+
+ [Test]
+ public void SerializeVersionClass()
+ {
+ SerializeVersionClass("1.0.0.0", "2.0.0.0");
+ SerializeVersionClass("1.2.0.0", "2.3.0.0");
+ SerializeVersionClass("1.2.3.0", "2.3.4.0");
+ SerializeVersionClass("1.2.3.4", "2.3.4.5");
+
+ SerializeVersionClass("1.2", "2.3");
+ SerializeVersionClass("1.2.3", "2.3.4");
+ SerializeVersionClass("1.2.3.4", "2.3.4.5");
+ }
+
+ private void DeserializeVersionClass(string version1, string version2)
+ {
+ string json = string.Format(@"{{""StringProperty1"": ""StringProperty1"", ""Version1"": ""{0}"", ""Version2"": ""{1}"", ""StringProperty2"": ""StringProperty2""}}", version1, version2);
+ Version expectedVersion1 = new Version(version1);
+ Version expectedVersion2 = new Version(version2);
+
+ VersionClass versionClass = JsonConvert.DeserializeObject<VersionClass>(json, new VersionConverter());
+
+ Assert.AreEqual("StringProperty1", versionClass.StringProperty1);
+ Assert.AreEqual(expectedVersion1, versionClass.Version1);
+ Assert.AreEqual(expectedVersion2, versionClass.Version2);
+ Assert.AreEqual("StringProperty2", versionClass.StringProperty2);
+ }
+
+ [Test]
+ public void DeserializeVersionClass()
+ {
+ DeserializeVersionClass("1.0.0.0", "2.0.0.0");
+ DeserializeVersionClass("1.2.0.0", "2.3.0.0");
+ DeserializeVersionClass("1.2.3.0", "2.3.4.0");
+ DeserializeVersionClass("1.2.3.4", "2.3.4.5");
+
+ DeserializeVersionClass("1.2", "2.3");
+ DeserializeVersionClass("1.2.3", "2.3.4");
+ DeserializeVersionClass("1.2.3.4", "2.3.4.5");
+ }
+ }
+} \ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs b/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs
index 4dc32b2..c672ac5 100644
--- a/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs
+++ b/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs
@@ -1285,7 +1285,7 @@ namespace Newtonsoft.Json.Tests.Converters
Assert.AreEqual(@"<?xml version=""1.0"" encoding=""utf-8""?><root booleanType=""true"" />", xmlString);
}
- static void JsonBodyToSoapXml(Stream json, Stream xml)
+ private static void JsonBodyToSoapXml(Stream json, Stream xml)
{
Newtonsoft.Json.JsonSerializerSettings settings = new Newtonsoft.Json.JsonSerializerSettings();
settings.Converters.Add(new Newtonsoft.Json.Converters.XmlNodeConverter());
@@ -1301,6 +1301,494 @@ namespace Newtonsoft.Json.Tests.Converters
}
}
}
+
+#if !NET20
+ [Test]
+ public void DeserializeXNodeDefaultNamespace()
+ {
+ string xaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width=""63*"" />
+ <ColumnDefinition Width=""320*"" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions xmlns="""">
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
+</Grid>";
+
+ string json = JsonConvert.SerializeXNode(XDocument.Parse(xaml), Formatting.Indented);
+
+ string expectedJson = @"{
+ ""Grid"": {
+ ""@xmlns"": ""http://schemas.microsoft.com/winfx/2006/xaml/presentation"",
+ ""@xmlns:x"": ""http://schemas.microsoft.com/winfx/2006/xaml"",
+ ""@xmlns:toolkit"": ""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"",
+ ""@Style"": ""{StaticResource trimFormGrid}"",
+ ""@x:Name"": ""TrimObjectForm"",
+ ""Grid.ColumnDefinitions"": {
+ ""ColumnDefinition"": [
+ {
+ ""@Width"": ""63*""
+ },
+ {
+ ""@Width"": ""320*""
+ }
+ ]
+ },
+ ""Grid.RowDefinitions"": {
+ ""@xmlns"": """",
+ ""RowDefinition"": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ]
+ },
+ ""TextBox"": [
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordTypedTitle"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""0"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordExternalReference"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""1"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Author, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordAuthor"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""4"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Container, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordContainer"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""5"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordIsEnclosed"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""6"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordAssignee"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""7"",
+ ""@xmlns"": """"
+ }
+ ],
+ ""toolkit:DatePicker"": [
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_DP}"",
+ ""@Value"": ""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordDateCreated"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""2""
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_DP}"",
+ ""@Value"": ""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordDateDue"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""3""
+ }
+ ],
+ ""TextBlock"": [
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Title (Free Text Part)"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""0"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""External ID"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""1"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Date Created"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""2"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Date Due"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""3"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Author"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""4"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Container"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""5"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Enclosed?"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""6"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Assignee"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""7"",
+ ""@xmlns"": """"
+ }
+ ]
+ }
+}";
+
+ Assert.AreEqual(expectedJson, json);
+
+ XNode node = JsonConvert.DeserializeXNode(json);
+
+ string xaml2 = node.ToString();
+
+ string expectedXaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width=""63*"" />
+ <ColumnDefinition Width=""320*"" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions xmlns="""">
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
+ <TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
+</Grid>";
+
+ Assert.AreEqual(expectedXaml, xaml2);
+ }
+#endif
+
+ [Test]
+ public void DeserializeXmlNodeDefaultNamespace()
+ {
+ string xaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width=""63*"" />
+ <ColumnDefinition Width=""320*"" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions xmlns="""">
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
+</Grid>";
+
+ XmlDocument document = new XmlDocument();
+ document.LoadXml(xaml);
+
+ string json = JsonConvert.SerializeXmlNode(document, Formatting.Indented);
+
+ string expectedJson = @"{
+ ""Grid"": {
+ ""@xmlns"": ""http://schemas.microsoft.com/winfx/2006/xaml/presentation"",
+ ""@xmlns:x"": ""http://schemas.microsoft.com/winfx/2006/xaml"",
+ ""@xmlns:toolkit"": ""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"",
+ ""@Style"": ""{StaticResource trimFormGrid}"",
+ ""@x:Name"": ""TrimObjectForm"",
+ ""Grid.ColumnDefinitions"": {
+ ""ColumnDefinition"": [
+ {
+ ""@Width"": ""63*""
+ },
+ {
+ ""@Width"": ""320*""
+ }
+ ]
+ },
+ ""Grid.RowDefinitions"": {
+ ""@xmlns"": """",
+ ""RowDefinition"": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ]
+ },
+ ""TextBox"": [
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordTypedTitle"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""0"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordExternalReference"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""1"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Author, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordAuthor"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""4"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Container, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordContainer"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""5"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordIsEnclosed"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""6"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_TB}"",
+ ""@Text"": ""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordAssignee"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""7"",
+ ""@xmlns"": """"
+ }
+ ],
+ ""toolkit:DatePicker"": [
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_DP}"",
+ ""@Value"": ""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordDateCreated"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""2""
+ },
+ {
+ ""@Style"": ""{StaticResource trimFormGrid_DP}"",
+ ""@Value"": ""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"",
+ ""@Name"": ""RecordDateDue"",
+ ""@Grid.Column"": ""1"",
+ ""@Grid.Row"": ""3""
+ }
+ ],
+ ""TextBlock"": [
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Title (Free Text Part)"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""0"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""External ID"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""1"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Date Created"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""2"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Date Due"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""3"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Author"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""4"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Container"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""5"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Enclosed?"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""6"",
+ ""@xmlns"": """"
+ },
+ {
+ ""@Grid.Column"": ""0"",
+ ""@Text"": ""Assignee"",
+ ""@Style"": ""{StaticResource trimFormGrid_LBL}"",
+ ""@Grid.Row"": ""7"",
+ ""@xmlns"": """"
+ }
+ ]
+ }
+}";
+
+ Assert.AreEqual(expectedJson, json);
+
+ XmlNode node = JsonConvert.DeserializeXmlNode(json);
+
+ StringWriter sw = new StringWriter();
+ XmlWriter writer = XmlWriter.Create(sw, new XmlWriterSettings
+ {
+ Indent = true,
+ OmitXmlDeclaration = true
+ });
+ node.WriteTo(writer);
+ writer.Flush();
+
+ string xaml2 = sw.ToString();
+
+ string expectedXaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width=""63*"" />
+ <ColumnDefinition Width=""320*"" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions xmlns="""">
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ <RowDefinition />
+ </Grid.RowDefinitions>
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
+ <TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
+ <toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
+ <TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
+ <TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
+</Grid>";
+
+ Assert.AreEqual(expectedXaml, xaml2);
+ }
}
}
#endif \ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs
index 446512c..a1cb857 100644
--- a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs
+++ b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs
@@ -1923,5 +1923,15 @@ bye", reader.Value);
reader.Read();
Assert.AreEqual(JsonToken.EndArray, reader.TokenType);
}
+
+ [Test]
+ [ExpectedException(typeof(JsonReaderException), ExpectedMessage = "Additional text encountered after finished reading JSON content: }. Line 1, position 2.")]
+ public void UnexpectedEndTokenWhenParsingOddEndToken()
+ {
+ JsonReader reader = new JsonTextReader(new StringReader(@"{}}"));
+ Assert.IsTrue(reader.Read());
+ Assert.IsTrue(reader.Read());
+ reader.Read();
+ }
}
} \ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj
index 135fa42..f9c40b4 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net20.csproj
@@ -84,6 +84,7 @@
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\RegexConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
+ <Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="JsonValidatingReaderTests.cs" />
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net35.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net35.csproj
index b1729d7..af23192 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net35.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Net35.csproj
@@ -114,6 +114,7 @@
<Compile Include="Converters\CustomCreationConverterTests.cs" />
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
+ <Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="JsonValidatingReaderTests.cs" />
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj
index 25d36f2..6a9ae0f 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj
@@ -110,6 +110,7 @@
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\RegexConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
+ <Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="Linq\ComponentModel\BindingTests.cs" />
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WindowsPhone.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WindowsPhone.csproj
index 78fe5a6..e019d0d 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WindowsPhone.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WindowsPhone.csproj
@@ -74,6 +74,7 @@
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\RegexConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
+ <Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="Linq\ComponentModel\BindingTests.cs" />
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj
index 2a87afd..925083a 100644
--- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj
+++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj
@@ -115,6 +115,7 @@
<Compile Include="Converters\CustomCreationConverterTests.cs" />
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
+ <Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="FileSystemEntityModel.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
index 032490a..d1e339e 100644
--- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
+++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
@@ -24,26 +24,32 @@
#endregion
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Security;
// 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.
-#if SILVERLIGHT
-[assembly: AssemblyTitle("Newtonsoft Json.NET Tests Silverlight")]
+#if WINDOWS_PHONE
+[assembly: AssemblyTitle("Json.NET Tests Windows Phone")]
+#elif SILVERLIGHT
+[assembly: AssemblyTitle("Json.NET Tests Silverlight")]
#elif PocketPC
-[assembly: AssemblyTitle("Newtonsoft Json.NET Tests Compact")]
+[assembly: AssemblyTitle("Json.NET Tests Compact")]
+#elif NET20
+[assembly: AssemblyTitle("Json.NET Tests .NET 2.0")]
+#elif NET35
+[assembly: AssemblyTitle("Json.NET Tests .NET 3.5")]
#else
-[assembly: AssemblyTitle("Newtonsoft Json.NET Tests")]
+[assembly: AssemblyTitle("Json.NET")]
#endif
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Newtonsoft")]
-[assembly: AssemblyProduct("Newtonsoft Json.NET Tests")]
-[assembly: AssemblyCopyright("Copyright © Newtonsoft 2008")]
+[assembly: AssemblyProduct("Json.NET Tests")]
+[assembly: AssemblyCopyright("Copyright © James Newton-King 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -64,7 +70,7 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("4.0.7.0")]
+[assembly: AssemblyVersion("4.0.8.0")]
#if !PocketPC
-[assembly: AssemblyFileVersion("4.0.7.14610")]
+[assembly: AssemblyFileVersion("4.0.8.14611")]
#endif