Ejemplo n.º 1
0
        public void CanConvertToAndFromJsonWithNestedPatchRequests()
        {
            var patch = new PatchRequest
            {
                Name     = "Comments",
                Type     = PatchCommandType.Modify,
                Position = 0,
                Nested   = new[]
                {
                    new PatchRequest
                    {
                        Name  = "AuthorId",
                        Type  = PatchCommandType.Set,
                        Value = "authors/456"
                    },
                    new PatchRequest
                    {
                        Name  = "AuthorName",
                        Type  = PatchCommandType.Set,
                        Value = "Tolkien"
                    },
                }
            };

            var jsonPatch   = patch.ToJson();
            var backToPatch = PatchRequest.FromJson(jsonPatch);

            Assert.Equal(patch.Name, backToPatch.Name);
            Assert.Equal(patch.Nested.Length, backToPatch.Nested.Length);
        }
Ejemplo n.º 2
0
		public void CanConvertToAndFromJsonWithNestedPatchRequests()
		{
			var patch = new PatchRequest
							{
								Name = "Comments",
								Type = PatchCommandType.Modify,
								Position = 0,
								Nested = new[]
											 {
												 new PatchRequest
													 {
														 Name = "AuthorId",
														 Type = PatchCommandType.Set,
														 Value = "authors/456"
													 },
													new PatchRequest
													 {
														 Name = "AuthorName",
														 Type = PatchCommandType.Set,
														 Value = "Tolkien"
													 },
											 }
							};

			var jsonPatch = patch.ToJson();
			var backToPatch = PatchRequest.FromJson(jsonPatch);
			Assert.Equal(patch.Name, backToPatch.Name);
			Assert.Equal(patch.Nested.Length, backToPatch.Nested.Length);
		}		
Ejemplo n.º 3
0
		public void CanConvertToAndFromJsonWithoutNestedPatchRequests()
		{
			var patch = new PatchRequest
							{
								Name = "Comments",
								Type = PatchCommandType.Modify,
								Position = 0,
								Nested = null
							};

			var jsonPatch = patch.ToJson();
			var backToPatch = PatchRequest.FromJson(jsonPatch);
			Assert.Equal(patch.Name, backToPatch.Name);
			Assert.Equal(patch.Nested, backToPatch.Nested);
		}
Ejemplo n.º 4
0
        public void CanConvertToAndFromJsonWithEmptyNestedPatchRequests()
        {
            var patch = new PatchRequest
            {
                Name     = "Comments",
                Type     = PatchCommandType.Modify,
                Position = 0,
                Nested   = new PatchRequest[] { }
            };

            var jsonPatch   = patch.ToJson();
            var backToPatch = PatchRequest.FromJson(jsonPatch);

            Assert.Equal(patch.Name, backToPatch.Name);
            Assert.Equal(patch.Nested.Length, backToPatch.Nested.Length);
        }