/// <summary> /// Execute all the given <see cref = "IGivenCommand{TResult}"/> when the actor uses the system /// </summary> /// <param name = "commands">A list of <see cref = "IGivenCommand{TResult}"/> representing the actions performed by the actor</param> /// <typeparam name="TResult">The type returned by the action. Use the <see cref="Unit"/> to represent void actions</typeparam> /// <param name="actor">The actor used to perform the actions</param> /// <returns>An array of all the command results</returns> public static ImmutableArray <TResult> Given <TResult>(this IActorFacade actor, params IGivenCommand <TResult>[] commands) { if (actor == null) { throw new ArgumentNullException(nameof(actor)); } if (commands == null) { throw new ArgumentNullException(nameof(commands)); } return(commands.Select(c => actor.Given(c)).ToImmutableArray()); }
public void Before() { var screenshotName = Context.ScenarioInfo.Title; #if DEBUG var delay = IsLiveUnitTesting ? TimeSpan.Zero : TimeSpan.FromSeconds(1); #else var delay = TimeSpan.Zero; #endif if (IsLiveUnitTesting) { delay = TimeSpan.Zero; } var actorSource = new Actor("John"); IActorFacade actor = actorSource; if (TestLevel == TestLevel.UI) { var driver = CreateWebDriver(); actor = actorSource.WithSeleniumReporting( new SeleniumReportingConfiguration( GetScreenshotsPath(), screenshotName) .AddTextObservers(new DebugObserver()) .WithCanNotify(new CanNotify()) .WithScreenshotPng() .WithTakeScreenshotStrategy(new TakeScreenshotOnErrorStrategy()), out var seleniumReporter) .HighlightTargets() .SlowSelenium(delay) .CanUse(seleniumReporter) .CanUse(WebBrowser.With(driver)); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); Context.Set(driver); } // Indicates what level of automation is supported by the current scenario var levels = new[] { TestLevel.UI, TestLevel.Api }.Where(l => l >= TestLevel).ToArray(); actor = actor.CanUse <IActionTags <TestLevel> >(ActionTags.Create(levels)) .CanUse(ClientFactory()); Context.Set(actor); if (TestLevel == TestLevel.UI) { actor.Given(Open.TheApplication()); } }