/// <summary> /// Creates Module Attribute /// </summary> /// <param name="apiModule">ApiModule</param> /// <param name="name"> Name of the Module Attribute</param> /// <param name="valueRange">ValueRange of the Module Attribute</param> /// <param name="value">Default value of the Module Attribute</param> /// <param name="pathType">pathType of the Module Attribute</param> /// <param name="path">path of the Module Attribute</param> /// <param name="actionMode">Default ActionMode of the Module Attribute</param> /// <param name="dataType">Data Type of the Module Attribute</param> /// <returns>Module Attribute</returns> public static XModuleAttribute CreateModuleAttribute(this ApiModule apiModule, string name, string valueRange, string value, string pathType, string path, XTestStepActionMode actionMode = XTestStepActionMode.Verify, ModuleAttributeDataType dataType = ModuleAttributeDataType.String) { XModuleAttribute xModuleAttribute = apiModule.CreateModuleAttribute(); xModuleAttribute.Name = name; xModuleAttribute.DefaultValue = value; if (!string.IsNullOrEmpty(valueRange)) { xModuleAttribute.ValueRange = valueRange; } xModuleAttribute.EnsureUniqueName(); xModuleAttribute.AddXParamToModuleAttribute("PathType", pathType, ParamTypeE.TechnicalID); xModuleAttribute.AddXParamToModuleAttribute("Path", path, ParamTypeE.TechnicalID); xModuleAttribute.AddXParamToModuleAttribute("ExplicitName", "True", ParamTypeE.Configuration); xModuleAttribute.DefaultActionMode = actionMode; xModuleAttribute.DefaultDataType = dataType; return(xModuleAttribute); }
/// <summary> /// Creates and set module attributes at module and teststep /// </summary> /// <param name="wseTestStepValue">TestStepValues of WSE Teststep</param> /// <param name="tcPath">XPath and JsonPath for xml and Json respectively</param> /// <param name="xModule">xModule and xModuleAttribute of ApiEngine</param> /// <param name="xModuleDemo">ApiModule</param> /// <param name="parameterPathType">Enum which define creation of xml and json moduleattributes</param> /// <param name="parentTest">TestStep and TestStepValues for ApiTestStep</param> /// <param name="cardinality">Cardinality of WSE XModule</param> /// <param name="isArray">True if Wse Xmodule attributes is array</param> /// <returns></returns> public static XTestStepValue CreateBusinessParameterInTosca(XTestStepValue wseTestStepValue, string tcPath, dynamic xModule, ApiModule xModuleDemo, BusinessParameterPathTypes parameterPathType, dynamic parentTest, string cardinality, bool isArray) { string businessParameterName = wseTestStepValue.Name; string businessParameterValue = wseTestStepValue.Value == "{NULL}" ? string.Empty : wseTestStepValue.Value; XTestStepActionMode xTestStepActionMode = wseTestStepValue.ActionModeToUse; ModuleAttributeDataType attributeDataType = wseTestStepValue.DataType; var mAttributes = xModuleDemo.Search("=>SUBPARTS:XModuleAttribute").Cast <XModuleAttribute>(); XModuleAttribute xModuleAttribute = GetExistingXModuleAttribute(mAttributes, tcPath, parameterPathType); if (xModuleAttribute != null) { if (!string.IsNullOrEmpty(xModuleAttribute.ValueRange)) { if (!xModuleAttribute.ValueRange.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) .Contains(businessParameterValue)) { xModuleAttribute.ValueRange = $"{xModuleAttribute.ValueRange};{businessParameterValue}"; } } else { xModuleAttribute.ValueRange = $"{businessParameterValue}"; } } else { xModuleAttribute = xModule.CreateModuleAttribute(); xModuleAttribute.Name = businessParameterName; xModuleAttribute.AddXParamToModuleAttribute("PathType", parameterPathType == BusinessParameterPathTypes.XPATH ? "XPath" : parameterPathType == BusinessParameterPathTypes.JSONPATH ? "JsonPath" : "", ParamTypeE.TechnicalID); xModuleAttribute.AddXParamToModuleAttribute("Path", tcPath, ParamTypeE.TechnicalID); xModuleAttribute.AddXParamToModuleAttribute("ExplicitName", "True", ParamTypeE.Configuration); xModuleAttribute.DefaultActionMode = xTestStepActionMode; xModuleAttribute.DefaultDataType = wseTestStepValue.ModuleAttribute.DefaultDataType; xModuleAttribute.DefaultValue = wseTestStepValue.ModuleAttribute?.DefaultValue == "{NULL}" ? string.Empty : wseTestStepValue.ModuleAttribute?.DefaultValue; xModuleAttribute.ValueRange = $"{businessParameterValue}"; xModuleAttribute.Cardinality = isArray ? "0-N" : cardinality; xModuleAttribute.EnsureUniqueName(); } XTestStepValue testStepValue = parentTest.CreateXTestStepValue(xModuleAttribute); testStepValue.ActionProperty = wseTestStepValue.ActionProperty; testStepValue.Operator = wseTestStepValue.Operator; testStepValue.Value = wseTestStepValue.Value; testStepValue.ActionMode = xTestStepActionMode; testStepValue.DataType = attributeDataType; testStepValue.Disabled = wseTestStepValue.Disabled; SetConstraintIndexProperty(wseTestStepValue, testStepValue); return(testStepValue); }