本文整理汇总了C#中Raven.Database.Json.JsonPatcher.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# JsonPatcher.ToString方法的具体用法?C# JsonPatcher.ToString怎么用?C# JsonPatcher.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Database.Json.JsonPatcher
的用法示例。
在下文中一共展示了JsonPatcher.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PropertyAddition_WithConcurrenty_ExistingValueOn_Ok
public void PropertyAddition_WithConcurrenty_ExistingValueOn_Ok()
{
JObject apply = new JsonPatcher(doc).Apply(
JArray.Parse(@"[{ ""type"":""set"",""name"": ""body"", ""value"": ""differnt markup"", ""prevVal"": ""html markup"" }]")
);
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""differnt markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}]}", apply.ToString(Formatting.None));
}
示例2: PropertyRemovalPropertyDoesNotExists
public void PropertyRemovalPropertyDoesNotExists()
{
var patchedDoc = new JsonPatcher(doc).Apply(
JArray.Parse(@"[{ ""type"": ""unset"", ""name"": ""ip"" }]")
);
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}]}", patchedDoc.ToString(Formatting.None));
}
示例3: AddingItemToArray_WithConcurrency_Ok
public void AddingItemToArray_WithConcurrency_Ok()
{
var patchedDoc = new JsonPatcher(doc).Apply(
JArray.Parse(@"[{ ""type"": ""add"" , ""name"": ""comments"", ""value"": {""author"":""oren"",""text"":""agreed""}, ""prevVal"": [{""author"":""ayende"",""text"":""good post 1""},{author: ""ayende"", text:""good post 2""}] }]")
);
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""},{""author"":""oren"",""text"":""agreed""}]}",
patchedDoc.ToString(Formatting.None));
}
示例4: PropertyAddition_WithConcurrenty_MissingProp
public void PropertyAddition_WithConcurrenty_MissingProp()
{
var patchedDoc = new JsonPatcher(doc).Apply(
JArray.Parse(@"[{ ""type"":""set"",""name"": ""blog_id"", ""value"": 1, ""prevVal"": undefined }]")
);
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}],""blog_id"":1}",
patchedDoc.ToString(Formatting.None));
}
示例5: AddingItemToArrayWhenArrayDoesNotExists_WithConcurrency_Ok
public void AddingItemToArrayWhenArrayDoesNotExists_WithConcurrency_Ok()
{
var patchedDoc = new JsonPatcher(doc).Apply(
JArray.Parse(@"[{ ""type"":""add"", ""name"": ""blog_id"", ""value"": 1, ""prevVal"": undefined }]")
);
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""blog_id"":[1]}",
patchedDoc.ToString(Formatting.None));
}
示例6: SetValueNestedInArray
public void SetValueNestedInArray()
{
var patchedDoc = new JsonPatcher(doc).Apply(
JArray.Parse(
@"[{ ""type"": ""modify"", ""name"": ""comments"", ""position"": 1, ""value"": [{ ""type"":""set"",""name"":""author"",""value"":""oren""} ]}]")
);
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""oren"",""text"":""good post 2""}],""user"":{""name"":""ayende"",""id"":13}}",
patchedDoc.ToString(Formatting.None));
}
示例7: PropertyMove
public void PropertyMove()
{
var patchedDoc = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = PatchCommandType.Rename,
Name = "comments",
Value = new JValue("cmts")
},
});
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""cmts"":[{""author"":""ayende"",""text"":""good post""}]}",
patchedDoc.ToString(Formatting.None));
}
示例8: ExistingPropertySetToArray
public void ExistingPropertySetToArray()
{
var patchedDoc = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = PatchCommandType.Set,
Name = "title",
Value = new RavenJArray()
},
});
Assert.Equal(@"{""title"":[],""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}]}",
patchedDoc.ToString(Formatting.None));
}
示例9: PropertyAddition
public void PropertyAddition()
{
var patchedDoc = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = PatchCommandType.Set,
Name = "blog_id",
Value = new RavenJValue(1)
},
});
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}],""blog_id"":1}",
patchedDoc.ToString(Formatting.None));
}
示例10: AddingItemToArrayWhenArrayDoesNotExists
public void AddingItemToArrayWhenArrayDoesNotExists()
{
var patchedDoc = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = "add",
Name = "blog_id",
Value = new JValue(1),
}
});
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""blog_id"":[1]}",
patchedDoc.ToString(Formatting.None));
}
示例11: PropertyCopyNonExistingProperty
public void PropertyCopyNonExistingProperty()
{
var patchedDoc = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = PatchCommandType.Copy,
Name = "non-existing",
Value = new RavenJValue("irrelevant")
},
});
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}]}",
patchedDoc.ToString(Formatting.None));
}
示例12: PropertyAddition_WithConcurrenty_ExistingValueOn_Ok
public void PropertyAddition_WithConcurrenty_ExistingValueOn_Ok()
{
JObject apply = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = "set",
Name = "body",
Value = new JValue("differnt markup"),
PrevVal = new JValue("html markup")
},
});
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""differnt markup"",""comments"":[{""author"":""ayende"",""text"":""good post""}]}", apply.ToString(Formatting.None));
}
示例13: AddingEmptyObject
public void AddingEmptyObject()
{
var patchedDoc = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = PatchCommandType.Set,
Name = "NewProp",
Value = new RavenJObject()
}
});
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""NewProp"":{}}",
patchedDoc.ToString(Formatting.None));
}
示例14: AddingItemToArray
public void AddingItemToArray()
{
var patchedDoc = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = PatchCommandType.Add,
Name = "comments",
Value = RavenJObject.Parse(@"{""author"":""oren"",""text"":""agreed""}")
}
});
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""},{""author"":""oren"",""text"":""agreed""}]}",
patchedDoc.ToString(Formatting.None));
}
示例15: SetValueInNestedElement
public void SetValueInNestedElement()
{
var patchedDoc = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = PatchCommandType.Modify,
Name = "user",
Nested = new[]
{
new PatchRequest {Type = PatchCommandType.Set, Name = "name", Value = new JValue("rahien")},
}
},
});
Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""user"":{""name"":""rahien"",""id"":13}}",
patchedDoc.ToString(Formatting.None));
}