public static void Cast(ICast cast, BattleUnitsStack caster, params BattleUnitsStack[] targets) { caster.state = State.MadeMove; caster.GetLastEffect()?.BeforeCast(cast, caster, targets); foreach (var target in targets) { target.GetLastEffect()?.BeforeCast(cast, caster, targets); } if (cast is ISingleCast) { if (targets.Length != 1) { throw new GameException($"Invalid number of targets: {targets.Length} (Cast {cast.type})"); } ((ISingleCast)cast).Cast(caster, targets[0]); } caster.GetLastEffect()?.AfterCast(cast, caster, targets); foreach (var target in targets) { target.GetLastEffect()?.AfterCast(cast, caster, targets); } Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"{cast.type} casted!"); Console.ResetColor(); }
/// <summary> /// Initializes a new instance of the <see cref="T:CSF.Screenplay.Actors.Stage"/> class. /// </summary> /// <param name="cast">Cast.</param> public Stage(ICast cast) { if (cast == null) { throw new ArgumentNullException(nameof(cast)); } this.cast = cast; }
public void Using_GetDataSlowly_raises_exception_if_timeout_is_1_second(ICast cast) { // Arrange var joe = cast.Get <Joe>(); // Act & assert Assert.That(() => When(joe).AttemptsTo(Invoke.TheJsonWebService(SlowlyGetData.For(joe.Name)).WithATimeoutOf(1).Seconds().AndReadTheResultAs <SampleApiData>()), Throws.InstanceOf <TimeoutException>()); }
public void A_new_item_can_be_added_to_an_empty_list(ICast cast, BrowseTheWeb browseTheWeb) { var joe = cast.Get("Joe"); joe.IsAbleTo(browseTheWeb); Given(joe).WasAbleTo(OpenTheirBrowserOn.ThePage <HomePage>()); When(joe).AttemptsTo(Enter.TheText("*****@*****.**").Into(HomePage.EmalInput)); // The rest of the test is unchanged }
public void Using_CheckData_does_not_raise_exception_for_valid_data(ICast cast) { // Arrange var joe = cast.Get <Joe>(); var theData = new SampleApiData { Name = ExecutionController.ValidName, DateAndTime = DateTime.Today }; // Act & assert Assert.That(() => When(joe).AttemptsTo(Invoke.TheJsonWebService <CheckData>().WithTheData(theData).AndVerifyItSucceeds()), Throws.Nothing); }
public void Using_SetTheNumber_does_not_raise_exception(ICast cast) { // Arrange var joe = cast.Get <Joe>(); var theData = new SampleApiData() { NewNumber = 5 }; // Act & assert Assert.That(() => When(joe).AttemptsTo(Invoke.TheJsonWebService <SetNumber>().WithTheData(theData).AndVerifyItSucceeds()), Throws.Nothing); }
public void Using_CheckData_raises_exception_for_invalid_data(ICast cast) { // Arrange var joe = cast.Get <Joe>(); var theData = new SampleApiData { Name = "Invalid, crash expected", DateAndTime = DateTime.Today }; // Act & assert Assert.That(() => When(joe).AttemptsTo(Invoke.TheJsonWebService <CheckData>().WithTheData(theData).AndVerifyItSucceeds()), Throws.InstanceOf <WebApiException>()); }
public void ShineTheSpotlightOn_persona_uses_cast_to_get_actor([Frozen] ICast cast, IActor actor, Stage sut) { // Arrange Mock.Get(cast).Setup(x => x.Get <MyPersona>()).Returns(actor); // Act var result = sut.ShineTheSpotlightOn <MyPersona>(); // Assert Assert.That(result, Is.SameAs(actor)); }
public void Using_GetData_returns_expected_result(ICast cast) { // Arrange var joe = cast.Get <Joe>(); // Act var result = When(joe).AttemptsTo(Invoke.TheJsonWebService(GetData.For(joe.Name)).AndReadTheResultAs <SampleApiData>()); // Assert Assert.That(result, Is.Not.Null, "Result should not be null"); Assert.That(result.Name, Is.EqualTo(joe.Name), "Result name should be as expected"); Assert.That(result.DateAndTime, Is.EqualTo(DataController.SampleDateTime), "Result date should be as expected"); }
public AprilSteps(ICast cast, ConsumeWebServices actAsTheApplication) { if (actAsTheApplication == null) { throw new ArgumentNullException(nameof(actAsTheApplication)); } if (cast == null) { throw new ArgumentNullException(nameof(cast)); } this.actAsTheApplication = actAsTheApplication; this.cast = cast; }
public void ShineTheSpotlightOn_persona_records_actor_in_spotlight([Frozen] ICast cast, IActor actor, Stage sut) { // Arrange Mock.Get(cast).Setup(x => x.Get <MyPersona>()).Returns(actor); // Act var first = sut.ShineTheSpotlightOn <MyPersona>(); var second = sut.GetTheActorInTheSpotlight(); // Assert Assert.That(first, Is.SameAs(second)); }
public TicketCreationSteps(ICast cast, IStage stage) { if (stage == null) { throw new ArgumentNullException(nameof(stage)); } if (cast == null) { throw new ArgumentNullException(nameof(cast)); } this.cast = cast; this.stage = stage; }
public PasswordChangeSteps(ICast cast, IStage stage) { if (cast == null) { throw new ArgumentNullException(nameof(cast)); } if (stage == null) { throw new ArgumentNullException(nameof(stage)); } this.cast = cast; this.stage = stage; }
public JoeSteps(ICast cast, BrowseTheWeb browseTheWeb) { if (browseTheWeb == null) { throw new ArgumentNullException(nameof(browseTheWeb)); } if (cast == null) { throw new ArgumentNullException(nameof(cast)); } this.cast = cast; this.browseTheWeb = browseTheWeb; }
public void A_new_item_can_be_added_to_an_empty_list(ICast cast, BrowseTheWeb browseTheWeb) { var joe = cast.Get("Joe"); joe.IsAbleTo(browseTheWeb); // Given Joe opens an empty to-do list Given(joe).WasAbleTo <OpenAnEmptyToDoList>(); // When Joe adds a new item called "Wash dishes" When(joe).AttemptsTo(AddAToDoItem.Named("Wash dishes")); // Then the top item should be called "Wash dishes" var theText = Then(joe).ShouldRead(TheTopToDoItem.FromTheList()); Assert.That(theText, Is.EqualTo("Wash dishes")); }
public void Using_SetTheNumber_then_GetTheNumber_returns_the_correct_number(ICast cast) { // Arrange var theNumber = 42; var theData = new SampleApiData() { NewNumber = theNumber }; var joe = cast.Get <Joe>(); Given(joe).WasAbleTo(Invoke.TheJsonWebService <SetNumber>().WithTheData(theData).AndVerifyItSucceeds()); // Act var result = When(joe).AttemptsTo(Invoke.TheJsonWebService <GetNumber>().AndReadTheResultAs <int>()); // Assert Assert.That(result, Is.EqualTo(theNumber)); }
public SprintViewingSteps(ICast cast, IStage stage, ScenarioContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (cast == null) { throw new ArgumentNullException(nameof(cast)); } if (stage == null) { throw new ArgumentNullException(nameof(stage)); } this.context = context; this.cast = cast; this.stage = stage; }
public void A_new_item_is_added_to_the_top_of_the_list(ICast cast, BrowseTheWeb browseTheWeb) { var joe = cast.Get("Joe"); joe.IsAbleTo(browseTheWeb); // Given Joe opens an empty to-do list Given(joe).WasAbleTo <OpenAnEmptyToDoList>(); // And he has added an item called "Buy bread" Given(joe).WasAbleTo(AddAToDoItem.Named("Buy bread")); // When Joe adds a new item called "Buy shampoo" When(joe).AttemptsTo(AddAToDoItem.Named("Buy shampoo")); // Then the top item should be called "Buy shampoo" var theText = Then(joe).ShouldRead(TheTopToDoItem.FromTheList()); Assert.That(theText, Is.EqualTo("Buy shampoo")); }
/// <summary> /// Initializes a new instance of the <see cref="T:CSF.Screenplay.NUnit.CastReporter"/> class. /// </summary> /// <param name="cast">Cast.</param> /// <param name="reporter">Reporter.</param> /// <param name="context">The current context.</param> public CastReportingHelper(ICast cast, IReporter reporter, ScreenplayContext context) { if (reporter == null) { throw new ArgumentNullException(nameof(reporter)); } if (cast == null) { throw new ArgumentNullException(nameof(cast)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } this.cast = cast; this.reporter = reporter; this.context = context; }
public static void Send(ICast cast) { cast.Send(); }
public UserAccountSteps(ICast cast, IResolvesServices resolver) { this.cast = cast ?? throw new ArgumentNullException(nameof(cast)); this.resolver = resolver ?? throw new ArgumentNullException(nameof(resolver)); }
public void AGAG(ICast cast, MyAbility ability) { }
public void XX(ICast cast, IAbility ability) { }
public static IActor GetMathsWhiz(this ICast cast, string name) { return(cast.Get(name, CustomiseActor)); }
public YoussefSteps(ICast cast, BrowseTheWeb browseTheWeb) { this.cast = cast ?? throw new ArgumentNullException(nameof(cast)); this.browseTheWeb = browseTheWeb ?? throw new ArgumentNullException(nameof(browseTheWeb)); }
public static void AddCaster(ICast caster) { CasterRepository.casters.Add(caster.Id, caster); }
public abstract void AfterCast(ICast cast, BattleUnitsStack caster, params BattleUnitsStack[] targets);
public ProjectSetupSteps(ICast cast, Lazy <AprilSteps> aprilSteps) { this.aprilSteps = aprilSteps ?? throw new ArgumentNullException(nameof(aprilSteps)); this.cast = cast ?? throw new ArgumentNullException(nameof(cast)); }
public CastStatsInterface(ICast _cast, UIStep _prevStep) { prevStep = _prevStep; cast = _cast; }
public InstallationSteps(ICast cast, Lazy <AprilSteps> aprilSteps) { this.aprilSteps = aprilSteps ?? throw new ArgumentNullException(nameof(aprilSteps)); this.cast = cast ?? throw new ArgumentNullException(nameof(cast)); }