Esempio n. 1
0
        private async Task RunApplyLiveOnlyMerge(StandardTestYaml testYaml)
        {
            // arrange
            IResourcePatcher patcher = new ResourcePatcher();

            // act
            var parameters = new CreatePatchParameters
            {
                ApplyResource = testYaml.Apply,
                LiveResource  = testYaml.Live,
            };

            if (testYaml.ResourceKind != null)
            {
                parameters.ResourceKind = await Manager.GetResourceKindAsync(
                    testYaml.ResourceKind.ApiVersion,
                    testYaml.ResourceKind.Kind);
            }

            var patch = patcher.CreateJsonPatch(parameters);

            // assert
            var operations = new ResourceSerializers().Convert <List <PatchOperation> >(patch);

            operations.ShouldBe(testYaml.Patch, ignoreOrder: true);
        }
Esempio n. 2
0
        public JsonPatchDocument CreateJsonPatch(CreatePatchParameters parameters)
        {
            if (parameters is null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            var context = new Context(parameters);

            var patch = AccumulatePatch(new JsonPatchDocument(), context);

            return(patch);
        }