private async Task RunApplyLiveOnlyMerge(StandardTestYaml testYaml) { IResourcePatcher patcher = new ResourcePatcher(); 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); var operations = new ResourceSerializers().Convert <List <PatchOperation> >(patch); var expected = testYaml.Patch.OrderBy(op => op.ToString()).ToList(); operations = operations.OrderBy(op => op.ToString()).ToList(); Assert.Equal(expected, operations); }
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); }
public async Task RunStandardTest(StandardTestYaml testYaml) { if (testYaml is null) { throw new ArgumentNullException(nameof(testYaml)); } await RunThreeWayMerge(testYaml); if (!testYaml.Patch.Any(operation => operation.Op == "remove")) { await RunApplyLiveOnlyMerge(testYaml); } }