Example #1
0
        public void UpdateUtilityAppendsReplaceComponentOp()
        {
            var    op       = new UpdateOperationsUtility();
            string path     = "testPath";
            string property = "someProperty";
            int    value    = 10;

            op.AppendReplaceComponentOp(path, new Dictionary <string, object> {
                { property, value }
            });
            string operations = op.Serialize();

            // There should be a single operation added.
            var jArray = JArray.Parse(operations);

            jArray.Count.Should().Be(1);

            // The patch operation added should be a "replace" operation.
            JToken jObject = jArray.First;

            jObject.Value <string>(Op).Should().Be(Replace);

            // The value should have a "$metadata" : {} mapping.
            JObject patchValue = jObject.Value <JObject>(Value);

            patchValue[Metadata].Should().NotBeNull();
            patchValue[Metadata].Should().BeEmpty();
        }