public static void LoadWithData(TCFolder folder) { TosCode.Connector.App app = new TosCode.Connector.App(); app.InitializeComponent(); app.Folder = folder; app.Run(); }
/// <summary> /// Migrates the Wse Module and all referencing XTestSteps. /// </summary> /// <param name="objectToExecuteOn">Only WSE XTestSteps and XModules which are present under this object will be migrated.</param> public void Migrate(TCObject objectToExecuteOn) { var wseTestSteps = CommonUtilities.GetFilteredWseTestSteps(objectToExecuteOn, wseModule.TestSteps); if (!wseTestSteps.Any()) { WseModuleParser wseParser = new WseModuleParser(); wseParser.Parse(wseModule); FolderStructureHandler folderStructureHandler = new FolderStructureHandler(); TCFolder apiModuleFolder = folderStructureHandler.CreateFolderForApiModules(wseModule); ApiModuleHandler.CreateApiModulePair(apiModuleFolder, wseModule.Name, wseParser); } else { foreach (var wseTestStep in wseTestSteps) { WseTestStepParser wseTestStepParser = new WseTestStepParser(); wseTestStepParser.Parse(wseTestStep, new XmlPayloadParser()); (ApiModule requestApiModule, ApiModule responseApiModule) = GetExistingOrCreateNewApiModulePair(objectToExecuteOn, wseTestStep, wseTestStepParser); WseTestStepMigrator wseTestStepMigrator = new WseTestStepMigrator(); wseTestStepMigrator.Migrate(objectToExecuteOn, requestApiModule, responseApiModule, new XmlPayloadParser(), new XmlPayloadSetterFactory(), wseTestStep); } } }
public override int ColumnSettingForDetailView(PersistableObject obj) { switch (obj.GetType().Name) { case "TCFolder": TCFolder folder = obj as TCFolder; if (folder != null) { TCFolderPolicy policy = folder.ContentPolicy; if (policy.OnlyTestCaseDesignAllowed) { return((int)ColumnsSetting.TestCaseDesign); } } break; default: if (obj.GetType().Assembly == this.GetType().Assembly) { return((int)ColumnsSetting.TestCaseDesign); } break; } return((int)ColumnsSetting.Unknown); }
/// <summary> /// Creates request module /// </summary> /// <param name="moduleFolder">Folder path reference to create Request module</param> /// <param name="name">Name of Request module</param> /// <param name="wseModuleParser">Contains transport information used to fill in Request Module</param> /// <param name="correlationId">Uniquely identify the Request Module</param> /// <returns></returns> public static ApiModule CreateRequestModule(TCFolder moduleFolder, string name, IWseArtifactsParser wseModuleParser, string correlationId) { //Module Properties ApiModule requestApiModule = SetModuleStandardProperties(moduleFolder, name, correlationId, ScanTag.GetRequestScanTag(wseModuleParser)); //Request Properties requestApiModule.AddTechnicalIdParam("Direction", Direction.Out.ToString()); requestApiModule.AddTechnicalIdParam("InactiveNodes", "Remove"); requestApiModule.AddTechnicalIdParam("IsRequest", "True"); requestApiModule.AddTechnicalIdParam("MessagesGenerated", "True"); requestApiModule.AddConfigurationParam("Executor", "HttpSend"); requestApiModule.AddTechnicalIdParam("Method", wseModuleParser.Method); requestApiModule.AddTechnicalIdParam("Endpoint", wseModuleParser.Endpoint); requestApiModule.AddTechnicalIdParam("Resource", wseModuleParser.Resource); requestApiModule.AddQueryParams(wseModuleParser.QueryParams); requestApiModule.AddPathParams(wseModuleParser.PathParams); requestApiModule.AddHeaders(wseModuleParser.Headers); if (!string.IsNullOrEmpty(wseModuleParser.RequestPayload)) { requestApiModule.APISetMessagePayload(wseModuleParser.RequestPayload); } return(requestApiModule); }
private void ThreadStart(object target) { TCFolder folder = target as TCFolder; var connector = new Connector(folder); var assemblyModels = connector.GenerateAssemblyModels(); var window = new MainWindow(assemblyModels); window.ShowDialog(); foreach (var assembly in window.Assemblies) { var matches = connector.MatchMethodModules(assembly.Model()); foreach (var match in matches) { match.MethodModel.FriendlyName = match.XModule.Name; match.MethodModel.IsSelected = true; } var assemblyFolder = GetOrCreateChildFolder(folder, assembly.Name); foreach (var cls in assembly.Classes) { var classFolder = GetOrCreateChildFolder(assemblyFolder, cls.Name); foreach (var method in cls.Methods.Where(x => x.IsSelected)) { //TODO: //Fix this matching algorithm if (!matches.Any(x => x.MethodModel.MethodName == method.Name)) { var module = CreateModule(assembly, cls, method, classFolder); } } } } }
static void Main(string[] args) { using (TCAPI tcapi = TCAPI.CreateInstance()) { TCWorkspace workspace = tcapi.OpenWorkspace( twsPath: @"C:\Users\estan\Desktop\trainings\TOSCA Customizations\Tosca Workspace\Training Customizations\Training Customizations.tws", loginName: "Admin", loginPassword: ""); TCProject project = workspace.GetProject(); TCFolder folder = project.CreateComponentFolder(); folder.Name = "Created folder With Script"; folder.EnsureUniqueName(); // workspace.Save(); List <TCObject> search_result = project.Search(tqlString: "=>SUBPARTS:TestCase[Name==\"Test\"]"); TestCase copyTestCase = (TestCase)search_result.First(); OwnedItem parentFolder = copyTestCase.ParentFolder; // parentFolder.CheckoutTree(); for (int i = 0; i < 10; i++) { parentFolder.Copy(copyTestCase); } //workspace.CheckInAll(""); workspace.Save(); Console.WriteLine(value: "Created folder and Test Cases Copied"); } }
private void btnCreate_Click(object sender, EventArgs e) { TCAPI.CreateInstance(new Tricentis.TCAPIObjects.TCAPIConnectionInfo()); TCWorkspace workspace = TCAPI.Instance.OpenWorkspace(txtPath.Text, txtUser.Text, txtPassword.Text); TCProject project = workspace.GetProject(); TestCase testCase = (TestCase)project.Search($"=>SUBPARTS:TestCase[Name==\"{txtTestCase.Text}\"]").FirstOrDefault(); if (testCase != null) { TCFolder executionListFolder = (TCFolder)project.Search("=>SUBPARTS:TCFolder[PossibleContent==\"Folder;ExecutionList\"]").First(); if (executionListFolder.IsTaskApplicable(TCTasks.Checkout)) { executionListFolder.Checkout(); } ExecutionList executionList = executionListFolder.CreateExecutionList(); executionList.Name = txtTestCase.Text; executionList.CreateExecutionEntry(testCase); if (executionListFolder.CheckOutState.Equals(CheckOutState.CheckedOut)) { workspace.CheckInAll("Execution list created from code!"); } workspace.Save(); MessageBox.Show("Execution list created successfully"); } else { MessageBox.Show("TestCase not found!"); } TCAPI.Instance.CloseWorkspace(); TCAPI.CloseInstance(); }
/// <summary> /// Creates response module /// </summary> /// <param name="moduleFolder">Folder path reference to create Response module</param> /// <param name="name">Name of Response module</param> /// <param name="wseModuleParser">Contains transport information used to fill in Response Module</param> /// <param name="correlationId">Uniquely identify the Response Module</param> /// <returns></returns> public static ApiModule CreateResponseModule(TCFolder moduleFolder, string name, IWseArtifactsParser wseModuleParser, string correlationId ) { //tosca specific properties ApiModule responseApiModule = SetModuleStandardProperties(moduleFolder, name, correlationId, ScanTag.GetResponseScanTag(wseModuleParser)); responseApiModule.AddTechnicalIdParam("Direction", Direction.In.ToString()); responseApiModule.AddTechnicalIdParam("InactiveNodes", "Keep"); responseApiModule.AddTechnicalIdParam("IsRequest", "False"); responseApiModule.AddConfigurationParam("Executor", "HttpReceive"); responseApiModule.AddHeaders(wseModuleParser.ResponseHeaders); responseApiModule.AddTechnicalIdParam("StatusCode", wseModuleParser.ResponseStatus); if (!string.IsNullOrEmpty(wseModuleParser.ResponsePayload)) { responseApiModule.APISetMessagePayload(wseModuleParser.ResponsePayload); } return(responseApiModule); }
static void Main(string[] args) { using (TCAPI tcapi = TCAPI.CreateInstance()) { TCWorkspace workspace = tcapi.OpenWorkspace(@"C:\Users\estan\Desktop\trainings\TOSCA Customizations\Tosca Workspace\Training Customizations\Training Customizations.tws", "Admin", ""); TCProject project = workspace.GetProject(); List <TCObject> result = project.Search($"=>SUBPARTS:TCFolder[UniqueId==\"{unique_id_test_case_folder}\"]"); TCFolder testCaseFolder = (TCFolder)result.First(); testCaseFolder.Checkout(); TestCase testCase = testCaseFolder.CreateTestCase(); testCase.Name = "Test Creating Test Case"; XModule tboxSetBuffer = (XModule)project.Search($"=>SUBPARTS:XModule[UniqueId==\"{unique_id_tbox_set_buffer}\"]").First(); XModule tboxWait = (XModule)project.Search($"=>SUBPARTS:XModule[UniqueId==\"{unique_id_tbox_wait}\"]").First(); XTestStep setBufferTestStep = testCase.CreateXTestStepFromXModule(tboxSetBuffer); XTestStepValue setBUfferStepvalue = setBufferTestStep.CreateXTestStepValue(tboxSetBuffer.Attributes.First()); setBUfferStepvalue.Name = "Test Buffer Creation"; setBUfferStepvalue.Value = "42"; setBUfferStepvalue.ActionMode = XTestStepActionMode.Input; XTestStep tboxSetWaitTimeStep = testCase.CreateXTestStepFromXModule(tboxWait); XTestStepValue tboxWaitSettimeStepValue = tboxSetWaitTimeStep.TestStepValues.First(); tboxWaitSettimeStepValue.Value = "500"; } }
public XModule SetupXModule(string windowTitle, TCFolder folder) { var newXModule = folder.CreateXModule(); if (windowTitle == "") { windowTitle = "HtmlDocument"; } newXModule.Name = windowTitle; newXModule.BusinessType = "HtmlDocument"; newXModule.InterfaceType = XModule_InterfaceTypeE.GUI; var engine = newXModule.CreateConfigurationParam(); engine.Name = "Engine"; engine.Value = "Html"; var title = newXModule.CreateTechnicalIDParam(); title.Name = "Title"; title.Value = windowTitle; return(newXModule); }
public static bool IsTaskPossible(TCFolder folder) { if (folder == null) { return(false); } return(true); }
private TCFolder GetOrCreateChildFolder(TCFolder parent, string name) { //TCFolder child = parent.AllOwnedSubItems.FirstOrDefault(x => x.Name == name) as TCFolder; //if(child == null) //{ // child = TCFolder.Create(parent.ContentPolicy); // child.ParentFolder.Set(parent); //} return(parent.GetOrCreateSubFolder(name, parent.ContentPolicy)); }
public override void GetTasks(PersistableObject obj, List <Tricentis.TCCore.Persistency.Task> tasks) { if (obj is TCFolder) { TCFolder fldr = (TCFolder)obj; if (fldr.PossibleContent.Contains("Module")) { tasks.Add(new SyncAssemblyTask()); } } }
public MainWindow(TCFolder folder) : base() { this.ToscaFolder = folder; this.IsInitialisedFromTosca = this.ToscaFolder != null; connector = new Connector(this.ToscaFolder); if (this.IsInitialisedFromTosca) { this.saveToTosca.Visibility = Visibility.Collapsed; } }
public override object Execute(PersistableObject obj, ITaskContext context) { TCFolder folder = obj as TCFolder; if (!IsTaskPossible(folder)) { return(null); } folder.Items.Clear(); GetBuffersFromSettings(folder); return(null); }
protected override void RunInMainThread() { TCFolder folder = this.Object as TCFolder; //var window = new MainWindow(); //window.ShowDialog(); ParameterizedThreadStart pts = new ParameterizedThreadStart(ThreadStart); Thread t = new Thread(ThreadStart); t.SetApartmentState(ApartmentState.STA); t.Start(folder); t.Join(); }
/// <summary> /// Identify location of existing WSE Modules and create generic folder for storing API modules /// </summary> /// <param name="wseModule">Xmodule of WSE Engine</param> /// <returns></returns> public TCFolder CreateFolderForApiModules(XModule wseModule) { TCFolder parentFolder = wseModule.ParentFolder as TCFolder; TCFolder apiFolder = parentFolder?.CreateFolder(); if (apiFolder != null) { apiFolder.Name = $"API_{wseModule.Name}"; apiFolder.EnsureUniqueName(); } return(apiFolder); }
static void Main(string[] args) { TCWorkspace myWorkspace = InitializeAPIAndOpenWorkSpace(); TCFolder root = GetRootFolderForExecLists(myWorkspace); if (root != null) { FileGenerator fg = new FileGenerator(root.Name, ToscaReportGenerator.Default.filenameXml, ToscaReportGenerator.Default.filenameXslt, ToscaReportGenerator.Default.foldername); fg.GetSubFolders(root); fg.GenerateXML(); } CloseWorkspaceAndAPI(); Console.ReadLine(); }
public override TCObject Execute(TCObject obj, List <TCObject> dropObjects, bool copy, TCAddOnTaskContext context) { TCFolder folder = obj as TCFolder; TestCase tc = folder.CreateTestCase(); tc.Name = "AddOn Drag-drop Test Cases"; foreach (TCObject objDrop in dropObjects) { TCFolder moduleFolder = objDrop as TCFolder; List <TCObject> modules = moduleFolder.Search("=>SUBPARTS:XModule"); tc.CreateXTestStepFromXModule(modules); } return(null); }
public override object Execute(PersistableObject obj, ITaskContext context) { TCFolder folder = obj as TCFolder; if (!IsTaskPossible(folder)) { return(null); } Buffer buffer = Buffer.Create(); buffer.Name = "Buffer"; folder.Items.Add(buffer); buffer.EnsureUniqueNameIfNecessary(); return(buffer); }
private static ApiModule SetModuleStandardProperties(TCFolder moduleFolder, string name, string correlationId, string scanTag) { ApiModule requestApiModule = moduleFolder.CreateApiModule(); requestApiModule.Name = name; requestApiModule.EnsureUniqueName(); requestApiModule.AddTechnicalIdParam("CorrelationId", correlationId); requestApiModule.AddTechnicalIdParam("Version", AddOnConstants.ToscaVersion); requestApiModule.AddConfigurationParam("Engine", "API"); requestApiModule.AddTechnicalIdParam("ScanTag", scanTag); return(requestApiModule); }
public override bool IsTaskPossible(TCObject obj) { TCFolder moduleFolder = obj as TCFolder; if (obj == null) { return(false); } if (moduleFolder.PossibleContent.Equals("Folder;Module") && ((TCFolder)obj).Search("=>SUBPARTS:XModule").Count > 0) { return(true); } return(false); }
public void GetSubFolders(TCFolder tcf) { Helper.Schrijf(tcf.Name, "GetSubFolders", 1); foreach (TCObject subitem in tcf.Items) { if (subitem is ExecutionList) { AddExecutionList(subitem); GetSubLists(subitem as ExecutionList); } if (subitem is TCFolder) { GetSubFolders(subitem as TCFolder); } } }
public override bool IsTaskPossible(TCObject obj) { try { if (obj is TCFolder) { TCFolder f = (TCFolder)obj; return(f.PossibleContent.Contains("Issue")); } return(false); } catch { return(base.IsTaskPossible(obj)); } }
/// <summary> /// Identify whether WSE XtestStepvalues(Request/Response) is using Web service request/response data in JSON Resource specialization /// Identify whether WSE XtestStepvalues(Request/Response) is using Web service request/response data in XML Resource specialization /// </summary> /// <param name="wseTestStep">Wse TestStep</param> /// <param name="tcFolder">Specialization Module</param> /// <returns>true if xmodule is using specialization</returns> public static bool IsUsingEmbeddedResource(XTestStep wseTestStep, out TCFolder tcFolder) { if (IsRequestIsUsingEmbeddedModule(wseTestStep, out XModule requestSpecializationModule)) { tcFolder = (TCFolder)requestSpecializationModule.ParentFolder; return(true); } if (IsResponseIsUsingEmbeddedModule(wseTestStep, out XModule responseSpecializationModule)) { tcFolder = (TCFolder)responseSpecializationModule.ParentFolder; return(true); } tcFolder = null; return(false); }
public override bool IsTaskPossible(TCObject targetObject, TCObject sourceObject) { TCFolder moduleFolder = sourceObject as TCFolder; TCFolder testCaseFolder = targetObject as TCFolder; if (moduleFolder == null || testCaseFolder == null) { return(false); } if (moduleFolder.PossibleContent.Equals("Folder;Module") && testCaseFolder.PossibleContent.Equals("Folder;TestCase")) { return(true); } return(false); }
private void GetBuffersFromSettings(TCFolder folder) { XDocument doc = XDocument.Load(@"C:\ProgramData\TRICENTIS\TOSCA Testsuite\7.0.0\Settings\XML\Settings.xml"); var bufferRoot = doc.Root.Descendants().FirstOrDefault(Helper.IsXmlBufferNode); if (bufferRoot == null) { return; } foreach (var element in bufferRoot.Elements()) { var buffer = CreateToscaBuffer(element); if (buffer != null) { folder.Items.Add(buffer); } } }
private (ApiModule requestApiModule, ApiModule responseApiModule) GetExistingOrCreateNewApiModulePair( TCObject objectToExecuteOn, XTestStep wseTestStep, IWseArtifactsParser wseParser) { ApiModule requestApiModule = null; ApiModule responseApiModule = null; (requestApiModule, responseApiModule) = CommonUtilities.SearchExistingApiModule(objectToExecuteOn, wseParser, wseTestStep); if (requestApiModule != null) { return(requestApiModule, responseApiModule); } FolderStructureHandler folderStructureHandler = new FolderStructureHandler(); TCFolder apiModuleFolder = folderStructureHandler.CreateFolderForApiModules(wseModule); return(ApiModuleHandler.CreateApiModulePair(apiModuleFolder, wseModule.Name, wseParser)); }
private static TCFolder GetRootFolderForExecLists(TCWorkspace myWorkspace) { //Retrieve the project TCProject project = myWorkspace.GetProject(); //SearchFor ExecutionListFolder TCFolder execListFolder = null; foreach (OwnedItem item in project.Items) { if (item.Name == EXLISTROOTNODE) { execListFolder = item as TCFolder; break; } } if (execListFolder == null) { Console.WriteLine("ExecutionList TopFolder was not found"); return(null); } TCFolder execStartFolder = null; foreach (OwnedItem subfolder in execListFolder.Items) { if (String.Equals(ToscaReportGenerator.Default.mainExList, subfolder.Name, StringComparison.InvariantCultureIgnoreCase)) { execStartFolder = subfolder as TCFolder; break; } } if (execStartFolder == null) { Console.WriteLine(String.Format("ExecutionFolder {0} was not found", ToscaReportGenerator.Default.mainExList)); return(null); } return(execStartFolder); }
/// <summary> /// Creates request and response module pair /// </summary> /// <param name="apiModuleFolder">Folder path reference to create Request and Response module</param> /// <param name="moduleName">Name of Request and Response module</param> /// <param name="wseParser">Contains transport information like Endpoint, Headers, Payload used to fill in Request and Response Module</param> /// <returns></returns> public static (ApiModule, ApiModule) CreateApiModulePair(TCFolder apiModuleFolder, string moduleName, IWseArtifactsParser wseParser ) { string correlationId = Guid.NewGuid().ToString(); ApiModule requestApiModule = CreateRequestModule(apiModuleFolder, moduleName, wseParser, correlationId ); ApiModule responseApiModule = CreateResponseModule(apiModuleFolder, $"{moduleName} Response", wseParser, correlationId ); return(requestApiModule, responseApiModule); }
private void AddExecutionEntries(TCFolder tf) { GetTCFolder(tf); foreach (ExecutionList el in lists) { AddExecutionEntries(el); } }
private void GetTCFolder(TCFolder tf) { foreach (OwnedItem oi in tf.Items) { if (oi is ExecutionList) { lists.Add(oi as ExecutionList); } if (oi is TCFolder) { GetTCFolder(oi as TCFolder); } } }