diff --git a/src/AzureDataFactory.TestingFramework/Generated/Models/SetVariableActivity.Serialization.cs b/src/AzureDataFactory.TestingFramework/Generated/Models/SetVariableActivity.Serialization.cs index 2e530b24..043363a6 100644 --- a/src/AzureDataFactory.TestingFramework/Generated/Models/SetVariableActivity.Serialization.cs +++ b/src/AzureDataFactory.TestingFramework/Generated/Models/SetVariableActivity.Serialization.cs @@ -106,6 +106,7 @@ internal static SetVariableActivity DeserializeSetVariableActivity(JsonElement e Optional> userProperties = default; Optional variableName = default; Optional> value = default; + Optional>> pipelineReturnValues = default; Optional setSystemVariable = default; IDictionary> additionalProperties = default; Dictionary> additionalPropertiesDictionary = new Dictionary>(); @@ -201,6 +202,16 @@ internal static SetVariableActivity DeserializeSetVariableActivity(JsonElement e { continue; } + + if (property0.Value.ValueKind == JsonValueKind.Array) + { + pipelineReturnValues = new Dictionary>(); + foreach (var item in property0.Value.EnumerateArray()) + pipelineReturnValues.Value.Add(item.GetProperty("key"u8).GetString(), JsonSerializer.Deserialize>(item.GetProperty("value"u8).GetRawText())); + + continue; + } + value = JsonSerializer.Deserialize>(property0.Value.GetRawText()); continue; } @@ -219,7 +230,7 @@ internal static SetVariableActivity DeserializeSetVariableActivity(JsonElement e additionalPropertiesDictionary.Add(property.Name, JsonSerializer.Deserialize>(property.Value.GetRawText())); } additionalProperties = additionalPropertiesDictionary; - return new SetVariableActivity(name, type, description.Value, Optional.ToNullable(state), Optional.ToNullable(onInactiveMarkAs), Optional.ToList(dependsOn), Optional.ToList(userProperties), additionalProperties, policy.Value, variableName.Value, value.Value, Optional.ToNullable(setSystemVariable)); + return new SetVariableActivity(name, type, description.Value, Optional.ToNullable(state), Optional.ToNullable(onInactiveMarkAs), Optional.ToList(dependsOn), Optional.ToList(userProperties), additionalProperties, policy.Value, variableName.Value, value.Value, pipelineReturnValues.Value, Optional.ToNullable(setSystemVariable)); } } } diff --git a/src/AzureDataFactory.TestingFramework/Generated/Models/SetVariableActivity.cs b/src/AzureDataFactory.TestingFramework/Generated/Models/SetVariableActivity.cs index ce8bfd10..b93ca687 100644 --- a/src/AzureDataFactory.TestingFramework/Generated/Models/SetVariableActivity.cs +++ b/src/AzureDataFactory.TestingFramework/Generated/Models/SetVariableActivity.cs @@ -36,11 +36,12 @@ public SetVariableActivity(string name) : base(name) /// Name of the variable whose value needs to be set. /// Value to be set. Could be a static value or Expression. /// If set to true, it sets the pipeline run return value. - internal SetVariableActivity(string name, string activityType, string description, PipelineActivityState? state, ActivityOnInactiveMarkAs? onInactiveMarkAs, IList dependsOn, IList userProperties, IDictionary> additionalProperties, SecureInputOutputPolicy policy, string variableName, DataFactoryElement value, bool? setSystemVariable) : base(name, activityType, description, state, onInactiveMarkAs, dependsOn, userProperties, additionalProperties) + internal SetVariableActivity(string name, string activityType, string description, PipelineActivityState? state, ActivityOnInactiveMarkAs? onInactiveMarkAs, IList dependsOn, IList userProperties, IDictionary> additionalProperties, SecureInputOutputPolicy policy, string variableName, DataFactoryElement value, Dictionary> pipelineReturnValues, bool? setSystemVariable) : base(name, activityType, description, state, onInactiveMarkAs, dependsOn, userProperties, additionalProperties) { Policy = policy; VariableName = variableName; Value = value; + PipelineReturnValues = pipelineReturnValues; SetSystemVariable = setSystemVariable; ActivityType = activityType ?? "SetVariable"; } @@ -51,6 +52,8 @@ internal SetVariableActivity(string name, string activityType, string descriptio public string VariableName { get; set; } /// Value to be set. Could be a static value or Expression. public DataFactoryElement Value { get; set; } + /// Value to be set. Could be a static value or Expression. + public Dictionary> PipelineReturnValues { get; set; } /// If set to true, it sets the pipeline run return value. public bool? SetSystemVariable { get; set; } } diff --git a/src/AzureDataFactory.TestingFramework/Models/Activities/SetVariableActivity/SetVariableActivity.cs b/src/AzureDataFactory.TestingFramework/Models/Activities/SetVariableActivity/SetVariableActivity.cs index 1f150aec..91f90d76 100644 --- a/src/AzureDataFactory.TestingFramework/Models/Activities/SetVariableActivity/SetVariableActivity.cs +++ b/src/AzureDataFactory.TestingFramework/Models/Activities/SetVariableActivity/SetVariableActivity.cs @@ -9,6 +9,10 @@ public override PipelineActivity Evaluate(PipelineRunState state) { base.Evaluate(state); + // If SetVariable is used for setting return values, local variables are ignored + if (VariableName == "pipelineReturnValue") + return this; + var existingVariable = state.Variables.SingleOrDefault(variable => variable.Name == VariableName) ?? throw new VariableBeingEvaluatedDoesNotExistException(VariableName); diff --git a/src/AzureDataFactory.TestingFramework/Shared/DataFactoryElementJsonConverter.cs b/src/AzureDataFactory.TestingFramework/Shared/DataFactoryElementJsonConverter.cs index 1e503968..fa6343b4 100644 --- a/src/AzureDataFactory.TestingFramework/Shared/DataFactoryElementJsonConverter.cs +++ b/src/AzureDataFactory.TestingFramework/Shared/DataFactoryElementJsonConverter.cs @@ -334,7 +334,21 @@ private static bool TryGetNonLiteral(JsonElement json, out DataFactoryElement // Expression should only have two properties: type and value return false; } - var expressionValue = json.GetProperty("value").GetString(); + + string expressionValue = null; + if (json.TryGetProperty("value", out var value)) + { + expressionValue = value.GetString(); + } + else if (json.TryGetProperty("content", out var content)) + { + expressionValue = content.GetString(); + } + else + { + throw new JsonException("Expression object does not have a value or content property."); + } + element = new DataFactoryElement(expressionValue, DataFactoryElementKind.Expression); } else