public static void UseAgiilWebDriverFromConfiguration(this IIntegrationConfigBuilder builder,
                                                              string name = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.ServiceRegistrations.PerTestRun.Add(b => {
                b.RegisterFactory(() => GetWebDriverFactory.FromConfiguration())
                .AsOwnType()
                .WithName(name);
            });

            builder.ServiceRegistrations.PerScenario.Add(b => {
                b.RegisterDynamicFactory(GetLazyWebDriverTracker(name))
                .As <ITracksWebDriverCreation>()
                .WithName(name);

                b.RegisterDynamicFactory(resolver => resolver.Resolve <ITracksWebDriverCreation>().GetWebDriver())
                .AsOwnType()
                .WithName(name);
            });

            builder.AfterScenario.Add(MarkWebDriverWithOutcome(name));
        }
        void SubscribeToCast(IIntegrationConfigBuilder integration)
        {
            integration.BeforeScenario.Add((scenario) => {
                if (!subscribeToCastActorCreation && !subscribeToCastActorAddition)
                {
                    return;
                }

                var cast     = scenario.DiContainer.Resolve <ICast>(castName);
                var reporter = scenario.DiContainer.Resolve <IObservesReportableEvents>(name);

                if (subscribeToCastActorCreation)
                {
                    cast.ActorCreated += (sender, e) => {
                        reporter.Subscribe(e.Actor);
                    };
                }
                else
                {
                    cast.ActorAdded += (sender, e) => {
                        reporter.Subscribe(e.Actor);
                    };
                }
            });
        }
 void RegisterObjectFormatters(IIntegrationConfigBuilder integration)
 {
     integration.ServiceRegistrations.PerTestRun.Add(h => {
         h.RegisterInstance(formatterRegistry).As <IObjectFormatingStrategyRegistry>().WithName(name);
         var objectFormatter = new StrategyBasedObjectFormatter(formatterRegistry);
         h.RegisterInstance(objectFormatter).As <IFormatsObjectForReport>().WithName(name);
     });
 }
        void SubscribeToCast(IIntegrationConfigBuilder integration)
        {
            integration.BeforeScenario.Add((scenario) => {
                var cast     = scenario.DiContainer.Resolve <ICast>(name);
                var reporter = scenario.DiContainer.Resolve <IObservesReportableEvents>(name);

                cast.ActorCreated += (sender, e) => reporter.Subscribe(e.Actor);
            });
        }
Example #5
0
 void ConfigureReporting(IIntegrationConfigBuilder builder)
 {
     builder.UseReporting(reporting => {
         reporting
         .WithFormatter <StringCollectionFormattingStrategy>()
         .WithFormatter <OptionCollectionFormatter>()
         .WithFormatter <ElementCollectionFormatter>()
         .WithReportJsonFile("Agiil.Tests.BDD.report.json");
     });
 }
Example #6
0
        public static void UseAutofacContainer(this IIntegrationConfigBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.ServiceRegistrations.PerTestRun.Add(reg => {
                reg.RegisterFactory(GetContainer <Web.App_Start.WebAppTestingContainerFactory>);
            });
        }
Example #7
0
        public void Configure(IIntegrationConfigBuilder builder)
        {
            builder.UseSharedUriTransformer(new RootUriPrependingTransformer(ApplicationBaseUri));
            builder.UseAgiilWebDriverFromConfiguration();
            builder.UseWebBrowser();
            builder.UseBrowserFlags();
            builder.UseWebApis(ApiBaseUri);
            builder.UseAutofacContainer();

            ConfigureReporting(builder);
        }
Example #8
0
 public void Configure(IIntegrationConfigBuilder builder)
 {
     builder.UseWebApis("http://localhost:8080/api/");
     builder.UseReporting(config => {
         config
         .WithFormatter <TimeoutExceptionFormatter>()
         .WithFormatter <WebApiExceptionFormatter>()
         .WithReportJsonFile("JsonApis.report.json")
         ;
     });
 }
 public void Configure(IIntegrationConfigBuilder builder)
 {
     builder.UseWebApis("http://localhost:63444/api/");
     builder.UseReporting(config => {
         config
         .SubscribeToActorsCreatedInCast()
         .WithFormattingStrategy <TimeoutExceptionFormatter>()
         .WithFormattingStrategy <WebApiExceptionFormatter>()
         .WithScenarioRenderer(JsonScenarioRenderer.CreateForFile(TestContext.CurrentContext.WorkDirectory + "\\JsonApis.report.json"))
         ;
     });
 }
        void SubscribeToScenario(IIntegrationConfigBuilder integration)
        {
            integration.BeforeScenario.Add((scenario) => {
                var reporter = scenario.DiContainer.Resolve <IObservesReportableEvents>(name);
                reporter.Subscribe(scenario);
            });

            integration.AfterScenario.Add((scenario) => {
                var reporter = scenario.DiContainer.Resolve <IObservesReportableEvents>(name);
                reporter.Unsubscribe(scenario);
            });
        }
Example #11
0
        /// <summary>
        /// Configures the current integration to make the <see cref="ConsumeWebServices"/> ability available via
        /// dependency injection.
        /// </summary>
        /// <param name="helper">The integration helper.</param>
        /// <param name="baseUri">A base URI for all API requests which have relative URIs.</param>
        /// <param name="defaultTimeout">A default timeout for API requests which do not specify an explicit timeout.</param>
        /// <param name="name">The registered name of this ability.</param>
        public static void UseWebApis(this IIntegrationConfigBuilder helper,
                                      string baseUri,
                                      TimeSpan?defaultTimeout = null,
                                      string name             = null)
        {
            if (helper == null)
            {
                throw new ArgumentNullException(nameof(helper));
            }

            helper.UseWebApis(new Uri(baseUri), defaultTimeout, name);
        }
        public void Configure(IIntegrationConfigBuilder builder)
        {
            builder.UseReporting(config => {
                config
                .WithFormatter <ReportFormatting.TimeSpanFormattingStrategy>()
                .WithReportJsonFile("SpecFlow.report.json")
                ;
            });

            builder.ServiceRegistrations.PerScenario.Add(b => {
                b.RegisterType <AddNumbers>();
            });
        }
        internal void ApplyToIntegration(IIntegrationConfigBuilder integration)
        {
            if (integration == null)
            {
                throw new ArgumentNullException(nameof(integration));
            }

            RegisterReporter(integration);
            RegisterObjectFormatters(integration);
            SubscribeToCast(integration);
            SubscribeToBeginAndEndTestRun(integration);
            SubscribeToScenario(integration);
        }
        /// <summary>
        /// Configures the current integration to make use of an <see cref="IStage"/> instance.
        /// </summary>
        /// <param name="helper">Helper.</param>
        /// <param name="name">Name.</param>
        public static void UseStage(this IIntegrationConfigBuilder helper, string name = null)
        {
            if (helper == null)
            {
                throw new ArgumentNullException(nameof(helper));
            }

            helper.ServiceRegistrations.PerScenario.Add(regBuilder => {
                regBuilder
                .RegisterFactory((ICast cast) => new Stage(cast))
                .As <IStage>()
                .WithName(name);
            });
        }
        /// <summary>
        /// Configures the current integration to make use of an <see cref="ICast"/> instance.
        /// This includes dismissing that cast after each scenario.
        /// </summary>
        /// <param name="helper">Helper.</param>
        /// <param name="name">Name.</param>
        public static void UseCast(this IIntegrationConfigBuilder helper, string name = null)
        {
            if (helper == null)
            {
                throw new ArgumentNullException(nameof(helper));
            }

            helper.ServiceRegistrations.PerScenario.Add(regBuilder => {
                regBuilder
                .RegisterFactory((IScenario s, IResolvesServices resolver) => new Cast(s.Identity, resolver))
                .As <ICast>()
                .WithName(name);
            });
        }
Example #16
0
        public void Configure(IIntegrationConfigBuilder builder)
        {
            builder.UseReporting(config => {
                config
                .SubscribeToActorsCreatedInCast()
                .WithFormattingStrategy <ReportFormatting.TimeSpanFormattingStrategy>()
                .WithScenarioRenderer(JsonScenarioRenderer.CreateForFile(TestContext.CurrentContext.WorkDirectory + "\\SpecFlow.report.json"))
                ;
            });

            builder.ServiceRegistrations.PerScenario.Add(b => {
                b.RegisterType <AddNumbers>();
            });
        }
        void RegisterReporter(IIntegrationConfigBuilder integration)
        {
            var reporter = reporterToUse ?? (formatter => new NoOpReportableEventHandler());

            integration.ServiceRegistrations.PerTestRun.Add(h => {
                h.RegisterFactory(reporter).As <IHandlesReportableEvents>().WithName(name);
                h.RegisterFactory(GetReportableEventObserverFactory()).As <IObservesReportableEvents>().WithName(name);
                h.RegisterFactory(GetScenarioCompletionProviderFactory()).As <IExposesCompletedScenarios>().WithName(name);

                if (scenarioCompletionObserver != null)
                {
                    h.RegisterInstance(scenarioCompletionObserver).As <IObservesScenarioCompletion>().WithName(name);
                }
            });
        }
Example #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:CSF.Screenplay.Integration.ScreenplayIntegration"/> class.
        /// </summary>
        /// <param name="configBuilder">Config builder.</param>
        /// <param name="rootContainer">The root DI container.</param>
        public ScreenplayIntegration(IIntegrationConfigBuilder configBuilder,
                                     IContainer rootContainer = null)
        {
            if (configBuilder == null)
            {
                throw new ArgumentNullException(nameof(configBuilder));
            }

            builder            = configBuilder;
            this.rootContainer = new Lazy <IContainer>(() => {
                var output = rootContainer ?? CreateRootContainer();
                AddRootContainerRegistrations(output);
                return(output);
            });
            testRunEvents = new TestRunEvents();
        }
Example #19
0
        /// <summary>
        /// Configures the current integration to make the <see cref="ConsumeWebServices"/> ability available via
        /// dependency injection.
        /// </summary>
        /// <param name="helper">The integration helper.</param>
        /// <param name="baseUri">A base URI for all API requests which have relative URIs.</param>
        /// <param name="defaultTimeout">A default timeout for API requests which do not specify an explicit timeout.</param>
        /// <param name="name">The registered name of this ability.</param>
        public static void UseWebApis(this IIntegrationConfigBuilder helper,
                                      Uri baseUri             = null,
                                      TimeSpan?defaultTimeout = null,
                                      string name             = null)
        {
            if (helper == null)
            {
                throw new ArgumentNullException(nameof(helper));
            }

            helper.ServiceRegistrations.PerScenario.Add(regBuilder => {
                regBuilder
                .RegisterFactory(() => new ConsumeWebServices(baseUri: baseUri, defaultTimeout: defaultTimeout))
                .AsOwnType()
                .WithName(name);
            });
        }
Example #20
0
        /// <summary>
        /// Registers and configures reporting within the Screenplay test run.  A configuration builder is used to
        /// actually configure reporting, as there are several options available.
        /// </summary>
        /// <param name="helper">Helper.</param>
        /// <param name="config">Config.</param>
        public static void UseReporting(this IIntegrationConfigBuilder helper,
                                        Action <ReportingIntegrationBuilder> config)
        {
            if (helper == null)
            {
                throw new ArgumentNullException(nameof(helper));
            }
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var reportingHelper = new ReportingIntegrationBuilder();

            config(reportingHelper);
            reportingHelper.ApplyToIntegration(helper);
        }
 public void Configure(IIntegrationConfigBuilder builder)
 {
 }
Example #22
0
 IScreenplayIntegration GetSut(IIntegrationConfigBuilder builder = null, IContainer container = null)
 => new ScreenplayIntegration(builder ?? GetBuilder(), container);
 void SubscribeToBeginAndEndTestRun(IIntegrationConfigBuilder integration)
 {
     integration.BeforeFirstScenario.Add(SubscribeObserverToReportEvents);
     integration.BeforeFirstScenario.Add(SubscribeRendererToCompletedScenrios);
 }
Example #24
0
 void AddBaselineIntegrationConfiguration(IIntegrationConfigBuilder builder)
 {
     builder.UseCast();
     builder.UseStage();
 }