Updating tests to run on dnxcore50

This commit is contained in:
Pranav K 2015-11-23 16:40:15 -08:00
parent b09bdc08f4
commit 60f5fd591e
11 changed files with 96 additions and 90 deletions

View File

@ -18,7 +18,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
dynamic doc = new dynamic doc = new
{ {
Test = 1 Test = 1
}; };
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
@ -33,14 +33,14 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
}); });
Assert.Equal( Assert.Equal(
"The property at path '/NewInt' could not be added.", "The property at path '/NewInt' could not be added.",
exception.Message); exception.Message);
} }
[Fact] [Fact]
public void AddNewProperty() public void AddNewProperty()
{ {
dynamic obj = new ExpandoObject(); dynamic obj = new ExpandoObject();
obj.Test = 1; obj.Test = 1;
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
@ -48,7 +48,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
deserialized.ApplyTo(obj); deserialized.ApplyTo(obj);
Assert.Equal(1, obj.NewInt); 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.", "The property at path '/Nested/NewInt' could not be added.",
exception.Message); exception.Message);
} }
[Fact] [Fact]
public void AddToExistingPropertyOnNestedObject() public void AddToExistingPropertyOnNestedObject()
{ {
@ -120,7 +120,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
deserialized.ApplyTo(doc); deserialized.ApplyTo(doc);
Assert.Equal("A", doc.nested.StringProperty); Assert.Equal("A", doc.nested.StringProperty);
@ -142,13 +142,13 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
deserialized.ApplyTo(doc); deserialized.ApplyTo(doc);
Assert.Equal(1, doc.nested.NewInt); Assert.Equal(1, doc.nested.NewInt);
Assert.Equal(1, doc.Test); Assert.Equal(1, doc.Test);
} }
[Fact] [Fact]
public void AddNewPropertyToExpandoOjectInTypedObject() public void AddNewPropertyToExpandoOjectInTypedObject()
{ {
@ -156,7 +156,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
{ {
DynamicProperty = new ExpandoObject() DynamicProperty = new ExpandoObject()
}; };
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Add("DynamicProperty/NewInt", 1); patchDoc.Add("DynamicProperty/NewInt", 1);
@ -168,9 +168,9 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
Assert.Equal(1, doc.DynamicProperty.NewInt); Assert.Equal(1, doc.DynamicProperty.NewInt);
} }
[Fact] [Fact]
public void AddNewPropertyToTypedObjectInExpandoObject() public void AddNewPropertyToTypedObjectInExpandoObject()
{ {
dynamic dynamicProperty = new ExpandoObject(); dynamic dynamicProperty = new ExpandoObject();
dynamicProperty.StringProperty = "A"; dynamicProperty.StringProperty = "A";
@ -246,7 +246,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
public void AddResultsShouldReplace() public void AddResultsShouldReplace()
{ {
dynamic doc = new ExpandoObject(); dynamic doc = new ExpandoObject();
doc.StringProperty = "A"; doc.StringProperty = "A";
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
@ -289,11 +289,11 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
doc.Nested.DynamicProperty.InBetweenFirst = new ExpandoObject(); doc.Nested.DynamicProperty.InBetweenFirst = new ExpandoObject();
doc.Nested.DynamicProperty.InBetweenFirst.InBetweenSecond = new ExpandoObject(); doc.Nested.DynamicProperty.InBetweenFirst.InBetweenSecond = new ExpandoObject();
doc.Nested.DynamicProperty.InBetweenFirst.InBetweenSecond.StringProperty = "A"; doc.Nested.DynamicProperty.InBetweenFirst.InBetweenSecond.StringProperty = "A";
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Add("/Nested/DynamicProperty/InBetweenFirst/InBetweenSecond/StringProperty", "B"); patchDoc.Add("/Nested/DynamicProperty/InBetweenFirst/InBetweenSecond/StringProperty", "B");
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
@ -301,7 +301,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
Assert.Equal("B", doc.Nested.DynamicProperty.InBetweenFirst.InBetweenSecond.StringProperty); Assert.Equal("B", doc.Nested.DynamicProperty.InBetweenFirst.InBetweenSecond.StringProperty);
} }
[Fact] [Fact]
public void ShouldNotBeAbleToAddToNonExistingPropertyThatIsNotTheRoot() public void ShouldNotBeAbleToAddToNonExistingPropertyThatIsNotTheRoot()
{ {
@ -387,7 +387,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Add("stringproperty", "B"); patchDoc.Add("stringproperty", "B");
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
@ -415,7 +415,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
Assert.Equal(new List<int>() { 4, 1, 2, 3 }, doc.IntegerList); Assert.Equal(new List<int>() { 4, 1, 2, 3 }, doc.IntegerList);
} }
[Fact] [Fact]
public void AddToListNegativePosition() public void AddToListNegativePosition()
{ {
@ -452,7 +452,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
deserialized.ApplyTo(doc); deserialized.ApplyTo(doc);
Assert.Equal(new List<int>() { 4, 1, 2, 3 }, doc.IntegerList); Assert.Equal(new List<int>() { 4, 1, 2, 3 }, doc.IntegerList);

View File

@ -21,7 +21,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Add("IntegerList/-1", 4); patchDoc.Add("IntegerList/-1", 4);
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
@ -101,11 +101,11 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
IntegerList = new List<int>() { 1, 2, 3 } IntegerList = new List<int>() { 1, 2, 3 }
} }
} }
}; };
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Add("ListOfSimpleDTO/20/IntegerList/0", 4); patchDoc.Add("ListOfSimpleDTO/20/IntegerList/0", 4);
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);

View File

@ -8,7 +8,7 @@ using Xunit;
namespace Microsoft.AspNet.JsonPatch.Test.Dynamic namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
{ {
public class PatchDocumentTests public class PatchDocumentTests
{ {
[Fact] [Fact]
public void InvalidPathAtBeginningShouldThrowException() public void InvalidPathAtBeginningShouldThrowException()
{ {
@ -20,11 +20,11 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
Assert.Equal( Assert.Equal(
"The provided string '//NewInt' is an invalid path.", "The provided string '//NewInt' is an invalid path.",
exception.Message); exception.Message);
} }
[Fact] [Fact]
public void InvalidPathAtEndShouldThrowException() public void InvalidPathAtEndShouldThrowException()
{ {
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
var exception = Assert.Throws<JsonPatchException>(() => var exception = Assert.Throws<JsonPatchException>(() =>
{ {
@ -33,11 +33,11 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
Assert.Equal( Assert.Equal(
"The provided string 'NewInt//' is an invalid path.", "The provided string 'NewInt//' is an invalid path.",
exception.Message); exception.Message);
} }
[Fact] [Fact]
public void InvalidPathWithDotShouldThrowException() public void InvalidPathWithDotShouldThrowException()
{ {
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
var exception = Assert.Throws<JsonPatchException>(() => var exception = Assert.Throws<JsonPatchException>(() =>
{ {
@ -56,7 +56,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
StringProperty = "A", StringProperty = "A",
AnotherStringProperty = "B" AnotherStringProperty = "B"
}; };
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Copy("StringProperty", "AnotherStringProperty"); patchDoc.Copy("StringProperty", "AnotherStringProperty");

View File

@ -39,7 +39,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
public void RemovePropertyShouldFailIfItDoesntExist() public void RemovePropertyShouldFailIfItDoesntExist()
{ {
dynamic doc = new ExpandoObject(); dynamic doc = new ExpandoObject();
doc.Test = 1; doc.Test = 1;
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
@ -61,7 +61,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
public void RemovePropertyFromExpandoObject() public void RemovePropertyFromExpandoObject()
{ {
dynamic obj = new ExpandoObject(); dynamic obj = new ExpandoObject();
obj.Test = 1; obj.Test = 1;
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
@ -69,13 +69,13 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
deserialized.ApplyTo(obj); deserialized.ApplyTo(obj);
var cont = obj as IDictionary<string, object>; var cont = obj as IDictionary<string, object>;
object valueFromDictionary; object valueFromDictionary;
cont.TryGetValue("Test", out valueFromDictionary); cont.TryGetValue("Test", out valueFromDictionary);
Assert.Null(valueFromDictionary); Assert.Null(valueFromDictionary);
} }
@ -91,7 +91,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
deserialized.ApplyTo(obj); deserialized.ApplyTo(obj);
var cont = obj as IDictionary<string, object>; var cont = obj as IDictionary<string, object>;
@ -137,7 +137,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
deserialized.ApplyTo(obj); deserialized.ApplyTo(obj);
var cont = obj as IDictionary<string, object>; var cont = obj as IDictionary<string, object>;
@ -151,9 +151,9 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
{ {
dynamic doc = new ExpandoObject(); dynamic doc = new ExpandoObject();
doc.SimpleDTO = new SimpleDTO() doc.SimpleDTO = new SimpleDTO()
{ {
StringProperty = "A" StringProperty = "A"
}; };
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
@ -192,10 +192,10 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
{ {
dynamic doc = new ExpandoObject(); dynamic doc = new ExpandoObject();
doc.SimpleDTO = new SimpleDTO() doc.SimpleDTO = new SimpleDTO()
{ {
IntegerList = new List<int>() { 1, 2, 3 } IntegerList = new List<int>() { 1, 2, 3 }
}; };
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Remove("SimpleDTO/IntegerList/2"); patchDoc.Remove("SimpleDTO/IntegerList/2");
@ -216,7 +216,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
{ {
IntegerList = new List<int>() { 1, 2, 3 } IntegerList = new List<int>() { 1, 2, 3 }
}; };
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Remove("SimpleDTO/Integerlist/2"); patchDoc.Remove("SimpleDTO/Integerlist/2");
@ -234,9 +234,9 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
{ {
dynamic doc = new ExpandoObject(); dynamic doc = new ExpandoObject();
doc.SimpleDTO = new SimpleDTO() doc.SimpleDTO = new SimpleDTO()
{ {
IntegerList = new List<int>() { 1, 2, 3 } IntegerList = new List<int>() { 1, 2, 3 }
}; };
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
@ -259,9 +259,9 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
{ {
dynamic doc = new ExpandoObject(); dynamic doc = new ExpandoObject();
doc.SimpleDTO = new SimpleDTO() doc.SimpleDTO = new SimpleDTO()
{ {
IntegerList = new List<int>() { 1, 2, 3 } IntegerList = new List<int>() { 1, 2, 3 }
}; };
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();
@ -284,9 +284,9 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
{ {
dynamic doc = new ExpandoObject(); dynamic doc = new ExpandoObject();
doc.SimpleDTO = new SimpleDTO() doc.SimpleDTO = new SimpleDTO()
{ {
IntegerList = new List<int>() { 1, 2, 3 } IntegerList = new List<int>() { 1, 2, 3 }
}; };
// create patch // create patch
JsonPatchDocument patchDoc = new JsonPatchDocument(); JsonPatchDocument patchDoc = new JsonPatchDocument();

View File

@ -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.", "For operation 'remove' on array property at path '/IntegerList/3', the index is larger than the array size.",
exception.Message); exception.Message);
} }
[Fact] [Fact]
public void RemoveFromListInvalidPositionTooSmall() public void RemoveFromListInvalidPositionTooSmall()
{ {
@ -135,7 +135,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
var serialized = JsonConvert.SerializeObject(patchDoc); var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
deserialized.ApplyTo(doc); deserialized.ApplyTo(doc);
Assert.Equal(null, doc.SimpleDTO.StringProperty); 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.", "For operation 'remove' on array property at path '/SimpleDTO/IntegerList/3', the index is larger than the array size.",
exception.Message); exception.Message);
} }
[Fact] [Fact]
public void NestedRemoveFromListInvalidPositionTooSmall() public void NestedRemoveFromListInvalidPositionTooSmall()
{ {
@ -216,7 +216,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
Assert.Equal( Assert.Equal(
"For operation 'remove' on array property at path '/SimpleDTO/IntegerList/-1', the index is negative.", "For operation 'remove' on array property at path '/SimpleDTO/IntegerList/-1', the index is negative.",
exception.Message); exception.Message);
} }
[Fact] [Fact]
public void NestedRemoveFromEndOfList() public void NestedRemoveFromEndOfList()

View File

@ -11,7 +11,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
public NestedDTO NestedDTO { get; set; } public NestedDTO NestedDTO { get; set; }
public SimpleDTO SimpleDTO { get; set; } public SimpleDTO SimpleDTO { get; set; }
public List<SimpleDTO> ListOfSimpleDTO { get; set; } public List<SimpleDTO> ListOfSimpleDTO { get; set; }
public SimpleDTOWithNestedDTO() public SimpleDTOWithNestedDTO()
{ {
NestedDTO = new NestedDTO(); NestedDTO = new NestedDTO();

View File

@ -1,11 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved. // 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. // 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.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Microsoft.AspNet.JsonPatch.Exceptions;
using Newtonsoft.Json;
using Xunit; using Xunit;
namespace Microsoft.AspNet.JsonPatch.Test namespace Microsoft.AspNet.JsonPatch.Test
@ -388,7 +387,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var exception = Assert.Throws<JsonPatchException>(() => { patchDoc.ApplyTo(doc); }); var exception = Assert.Throws<JsonPatchException>(() => { patchDoc.ApplyTo(doc); });
Assert.Equal( Assert.Equal(
"For operation 'add' on array property at path '/simpledto/integerlist/4', the index is " + "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); exception.Message);
} }
@ -442,7 +441,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger<SimpleDTOWithNestedDTO>(); var logger = new TestErrorLogger<SimpleDTOWithNestedDTO>();
patchDoc.ApplyTo(doc, logger.LogErrorMessage); patchDoc.ApplyTo(doc, logger.LogErrorMessage);
//Assert //Assert
Assert.Equal( Assert.Equal(
@ -524,8 +523,8 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.ApplyTo(doc, logger.LogErrorMessage); patchDoc.ApplyTo(doc, logger.LogErrorMessage);
//Assert //Assert
Assert.Equal( Assert.Equal(
"For operation 'add' on array property at path '/simpledto/integerlist/-1', the index is negative.", "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<int>(o => o.SimpleDTO.IntegerList, 3); patchDoc.Remove<int>(o => o.SimpleDTO.IntegerList, 3);
var logger = new TestErrorLogger<SimpleDTOWithNestedDTO>(); var logger = new TestErrorLogger<SimpleDTOWithNestedDTO>();
patchDoc.ApplyTo(doc, logger.LogErrorMessage); patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert // Assert
Assert.Equal( Assert.Equal(
"For operation 'remove' on array property at path '/simpledto/integerlist/3', the index is " + "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); patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert // Assert
Assert.Equal("For operation 'remove' on array property at path '/simpledto/integerlist/-1', the index is negative.", logger.ErrorMessage); 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<SimpleDTOWithNestedDTO>(); var logger = new TestErrorLogger<SimpleDTOWithNestedDTO>();
patchDoc.ApplyTo(doc, logger.LogErrorMessage); patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert // Assert
Assert.Equal( Assert.Equal(
@ -1319,7 +1318,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
// create patch // create patch
var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>(); var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
patchDoc.Replace<int>(o => o.SimpleDTO.IntegerList, 5, -1); patchDoc.Replace<int>(o => o.SimpleDTO.IntegerList, 5, -1);
// Act & Assert // Act & Assert
var exception = Assert.Throws<JsonPatchException>(() => { patchDoc.ApplyTo(doc); }); var exception = Assert.Throws<JsonPatchException>(() => { patchDoc.ApplyTo(doc); });
Assert.Equal("For operation 'replace' on array property at path '/simpledto/integerlist/-1', the index is negative.", 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<SimpleDTOWithNestedDTO>(); var logger = new TestErrorLogger<SimpleDTOWithNestedDTO>();
patchDoc.ApplyTo(doc, logger.LogErrorMessage); patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert // Assert
Assert.Equal( Assert.Equal(

View File

@ -202,7 +202,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger<SimpleDTO>(); var logger = new TestErrorLogger<SimpleDTO>();
patchDoc.ApplyTo(doc, logger.LogErrorMessage); patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert // Assert
Assert.Equal( Assert.Equal(
@ -356,7 +356,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger<SimpleDTO>(); var logger = new TestErrorLogger<SimpleDTO>();
patchDoc.ApplyTo(doc, logger.LogErrorMessage); patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert // Assert
Assert.Equal( Assert.Equal(
"For operation 'add' on array property at path '/integerlist/-1', the index is negative.", "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<SimpleDTO>(); var logger = new TestErrorLogger<SimpleDTO>();
patchDoc.ApplyTo(doc, logger.LogErrorMessage); patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert // Assert
Assert.Equal( Assert.Equal(
@ -618,7 +618,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
patchDoc.ApplyTo(doc, logger.LogErrorMessage); patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert // Assert
Assert.Equal("For operation 'remove' on array property at path '/integerlist/-1', the index is negative.", logger.ErrorMessage); Assert.Equal("For operation 'remove' on array property at path '/integerlist/-1', the index is negative.", logger.ErrorMessage);

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
namespace Microsoft.AspNet.JsonPatch.Test namespace Microsoft.AspNet.JsonPatch.Test

View File

@ -3,7 +3,7 @@
namespace Microsoft.AspNet.JsonPatch.Test namespace Microsoft.AspNet.JsonPatch.Test
{ {
public class TestErrorLogger<T> where T: class public class TestErrorLogger<T> where T : class
{ {
public string ErrorMessage { get; set; } public string ErrorMessage { get; set; }

View File

@ -1,18 +1,26 @@
{ {
"compilationOptions": { "compilationOptions": {
"warningsAsErrors": true "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": { "dnxcore50": {
"Microsoft.AspNet.JsonPatch": "1.0.0-*", "dependencies": {
"Microsoft.AspNet.Testing": "1.0.0-*", "moq.netcore": "4.4.0-beta8"
"Moq": "4.2.1312.1622", }
"Newtonsoft.Json": "6.0.6",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": { }
} }
}
} }