Beispiel #1
0
        public static IScenarioDiscoverer GetDiscoverer(IMessageSink diagnosticsMessageSink, IAttributeInfo scenarioAttribute)
        {
            if (scenarioAttribute == null)
            {
                throw new ArgumentNullException(nameof(scenarioAttribute));
            }
            var discovererAttribute = scenarioAttribute.GetCustomAttributes(typeof(ScenarioDiscovererAttribute)).SingleOrDefault();

            if (discovererAttribute == null)
            {
                throw new InvalidOperationException(
                          $"{ScenarioAttribute.GetAttributeTypeName(scenarioAttribute)} must be annotated with a single ScenarioDiscovererAttribute");
            }

            var args           = discovererAttribute.GetConstructorArguments().Cast <string>().ToList();
            var discovererType = LoadType(args[1], args[0]);

            if (discovererType == null)
            {
                throw new InvalidOperationException(
                          $"Could not load scenario discoverer of type \"{args[1]}, {args[0]}\" for {ScenarioAttribute.GetAttributeTypeName(scenarioAttribute)}");
            }

            return(GetDiscoverer(diagnosticsMessageSink, discovererType));
        }