Create the C# Runtime API client
Example 1
In this example, we start a test with the scenario WANImpact Local and then we add Virtual Users to population MyPopulationSmallCities.
using Neotys.RuntimeAPI.Client;using Neotys.RuntimeAPI.Model;using System;namespace TestRuntimeAPI{class StartTestExample{static void Main(string[] args){IRuntimeAPIClient client = RuntimeAPIClientFactory.NewClient("http://localhost:7400/Runtime/v1/Service.svc/");if (Status.READY == client.getStatus()){// make sure that NeoLoad is ready before running a testclient.StartTest(new StartTestParamsBuilder("WANImpact Local").Build());do{// wait that the test is launchedSystem.Threading.Thread.Sleep(1000);} while (Status.TEST_LOADING == client.getStatus());if (Status.TEST_RUNNING == client.getStatus()){int addedUsers = client.AddVirtualUsers(new AddVirtualUsersParamsBuilder("MyPopulationSmallCities", 10).Build());System.Console.WriteLine(addedUsers + " users added")}}}}}
Example 2
In this example, we stop Virtual Users in population MyPopulationSmallCities and then we stop the test itself.
using Neotys.RuntimeAPI.Client;using Neotys.RuntimeAPI.Model;using System;namespace TestRuntimeAPI{class StopTestExample{static void Main(string[] args){IRuntimeAPIClient client = RuntimeAPIClientFactory.NewClient("http://localhost:7400/Runtime/v1/Service.svc/");// make sure a test is runningif (Status.TEST_RUNNING == client.getStatus()){int stoppedUsers = client.StopVirtualUsers(new StopVirtualUsersParamsBuilder("MyPopulationSmallCities", 5).Build());System.Console.WriteLine(stoppedUsers + " users stopped");System.Threading.Thread.Sleep(10000);client.StopTest(new StopTestParamsBuilder().Build());}}}}
Home