public void DeserialObjectsJson() { var actual = PipelineReceiverActions.ConvertFromJson(GetJsonContent(), PipelineReceiverActions.PassThru).ToArray(); Assert.Equal(2, actual.Length); Assert.Equal("TestObject1", actual[0].Properties["targetName"].Value); Assert.Equal("Test", actual[0].PropertyValue <PSObject>("spec").PropertyValue <PSObject>("properties").PropertyValue <string>("kind")); Assert.Equal(2, actual[1].PropertyValue <PSObject>("spec").PropertyValue <PSObject>("properties").PropertyValue <int>("value2")); Assert.Equal(2, actual[1].PropertyValue <PSObject>("spec").PropertyValue <PSObject>("properties").PropertyValue <PSObject[]>("array").Length); }
public void UseObjectPath() { var actual = PipelineReceiverActions.ConvertFromYaml(GetYamlContent(), (sourceObject) => PipelineReceiverActions.ReadObjectPath(sourceObject, PipelineReceiverActions.PassThru, "items", true) ).ToArray(); Assert.Equal(2, actual.Length); Assert.Equal("TestObject1", actual[0].Properties["targetName"].Value); Assert.Equal("Test", actual[0].PropertyValue <PSObject>("spec").PropertyValue <PSObject>("properties").PropertyValue <string>("kind")); Assert.Equal(2, actual[1].PropertyValue <PSObject>("spec").PropertyValue <PSObject>("properties").PropertyValue <int>("value2")); }
public void DeserializeObjectsPowerShellData() { var actual = PipelineReceiverActions.ConvertFromPowerShellData(GetDataContent(), PipelineReceiverActions.PassThru).ToArray(); Assert.Single(actual); Assert.Equal("TestObject1", actual[0].PropertyValue <string>("targetName")); Assert.Equal("Test", actual[0].PropertyValue("spec").PropertyValue("properties").PropertyValue <string>("kind")); Assert.Equal(1, actual[0].PropertyValue("spec").PropertyValue("properties").PropertyValue <int>("value1")); Assert.Equal(2, actual[0].PropertyValue("spec").PropertyValue("properties").PropertyValue <Array>("array").Length); Assert.Equal("TestObject1", PipelineHookActions.BindTargetName(null, false, actual[0])); }
public void DeserializeObjectsYaml() { var actual = PipelineReceiverActions.ConvertFromYaml(GetYamlContent(), PipelineReceiverActions.PassThru).ToArray(); Assert.Equal(2, actual.Length); Assert.Equal("TestObject1", actual[0].PropertyValue <string>("targetName")); Assert.Equal("Test", actual[0].PropertyValue("spec").PropertyValue("properties").PropertyValue <string>("kind")); Assert.Equal(2, actual[1].PropertyValue("spec").PropertyValue("properties").PropertyValue <int>("value2")); Assert.Equal(2, actual[1].PropertyValue("spec").PropertyValue("properties").PropertyValue <PSObject[]>("array").Length); Assert.Equal("TestObject1", PipelineHookActions.BindTargetName(null, false, actual[0])); }
public void DeserializeObjectsJson() { var actual = PipelineReceiverActions.ConvertFromJson(GetJsonContent(), PipelineReceiverActions.PassThru).ToArray(); Assert.Equal(2, actual.Length); Assert.Equal("TestObject1", actual[0].PropertyValue <string>("targetName")); Assert.Equal("Test", actual[0].PropertyValue("spec").PropertyValue("properties").PropertyValue <string>("kind")); Assert.Equal(2, actual[1].PropertyValue("spec").PropertyValue("properties").PropertyValue <int>("value2")); Assert.Equal(2, actual[1].PropertyValue("spec").PropertyValue("properties").PropertyValue <PSObject[]>("array").Length); Assert.Equal("TestObject1", PipelineHookActions.BindTargetName(null, false, actual[0])); // Single item actual = PipelineReceiverActions.ConvertFromJson(GetJsonContent("Single"), PipelineReceiverActions.PassThru).ToArray(); Assert.Single(actual); Assert.Equal("TestObject1", actual[0].PropertyValue <string>("targetName")); Assert.Equal("Test", actual[0].PropertyValue("spec").PropertyValue("properties").PropertyValue <string>("kind")); // Malformed item Assert.Throws <PipelineSerializationException>(() => PipelineReceiverActions.ConvertFromJson("{", PipelineReceiverActions.PassThru).ToArray()); Assert.Throws <PipelineSerializationException>(() => PipelineReceiverActions.ConvertFromJson("{ \"key\": ", PipelineReceiverActions.PassThru).ToArray()); }