private void OpenEditLocalParamPossibleValuesPageButton_Click(object sender, RoutedEventArgs e) { AppModelParameter SelectedAMDP = (AppModelParameter)ModelParametersGrid.CurrentItem; ModelOptionalValuesPage MDPVP = new ModelOptionalValuesPage(SelectedAMDP); MDPVP.ShowAsWindow(); }
private void UpdateOptionalValues() { if (AAMB == null) { return; } foreach (EnhancedActInputValue EIV in mAct.APIModelParamsValue) { string value = EIV.Value; EIV.OptionalValues.Clear(); AppModelParameter AMP = AAMB.AppModelParameters.Where(x => x.Guid == EIV.ParamGuid).FirstOrDefault(); if (AMP != null) { foreach (OptionalValue OV in AMP.OptionalValuesList) { EIV.OptionalValues.Add(OV.Value); } } else { AppModelParameter AGMP = AAMB.GlobalAppModelParameters.Where(x => x.Guid == EIV.ParamGuid).FirstOrDefault(); if (AGMP != null) { foreach (OptionalValue OV in AGMP.OptionalValuesList) { EIV.OptionalValues.Add(OV.Value); } } } EIV.Value = value; } }
private void SetMergedOptionalValues(AppModelParameter mergedParam) { ObservableList <OptionalValue> mergedOptionalValuesList = new ObservableList <OptionalValue>(); foreach (AppModelParameter apiModelParam in ModelParametersGrid.Grid.SelectedItems) { foreach (OptionalValue paramOV in apiModelParam.OptionalValuesList) { if (mergedOptionalValuesList.Where(x => x.Value == paramOV.Value).FirstOrDefault() == null) { OptionalValue ov = new OptionalValue(); ov.Value = paramOV.Value; mergedOptionalValuesList.Add(ov); } } } if (mergedOptionalValuesList.Count > 0) { //Set Default optional value to be as the default from the first optional values list OptionalValue defaultOV = ((AppModelParameter)ModelParametersGrid.Grid.SelectedItems[0]).OptionalValuesList.Where(x => x.IsDefault == true).FirstOrDefault(); OptionalValue ovToSetAsDefault = mergedOptionalValuesList.Where(x => x.Value == defaultOV.Value).FirstOrDefault(); ovToSetAsDefault.IsDefault = true; } mergedParam.OptionalValuesList = mergedOptionalValuesList; }
private void AddParamsRow(object sender, RoutedEventArgs e) { AppModelParameter newAppModelParam = new AppModelParameter(); SetUniquePlaceHolderName(newAppModelParam); ParamsList.Add(newAppModelParam); }
public void SetUniquePlaceHolderName(AppModelParameter newAppModelParam) { newAppModelParam.PlaceHolder = "{NewPlaceHolder}"; if (ParamsList.Where(x => x.PlaceHolder == newAppModelParam.PlaceHolder).FirstOrDefault() == null) { return; } List <AppModelParameter> samePlaceHolderList = ParamsList.Where(x => x.PlaceHolder == newAppModelParam.PlaceHolder).ToList <AppModelParameter>(); if (samePlaceHolderList.Count == 1 && samePlaceHolderList[0] == newAppModelParam) { return; //Same internal object } //Set unique name int counter = 2; while ((ParamsList.Where(x => x.PlaceHolder == "{NewPlaceHolder_" + counter.ToString() + "}").FirstOrDefault()) != null) { counter++; } newAppModelParam.PlaceHolder = "{NewPlaceHolder_" + counter.ToString() + "}"; }
private void InitLocalParametersListForGrid() { AddModelOptionalValuesWizard.ParamsList = new ObservableList <AppModelParameter>(); foreach (AppModelParameter AMP in AddModelOptionalValuesWizard.mAAMB.AppModelParameters) { if (AddModelOptionalValuesWizard.SourceType == eSourceType.Excel || AddModelOptionalValuesWizard.SourceType == eSourceType.DB) { if (!AddModelOptionalValuesWizard.ParameterValuesByNameDic.ContainsKey(AMP.ItemName)) { continue; } } AppModelParameter temp = new AppModelParameter(AMP.PlaceHolder, AMP.Description, AMP.TagName, AMP.Path, new ObservableList <OptionalValue>()); AddModelOptionalValuesWizard.ParamsList.Add(temp); } foreach (var parm in AddModelOptionalValuesWizard.ParameterValuesByNameDic) { var item = AddModelOptionalValuesWizard.mAAMB.AppModelParameters.SingleOrDefault(x => x.Key.ItemName == parm.Key); if (item == null) { AppModelParameter temp = new AppModelParameter(); temp.Guid = Guid.NewGuid(); temp.ExecutionValue = string.Empty; temp.PlaceHolder = parm.Key; temp.Description = string.Empty; temp.OptionalValuesList = new ObservableList <OptionalValue>(); SetOptionalValueList(parm, temp); AddModelOptionalValuesWizard.ParamsList.Add(temp); } } }
/// <summary> /// This method will get the appparameters from the requestbody inputs /// </summary> /// <param name="aPIModel"></param> /// <param name="actInputs"></param> /// <returns></returns> private ObservableList <AppModelParameter> ParseParametersFromRequestBodyInputs(ApplicationAPIModel aPIModel, ObservableList <ActInputValue> actInputs) { ObservableList <AppModelParameter> lstParameters = new ObservableList <AppModelParameter>(); foreach (var inptVal in actInputs) { AppModelParameter param = new AppModelParameter(); param.ItemName = inptVal.ItemName; OptionalValue opVal = new OptionalValue() { Value = inptVal.Value, IsDefault = true }; param.OptionalValuesList = new ObservableList <OptionalValue>() { opVal }; lstParameters.Add(param); } foreach (var par in lstParameters) { if (!CheckParameterExistsIfExistsThenAddValues(aPIModel.AppModelParameters, par)) { aPIModel.AppModelParameters.Add(par); } } return(lstParameters); }
private void selectBtn_Click(object sender, RoutedEventArgs e) { SelectedParameter = (AppModelParameter)xModelParamSelectionGrid.Grid.SelectedItem; if (mGenericWindow != null) { mGenericWindow.Close(); } }
private void GridPathVEButton_Click(object sender, RoutedEventArgs e) { ModelExpectedValueParamSelectionPage ParamSelectionPage = new ModelExpectedValueParamSelectionPage(mApplicationAPIModel.MergedParamsList); AppModelParameter selectedParam = ParamSelectionPage.ShowAsWindow(); if (selectedParam != null) { ((ActReturnValue)xOutputValuesGrid.Grid.SelectedItem).Path = GetParamWithStringTemplate(selectedParam); } }
/// <summary> /// This method is used to set the optional value list /// </summary> /// <param name="parm"></param> /// <param name="temp"></param> private void SetOptionalValueList(ParameterValues parm, AppModelParameter temp) { if (parm.ParameterValuesByNameDic != null && parm.ParameterValuesByNameDic.Count > 0) { foreach (var val in parm.ParameterValuesByNameDic) { temp.OptionalValuesList.Add(new OptionalValue { Value = val }); } } }
/// <summary> /// Update optional values only for selected Local parameters according to DB\Excel file /// </summary> /// <param name="AAM"></param> /// <param name="SelectedParametersGridList"></param> public void PopulateExcelDBOptionalValuesForAPIParametersExcelDB(ApplicationAPIModel AAM, List <AppModelParameter> SelectedParametersGridList, Dictionary <string, List <string> > ParameterValuesByNameDic) { int UpdatedParameters = 0; bool IsUpdate; List <AppModelParameter> RelevantParameterList = new List <AppModelParameter>(); foreach (AppModelParameter prm in SelectedParametersGridList) { AppModelParameter pOriginal = AAM.AppModelParameters.FirstOrDefault(p => p.ItemName == prm.ItemName); if (pOriginal != null) { RelevantParameterList.Add(pOriginal); } } foreach (var tuple in SelectedParametersGridList.Zip(RelevantParameterList, (x, y) => (x, y))) { IsUpdate = false; if (tuple.x.RequiredAsInput)//selected { if (ParameterValuesByNameDic.ContainsKey(tuple.y.ItemName)) { string[] paramExistingvalues = tuple.y.OptionalValuesString.Split(',');; OptionalValue defaultValue = tuple.y.OptionalValuesList.FirstOrDefault(x => x.IsDefault); foreach (string val in ParameterValuesByNameDic[tuple.y.ItemName]) { bool ValueAlreadyExists = paramExistingvalues.Any(x => x == val); if ((paramExistingvalues != null && !ValueAlreadyExists) && (defaultValue == null || defaultValue.Value != val)) { OptionalValue OptionalValue = new OptionalValue() { Value = val }; if (tuple.y.OptionalValuesList.Count == 0) { OptionalValue.IsDefault = true; } tuple.y.OptionalValuesList.Add(OptionalValue); IsUpdate = true; } } } } if (IsUpdate) { UpdatedParameters++; } } if (ShowMessage) { Reporter.ToUser(eUserMsgKeys.ParameterOptionalValues, UpdatedParameters); } }
private void MergeSelectedParams(object sender, RoutedEventArgs e) { if (ModelParametersGrid.Grid.SelectedItems.Count < 1) { return; } string newParamName = ((AppModelParameter)ModelParametersGrid.Grid.SelectedItems[0]).PlaceHolder; if (InputBoxWindow.GetInputWithValidation("Merge Parameters", "Set Palceholder for Merged Parameters", ref newParamName, new char[0])) { //Create new Merged param AppModelParameter mergedParam = new AppModelParameter(); mergedParam.PlaceHolder = newParamName; //Merged optional values SetMergedOptionalValues(mergedParam); //Set Grid selected index int selctedIndex = ModelParametersGrid.Grid.SelectedIndex; List <string> placeHoldersToReplace = new List <string>(); //Save Placeholders and remove old params for merge, and add the new merged one List <AppModelParameter> tobeRemoved = new List <AppModelParameter>(); for (int i = 0; i < ModelParametersGrid.Grid.SelectedItems.Count; i++) { AppModelParameter paramToRemove = (AppModelParameter)ModelParametersGrid.Grid.SelectedItems[i]; placeHoldersToReplace.Add(paramToRemove.PlaceHolder); tobeRemoved.Add(paramToRemove); } foreach (AppModelParameter Removeit in tobeRemoved) { mAAMB.AppModelParameters.Remove(Removeit); } mAAMB.AppModelParameters.Add(mergedParam); GingerCore.General.DoEvents(); ModelParametersGrid.DataSourceList.Move(ModelParametersGrid.DataSourceList.Count - 1, selctedIndex); //Update all places with new placeholder merged param name //TODO: Fix with New Reporter (on GingerWPF) if (System.Windows.MessageBox.Show(string.Format("Do you want to update the merged instances on all model configurations?"), "Models Parameters Merge", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Warning, System.Windows.MessageBoxResult.No) == System.Windows.MessageBoxResult.Yes) { mAAMB.UpdateParamsPlaceholder(mAAMB, placeHoldersToReplace, newParamName); } } }
private void grdLocalParams_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { AppModelParameter CurrentAMDP = null; if (e.Column.Header.ToString() == GridPlaceholderHeader) { CurrentAMDP = (AppModelParameter)ModelParametersGrid.CurrentItem; if (CurrentAMDP != null && !IsParamPlaceholderNameConflict(CurrentAMDP)) { mApplicationModel.UpdateParamsPlaceholder(mApplicationModel, new List <string> { LocalParamValueBeforeEdit }, CurrentAMDP.PlaceHolder); } } }
private void MergeSelectedParams(object sender, RoutedEventArgs e) { if (ModelParametersGrid.Grid.SelectedItems.Count < 1) { return; } string newParamName = ((AppModelParameter)ModelParametersGrid.Grid.SelectedItems[0]).PlaceHolder; if (InputBoxWindow.GetInputWithValidation("Merge Parameters", "Set Placeholder for Merged Parameters", ref newParamName, new char[0])) { //Create new Merged param AppModelParameter mergedParam = new AppModelParameter(); mergedParam.PlaceHolder = newParamName; //Merged optional values SetMergedOptionalValues(mergedParam); //Set Grid selected index int selctedIndex = ModelParametersGrid.Grid.SelectedIndex; List <string> placeHoldersToReplace = new List <string>(); //Save Placeholders and remove old params for merge, and add the new merged one List <AppModelParameter> tobeRemoved = new List <AppModelParameter>(); for (int i = 0; i < ModelParametersGrid.Grid.SelectedItems.Count; i++) { AppModelParameter paramToRemove = (AppModelParameter)ModelParametersGrid.Grid.SelectedItems[i]; placeHoldersToReplace.Add(paramToRemove.PlaceHolder); tobeRemoved.Add(paramToRemove); } foreach (AppModelParameter Removeit in tobeRemoved) { mApplicationModel.AppModelParameters.Remove(Removeit); } mApplicationModel.AppModelParameters.Add(mergedParam); GingerCore.General.DoEvents(); ModelParametersGrid.DataSourceList.Move(ModelParametersGrid.DataSourceList.Count - 1, selctedIndex); //Update all places with new placeholder merged param name if (Reporter.ToUser(eUserMsgKeys.ParameterMerge) == Amdocs.Ginger.Common.MessageBoxResult.Yes) { mApplicationModel.UpdateParamsPlaceholder(mApplicationModel, placeHoldersToReplace, newParamName); } } }
private void InitLocalParametersListForGrid() { AddModelOptionalValuesWizard.ParamsList = new ObservableList <AppModelParameter>(); foreach (AppModelParameter AMP in AddModelOptionalValuesWizard.mAAMB.AppModelParameters) { if (AddModelOptionalValuesWizard.SourceType == eSourceType.Excel || AddModelOptionalValuesWizard.SourceType == eSourceType.DB) { if (!AddModelOptionalValuesWizard.ParameterValuesByNameDic.ContainsKey(AMP.ItemName)) { continue; } } AppModelParameter temp = new AppModelParameter(AMP.PlaceHolder, AMP.Description, AMP.TagName, AMP.Path, new ObservableList <OptionalValue>()); AddModelOptionalValuesWizard.ParamsList.Add(temp); } }
private void InitLocalParametersListForGrid() { AddModelOptionalValuesWizard.ParamsList = new ObservableList <AppModelParameter>(); foreach (AppModelParameter AMP in AddModelOptionalValuesWizard.mAAMB.AppModelParameters) { if (AddModelOptionalValuesWizard.SourceType == eSourceType.Excel || AddModelOptionalValuesWizard.SourceType == eSourceType.DB) { var item = AddModelOptionalValuesWizard.ParameterValues.FirstOrDefault(o => o.ParamName == AMP.ItemName); if (item == null) { continue; } } AppModelParameter temp = new AppModelParameter(AMP.PlaceHolder, AMP.Description, AMP.TagName, AMP.Path, new ObservableList <OptionalValue>()); AddModelOptionalValuesWizard.ParamsList.Add(temp); } foreach (var parm in AddModelOptionalValuesWizard.ParameterValues) { if (!AddModelOptionalValuesWizard.IsDefaultPresentInParameterValues(parm)) { AddModelOptionalValuesWizard.SetFirstDefaultValueInParameterValues(parm); } var item = AddModelOptionalValuesWizard.mAAMB.AppModelParameters.SingleOrDefault(x => x.Key.ItemName == parm.ParamName); if (item == null) { AppModelParameter temp = new AppModelParameter(); temp.Guid = Guid.NewGuid(); temp.ExecutionValue = string.Empty; temp.PlaceHolder = parm.ParamName; temp.Description = parm.Description; temp.OptionalValuesList = new ObservableList <OptionalValue>(); SetOptionalValueList(parm, temp); AddModelOptionalValuesWizard.ParamsList.Add(temp); } else { item.ItemName = parm.ParamName; item.Description = parm.Description; item.OptionalValuesList = new ObservableList <OptionalValue>(); SetOptionalValueList(parm, item); } } }
private void SetExecutionValue <T>(T param, ActWebAPIModel actWebAPIModel) { AppModelParameter p = param as AppModelParameter; EnhancedActInputValue enhanceInput = actWebAPIModel.APIModelParamsValue.Where(x => x.ParamGuid == p.Guid).FirstOrDefault(); if (enhanceInput != null) { p.ExecutionValue = enhanceInput.ValueForDriver; } else { p.ExecutionValue = p.GetDefaultValue(); } if (p is GlobalAppModelParameter && p.ExecutionValue.Equals(GlobalAppModelParameter.CURRENT_VALUE)) { p.ExecutionValue = ((GlobalAppModelParameter)p).CurrentValue; } }
/// <summary> /// Security Header Credentials Added /// </summary> /// <param name="SoapSecurityContent"></param> private void SetCredentialPlaceHolders(List <string> SoapSecurityContent) { for (int i = 1; i < SoapSecurityContent.Count; i++) { AppModelParameter newAppModelParam = new AppModelParameter(); if (page.ParamsList.Count == 0) { newAppModelParam.PlaceHolder = SoapSecurityContent.ElementAt(i); } else { if (page.ParamsList.Where(x => x.PlaceHolder.Equals(SoapSecurityContent.ElementAt(i))).Count() == 0) { newAppModelParam.PlaceHolder = SoapSecurityContent.ElementAt(i); } } page.ParamsList.Add(newAppModelParam); } }
private void PopulateOptionalValuesByTuple(AppModelParameter AMP, Dictionary <Tuple <string, string>, List <string> > OptionalValuesPerParameterDict, Tuple <string, string> tuple) { foreach (string Value in OptionalValuesPerParameterDict[tuple]) { OptionalValue OptionalValueExist = AMP.OptionalValuesList.Where(x => x.Value == Value).FirstOrDefault(); if (OptionalValueExist == null) { OptionalValue OptionalValue = new OptionalValue() { Value = Value }; if (!string.IsNullOrEmpty(Value)) { OptionalValue.IsDefault = true; } AMP.OptionalValuesList.Add(OptionalValue); } } }
private bool IsParamPlaceholderNameConflict(AppModelParameter CurrentAMDP) { foreach (AppModelParameter AMDP in mApplicationModel.AppModelParameters) { if (AMDP != CurrentAMDP && AMDP.PlaceHolder == CurrentAMDP.PlaceHolder) { CurrentAMDP.PlaceHolder = LocalParamValueBeforeEdit; Reporter.ToUser(eUserMsgKeys.SpecifyUniqueValue); return(true); } } foreach (AppModelParameter GAMDP in mApplicationModel.GlobalAppModelParameters) { if (GAMDP != CurrentAMDP && GAMDP.PlaceHolder == CurrentAMDP.PlaceHolder) { CurrentAMDP.PlaceHolder = LocalParamValueBeforeEdit; Reporter.ToUser(eUserMsgKeys.SpecifyUniqueValue); return(true); } } return(false); }
private void UploadToGlobalParam(object sender, RoutedEventArgs e) { AppModelParameter CurrentAMDP = (AppModelParameter)ModelParametersGrid.CurrentItem; GlobalAppModelParameter globalAppModelParameter = GlobalAppModelParameter.DuplicateAppModelParamAsGlobal(CurrentAMDP); ObservableList <GlobalAppModelParameter> ModelsGlobalParamsList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <GlobalAppModelParameter>(); foreach (GlobalAppModelParameter GAMDP in ModelsGlobalParamsList) { if (GAMDP != globalAppModelParameter && GAMDP.PlaceHolder == CurrentAMDP.PlaceHolder) { Reporter.ToUser(eUserMsgKeys.ParameterAlreadyExists, "Global Model Parameters already contains a parameter Place Holder with the same value"); return; } } mApplicationModel.AppModelParameters.Remove(CurrentAMDP); WorkSpace.Instance.SolutionRepository.AddRepositoryItem(globalAppModelParameter); AddGlobalParametertoAPIGlobalParameterList(mApplicationModel.GlobalAppModelParameters, globalAppModelParameter); }
private void UploadToGlobalParam(object sender, RoutedEventArgs e) { AppModelParameter CurrentAMDP = (AppModelParameter)ModelParametersGrid.CurrentItem; GlobalAppModelParameter globalAppModelParameter = GlobalAppModelParameter.DuplicateAppModelParamAsGlobal(CurrentAMDP); ObservableList <GlobalAppModelParameter> ModelsGlobalParamsList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <GlobalAppModelParameter>(); foreach (GlobalAppModelParameter GAMDP in ModelsGlobalParamsList) { if (GAMDP != globalAppModelParameter && GAMDP.PlaceHolder == CurrentAMDP.PlaceHolder) { MessageBox.Show("Global Model Parameters allready contains a parameter Place Holder with the same value", "Cannot upload the selected parameter", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning, System.Windows.MessageBoxResult.OK); return; } } mAAMB.AppModelParameters.Remove(CurrentAMDP); WorkSpace.Instance.SolutionRepository.AddRepositoryItem(globalAppModelParameter); AddGlobalParametertoAPIGlobalParameterList(mAAMB.GlobalAppModelParameters, globalAppModelParameter); }
public ModelOptionalValuesPage(AppModelParameter AMDP, bool selectionModePage = false) { InitializeComponent(); mAMDP = AMDP; mSelectionModePage = selectionModePage; OptionalValuesGrid.DataSourceList = mAMDP.OptionalValuesList; SetOptionalValuesGridView(); if (!mSelectionModePage) { mAMDP.PropertyChanged += mAMDP_PropertyChanged; OptionalValuesGrid.btnAdd.AddHandler(Button.ClickEvent, new RoutedEventHandler(AddOptionalValue)); OptionalValuesGrid.SetbtnDeleteHandler(btnDelete_Click); OptionalValuesGrid.SetbtnClearAllHandler(btnClearAll_Click); OptionalValuesGrid.btnCopy.AddHandler(Button.ClickEvent, new RoutedEventHandler(BtnCopyClicked)); OptionalValuesGrid.btnCut.AddHandler(Button.ClickEvent, new RoutedEventHandler(BtnCopyClicked)); OptionalValuesGrid.btnPaste.AddHandler(Button.ClickEvent, new RoutedEventHandler(BtnPastClicked)); } this.Title = AMDP.PlaceHolder + " " + "Optional Values:"; }
private bool IsParamPlaceholderNameConflict(AppModelParameter CurrentAMDP) { foreach (AppModelParameter AMDP in mAAMB.AppModelParameters) { if (AMDP != CurrentAMDP && AMDP.PlaceHolder == CurrentAMDP.PlaceHolder) { CurrentAMDP.PlaceHolder = LocalParamValueBeforeEdit; System.Windows.MessageBox.Show("Please specify unique value", "Optional Value Already Exists", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning, System.Windows.MessageBoxResult.OK); return(true); } } foreach (AppModelParameter GAMDP in mAAMB.GlobalAppModelParameters) { if (GAMDP != CurrentAMDP && GAMDP.PlaceHolder == CurrentAMDP.PlaceHolder) { CurrentAMDP.PlaceHolder = LocalParamValueBeforeEdit; System.Windows.MessageBox.Show("Please specify unique value", "Optional Value Already Exists", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning, System.Windows.MessageBoxResult.OK); return(true); } } return(false); }
/// <summary> /// This method is used to set the optional value list /// </summary> /// <param name="parm"></param> /// <param name="temp"></param> private void SetOptionalValueList(KeyValuePair <string, List <string> > parm, AppModelParameter temp) { if (parm.Value != null && parm.Value.Count > 0) { foreach (var val in parm.Value) { temp.OptionalValuesList.Add(new OptionalValue { Value = val }); } } }
private void CloseWinClicked(object sender, EventArgs e) { SelectedParameter = null; mGenericWindow.Close(); }
/// <summary> /// This method is used to check if the Parameter exists in the model, if exists then add the values to model parameter /// </summary> /// <param name="lstParameters"></param> /// <param name="param"></param> /// <returns></returns> private bool CheckParameterExistsIfExistsThenAddValues(ObservableList <AppModelParameter> lstParameters, AppModelParameter param) { bool isExists = false; foreach (var item in lstParameters) { if (item.ItemName.Contains(param.ItemName)) { isExists = true; foreach (var val in param.OptionalValuesList) { var paramOptionalValue = item.OptionalValuesList.Where(x => x.Value == val.Value).FirstOrDefault(); if (!string.IsNullOrEmpty(Convert.ToString(val.Value)) && Convert.ToString(val.Value) != "?" && (paramOptionalValue == null || paramOptionalValue.Value != val.Value)) { item.OptionalValuesList.Add(val); } } break; } } return(isExists); }
public void APIParsingSavingAndPulling() { // Arrange //Act ApplicationAPIModel AAMS1 = new ApplicationAPIModel(); AAMS1.Name = "Soap1"; AAMS1.Description = "Description"; AAMS1.EndpointURL = "EndpointURL"; AAMS1.ReqHttpVersion = ApplicationAPIUtils.eHttpVersion.HTTPV10; AppModelParameter AMDP = new AppModelParameter() { PlaceHolder = "placeholder", Description = "Description" }; OptionalValue OV1 = new OptionalValue("Value1"); OptionalValue OV2 = new OptionalValue("Value2"); AMDP.OptionalValuesList.Add(OV1); AMDP.OptionalValuesList.Add(OV2); AAMS1.AppModelParameters = new ObservableList <AppModelParameter>(); AAMS1.AppModelParameters.Add(AMDP); APIModelKeyValue AMKV = new APIModelKeyValue("param", "value"); //AAMS1.APIModelKeyValueHeaders = new ObservableList<APIModelKeyValue>(); //AAMS1.APIModelKeyValueHeaders.Add(AMKV); AAMS1.NetworkCredentials = ApplicationAPIUtils.eNetworkCredentials.Custom; AAMS1.URLUser = "******"; AAMS1.URLDomain = "URLDomain"; AAMS1.URLPass = "******"; AAMS1.DoNotFailActionOnBadRespose = true; AAMS1.HttpHeaders = new ObservableList <APIModelKeyValue>(); AAMS1.HttpHeaders.Add(AMKV); AAMS1.RequestBodyType = ApplicationAPIUtils.eRequestBodyType.FreeText; AAMS1.CertificateType = ApplicationAPIUtils.eCretificateType.AllSSL; AAMS1.CertificatePath = "CertificatePath"; AAMS1.ImportCetificateFile = true; AAMS1.CertificatePassword = "******"; AAMS1.SecurityType = ApplicationAPIUtils.eSercurityType.Ssl3; AAMS1.AuthorizationType = ApplicationAPIUtils.eAuthType.BasicAuthentication; AAMS1.TemplateFileNameFileBrowser = "TemplateFileNameFileBrowser"; AAMS1.ImportRequestFile = "ImportRequestFile"; AAMS1.AuthUsername = "******"; AAMS1.AuthPassword = "******"; //APIParameter APIP = new APIParameter("parameterName", "parameterType", 1, 2); //AAMS1.ParametersList = new ObservableList<APIParameter>(); //AAMS1.ParametersList.Add(APIP); AAMS1.SOAPAction = "SOAPAction"; SR.AddRepositoryItem(AAMS1); //SR.ClearRepositoryItemsCache<ApplicationAPIModel>(); //TODO: we need to make sure this test run as stand alone or it will mess other UT ObservableList <ApplicationAPIModel> AAMBList = SR.GetAllRepositoryItems <ApplicationAPIModel>(); ApplicationAPIModel AAMS2 = (ApplicationAPIModel)(from x in AAMBList where x.Guid == AAMS1.Guid select x).FirstOrDefault(); // TODO: change 'Value Check' to the name of the field //Assert Assert.AreEqual(AAMS2.Name, "Soap1", "Value Check"); Assert.AreEqual(AAMS2.Description, "Description", "Value Check"); Assert.AreEqual(AAMS2.EndpointURL, "EndpointURL", "Value Check"); Assert.AreEqual(AAMS2.ReqHttpVersion, ApplicationAPIUtils.eHttpVersion.HTTPV10, "Value Check"); Assert.AreEqual(AAMS2.AppModelParameters.Count, 1, "Value Check"); Assert.AreEqual(AAMS2.AppModelParameters[0].OptionalValuesList.Count, 2, "Value Check"); //Assert.AreEqual(AAMS2.APIModelKeyValueHeaders.Count, 1, "Value Check"); Assert.AreEqual(AAMS2.NetworkCredentials, ApplicationAPIUtils.eNetworkCredentials.Custom, "Value Check"); Assert.AreEqual(AAMS2.URLUser, "URLUser", "Value Check"); Assert.AreEqual(AAMS2.URLDomain, "URLDomain", "Value Check"); Assert.AreEqual(AAMS2.URLPass, "URLPass", "Value Check"); Assert.AreEqual(AAMS2.DoNotFailActionOnBadRespose, true, "Value Check"); Assert.AreEqual(AAMS2.HttpHeaders.Count, 1, "Value Check"); Assert.AreEqual(AAMS2.RequestBodyType, ApplicationAPIUtils.eRequestBodyType.FreeText, "Value Check"); Assert.AreEqual(AAMS2.CertificateType, ApplicationAPIUtils.eCretificateType.AllSSL, "Value Check"); Assert.AreEqual(AAMS2.CertificatePath, "CertificatePath", "Value Check"); Assert.AreEqual(AAMS2.ImportCetificateFile, true, "Value Check"); Assert.AreEqual(AAMS2.CertificatePassword, "CertificatePassword", "Value Check"); Assert.AreEqual(AAMS2.SecurityType, ApplicationAPIUtils.eSercurityType.Ssl3, "Value Check"); Assert.AreEqual(AAMS2.AuthorizationType, ApplicationAPIUtils.eAuthType.BasicAuthentication, "Value Check"); Assert.AreEqual(AAMS2.TemplateFileNameFileBrowser, "TemplateFileNameFileBrowser", "Value Check"); Assert.AreEqual(AAMS2.ImportRequestFile, "ImportRequestFile", "Value Check"); Assert.AreEqual(AAMS2.AuthUsername, "AuthUsername", "Value Check"); Assert.AreEqual(AAMS2.AuthPassword, "AuthPassword", "Value Check"); //Assert.AreEqual(AAMS2.ParametersList.Count, 1, "Value Check"); Assert.AreEqual(AAMS2.SOAPAction, "SOAPAction", "Value Check"); }
private string GetParamWithStringTemplate(AppModelParameter param) { return("{AppModelParam Name = " + param.PlaceHolder + "}"); }