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
{
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<JsonPatchDocument>(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<JsonPatchDocument>(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<JsonPatchDocument>(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<JsonPatchDocument>(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<JsonPatchDocument>(serialized);
@ -415,7 +415,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
Assert.Equal(new List<int>() { 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<JsonPatchDocument>(serialized);
deserialized.ApplyTo(doc);
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
JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Add("IntegerList/-1", 4);
var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
@ -101,11 +101,11 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
IntegerList = new List<int>() { 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<JsonPatchDocument>(serialized);

View File

@ -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<JsonPatchException>(() =>
{
@ -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<JsonPatchException>(() =>
{
@ -56,7 +56,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
StringProperty = "A",
AnotherStringProperty = "B"
};
JsonPatchDocument patchDoc = new JsonPatchDocument();
patchDoc.Copy("StringProperty", "AnotherStringProperty");

View File

@ -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<JsonPatchDocument>(serialized);
deserialized.ApplyTo(obj);
var cont = obj as IDictionary<string, object>;
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<JsonPatchDocument>(serialized);
deserialized.ApplyTo(obj);
var cont = obj as IDictionary<string, object>;
@ -137,7 +137,7 @@ namespace Microsoft.AspNet.JsonPatch.Test.Dynamic
var serialized = JsonConvert.SerializeObject(patchDoc);
var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument>(serialized);
deserialized.ApplyTo(obj);
var cont = obj as IDictionary<string, object>;
@ -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<int>() { 1, 2, 3 }
};
{
IntegerList = new List<int>() { 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<int>() { 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<int>() { 1, 2, 3 }
};
{
IntegerList = new List<int>() { 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<int>() { 1, 2, 3 }
};
{
IntegerList = new List<int>() { 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<int>() { 1, 2, 3 }
};
{
IntegerList = new List<int>() { 1, 2, 3 }
};
// create patch
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.",
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<JsonPatchDocument>(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()

View File

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

View File

@ -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<JsonPatchException>(() => { 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<SimpleDTOWithNestedDTO>();
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<int>(o => o.SimpleDTO.IntegerList, 3);
var logger = new TestErrorLogger<SimpleDTOWithNestedDTO>();
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<SimpleDTOWithNestedDTO>();
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert
Assert.Equal(
@ -1319,7 +1318,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
// create patch
var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>();
patchDoc.Replace<int>(o => o.SimpleDTO.IntegerList, 5, -1);
// Act & Assert
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.",
@ -1371,8 +1370,8 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger<SimpleDTOWithNestedDTO>();
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert
Assert.Equal(

View File

@ -202,7 +202,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger<SimpleDTO>();
patchDoc.ApplyTo(doc, logger.LogErrorMessage);
// Assert
Assert.Equal(
@ -356,7 +356,7 @@ namespace Microsoft.AspNet.JsonPatch.Test
var logger = new TestErrorLogger<SimpleDTO>();
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<SimpleDTO>();
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);

View File

@ -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

View File

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

View File

@ -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"
}
}
}
}