Example #1
0
        /// <summary>
        /// Shines the spotlight upon an actor, such that they will now be returned by <see cref="GetTheActorInTheSpotlight"/>.
        /// This essentially marks them the subject of future test logic.
        /// </summary>
        /// <returns>The actor who has just been placed into the spotlight.</returns>
        /// <typeparam name="TPersona">The persona type.</typeparam>
        public IActor ShineTheSpotlightOn <TPersona>() where TPersona : class, IPersona, new()
        {
            var actor = cast.Get <TPersona>();

            ShineTheSpotlightOn(actor);
            return(actor);
        }
Example #2
0
        public void AprilOverridesTheApplicationVersionNumber(string versionNumber)
        {
            var april = cast.Get <April>();

            stage.ShineTheSpotlightOn(april);
            Given(april).WasAbleTo(OverrideTheApplicationVersion.To(versionNumber));
        }
Example #3
0
        public void GivenYoussefLooksAtTheListOfTickets()
        {
            var youssef = cast.Get <Youssef>();

            stage.ShineTheSpotlightOn(youssef);
            Given(youssef).WasAbleTo(OpenTheirBrowserOn.ThePage <TicketList>());
        }
Example #4
0
        public void GivenYoussefHasOpenedTheSprintListingPage()
        {
            var youssef = cast.Get <Youssef>();

            stage.ShineTheSpotlightOn(youssef);
            Given(youssef).WasAbleTo(OpenTheirBrowserOn.ThePage(SprintList.ForOpenSprints()));
        }
        public void GivenYoussefHasNavigatedToTheTicketWithTheTitle(string title)
        {
            var youssef = cast.Get <Youssef>();

            stage.ShineTheSpotlightOn(youssef);
            Given(youssef).WasAbleTo(OpenTheTicket.Titled(title));
        }
Example #6
0
        public void WhenYoussefChangesHisPassword(string newPassword)
        {
            var youssef = cast.Get <Youssef>();

            stage.ShineTheSpotlightOn(youssef);
            When(youssef).AttemptsTo(ChangeTheirPassword.From(Youssef.Password).To(newPassword));
        }
Example #7
0
        public void WhenJoeAttemptsToLogin(string username, string password)
        {
            var joe = cast.Get <Joe>();

            stage.ShineTheSpotlightOn(joe);

            When(joe).AttemptsTo(LogIntoTheSite.As(username).WithThePassword(password));
        }
Example #8
0
        public void GivenJoeIsLookingAtTheAppHomePage()
        {
            // Currently bugged due to https://github.com/csf-dev/CSF.Screenplay/issues/126
            //testRunner.Value.Given("Joe can browse the web");
            resolver.Resolve <JoeSteps>().GivenJoeCanBrowseTheWeb();

            var joe = cast.Get <Joe>();

            Given(joe).WasAbleTo <VisitTheHomePage>();
        }
Example #9
0
        public void GivenAprilAddsAUserAccount(string username, string password)
        {
            // Currently bugged due to https://github.com/csf-dev/CSF.Screenplay/issues/126
            //testRunner.Value.Given("April can act as the application");
            resolver.Resolve <AprilSteps>().GivenAprilCanActAsTheApplication();

            var april = cast.Get <April>();

            Given(april).WasAbleTo(AddAUserAccount.WithTheUsername(username).AndThePassword(password));
        }
Example #10
0
        public void GivenYoussefCanBrowseTheWeb()
        {
            var youssef = cast.Get <Youssef>();

            if (youssef.HasAbility <BrowseTheWeb>())
            {
                return;
            }

            youssef.IsAbleTo(browseTheWeb);
        }
Example #11
0
        public void GivenYoussefHasOpenedTheNewSprintPage()
        {
            var youssef = cast.Get <Youssef>();

            stage.ShineTheSpotlightOn(youssef);
            Given(youssef).WasAbleTo(OpenTheirBrowserOn.ThePage <CreateSprint>());
        }
Example #12
0
        public void GivenJoeHasAStopwatch()
        {
            var joe = cast.Get("Joe");

            joe.IsAbleTo <UseAStopwatch>();
            stage.ShineTheSpotlightOn(joe);
        }
Example #13
0
        public void WhenYoussefCreatesATicket(Table detailsTable)
        {
            var details = detailsTable.CreateInstance <TicketCreationDetails>();

            var youssef = cast.Get <Youssef>();

            stage.ShineTheSpotlightOn(youssef);
            When(youssef).AttemptsTo(CreateANewTicket.WithTheDetails(details));
        }
Example #14
0
        public void Using_GetDataSlowly_does_not_raise_exception_if_timeout_is_30_seconds(ICast cast)
        {
            // Arrange
            var joe = cast.Get <Joe>();

            // Act & assert
            Assert.That(() => When(joe).AttemptsTo(Invoke.TheJsonWebService(SlowlyGetData.For(joe.Name)).WithATimeoutOf(30).Seconds().AndReadTheResultAs <SampleApiData>()),
                        Throws.Nothing);
        }
Example #15
0
        public void GivenAgiilHasJustBeenInstalled()
        {
            // Currently bugged due to https://github.com/csf-dev/CSF.Screenplay/issues/126
            // testRunner.Value.Given("April can act as the application");
            aprilSteps.Value.GivenAprilCanActAsTheApplication();

            var april = cast.Get <April>();

            Given(april).WasAbleTo <InstallTheApplication>();
        }
Example #16
0
        public void GivenAprilHasSetUpTheSimpleSampleProject()
        {
            // Currently bugged due to https://github.com/csf-dev/CSF.Screenplay/issues/126
            // testRunner.Value.Given("April can act as the application");
            aprilSteps.Value.GivenAprilCanActAsTheApplication();

            var april = cast.Get <April>();

            Given(april).WasAbleTo <SetupTheSimpleSampleProject>();
        }
Example #17
0
        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
        }
Example #18
0
        public void GivenJoeCanBrowseTheWeb()
        {
            var joe = cast.Get <Joe>();

            if (joe.HasAbility <BrowseTheWeb>())
            {
                return;
            }

            joe.IsAbleTo(browseTheWeb);
        }
Example #19
0
        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);
        }
Example #20
0
        public void GivenAprilCanActAsTheApplication()
        {
            var april = cast.Get <April>();

            if (april.HasAbility <ConsumeWebServices>())
            {
                return;
            }

            april.IsAbleTo(actAsTheApplication);
        }
Example #21
0
        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);
        }
Example #22
0
        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>());
        }
Example #23
0
        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");
        }
Example #24
0
    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"));
    }
Example #25
0
        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));
        }
Example #26
0
    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"));
    }
Example #27
0
        public void GivenSarahIsAnActorFromAPersona()
        {
            var sarah = cast.Get <Sarah>();

            stage.ShineTheSpotlightOn(sarah);
        }
 public static IActor GetMathsWhiz(this ICast cast, string name)
 {
     return(cast.Get(name, CustomiseActor));
 }
Example #29
0
        public void GivenJoeIsAnActorInTheSpotlight()
        {
            var joe = cast.Get("Joe");

            stage.ShineTheSpotlightOn(joe);
        }