/// <summary>
        /// Gets the integration from a given NUnit test method.
        /// </summary>
        /// <returns>The integration.</returns>
        /// <param name="method">Method.</param>
        public IScreenplayIntegration GetIntegration(IMethodInfo method)
        {
            lock (syncRoot)
            {
                if (integration == null)
                {
                    var assembly = method?.MethodInfo?.DeclaringType?.Assembly;
                    if (assembly == null)
                    {
                        throw new ArgumentException(Resources.ExceptionFormats.MethodMustHaveAnAssembly,
                                                    nameof(method));
                    }

                    var assemblyAttrib = assembly.GetCustomAttribute <ScreenplayAssemblyAttribute>();
                    if (assemblyAttrib == null)
                    {
                        var message = String.Format(Resources.ExceptionFormats.AssemblyMustBeDecoratedWithScreenplay,
                                                    nameof(ScreenplayAttribute),
                                                    nameof(ScreenplayAssemblyAttribute));
                        throw new InvalidOperationException(message);
                    }

                    integration = assemblyAttrib.Integration;
                }
            }

            return(integration);
        }
Exemple #2
0
        public IScreenplayIntegration GetIntegration(Assembly assembly)
        {
            lock (syncRoot)
            {
                if (integration == null)
                {
                    if (assembly == null)
                    {
                        throw new ArgumentException("The test method must be inside a compiled assembly.");
                    }

                    var assemblyAttrib = assembly.GetCustomAttributes(typeof(ScreenplayAssemblyAttribute)).Cast <ScreenplayAssemblyAttribute>().FirstOrDefault();
                    if (assemblyAttrib == null)
                    {
                        var message = string.Format("All test methods decorated with `{0}` must be contained within assemblies which are decorated with `{1}`; ...",
                                                    nameof(ScreenplayAttribute), nameof(ScreenplayAssemblyAttribute));
                        throw new InvalidOperationException(message);
                    }

                    integration = assemblyAttrib.Integration;
                }
            }

            return(integration);
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:CSF.Screenplay.NUnit.ScenarioAdapter"/> class.
        /// </summary>
        /// <param name="featureSuite">Feature suite.</param>
        /// <param name="scenarioMethod">Scenario method.</param>
        /// <param name="integration">Screenplay integration.</param>
        public ScenarioAdapter(ITest featureSuite, IMethodInfo scenarioMethod, IScreenplayIntegration integration)
        {
            if (integration == null)
            {
                throw new ArgumentNullException(nameof(integration));
            }
            if (scenarioMethod == null)
            {
                throw new ArgumentNullException(nameof(scenarioMethod));
            }
            if (featureSuite == null)
            {
                throw new ArgumentNullException(nameof(featureSuite));
            }

            this.scenarioMethod = scenarioMethod;
            this.featureSuite   = featureSuite;
            this.integration    = integration;
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:CSF.Screenplay.SpecFlow.ScenarioAdapter"/> class.
        /// </summary>
        /// <param name="scenarioContext">Scenario context.</param>
        /// <param name="featureContext">Feature context.</param>
        /// <param name="integration">Integration.</param>
        public ScenarioAdapter(ScenarioContext scenarioContext,
                               FeatureContext featureContext,
                               IScreenplayIntegration integration)
        {
            if (integration == null)
            {
                throw new ArgumentNullException(nameof(integration));
            }
            if (featureContext == null)
            {
                throw new ArgumentNullException(nameof(featureContext));
            }
            if (scenarioContext == null)
            {
                throw new ArgumentNullException(nameof(scenarioContext));
            }

            this.integration     = integration;
            this.featureContext  = featureContext;
            this.scenarioContext = scenarioContext;
        }