From 60f5fd591ef301428347de955c02ee06286732db Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 23 Nov 2015 16:40:15 -0800 Subject: [PATCH] Updating tests to run on dnxcore50 --- .../Dynamic/AddOperationTests.cs | 36 +++++++-------- .../Dynamic/AddTypedOperationTests.cs | 6 +-- .../Dynamic/PatchDocumentTests.cs | 12 ++--- .../Dynamic/RemoveOperationTests.cs | 46 +++++++++---------- .../Dynamic/RemoveTypedOperationTests.cs | 8 ++-- .../Dynamic/SimpleDTOWithNestedDTO.cs | 2 +- .../NestedObjectTests.cs | 29 ++++++------ .../ObjectAdapterTests.cs | 8 ++-- .../SimpleDTO.cs | 1 - .../TestErrorLogger.cs | 2 +- .../project.json | 36 +++++++++------ 11 files changed, 96 insertions(+), 90 deletions(-) diff --git a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/AddOperationTests.cs b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/AddOperationTests.cs index 3c2523c5fb..f5a3c384ef 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/AddOperationTests.cs +++ b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/AddOperationTests.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic dynamic doc = new { Test = 1 - }; + }; // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); @@ -33,14 +33,14 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic }); Assert.Equal( "The property at path '/NewInt' could not be added.", - exception.Message); + exception.Message); } [Fact] public void AddNewProperty() { dynamic obj = new ExpandoObject(); - obj.Test = 1; + obj.Test = 1; // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); @@ -48,7 +48,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); - + deserialized.ApplyTo(obj); Assert.Equal(1, obj.NewInt); @@ -104,7 +104,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic "The property at path '/Nested/NewInt' could not be added.", exception.Message); } - + [Fact] public void AddToExistingPropertyOnNestedObject() { @@ -120,7 +120,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); - + deserialized.ApplyTo(doc); Assert.Equal("A", doc.nested.StringProperty); @@ -142,13 +142,13 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); - + deserialized.ApplyTo(doc); Assert.Equal(1, doc.nested.NewInt); Assert.Equal(1, doc.Test); } - + [Fact] public void AddNewPropertyToExpandoOjectInTypedObject() { @@ -156,7 +156,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic { DynamicProperty = new ExpandoObject() }; - + // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); patchDoc.Add("DynamicProperty/NewInt", 1); @@ -168,9 +168,9 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic Assert.Equal(1, doc.DynamicProperty.NewInt); } - + [Fact] - public void AddNewPropertyToTypedObjectInExpandoObject() + public void AddNewPropertyToTypedObjectInExpandoObject() { dynamic dynamicProperty = new ExpandoObject(); dynamicProperty.StringProperty = "A"; @@ -246,7 +246,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic public void AddResultsShouldReplace() { dynamic doc = new ExpandoObject(); - doc.StringProperty = "A"; + doc.StringProperty = "A"; // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); @@ -289,11 +289,11 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic doc.Nested.DynamicProperty.InBetweenFirst = new ExpandoObject(); doc.Nested.DynamicProperty.InBetweenFirst.InBetweenSecond = new ExpandoObject(); doc.Nested.DynamicProperty.InBetweenFirst.InBetweenSecond.StringProperty = "A"; - + // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); patchDoc.Add("/Nested/DynamicProperty/InBetweenFirst/InBetweenSecond/StringProperty", "B"); - + var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); @@ -301,7 +301,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic Assert.Equal("B", doc.Nested.DynamicProperty.InBetweenFirst.InBetweenSecond.StringProperty); } - + [Fact] public void ShouldNotBeAbleToAddToNonExistingPropertyThatIsNotTheRoot() { @@ -387,7 +387,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); patchDoc.Add("stringproperty", "B"); - + var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); @@ -415,7 +415,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic Assert.Equal(new List() { 4, 1, 2, 3 }, doc.IntegerList); } - + [Fact] public void AddToListNegativePosition() { @@ -452,7 +452,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); - + deserialized.ApplyTo(doc); Assert.Equal(new List() { 4, 1, 2, 3 }, doc.IntegerList); diff --git a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/AddTypedOperationTests.cs b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/AddTypedOperationTests.cs index 4d2e8c646d..7913541514 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/AddTypedOperationTests.cs +++ b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/AddTypedOperationTests.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); patchDoc.Add("IntegerList/-1", 4); - + var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); @@ -101,11 +101,11 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic IntegerList = new List() { 1, 2, 3 } } } - }; + }; // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); patchDoc.Add("ListOfSimpleDTO/20/IntegerList/0", 4); - + var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); diff --git a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/PatchDocumentTests.cs b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/PatchDocumentTests.cs index e15f85da8e..8b14c3448b 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/PatchDocumentTests.cs +++ b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/PatchDocumentTests.cs @@ -8,7 +8,7 @@ using Xunit; namespace Microsoft.AspNet.JsonPatch.Test.Dynamic { public class PatchDocumentTests - { + { [Fact] public void InvalidPathAtBeginningShouldThrowException() { @@ -20,11 +20,11 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic Assert.Equal( "The provided string '//NewInt' is an invalid path.", exception.Message); - } + } [Fact] public void InvalidPathAtEndShouldThrowException() - { + { JsonPatchDocument patchDoc = new JsonPatchDocument(); var exception = Assert.Throws(() => { @@ -33,11 +33,11 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic Assert.Equal( "The provided string 'NewInt//' is an invalid path.", exception.Message); - } + } [Fact] public void InvalidPathWithDotShouldThrowException() - { + { JsonPatchDocument patchDoc = new JsonPatchDocument(); var exception = Assert.Throws(() => { @@ -56,7 +56,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic StringProperty = "A", AnotherStringProperty = "B" }; - + JsonPatchDocument patchDoc = new JsonPatchDocument(); patchDoc.Copy("StringProperty", "AnotherStringProperty"); diff --git a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/RemoveOperationTests.cs b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/RemoveOperationTests.cs index 9ef28ad7cc..9ecb520b38 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/RemoveOperationTests.cs +++ b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/RemoveOperationTests.cs @@ -39,7 +39,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic public void RemovePropertyShouldFailIfItDoesntExist() { dynamic doc = new ExpandoObject(); - doc.Test = 1; + doc.Test = 1; // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); @@ -61,7 +61,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic public void RemovePropertyFromExpandoObject() { dynamic obj = new ExpandoObject(); - obj.Test = 1; + obj.Test = 1; // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); @@ -69,13 +69,13 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); - + deserialized.ApplyTo(obj); var cont = obj as IDictionary; object valueFromDictionary; - cont.TryGetValue("Test", out valueFromDictionary); + cont.TryGetValue("Test", out valueFromDictionary); Assert.Null(valueFromDictionary); } @@ -91,7 +91,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); - + deserialized.ApplyTo(obj); var cont = obj as IDictionary; @@ -137,7 +137,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); - + deserialized.ApplyTo(obj); var cont = obj as IDictionary; @@ -151,9 +151,9 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic { dynamic doc = new ExpandoObject(); doc.SimpleDTO = new SimpleDTO() - { - StringProperty = "A" - }; + { + StringProperty = "A" + }; // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); @@ -192,10 +192,10 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic { dynamic doc = new ExpandoObject(); doc.SimpleDTO = new SimpleDTO() - { - IntegerList = new List() { 1, 2, 3 } - }; - + { + IntegerList = new List() { 1, 2, 3 } + }; + // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); patchDoc.Remove("SimpleDTO/IntegerList/2"); @@ -216,7 +216,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic { IntegerList = new List() { 1, 2, 3 } }; - + // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); patchDoc.Remove("SimpleDTO/Integerlist/2"); @@ -234,9 +234,9 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic { dynamic doc = new ExpandoObject(); doc.SimpleDTO = new SimpleDTO() - { - IntegerList = new List() { 1, 2, 3 } - }; + { + IntegerList = new List() { 1, 2, 3 } + }; // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); @@ -259,9 +259,9 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic { dynamic doc = new ExpandoObject(); doc.SimpleDTO = new SimpleDTO() - { - IntegerList = new List() { 1, 2, 3 } - }; + { + IntegerList = new List() { 1, 2, 3 } + }; // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); @@ -284,9 +284,9 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic { dynamic doc = new ExpandoObject(); doc.SimpleDTO = new SimpleDTO() - { - IntegerList = new List() { 1, 2, 3 } - }; + { + IntegerList = new List() { 1, 2, 3 } + }; // create patch JsonPatchDocument patchDoc = new JsonPatchDocument(); diff --git a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/RemoveTypedOperationTests.cs b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/RemoveTypedOperationTests.cs index db5d6502d1..802fb27e40 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/RemoveTypedOperationTests.cs +++ b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/RemoveTypedOperationTests.cs @@ -73,7 +73,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic "For operation 'remove' on array property at path '/IntegerList/3', the index is larger than the array size.", exception.Message); } - + [Fact] public void RemoveFromListInvalidPositionTooSmall() { @@ -135,7 +135,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject(serialized); - + deserialized.ApplyTo(doc); Assert.Equal(null, doc.SimpleDTO.StringProperty); @@ -190,7 +190,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic "For operation 'remove' on array property at path '/SimpleDTO/IntegerList/3', the index is larger than the array size.", exception.Message); } - + [Fact] public void NestedRemoveFromListInvalidPositionTooSmall() { @@ -216,7 +216,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic Assert.Equal( "For operation 'remove' on array property at path '/SimpleDTO/IntegerList/-1', the index is negative.", exception.Message); - } + } [Fact] public void NestedRemoveFromEndOfList() diff --git a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/SimpleDTOWithNestedDTO.cs b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/SimpleDTOWithNestedDTO.cs index 2147fcceb1..03c74f8a1b 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/SimpleDTOWithNestedDTO.cs +++ b/test/Microsoft.AspNet.JsonPatch.Test/Dynamic/SimpleDTOWithNestedDTO.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic public NestedDTO NestedDTO { get; set; } public SimpleDTO SimpleDTO { get; set; } public List ListOfSimpleDTO { get; set; } - + public SimpleDTOWithNestedDTO() { NestedDTO = new NestedDTO(); diff --git a/test/Microsoft.AspNet.JsonPatch.Test/NestedObjectTests.cs b/test/Microsoft.AspNet.JsonPatch.Test/NestedObjectTests.cs index 33649b7788..e736373ed8 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/NestedObjectTests.cs +++ b/test/Microsoft.AspNet.JsonPatch.Test/NestedObjectTests.cs @@ -1,11 +1,10 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNet.JsonPatch.Exceptions; -using Newtonsoft.Json; -using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using Microsoft.AspNet.JsonPatch.Exceptions; +using Newtonsoft.Json; using Xunit; namespace Microsoft.AspNet.JsonPatch.Test @@ -388,7 +387,7 @@ namespace Microsoft.AspNet.JsonPatch.Test var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); }); Assert.Equal( "For operation 'add' on array property at path '/simpledto/integerlist/4', the index is " + - "larger than the array size.", + "larger than the array size.", exception.Message); } @@ -442,7 +441,7 @@ namespace Microsoft.AspNet.JsonPatch.Test var logger = new TestErrorLogger(); patchDoc.ApplyTo(doc, logger.LogErrorMessage); - + //Assert Assert.Equal( @@ -524,8 +523,8 @@ namespace Microsoft.AspNet.JsonPatch.Test patchDoc.ApplyTo(doc, logger.LogErrorMessage); - - + + //Assert Assert.Equal( "For operation 'add' on array property at path '/simpledto/integerlist/-1', the index is negative.", @@ -750,9 +749,9 @@ namespace Microsoft.AspNet.JsonPatch.Test patchDoc.Remove(o => o.SimpleDTO.IntegerList, 3); var logger = new TestErrorLogger(); - + patchDoc.ApplyTo(doc, logger.LogErrorMessage); - + // Assert Assert.Equal( "For operation 'remove' on array property at path '/simpledto/integerlist/3', the index is " + @@ -828,7 +827,7 @@ namespace Microsoft.AspNet.JsonPatch.Test patchDoc.ApplyTo(doc, logger.LogErrorMessage); - + // Assert Assert.Equal("For operation 'remove' on array property at path '/simpledto/integerlist/-1', the index is negative.", logger.ErrorMessage); } @@ -1293,9 +1292,9 @@ namespace Microsoft.AspNet.JsonPatch.Test var logger = new TestErrorLogger(); - + patchDoc.ApplyTo(doc, logger.LogErrorMessage); - + // Assert Assert.Equal( @@ -1319,7 +1318,7 @@ namespace Microsoft.AspNet.JsonPatch.Test // create patch var patchDoc = new JsonPatchDocument(); patchDoc.Replace(o => o.SimpleDTO.IntegerList, 5, -1); - + // Act & Assert var exception = Assert.Throws(() => { patchDoc.ApplyTo(doc); }); Assert.Equal("For operation 'replace' on array property at path '/simpledto/integerlist/-1', the index is negative.", @@ -1371,8 +1370,8 @@ namespace Microsoft.AspNet.JsonPatch.Test var logger = new TestErrorLogger(); - patchDoc.ApplyTo(doc, logger.LogErrorMessage); - + patchDoc.ApplyTo(doc, logger.LogErrorMessage); + // Assert Assert.Equal( diff --git a/test/Microsoft.AspNet.JsonPatch.Test/ObjectAdapterTests.cs b/test/Microsoft.AspNet.JsonPatch.Test/ObjectAdapterTests.cs index 0cc97e32c4..85d9404e6d 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/ObjectAdapterTests.cs +++ b/test/Microsoft.AspNet.JsonPatch.Test/ObjectAdapterTests.cs @@ -202,7 +202,7 @@ namespace Microsoft.AspNet.JsonPatch.Test var logger = new TestErrorLogger(); patchDoc.ApplyTo(doc, logger.LogErrorMessage); - + // Assert Assert.Equal( @@ -356,7 +356,7 @@ namespace Microsoft.AspNet.JsonPatch.Test var logger = new TestErrorLogger(); patchDoc.ApplyTo(doc, logger.LogErrorMessage); - + // Assert Assert.Equal( "For operation 'add' on array property at path '/integerlist/-1', the index is negative.", @@ -553,7 +553,7 @@ namespace Microsoft.AspNet.JsonPatch.Test var logger = new TestErrorLogger(); patchDoc.ApplyTo(doc, logger.LogErrorMessage); - + // Assert Assert.Equal( @@ -618,7 +618,7 @@ namespace Microsoft.AspNet.JsonPatch.Test patchDoc.ApplyTo(doc, logger.LogErrorMessage); - + // Assert Assert.Equal("For operation 'remove' on array property at path '/integerlist/-1', the index is negative.", logger.ErrorMessage); diff --git a/test/Microsoft.AspNet.JsonPatch.Test/SimpleDTO.cs b/test/Microsoft.AspNet.JsonPatch.Test/SimpleDTO.cs index 0c29a86e83..b1177bc5ce 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/SimpleDTO.cs +++ b/test/Microsoft.AspNet.JsonPatch.Test/SimpleDTO.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections; using System.Collections.Generic; namespace Microsoft.AspNet.JsonPatch.Test diff --git a/test/Microsoft.AspNet.JsonPatch.Test/TestErrorLogger.cs b/test/Microsoft.AspNet.JsonPatch.Test/TestErrorLogger.cs index c254eab3e3..525321cfb3 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/TestErrorLogger.cs +++ b/test/Microsoft.AspNet.JsonPatch.Test/TestErrorLogger.cs @@ -3,7 +3,7 @@ namespace Microsoft.AspNet.JsonPatch.Test { - public class TestErrorLogger where T: class + public class TestErrorLogger where T : class { public string ErrorMessage { get; set; } diff --git a/test/Microsoft.AspNet.JsonPatch.Test/project.json b/test/Microsoft.AspNet.JsonPatch.Test/project.json index 629b7a1be3..8b97af645a 100644 --- a/test/Microsoft.AspNet.JsonPatch.Test/project.json +++ b/test/Microsoft.AspNet.JsonPatch.Test/project.json @@ -1,18 +1,26 @@ { - "compilationOptions": { - "warningsAsErrors": true + "compilationOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "Microsoft.AspNet.JsonPatch": "1.0.0-*", + "Microsoft.AspNet.Testing": "1.0.0-*", + "Newtonsoft.Json": "6.0.6", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "commands": { + "test": "xunit.runner.aspnet" + }, + "frameworks": { + "dnx451": { + "dependencies": { + "Moq": "4.2.1312.1622" + } }, - "dependencies": { - "Microsoft.AspNet.JsonPatch": "1.0.0-*", - "Microsoft.AspNet.Testing": "1.0.0-*", - "Moq": "4.2.1312.1622", - "Newtonsoft.Json": "6.0.6", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "commands": { - "test": "xunit.runner.aspnet" - }, - "frameworks": { - "dnx451": { } + "dnxcore50": { + "dependencies": { + "moq.netcore": "4.4.0-beta8" + } } + } } \ No newline at end of file