public AsyncScenario(string scenarioName, ApiLogger logger, Guid guid)
 {
     _cookieContainer = new CookieContainer();
     _logger = logger;
     _guid = guid;
     _scenarioName = scenarioName;
 }
        private async Task ExecuteTestMethods(Type type, List<TestContainer> testContainers, Guid guid,
            ApiLogger logger)
        {
            object classInstance = Activator.CreateInstance(type, guid, logger);
            var tasks = new Task[testContainers.Count];

            for (int i = 0; i < testContainers.Count; i++)
            {
                int copy = i;
                Task task = Task.Run(() => ExecuteTestMethod(testContainers[copy], classInstance));
                tasks[i] = task;
            }
            await Task.WhenAll(tasks);
        }
Example #3
0
 public AsyncStep(string stepName, AsyncScenario scenario, string currentEventValidation,
     string currentViewState, CookieContainer container, string currentHtml, ApiLogger logger, Guid guid, string currentEventTarget)
     : base(new HttpClientHandler
     {
         CookieContainer = container,
         AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
     },
         currentEventValidation,
         currentViewState,
         currentHtml,
         currentEventTarget,
         guid)
 {
     _scenario = scenario;
     FormContent = new List<KeyValuePair<string, string>>();
     _logger = logger;
     _stepName = stepName;
     Headers = new List<KeyValuePair<string, string>>();
 }
 public async Task Begin(TestRun testRun)
 {
     //probably do something here with DI to set up the logger
     var logger = new ApiLogger();
     //we need these two lists later
     var testConfigurations = new List<TestConfiguration>();
     //deserialise our config
     testConfigurations.AddRange(testRun.TestConfigurations);
     //load the assembly and get test method, this needs to be dynamic
     Assembly assembly = Assembly.LoadFrom(testRun.DllThatContainsTestsPath);
     //get all the classes in the assembly
     Type[] types = assembly.GetTypes().Where(x => x.IsClass).ToArray();
     //get all the methods in the classes
     List<MethodInfo> methodInfos = (from type in types
         from methodInfo
             in type.GetMethods()
         from attribute
             in methodInfo.CustomAttributes
         where attribute.AttributeType == typeof (PerformanceTest)
         select methodInfo).ToList();
     //now we have all of the methods we need to find their configurations for this test run
     //this needs to look at a config file and match on namespace/method name or something
     //or we could pass the configs into as arguments
     List<TestContainer> testContainers = (from method in methodInfos
         from testConfiguration in testConfigurations
         where
             method.DeclaringType != null &&
             (testConfiguration.MethodName == method.Name &&
              testConfiguration.NameSpace == method.DeclaringType.UnderlyingSystemType.FullName)
         select new TestContainer(method, testConfiguration)).ToList();
     //execute the methods that were identified with their configs
     Task task = ExecuteTestMethods(types[0], testContainers, testRun.TestRunIdentifier, logger);
     await task.ContinueWith(x =>
     {
         Console.WriteLine(x.Status.ToString());
         Console.WriteLine("end");
     });
     task.Wait();
 }
Example #5
0
 public DslTests()
 {
     _logger = new ApiLogger();
 }
Example #6
0
 public Tests(Guid guid, ApiLogger logger)
 {
     _guid = guid;
     _logger = logger;
 }