From e93122e03d89f5fcdaf10a8d81e6c0b5ac6404ea Mon Sep 17 00:00:00 2001 From: Redth Date: Tue, 9 Sep 2014 08:22:09 -0400 Subject: [PATCH 1/7] Ignore .userprefs from Xamarin Studio --- .gitignore | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 58159f66..35ef4a02 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,17 @@ -[Bb]in/ -[Oo]bj/ -[Ww]orking/ -Build/runbuild.txt -Doc/doc.shfbproj_* -TestResults/ -AppPackages/ -*.suo -*.user -_ReSharper.* -*.ReSharper.user -*.resharper.user - -#NuGet -packages +[Bb]in/ +[Oo]bj/ +[Ww]orking/ +Build/runbuild.txt +Doc/doc.shfbproj_* +TestResults/ +AppPackages/ +*.suo +*.user +*.userprefs +_ReSharper.* +*.ReSharper.user +*.resharper.user + +#NuGet +packages !packages/repositories.config \ No newline at end of file From fc9c3ad720275c8745c27f50436d2df05000276c Mon Sep 17 00:00:00 2001 From: Redth Date: Tue, 9 Sep 2014 08:22:56 -0400 Subject: [PATCH 2/7] Added gitattribute for explicit crlf line endings --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index d42ed740..efbd36b9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,5 @@ +* text eol=crlf + *.doc diff=astextplain *.DOC diff=astextplain *.docx diff=astextplain From aa6c474999953692b4974c92caabe54fa6515616 Mon Sep 17 00:00:00 2001 From: Redth Date: Tue, 9 Sep 2014 09:35:01 -0400 Subject: [PATCH 3/7] Changed tests to explicitly assert for strings with \r\n As opposed to leaving it up to the IDE to decide at compile time by having newlines in the actual document --- .../Bson/BsonReaderTests.cs | 12 +--- Src/Newtonsoft.Json.Tests/JsonConvertTest.cs | 6 +- .../JsonTextReaderTest.cs | 60 +------------------ .../JsonTextWriterTest.cs | 3 +- 4 files changed, 7 insertions(+), 74 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs index 73aa7d34..962ccb68 100644 --- a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs +++ b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs @@ -808,10 +808,7 @@ namespace Newtonsoft.Json.Tests.Bson Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.String, reader.TokenType); - Assert.AreEqual(@"for (int i = 0; i < 1000; i++) -{ - alert(arg1); -}", reader.Value); + Assert.AreEqual("for (int i = 0; i < 1000; i++)\r\n{\r\n alert(arg1);\r\n}", reader.Value); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.PropertyName, reader.TokenType); @@ -1299,12 +1296,7 @@ namespace Newtonsoft.Json.Tests.Bson Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.String, reader.TokenType); - Assert.AreEqual(@"

I'm the Director for Research and Development for ProPhoenix, a public safety software company. This position allows me to investigate new and existing technologies and incorporate them into our product line, with the end goal being to help public safety agencies to do their jobs more effeciently and safely.

- -

I'm an advocate for PowerShell, as I believe it encourages administrative best practices and allows developers to provide additional access to their applications, without needing to explicity write code for each administrative feature. Part of my advocacy for PowerShell includes my blog, appearances on various podcasts, and acting as a Community Director for PowerShellCommunity.Org

- -

I’m also a co-host of Mind of Root (a weekly audio podcast about systems administration, tech news, and topics).

-", reader.Value); + Assert.AreEqual("

I'm the Director for Research and Development for ProPhoenix, a public safety software company. This position allows me to investigate new and existing technologies and incorporate them into our product line, with the end goal being to help public safety agencies to do their jobs more effeciently and safely.

\r\n\r\n

I'm an advocate for PowerShell, as I believe it encourages administrative best practices and allows developers to provide additional access to their applications, without needing to explicity write code for each administrative feature. Part of my advocacy for PowerShell includes my blog, appearances on various podcasts, and acting as a Community Director for PowerShellCommunity.Org

\r\n\r\n

I’m also a co-host of Mind of Root (a weekly audio podcast about systems administration, tech news, and topics).

\r\n", reader.Value); Assert.AreEqual(typeof(string), reader.ValueType); Assert.IsTrue(reader.Read()); diff --git a/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs b/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs index 9ad0f186..d3b7df11 100644 --- a/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs @@ -342,8 +342,7 @@ namespace Newtonsoft.Json.Tests result = JavaScriptUtils.ToEscapedJavaScriptString("How now cow?", '"', true); Assert.AreEqual(@"""How now cow?""", result); - result = JavaScriptUtils.ToEscapedJavaScriptString(@"How -now brown cow?", '"', true); + result = JavaScriptUtils.ToEscapedJavaScriptString("How \r\nnow brown cow?", '"', true); Assert.AreEqual(@"""How \r\nnow brown cow?""", result); result = JavaScriptUtils.ToEscapedJavaScriptString("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007", '"', true); @@ -576,8 +575,7 @@ now brown cow?", '"', true); [Test] public void StringEscaping() { - string v = @"It's a good day -""sunshine"""; + string v = "It's a good day\r\n\"sunshine\""; string json = JsonConvert.ToString(v); Assert.AreEqual(@"""It's a good day\r\n\""sunshine\""""", json); diff --git a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs index afa3071f..a92affb6 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs @@ -344,62 +344,7 @@ third line", jsonTextReader.Value); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.String, reader.TokenType); - Assert.AreEqual(@"#C16------------------------------ -#C12Ingredients #C20 -#C16------------------------------ - -a piece of Leather Armor -( ie #L ""Enhanced Leather Armor Boots"" ""85644"" ) - - -#L ""Hacker Tool"" ""87814"" - - -#L ""Clanalizer"" ""208313"" - - -#C16------------------------------ -#C12Recipe #C16 -#C16------------------------------#C20 - -Hacker Tool -#C15+#C20 -a piece of Leather Armor -#C15=#C20 - -a piece of Hacked Leather Armor -( ie : #L ""Hacked Leather Armor Boots"" ""245979"" ) -#C16Skills: | BE |#C20 - -#C14------------------------------#C20 - -Clanalizer -#C15+#C20 -a piece of Hacked Leather Armor -#C15=#C20 - -a piece of Apocalypse Leather Armor -( ie : #L ""Apocalypse Leather Armor Boots"" ""245966"" ) -#C16Skills: | ?? |#C20 - -#C16------------------------------ -#C12Details#C16 -#C16------------------------------#C20 - -#L ""Apocalypse Leather Armor Boots"" ""245967"" -#L ""Apocalypse Leather Armor Gloves"" ""245969"" -#L ""Apocalypse Leather Armor Helmet"" ""245975"" -#L ""Apocalypse Leather Armor Pants"" ""245971"" -#L ""Apocalypse Leather Armor Sleeves"" ""245973"" -#L ""Apocalypse Leather Body Armor"" ""245965"" - -#C16------------------------------ -#C12Comments#C16 -#C16------------------------------#C20 - -Nice froob armor.. but ugleh! - -", reader.Value); + Assert.AreEqual("#C16------------------------------\r\n#C12Ingredients #C20\r\n#C16------------------------------\r\n\r\na piece of Leather Armor\r\n( ie #L \"Enhanced Leather Armor Boots\" \"85644\" )\r\n\r\n\r\n#L \"Hacker Tool\" \"87814\"\r\n\r\n\r\n#L \"Clanalizer\" \"208313\"\r\n\r\n\r\n#C16------------------------------\r\n#C12Recipe #C16\r\n#C16------------------------------#C20\r\n\r\nHacker Tool\r\n#C15+#C20\r\na piece of Leather Armor\r\n#C15=#C20\r\n\r\na piece of Hacked Leather Armor\r\n( ie : #L \"Hacked Leather Armor Boots\" \"245979\" )\r\n#C16Skills: | BE |#C20\r\n\r\n#C14------------------------------#C20\r\n\r\nClanalizer\r\n#C15+#C20\r\na piece of Hacked Leather Armor\r\n#C15=#C20\r\n\r\na piece of Apocalypse Leather Armor\r\n( ie : #L \"Apocalypse Leather Armor Boots\" \"245966\" )\r\n#C16Skills: | ?? |#C20\r\n\r\n#C16------------------------------\r\n#C12Details#C16\r\n#C16------------------------------#C20\r\n\r\n#L \"Apocalypse Leather Armor Boots\" \"245967\"\r\n#L \"Apocalypse Leather Armor Gloves\" \"245969\"\r\n#L \"Apocalypse Leather Armor Helmet\" \"245975\"\r\n#L \"Apocalypse Leather Armor Pants\" \"245971\"\r\n#L \"Apocalypse Leather Armor Sleeves\" \"245973\"\r\n#L \"Apocalypse Leather Body Armor\" \"245965\"\r\n\r\n#C16------------------------------\r\n#C12Comments#C16\r\n#C16------------------------------#C20\r\n\r\nNice froob armor.. but ugleh!\r\n\r\n", reader.Value); } [Test] @@ -1272,8 +1217,7 @@ Parameter name: reader", Assert.IsTrue(reader.Read()); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.PropertyName, reader.TokenType); - Assert.AreEqual(@"hi -bye", reader.Value); + Assert.AreEqual("hi\r\nbye", reader.Value); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.Integer, reader.TokenType); Assert.AreEqual(1L, reader.Value); diff --git a/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs index d8bafe89..d6d81c98 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs @@ -261,8 +261,7 @@ namespace Newtonsoft.Json.Tests jsonWriter.WriteStartArray(); jsonWriter.WriteValue(@"""These pretzels are making me thirsty!"""); jsonWriter.WriteValue("Jeff's house was burninated."); - jsonWriter.WriteValue(@"1. You don't talk about fight club. -2. You don't talk about fight club."); + jsonWriter.WriteValue("1. You don't talk about fight club.\r\n2. You don't talk about fight club."); jsonWriter.WriteValue("35% of\t statistics\n are made\r up."); jsonWriter.WriteEndArray(); } From 831e32809ea7b956d1a6aaf2c3ee9a42f6996dff Mon Sep 17 00:00:00 2001 From: Redth Date: Tue, 9 Sep 2014 09:39:05 -0400 Subject: [PATCH 4/7] Added Exception.Throws overload to take multiple possible messages to match This way tests can pass in multiple possible string matches which the runtime may use as a message depending on the given platform (e.g.: MS-Runtime vs Mono) --- .../JsonTextReaderTest.cs | 10 ++-- .../ImmutableCollectionsTests.cs | 8 ++- .../Serialization/JsonSerializerTest.cs | 23 ++++++--- Src/Newtonsoft.Json.Tests/TestFixtureBase.cs | 19 +++++++ ...xpressionReflectionDelegateFactoryTests.cs | 51 +++++++++++-------- 5 files changed, 77 insertions(+), 34 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs index a92affb6..a4cf9e24 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs @@ -791,10 +791,12 @@ third line", jsonTextReader.Value); [Test] public void NullTextReader() { - ExceptionAssert.Throws( - @"Value cannot be null. -Parameter name: reader", - () => { new JsonTextReader(null); }); + ExceptionAssert.Throws ( + () => { new JsonTextReader (null); }, + new string[] { + "Value cannot be null." + Environment.NewLine + "Parameter name: reader", + "Argument cannot be null." + Environment.NewLine + "Parameter name: reader" // Mono + }); } [Test] diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs index de83bd17..588cb515 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs @@ -141,8 +141,12 @@ namespace Newtonsoft.Json.Tests.Serialization [Test] public void SerializeDefaultArray() { - ExceptionAssert.Throws("Object reference not set to an instance of an object.", () => - JsonConvert.SerializeObject(default(ImmutableArray), Formatting.Indented)); + ExceptionAssert.Throws( + () => JsonConvert.SerializeObject(default(ImmutableArray), Formatting.Indented), + new [] { + "Object reference not set to an instance of an object.", + "Object reference not set to an instance of an object" // mono + }); } #endregion diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index 68c52478..f9365179 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -2975,8 +2975,11 @@ Path '', line 1, position 1.", string json = @"[]"; ExceptionAssert.Throws( - @"Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JObject'.", - () => { JsonConvert.DeserializeObject(json); }); + () => { JsonConvert.DeserializeObject(json); }, + new [] { + "Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JObject'.", + "Cannot cast from source type to destination type." // mono + }); } [Test] @@ -6304,18 +6307,22 @@ To fix this error either change the environment to be fully trusted, change the public void DeserializeDoubleFromNullString() { ExceptionAssert.Throws( - @"Value cannot be null. -Parameter name: value", - () => { JsonConvert.DeserializeObject(null); }); + () => { JsonConvert.DeserializeObject(null); }, + new [] { + "Value cannot be null." + Environment.NewLine + "Parameter name: value", + "Argument cannot be null." + Environment.NewLine + "Parameter name: value" // mono + }); } [Test] public void DeserializeFromNullString() { ExceptionAssert.Throws( - @"Value cannot be null. -Parameter name: value", - () => { JsonConvert.DeserializeObject(null); }); + () => { JsonConvert.DeserializeObject(null); }, + new [] { + "Value cannot be null." + Environment.NewLine + "Parameter name: value", + "Argument cannot be null." + Environment.NewLine + "Parameter name: value" // mono + }); } [Test] diff --git a/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs b/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs index 9c5a651c..e5a520ec 100644 --- a/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs +++ b/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs @@ -193,5 +193,24 @@ namespace Newtonsoft.Json.Tests throw new Exception(string.Format("Exception of type {0} expected; got exception of type {1}.", typeof(TException).Name, ex.GetType().Name), ex); } } + + public static void Throws(Action action, params string[] possibleMessages) + where TException : Exception + { + try + { + action(); + + Assert.Fail("Exception of type {0} expected; got none exception", typeof(TException).Name); + } + catch (TException ex) + { + Assert.Contains (ex.Message, possibleMessages, "Unexpected exception message." + Environment.NewLine + "Expected One of: " + string.Join (Environment.NewLine, possibleMessages) + Environment.NewLine + "Got: " + ex.Message + Environment.NewLine + Environment.NewLine + ex); + } + catch (Exception ex) + { + throw new Exception(string.Format("Exception of type {0} expected; got exception of type {1}.", typeof(TException).Name, ex.GetType().Name), ex); + } + } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs b/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs index 7db83186..9775c32c 100644 --- a/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs +++ b/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs @@ -107,13 +107,15 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void DefaultConstructor_Abstract() { - ExceptionAssert.Throws("Cannot create an abstract class.", - () => - { + ExceptionAssert.Throws( + () => { Func create = ExpressionReflectionDelegateFactory.Instance.CreateDefaultConstructor(typeof(Type)); create(); - }); + }, new [] { + "Cannot create an abstract class.", + "Cannot create an abstract class 'System.Type'." // mono + }); } [Test] @@ -277,24 +279,26 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void CreateGetWithBadObjectTarget() { - ExceptionAssert.Throws("Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.", - () => - { - Person p = new Person(); - p.Name = "Hi"; + ExceptionAssert.Throws( + () => { + Person p = new Person(); + p.Name = "Hi"; - Func setter = ExpressionReflectionDelegateFactory.Instance.CreateGet(typeof(Movie).GetProperty("Name")); + Func setter = ExpressionReflectionDelegateFactory.Instance.CreateGet(typeof(Movie).GetProperty("Name")); - setter(p); - }); + setter(p); + }, + new [] { + "Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.", + "Cannot cast from source type to destination type." // mono + }); } [Test] public void CreateSetWithBadObjectTarget() { - ExceptionAssert.Throws("Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.", - () => - { + ExceptionAssert.Throws( + () => { Person p = new Person(); Movie m = new Movie(); @@ -307,21 +311,28 @@ namespace Newtonsoft.Json.Tests.Utilities setter(p, "Hi"); Assert.AreEqual(p.Name, "Hi"); - }); + }, + new [] { + "Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.", + "Cannot cast from source type to destination type." // mono + + }); } [Test] public void CreateSetWithBadObjectValue() { - ExceptionAssert.Throws("Unable to cast object of type 'System.Version' to type 'System.String'.", - () => - { + ExceptionAssert.Throws( + () => { Movie m = new Movie(); Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(Movie).GetProperty("Name")); setter(m, new Version("1.1.1.1")); - }); + }, new [] { + "Unable to cast object of type 'System.Version' to type 'System.String'.", + "Cannot cast from source type to destination type." //mono + }); } [Test] From 59a3ff8b2aa25de8460c26259e44d229827de464 Mon Sep 17 00:00:00 2001 From: Redth Date: Tue, 9 Sep 2014 09:40:07 -0400 Subject: [PATCH 5/7] Added check for multiple exception messages to match for mono Some tests check explicitly for a given exception message which differs on Mono, so added possible options to check for so both platforms will pass --- .../SerializationErrorHandlingTests.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs index db328fd4..70306dd5 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs @@ -66,10 +66,14 @@ namespace Newtonsoft.Json.Tests.Serialization } ]"; + var possibleMsgs = new [] { + "[1] - Error message for member 1 = An item with the same key has already been added.", + "[1] - Error message for member 1 = An element with the same key already exists in the dictionary." // mono + }; VersionKeyedCollection c = JsonConvert.DeserializeObject(json); Assert.AreEqual(1, c.Count); Assert.AreEqual(1, c.Messages.Count); - Assert.AreEqual("[1] - Error message for member 1 = An item with the same key has already been added.", c.Messages[0]); + Assert.IsTrue (possibleMsgs.Any (m => m == c.Messages[0]), "Expected One of: " + Environment.NewLine + string.Join (Environment.NewLine, possibleMsgs) + Environment.NewLine + "Was: " + Environment.NewLine + c.Messages[0]); } [Test] @@ -302,7 +306,13 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual(3, errors.Count); #if !(NET20 || NET35) - Assert.AreEqual("[1] - 1 - The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.", errors[0]); + var possibleErrs = new [] { + "[1] - 1 - The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.", + "[1] - 1 - String was not recognized as a valid DateTime." + }; + + Assert.IsTrue(possibleErrs.Any (m => m == errors[0]), + "Expected One of: " + string.Join (Environment.NewLine, possibleErrs) + Environment.NewLine + "But was: " + errors[0]); #else Assert.AreEqual("[1] - 1 - The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.", errors[0]); #endif From bc341c67648b891796904ac62ef72698afe33117 Mon Sep 17 00:00:00 2001 From: Redth Date: Tue, 9 Sep 2014 09:42:16 -0400 Subject: [PATCH 6/7] Tests.Portable.csproj fixes for Xamarin Studio global alias caused compilation errors, as well as the Entity Data model that doesn't seem to be actually used in the project. --- .../Newtonsoft.Json.Tests.Portable.csproj | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Portable.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Portable.csproj index 8afca9fa..8c79f185 100644 --- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Portable.csproj +++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Portable.csproj @@ -129,11 +129,6 @@ - - True - True - FileSystemEntityModel.edmx - @@ -344,12 +339,6 @@ - - - EntityModelCodeGenerator - FileSystemEntityModel.Designer.cs - - PreserveNewest @@ -382,7 +371,6 @@ {959F7F85-C98B-4876-971A-9036224578E4} Newtonsoft.Json.Portable - global From 69ce5fe690ec197bfc3566eb2796daac4d2ac25c Mon Sep 17 00:00:00 2001 From: Redth Date: Tue, 9 Sep 2014 09:56:22 -0400 Subject: [PATCH 7/7] Fixed whitespace --- .../Bson/BsonReaderTests.cs | 4 +- .../JsonTextReaderTest.cs | 14 +++--- .../ImmutableCollectionsTests.cs | 10 ++--- .../Serialization/JsonSerializerTest.cs | 30 ++++++------- .../SerializationErrorHandlingTests.cs | 22 ++++----- Src/Newtonsoft.Json.Tests/TestFixtureBase.cs | 34 +++++++------- ...xpressionReflectionDelegateFactoryTests.cs | 45 +++++++++---------- 7 files changed, 79 insertions(+), 80 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs index 962ccb68..b28cfc43 100644 --- a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs +++ b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs @@ -808,7 +808,7 @@ namespace Newtonsoft.Json.Tests.Bson Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.String, reader.TokenType); - Assert.AreEqual("for (int i = 0; i < 1000; i++)\r\n{\r\n alert(arg1);\r\n}", reader.Value); + Assert.AreEqual("for (int i = 0; i < 1000; i++)\r\n{\r\n alert(arg1);\r\n}", reader.Value); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.PropertyName, reader.TokenType); @@ -1296,7 +1296,7 @@ namespace Newtonsoft.Json.Tests.Bson Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.String, reader.TokenType); - Assert.AreEqual("

I'm the Director for Research and Development for ProPhoenix, a public safety software company. This position allows me to investigate new and existing technologies and incorporate them into our product line, with the end goal being to help public safety agencies to do their jobs more effeciently and safely.

\r\n\r\n

I'm an advocate for PowerShell, as I believe it encourages administrative best practices and allows developers to provide additional access to their applications, without needing to explicity write code for each administrative feature. Part of my advocacy for PowerShell includes my blog, appearances on various podcasts, and acting as a Community Director for PowerShellCommunity.Org

\r\n\r\n

I’m also a co-host of Mind of Root (a weekly audio podcast about systems administration, tech news, and topics).

\r\n", reader.Value); + Assert.AreEqual("

I'm the Director for Research and Development for ProPhoenix, a public safety software company. This position allows me to investigate new and existing technologies and incorporate them into our product line, with the end goal being to help public safety agencies to do their jobs more effeciently and safely.

\r\n\r\n

I'm an advocate for PowerShell, as I believe it encourages administrative best practices and allows developers to provide additional access to their applications, without needing to explicity write code for each administrative feature. Part of my advocacy for PowerShell includes my blog, appearances on various podcasts, and acting as a Community Director for PowerShellCommunity.Org

\r\n\r\n

I’m also a co-host of Mind of Root (a weekly audio podcast about systems administration, tech news, and topics).

\r\n", reader.Value); Assert.AreEqual(typeof(string), reader.ValueType); Assert.IsTrue(reader.Read()); diff --git a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs index a4cf9e24..d52f5650 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs @@ -344,7 +344,7 @@ third line", jsonTextReader.Value); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.String, reader.TokenType); - Assert.AreEqual("#C16------------------------------\r\n#C12Ingredients #C20\r\n#C16------------------------------\r\n\r\na piece of Leather Armor\r\n( ie #L \"Enhanced Leather Armor Boots\" \"85644\" )\r\n\r\n\r\n#L \"Hacker Tool\" \"87814\"\r\n\r\n\r\n#L \"Clanalizer\" \"208313\"\r\n\r\n\r\n#C16------------------------------\r\n#C12Recipe #C16\r\n#C16------------------------------#C20\r\n\r\nHacker Tool\r\n#C15+#C20\r\na piece of Leather Armor\r\n#C15=#C20\r\n\r\na piece of Hacked Leather Armor\r\n( ie : #L \"Hacked Leather Armor Boots\" \"245979\" )\r\n#C16Skills: | BE |#C20\r\n\r\n#C14------------------------------#C20\r\n\r\nClanalizer\r\n#C15+#C20\r\na piece of Hacked Leather Armor\r\n#C15=#C20\r\n\r\na piece of Apocalypse Leather Armor\r\n( ie : #L \"Apocalypse Leather Armor Boots\" \"245966\" )\r\n#C16Skills: | ?? |#C20\r\n\r\n#C16------------------------------\r\n#C12Details#C16\r\n#C16------------------------------#C20\r\n\r\n#L \"Apocalypse Leather Armor Boots\" \"245967\"\r\n#L \"Apocalypse Leather Armor Gloves\" \"245969\"\r\n#L \"Apocalypse Leather Armor Helmet\" \"245975\"\r\n#L \"Apocalypse Leather Armor Pants\" \"245971\"\r\n#L \"Apocalypse Leather Armor Sleeves\" \"245973\"\r\n#L \"Apocalypse Leather Body Armor\" \"245965\"\r\n\r\n#C16------------------------------\r\n#C12Comments#C16\r\n#C16------------------------------#C20\r\n\r\nNice froob armor.. but ugleh!\r\n\r\n", reader.Value); + Assert.AreEqual("#C16------------------------------\r\n#C12Ingredients #C20\r\n#C16------------------------------\r\n\r\na piece of Leather Armor\r\n( ie #L \"Enhanced Leather Armor Boots\" \"85644\" )\r\n\r\n\r\n#L \"Hacker Tool\" \"87814\"\r\n\r\n\r\n#L \"Clanalizer\" \"208313\"\r\n\r\n\r\n#C16------------------------------\r\n#C12Recipe #C16\r\n#C16------------------------------#C20\r\n\r\nHacker Tool\r\n#C15+#C20\r\na piece of Leather Armor\r\n#C15=#C20\r\n\r\na piece of Hacked Leather Armor\r\n( ie : #L \"Hacked Leather Armor Boots\" \"245979\" )\r\n#C16Skills: | BE |#C20\r\n\r\n#C14------------------------------#C20\r\n\r\nClanalizer\r\n#C15+#C20\r\na piece of Hacked Leather Armor\r\n#C15=#C20\r\n\r\na piece of Apocalypse Leather Armor\r\n( ie : #L \"Apocalypse Leather Armor Boots\" \"245966\" )\r\n#C16Skills: | ?? |#C20\r\n\r\n#C16------------------------------\r\n#C12Details#C16\r\n#C16------------------------------#C20\r\n\r\n#L \"Apocalypse Leather Armor Boots\" \"245967\"\r\n#L \"Apocalypse Leather Armor Gloves\" \"245969\"\r\n#L \"Apocalypse Leather Armor Helmet\" \"245975\"\r\n#L \"Apocalypse Leather Armor Pants\" \"245971\"\r\n#L \"Apocalypse Leather Armor Sleeves\" \"245973\"\r\n#L \"Apocalypse Leather Body Armor\" \"245965\"\r\n\r\n#C16------------------------------\r\n#C12Comments#C16\r\n#C16------------------------------#C20\r\n\r\nNice froob armor.. but ugleh!\r\n\r\n", reader.Value); } [Test] @@ -791,12 +791,12 @@ third line", jsonTextReader.Value); [Test] public void NullTextReader() { - ExceptionAssert.Throws ( - () => { new JsonTextReader (null); }, - new string[] { - "Value cannot be null." + Environment.NewLine + "Parameter name: reader", - "Argument cannot be null." + Environment.NewLine + "Parameter name: reader" // Mono - }); + ExceptionAssert.Throws ( + () => { new JsonTextReader (null); }, + new string[] { + "Value cannot be null." + Environment.NewLine + "Parameter name: reader", + "Argument cannot be null." + Environment.NewLine + "Parameter name: reader" // Mono + }); } [Test] diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs index 588cb515..10894a63 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs @@ -142,11 +142,11 @@ namespace Newtonsoft.Json.Tests.Serialization public void SerializeDefaultArray() { ExceptionAssert.Throws( - () => JsonConvert.SerializeObject(default(ImmutableArray), Formatting.Indented), - new [] { - "Object reference not set to an instance of an object.", - "Object reference not set to an instance of an object" // mono - }); + () => JsonConvert.SerializeObject(default(ImmutableArray), Formatting.Indented), + new [] { + "Object reference not set to an instance of an object.", + "Object reference not set to an instance of an object" // mono + }); } #endregion diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index f9365179..92ff3a5c 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -2975,11 +2975,11 @@ Path '', line 1, position 1.", string json = @"[]"; ExceptionAssert.Throws( - () => { JsonConvert.DeserializeObject(json); }, - new [] { - "Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JObject'.", - "Cannot cast from source type to destination type." // mono - }); + () => { JsonConvert.DeserializeObject(json); }, + new [] { + "Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JObject'.", + "Cannot cast from source type to destination type." // mono + }); } [Test] @@ -6307,22 +6307,22 @@ To fix this error either change the environment to be fully trusted, change the public void DeserializeDoubleFromNullString() { ExceptionAssert.Throws( - () => { JsonConvert.DeserializeObject(null); }, - new [] { - "Value cannot be null." + Environment.NewLine + "Parameter name: value", - "Argument cannot be null." + Environment.NewLine + "Parameter name: value" // mono - }); + () => { JsonConvert.DeserializeObject(null); }, + new [] { + "Value cannot be null." + Environment.NewLine + "Parameter name: value", + "Argument cannot be null." + Environment.NewLine + "Parameter name: value" // mono + }); } [Test] public void DeserializeFromNullString() { ExceptionAssert.Throws( - () => { JsonConvert.DeserializeObject(null); }, - new [] { - "Value cannot be null." + Environment.NewLine + "Parameter name: value", - "Argument cannot be null." + Environment.NewLine + "Parameter name: value" // mono - }); + () => { JsonConvert.DeserializeObject(null); }, + new [] { + "Value cannot be null." + Environment.NewLine + "Parameter name: value", + "Argument cannot be null." + Environment.NewLine + "Parameter name: value" // mono + }); } [Test] diff --git a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs index 70306dd5..3269efe0 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs @@ -66,14 +66,14 @@ namespace Newtonsoft.Json.Tests.Serialization } ]"; - var possibleMsgs = new [] { - "[1] - Error message for member 1 = An item with the same key has already been added.", - "[1] - Error message for member 1 = An element with the same key already exists in the dictionary." // mono - }; + var possibleMsgs = new [] { + "[1] - Error message for member 1 = An item with the same key has already been added.", + "[1] - Error message for member 1 = An element with the same key already exists in the dictionary." // mono + }; VersionKeyedCollection c = JsonConvert.DeserializeObject(json); Assert.AreEqual(1, c.Count); Assert.AreEqual(1, c.Messages.Count); - Assert.IsTrue (possibleMsgs.Any (m => m == c.Messages[0]), "Expected One of: " + Environment.NewLine + string.Join (Environment.NewLine, possibleMsgs) + Environment.NewLine + "Was: " + Environment.NewLine + c.Messages[0]); + Assert.IsTrue (possibleMsgs.Any (m => m == c.Messages[0]), "Expected One of: " + Environment.NewLine + string.Join (Environment.NewLine, possibleMsgs) + Environment.NewLine + "Was: " + Environment.NewLine + c.Messages[0]); } [Test] @@ -306,13 +306,13 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual(3, errors.Count); #if !(NET20 || NET35) - var possibleErrs = new [] { - "[1] - 1 - The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.", - "[1] - 1 - String was not recognized as a valid DateTime." - }; + var possibleErrs = new [] { + "[1] - 1 - The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.", + "[1] - 1 - String was not recognized as a valid DateTime." + }; - Assert.IsTrue(possibleErrs.Any (m => m == errors[0]), - "Expected One of: " + string.Join (Environment.NewLine, possibleErrs) + Environment.NewLine + "But was: " + errors[0]); + Assert.IsTrue(possibleErrs.Any (m => m == errors[0]), + "Expected One of: " + string.Join (Environment.NewLine, possibleErrs) + Environment.NewLine + "But was: " + errors[0]); #else Assert.AreEqual("[1] - 1 - The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.", errors[0]); #endif diff --git a/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs b/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs index e5a520ec..5717f195 100644 --- a/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs +++ b/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs @@ -194,23 +194,23 @@ namespace Newtonsoft.Json.Tests } } - public static void Throws(Action action, params string[] possibleMessages) - where TException : Exception - { - try - { - action(); + public static void Throws(Action action, params string[] possibleMessages) + where TException : Exception + { + try + { + action(); - Assert.Fail("Exception of type {0} expected; got none exception", typeof(TException).Name); - } - catch (TException ex) - { - Assert.Contains (ex.Message, possibleMessages, "Unexpected exception message." + Environment.NewLine + "Expected One of: " + string.Join (Environment.NewLine, possibleMessages) + Environment.NewLine + "Got: " + ex.Message + Environment.NewLine + Environment.NewLine + ex); - } - catch (Exception ex) - { - throw new Exception(string.Format("Exception of type {0} expected; got exception of type {1}.", typeof(TException).Name, ex.GetType().Name), ex); - } - } + Assert.Fail("Exception of type {0} expected; got none exception", typeof(TException).Name); + } + catch (TException ex) + { + Assert.Contains (ex.Message, possibleMessages, "Unexpected exception message." + Environment.NewLine + "Expected One of: " + string.Join (Environment.NewLine, possibleMessages) + Environment.NewLine + "Got: " + ex.Message + Environment.NewLine + Environment.NewLine + ex); + } + catch (Exception ex) + { + throw new Exception(string.Format("Exception of type {0} expected; got exception of type {1}.", typeof(TException).Name, ex.GetType().Name), ex); + } + } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs b/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs index 9775c32c..967cefad 100644 --- a/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs +++ b/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs @@ -112,10 +112,10 @@ namespace Newtonsoft.Json.Tests.Utilities Func create = ExpressionReflectionDelegateFactory.Instance.CreateDefaultConstructor(typeof(Type)); create(); - }, new [] { - "Cannot create an abstract class.", - "Cannot create an abstract class 'System.Type'." // mono - }); + }, new [] { + "Cannot create an abstract class.", + "Cannot create an abstract class 'System.Type'." // mono + }); } [Test] @@ -280,18 +280,18 @@ namespace Newtonsoft.Json.Tests.Utilities public void CreateGetWithBadObjectTarget() { ExceptionAssert.Throws( - () => { - Person p = new Person(); - p.Name = "Hi"; + () => { + Person p = new Person(); + p.Name = "Hi"; - Func setter = ExpressionReflectionDelegateFactory.Instance.CreateGet(typeof(Movie).GetProperty("Name")); + Func setter = ExpressionReflectionDelegateFactory.Instance.CreateGet(typeof(Movie).GetProperty("Name")); - setter(p); - }, - new [] { - "Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.", - "Cannot cast from source type to destination type." // mono - }); + setter(p); + }, + new [] { + "Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.", + "Cannot cast from source type to destination type." // mono + }); } [Test] @@ -312,11 +312,10 @@ namespace Newtonsoft.Json.Tests.Utilities Assert.AreEqual(p.Name, "Hi"); }, - new [] { - "Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.", - "Cannot cast from source type to destination type." // mono - - }); + new [] { + "Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.", + "Cannot cast from source type to destination type." // mono + }); } [Test] @@ -329,10 +328,10 @@ namespace Newtonsoft.Json.Tests.Utilities Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(Movie).GetProperty("Name")); setter(m, new Version("1.1.1.1")); - }, new [] { - "Unable to cast object of type 'System.Version' to type 'System.String'.", - "Cannot cast from source type to destination type." //mono - }); + }, new [] { + "Unable to cast object of type 'System.Version' to type 'System.String'.", + "Cannot cast from source type to destination type." //mono + }); } [Test]