public void SetTargetPort_ShouldChangePropertiesAndTriggerEvent() { // Arrange var link = new TestLink(sourcePort: new PortModel(null), targetPort: null); var parent = new NodeModel(); var tp = new PortModel(parent); var eventsTriggered = 0; PortModel oldTp = null; PortModel newTp = null; BaseLinkModel linkInstance = null; // Act link.TargetPortChanged += (l, o, n) => { eventsTriggered++; linkInstance = l; oldTp = o; newTp = n; }; link.SetTargetPort(tp); // Assert eventsTriggered.Should().Be(1); link.TargetPort.Should().BeSameAs(tp); oldTp.Should().BeNull(); newTp.Should().BeSameAs(tp); linkInstance.Should().BeSameAs(link); link.TargetNode.Should().BeSameAs(parent); }
private TestLinkReport() { var apiKey = ConfigurationManager.AppSettings["apiKey"]; var testLinkUrl = ConfigurationManager.AppSettings["testLinkUrl"]; _testLink = new TestLink(apiKey, testLinkUrl); }
public TestLinkUtil(String apiKey, String url, bool log, int testPlanId, int buildVersion) { testLink = new TestLink(apiKey, url, log); _testPlanId = testPlanId; _buildVersion = buildVersion; }
public static bool ReportarCasoDePrueba(string urlTestlink, string keyTestlink, int idTestCaseInterno, int idTestCaseExterno, int idTestPlan, bool paso, int idBuild, string nombreBuild, string mensaje, int idPlataforma, string nombrePlataforma) { bool seEjecuto = false; try { var testlinkApi = new TestLink(keyTestlink, urlTestlink); testlinkApi.ReportTCResult( idTestCaseInterno, idTestPlan, paso ? TestCaseStatus.Passed : TestCaseStatus.Failed, idPlataforma, nombrePlataforma, false, true, mensaje, idBuild, 0); } catch (Exception e) { Console.WriteLine(e.Message); } return(seEjecuto); }
public void shouldFailBecauseOfNullDevKey() { proxy = new TestLink(null, testlinkUrl); var tcidList = proxy.GetTestCaseIDByName("10 G shock"); Assert.Catch <XmlRpcServerException>(() => proxy.SayHello()); Assert.Fail("Did not cause an exception"); }
public void Check_Single_Addition_Works(int firstNumber, int secondNumber, int expectedResult) { TestLink testLinkEngine = new TestLink(); var result = testLinkEngine.SimpleAddition(firstNumber, secondNumber); Assert.Equal(result, expectedResult); }
public void shouldFailBecauseOfInvalidURL() { proxy = new TestLink(apiKey, "http://localhost/testlink/api/xmlrpc.php"); string result = proxy.SayHello(); Assert.AreNotEqual("Hello!", result, "Unexpected Server Response"); Assert.Fail("Did not cause an exception"); }
public TestLinkUtil() { _testPlanId = Int32.Parse(AppConfig.GetValue("TestLinkTestPlanId")); _buildVersion = Int32.Parse(AppConfig.GetValue("TestLinkBuildId")); TestLinkUrl = AppConfig.GetValue("TestLinkUrl"); TestLinkApiKey = AppConfig.GetValue("TestLinkApiKey"); testLink = new TestLink(TestLinkApiKey, TestLinkUrl, true); }
public void shouldFailBecauseOfNullDevKey() { proxy = new TestLink(null, targetDBUrl); List <TestCaseId> tcidList = proxy.GetTestCaseIDByName("10 G shock"); string result = proxy.SayHello(); Assert.AreNotEqual("Hello!", result, "Unexpected Server Response"); Assert.Fail("Did not cause an exception"); }
public void ThenTheLinkisAddedtoTheCollection() { // arrange var testLink = new TestLink(); // act _sut.AddOrUpdateLink(testLink); // assert _sut.Links.Should().Contain(testLink); }
public async Task <bool> UpdateTestLink(TestLink entity) { try { _dataRepositories.TestLinkRepository.Edit(entity); _dataRepositories.TestLinkRepository.Save(); return(await Task.FromResult(true)); } catch (Exception e) { throw new Exception(e.Message); } }
public void ThenTheLinkisUpdatedWhenAlinkOfTheSameTypeAlreadyExistsInTheCollection() { // arrange _sut.AddOrUpdateLink(new TestLink()); _sut.Links.Count.Should().Be(1); var testLink = new TestLink(); // act _sut.AddOrUpdateLink(testLink); // assert _sut.Links.Count.Should().Be(1); _sut.Links.Should().Contain(testLink); }
//[HttpPut] public async Task <bool> Put(Guid id, TestLink testlink) { var result = await _dataServices.TestLinkService.UpdateTestLink(testlink); if (!result) { return(await Task.Run(() => false)); } //SignalR Methods Update var context = GlobalHost.ConnectionManager.GetHubContext <TestLinkHub>(); context.Clients.All.UpdateTestLink(testlink); var task = Task.Run(() => true); return(await task); }
public async Task <Guid?> Post(TestLink testlink) { var result = await _dataServices.TestLinkService.CreateTestLink(testlink); if (!result) { return(null); } //SignalR Methods Add Element var context = GlobalHost.ConnectionManager.GetHubContext <TestLinkHub>(); context.Clients.All.AddTestLink(testlink); var task = Task.Run(() => testlink.TestLinkId); return(await task); }
/// <summary> /// create the basic connection and test it out /// </summary> /// <param name="devKey"></param> /// <param name="url"></param> /// <returns>true if the connection is valid</returns> private bool basicConnection(string devKey, string url) { lastException = null; proxy = new TestLink(connectionData.DevKey, connectionData.Url); AllTestPlans = new List <TestPlan>(); try { allProjects = proxy.GetProjects(); } catch (TestLinkException tlex) { lastException = tlex; Console.WriteLine("Failed to connect to TestLink at {1}. Message was '{0}'", tlex.Message, url); return(false); } return(true); }
protected void TestLinkInitialize() { try { tl = new TestLink("f71e80e4c23bba99dfedf1b442bb42f5", "http://172.30.2.44/testlink/lib/api/xmlrpc.php"); testPlanId = tl.getTestPlanByName(ProjectName, PlanName).id; if (tl.GetBuildsForTestPlan(testPlanId).FirstOrDefault(x => x.name == buildName) == null) { tl.CreateBuild(testPlanId, buildName, "Build created by script"); } buildId = tl.GetBuildsForTestPlan(testPlanId).FirstOrDefault(x => x.name == buildName).id; } catch (Exception ex) { // } }
public async Task <bool> CreateTestLink(TestLink entity) { try { var result = false; _dataRepositories.TestLinkRepository.Add(entity); _dataRepositories.TestLinkRepository.Save(); if (entity.TestLinkId != Guid.NewGuid()) { result = true; } //entity.BusinessUnit = // Task.Run(async () => await _dataRepositories.BusinessUnitRepository.GetById(entity.BusinessUnitId)) // .Result; return(await Task.FromResult(result)); } catch (Exception e) { throw new Exception(e.Message); } }
protected void TestLinkInitialize() { try { Tl = new TestLink("f71e80e4c23bba99dfedf1b442bb42f5", "http://172.30.2.44/testlink/lib/api/xmlrpc.php"); TestPlanId = Tl.getTestPlanByName(Configs.ProjectName, Configs.PlanName).id; if (Tl.GetBuildsForTestPlan(TestPlanId).FirstOrDefault(x => x.name == Configs.BuildName) == null) { Tl.CreateBuild(TestPlanId, Configs.BuildName, "Build created by script"); } Build firstOrDefault = Tl.GetBuildsForTestPlan(TestPlanId).FirstOrDefault(x => x.name == Configs.BuildName); if (firstOrDefault != null) { BuildId = firstOrDefault.id; } } catch { // } }
/// <summary> /// 添加网络路由 /// </summary> /// <param name="dicParams">取到的系统参数</param> /// <returns>返回添加结果</returns> private bool AddNetWorkRoute(List <MSysDicItemInfo> dicParams) { bool result = false; TestLink link = new TestLink(); try { ////先获取默认网关 string defaultGateWay = link.GetDefaultGateWay(); foreach (var dicParam in dicParams) { if (!string.IsNullOrEmpty(defaultGateWay)) { List <string> temp = dicParam.ParaValue.Split('|').ToList(); //////取到网关,添加路由 string addRouteResult = link.AddNetWorkRoute(temp[0], temp[1], defaultGateWay); if (addRouteResult.Contains("操作完成") || addRouteResult.Contains("对象已存在")) { result = true; } } else { result = false; } } } catch (Exception ex) { MessagePipe.ExcuteWriteMessageEvent("添加路由出现异常" + ex.Message.ToString(), Color.Red, true); result = false; } return(result); }
/// <summary> /// Imports test cases and associated steps /// </summary> private void ImportTestCasesAndSteps(StreamWriter streamWriter, SpiraSoapService.SoapServiceClient spiraClient, TestLink testLinkApi) { //Loop through all the mapped, imported test suites foreach (KeyValuePair <int, int> kvp in this.testSuiteMapping) { //Get the test cases from the TestLink API int testSuiteId = kvp.Key; int testFolderId = kvp.Value; streamWriter.WriteLine(String.Format("Getting test cases in test suite: {0}", testSuiteId)); List <TestCaseFromTestSuite> testCasesInSuite = testLinkApi.GetTestCasesForTestSuite(testSuiteId, true); if (testCasesInSuite != null) { foreach (TestCaseFromTestSuite testCaseInSuite in testCasesInSuite) { //Extract the user data int tlTestCaseId = testCaseInSuite.id; string tlTestCaseExternalId = testCaseInSuite.external_id; streamWriter.WriteLine(String.Format("Finding test case: {0} - {1}", tlTestCaseId, tlTestCaseExternalId)); //Get the actual test case object (with steps) try { TestCase testCase = testLinkApi.GetTestCase(tlTestCaseId); if (testCase != null) { streamWriter.WriteLine(String.Format("Importing test case: {0}", tlTestCaseId)); string description = ""; if (!String.IsNullOrEmpty(testCase.summary)) { description += "<p>" + testCase.summary + "</p>"; } if (!String.IsNullOrEmpty(testCase.preconditions)) { description += "<p>" + testCase.preconditions + "</p>"; } //Reauthenticate at this point, in case disconnected spiraClient.Connection_Authenticate2(Properties.Settings.Default.SpiraUserName, Properties.Settings.Default.SpiraPassword, "TestLinkImporter"); spiraClient.Connection_ConnectToProject(this.newProjectId); //Create the new SpiraTest test case RemoteTestCase remoteTestCase = new RemoteTestCase(); remoteTestCase.Name = testCase.name; remoteTestCase.Description = description; remoteTestCase.TestCaseTypeId = /* Functional */ 3; remoteTestCase.TestCaseStatusId = (testCase.active) ? /* Ready For Test */ 5 : /* Draft*/ 1; remoteTestCase.CreationDate = testCase.creation_ts; if (testCase.importance >= 1 && testCase.importance <= 4) { remoteTestCase.TestCasePriorityId = testCase.importance; } //We don't import the author currently //remoteTestCase.AuthorId = this.usersMapping[createdById.Value]; //Map to the folder remoteTestCase.TestCaseFolderId = testFolderId; int newTestCaseId = spiraClient.TestCase_Create(remoteTestCase).TestCaseId.Value; streamWriter.WriteLine("Added test case: " + tlTestCaseId); //See if we have any test steps for this test case if (testCase.steps != null && testCase.steps.Count > 0) { streamWriter.WriteLine("Adding " + testCase.steps.Count + " test steps to test case: " + tlTestCaseId); foreach (TestStep testStep in testCase.steps) { RemoteTestStep remoteTestStep = new RemoteTestStep(); remoteTestStep.Description = testStep.actions; remoteTestStep.ExpectedResult = testStep.expected_results; spiraClient.TestCase_AddStep(remoteTestStep, newTestCaseId); } streamWriter.WriteLine("Added test steps to test case: " + tlTestCaseId); } //Add to the mapping hashtables if (!this.testCaseMapping.ContainsKey(tlTestCaseId)) { this.testCaseMapping.Add(tlTestCaseId, newTestCaseId); } } } catch (Exception ex) { streamWriter.WriteLine(String.Format("Error importing test case {0}: {1} ({2})", tlTestCaseId, ex.Message, ex.StackTrace)); } } } } }
private void ImportProject(StreamWriter streamWriter, SpiraSoapService.SoapServiceClient spiraClient, TestLink testLinkApi) { try { streamWriter.WriteLine(String.Format("Importing Test Link project '{0}' to Spira...", this.testLinkProjectName)); //Get the project info from the TestLink API TestProject tlProject = testLinkApi.GetProject(this.testLinkProjectName); if (tlProject == null) { throw new ApplicationException(String.Format("Empty project data returned by TestLink for project '{0}' so aborting import", this.testLinkProjectId)); } RemoteProject remoteProject = new RemoteProject(); remoteProject.Name = tlProject.name; remoteProject.Website = tlProject.notes; remoteProject.Active = tlProject.active; //Reconnect and import the project spiraClient.Connection_Authenticate2(Properties.Settings.Default.SpiraUserName, Properties.Settings.Default.SpiraPassword, "TestLinkImporter"); remoteProject = spiraClient.Project_Create(remoteProject, null); streamWriter.WriteLine("New Project '" + remoteProject.Name + "' Created"); int projectId = remoteProject.ProjectId.Value; this.newProjectId = remoteProject.ProjectId.Value; } catch (Exception exception) { streamWriter.WriteLine("General error importing data from TestLink to Spira The error message is: " + exception.Message); throw; } }
protected void Setup() { proxy = new TestLink(apiKey, targetDBUrl, true); }
public async Task EventHub_MultipleDispatch_IndependentMessages() { // send individual messages via EventHub client, process batch by host await using var ehClient = new EventHubProducerClient(EventHubsTestEnvironment.Instance.EventHubsConnectionString, _eventHubScope.EventHubName); var messages = new EventData[5]; var expectedLinks = new TestLink[messages.Length]; for (int i = 0; i < messages.Length; i++) { var operationId = ActivityTraceId.CreateRandom().ToHexString(); var spanId = ActivitySpanId.CreateRandom().ToHexString(); expectedLinks[i] = new TestLink { operation_Id = operationId, id = spanId }; messages[i] = new EventData(Encoding.UTF8.GetBytes(i.ToString())) { Properties = { ["Diagnostic-Id"] = $"00-{operationId}-{spanId}-01" } }; } await ehClient.SendAsync(messages); var(jobHost, host) = BuildHost <EventHubTestMultipleDispatchJobs>(); using (host) { bool result = _eventWait.WaitOne(Timeout); Assert.True(result); } List <RequestTelemetry> requests = _channel.Telemetries.OfType <RequestTelemetry>().ToList(); var ehTriggerRequests = requests.Where(r => r.Context.Operation.Name == nameof(EventHubTestMultipleDispatchJobs.ProcessMultipleEvents)); List <TestLink> actualLinks = new List <TestLink>(); foreach (var ehTriggerRequest in ehTriggerRequests) { ValidateEventHubRequest( ehTriggerRequest, true, EventHubsTestEnvironment.Instance.FullyQualifiedNamespace, _eventHubScope.EventHubName, nameof(EventHubTestMultipleDispatchJobs.ProcessMultipleEvents), null, null); Assert.NotNull(ehTriggerRequest.Context.Operation.Id); Assert.Null(ehTriggerRequest.Context.Operation.ParentId); Assert.True(ehTriggerRequest.Properties.TryGetValue("_MS.links", out var linksStr)); actualLinks.AddRange(JsonConvert.DeserializeObject <TestLink[]>(linksStr, jsonSettingThrowOnError)); } Assert.AreEqual(expectedLinks.Length, actualLinks.Count); foreach (var link in actualLinks) { Assert.True(expectedLinks.Any(l => l.operation_Id == link.operation_Id && l.id == link.id)); } }
public async Task EventHub_MultipleDispatch_IndependentMessages() { // send individual messages via EventHub client, process batch by host var ehClient = EventHubClient.CreateFromConnectionString(_connection); var messages = new EventData[5]; var expectedLinks = new TestLink[messages.Length]; for (int i = 0; i < messages.Length; i++) { var operationId = ActivityTraceId.CreateRandom().ToHexString(); var spanId = ActivitySpanId.CreateRandom().ToHexString(); expectedLinks[i] = new TestLink { operation_Id = operationId, id = $"|{operationId}.{spanId}." }; messages[i] = new EventData(Encoding.UTF8.GetBytes(_testPrefix + i)) { Properties = { ["Diagnostic-Id"] = $"00-{operationId}-{spanId}-01" } }; } await ehClient.SendAsync(messages); using (var host = BuildHost <EventHubTestMultipleDispatchJobs>()) { await host.StartAsync(); bool result = _eventWait.WaitOne(Timeout); Assert.True(result); } List <RequestTelemetry> requests = _channel.Telemetries.OfType <RequestTelemetry>().ToList(); var ehTriggerRequests = requests.Where(r => r.Context.Operation.Name == "ProcessMultipleEvents"); List <TestLink> actualLinks = new List <TestLink>(); foreach (var ehTriggerRequest in ehTriggerRequests) { ValidateEventHubRequest( ehTriggerRequest, true, "ProcessMultipleEvents", null, null); Assert.NotNull(ehTriggerRequest.Context.Operation.Id); Assert.Null(ehTriggerRequest.Context.Operation.ParentId); Assert.True(ehTriggerRequest.Properties.TryGetValue("_MS.links", out var linksStr)); actualLinks.AddRange(JsonConvert.DeserializeObject <TestLink[]>(linksStr, jsonSettingThrowOnError)); Assert.Equal(SamplingDecision.SampledIn, ehTriggerRequest.ProactiveSamplingDecision); } Assert.True(actualLinks.Count >= expectedLinks.Length); // we've sent 5 events foreach (var link in actualLinks) { Assert.Contains(expectedLinks, l => l.operation_Id == link.operation_Id && l.id == link.id); } }
public void ShouldFailBecauseOfInvalidDevKey() { proxy = new TestLink("empty", testlinkUrl); Assert.Catch <TestLinkException>(() => proxy.GetTestCaseIDByName("10 G shock")); }
/// <summary> /// Authenticates the user from the providing server/login/password information /// </summary> /// <param name="sender">The sending object</param> /// <param name="e">The event arguments</param> private void btnAuthenticate_Click(object sender, System.EventArgs e) { //Disable the next button this.btnNext.Enabled = false; //Make sure that a login was entered if (this.txtLogin.Text.Trim() == "") { MessageBox.Show("You need to enter a login", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //Make sure that a server was entered if (this.txtServer.Text.Trim() == "") { MessageBox.Show("You need to enter the URL to your TestLink instance", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } try { //Instantiate the connection to TestLink (by getting a list of projects) string apiKey = this.txtLogin.Text.Trim(); string url = this.txtServer.Text.Trim() + Utils.TESTLINK_URL_SUFFIX_XML_RPC; TestLink testLink = new TestLink(apiKey, url); List <TestProject> projects = testLink.GetProjects(); if (projects.Count > 0) { MessageBox.Show("You have logged into TestLink Successfully", "Authentication", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("You have logged into TestLink successfully, but you don't have any projects to import!", "No Projects Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //Now we need to populate the list of projects List <NameIdObject> projectsList = new List <NameIdObject>(); //Convert into a standard bindable list source for (int i = 0; i < projects.Count; i++) { NameIdObject project = new NameIdObject(); project.Id = projects[i].id.ToString(); project.Name = projects[i].name; projectsList.Add(project); } //Sort by name projectsList = projectsList.OrderBy(p => p.Name).ToList(); this.cboProject.DisplayMember = "Name"; this.cboProject.DataSource = projectsList; //Enable the Next button this.btnNext.Enabled = true; } catch (Exception exception) { MessageBox.Show("General error accessing the TestLink API. The error message is: " + exception.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } }
public void ShouldFailBecauseOfInvalidURL() { proxy = new TestLink(apiKey, "http://localhost/testlink/api/xmlrpc.php"); Assert.Catch <XmlRpcServerException>(() => proxy.SayHello()); Assert.Fail("Did not cause an exception"); }
public TestLinkProjectData(TestLink tl) { proxy = tl; }
public TestLinkUtil(String apiKey, String url, bool log, int testPlanId) { testLink = new TestLink(apiKey, url, log); _testPlanId = testPlanId; }
/// <summary> /// This method is responsible for actually importing the data /// </summary> /// <param name="stateInfo">State information handle</param> /// <remarks>This runs in background thread to avoid freezing the progress form</remarks> public void ImportData(object stateInfo) { //First open up the textfile that we will log information to (used for debugging purposes) string debugFile = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\Spira_TestLink_Import.log"; StreamWriter streamWriter = File.CreateText(debugFile); try { streamWriter.WriteLine("Starting import at: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()); //Create the mapping hashtables this.testCaseMapping = new Dictionary <int, int>(); this.testSuiteMapping = new Dictionary <int, int>(); this.testSuiteSectionMapping = new Dictionary <int, int>(); this.testStepMapping = new Dictionary <int, int>(); this.usersMapping = new Dictionary <int, int>(); this.testRunStepMapping = new Dictionary <int, int>(); this.testRunStepToTestStepMapping = new Dictionary <int, int>(); this.testSetMapping = new Dictionary <int, int>(); this.testSetTestCaseMapping = new Dictionary <int, int>(); //Connect to Spira streamWriter.WriteLine("Connecting to Spira..."); SpiraSoapService.SoapServiceClient spiraClient = new SpiraSoapService.SoapServiceClient(); //Set the end-point and allow cookies string spiraUrl = Properties.Settings.Default.SpiraUrl + ImportForm.IMPORT_WEB_SERVICES_URL; spiraClient.Endpoint.Address = new EndpointAddress(spiraUrl); BasicHttpBinding httpBinding = (BasicHttpBinding)spiraClient.Endpoint.Binding; ConfigureBinding(httpBinding, spiraClient.Endpoint.Address.Uri); bool success = spiraClient.Connection_Authenticate2(Properties.Settings.Default.SpiraUserName, Properties.Settings.Default.SpiraPassword, "TestLinkImporter"); if (!success) { string message = "Failed to authenticate with Spira using login: '******' so terminating import!"; streamWriter.WriteLine(message); streamWriter.Close(); //Display the exception message this.progressForm.ProgressForm_OnError(message); return; } //Connect to TestLink string apiKey = Properties.Settings.Default.TestLinkApiKey; string testLinkUrl = Properties.Settings.Default.TestLinkUrl + Utils.TESTLINK_URL_SUFFIX_XML_RPC; TestLink testLink = new TestLink(apiKey, testLinkUrl); //1) Create a new project ImportProject(streamWriter, spiraClient, testLink); //**** Show progress **** streamWriter.WriteLine("Project Created"); this.progressForm.ProgressForm_OnProgressUpdate(1); //2) Import test suites //Get the test suites from the TestLink API List <TestSuite> testSuites = testLink.GetFirstLevelTestSuitesForTestProject(this.testLinkProjectId); ImportTestSuites(streamWriter, spiraClient, testLink, testSuites); //**** Show progress **** streamWriter.WriteLine("Imported Test Suites"); this.progressForm.ProgressForm_OnProgressUpdate(2); //**** Show progress **** streamWriter.WriteLine("Imported Test Cases and Steps"); this.progressForm.ProgressForm_OnProgressUpdate(3); //3) Import test cases and test steps ImportTestCasesAndSteps(streamWriter, spiraClient, testLink); //**** Show progress **** streamWriter.WriteLine("Completed Import"); this.progressForm.ProgressForm_OnProgressUpdate(4); //**** Mark the form as finished **** streamWriter.WriteLine("Import completed at: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()); this.progressForm.ProgressForm_OnFinish(); //Close the debugging file streamWriter.Close(); } catch (Exception exception) { //Log the error streamWriter.WriteLine("*ERROR* Occurred during Import: '" + exception.Message + "' at " + exception.Source + " (" + exception.StackTrace + ")"); streamWriter.Close(); //Display the exception message this.progressForm.ProgressForm_OnError(exception); } }