public void RunScenario()
 {
     HelperClass.GivenWasCalled = false;
     var feature = new Feature("Hello");
     feature.AddScenario()
         .WithHelperObject<HelperClass>()
         .Given("something to call")
         .And("something else")
         .When("method should be called")
         .Then("this should work");
 }
Example #2
0
		public void ShouldRetrieveProducts()
		{
			var context = new RequestContext();

			var story = new Feature("Should retrieve products");
			story.AddScenario("Should retrieve all public and Company's products when User works for Company")
				.Given("User works for Company 1", () => context.UserWorksForCompany(1))
				.And("$productName belongs to Company $companyId", () => context.ProductBelongsToCompany("Product 1", 1))
				.And("$productName belongs to Company $companyId", () => context.ProductBelongsToCompany("Product 2", 2))
				.And("$productName is public", () => context.ProductIsPublic("Product 3"))
				.When("retrieve products for User", context.RetrieveProductsForUser)
				.Then("retrieved products are: $productNames",
				      () => context.RetrievedProductsAre(Strings.Create("Product 1", "Product 3")));

			story.AddScenario("Should retrieve only public products when User does not work for any Company")
				.Given("user does not work for any company", context.UserDoesNotWorkForAnyCompany)
				.And("$productName belongs to company $companyId", () => context.ProductBelongsToCompany("Product 1", 1))
				.And("$productName belongs to company $companyId", () => context.ProductBelongsToCompany("Product 2", 2))
				.And("$productName is public", () => context.ProductIsPublic("Product 3"))
				.When("retrieve products for User", context.RetrieveProductsForUser)
				.Then("retrieved products are: $productNames", () => context.RetrievedProductsAre(Strings.Create("Product 3")));
		}
 public void RunScenario()
 {
     var feature = new Feature("Hello");
     feature.AddScenario()
         .WithHelperObject(this)
             .Given("something to call")
             .And("something else")
             .When("method should be called")
             .Then("this should work");
 }
 public void Should_use_And_for_second_Then()
 {
     var feature = new Feature("Hello");
     var scenarioBuilder = feature.AddScenario();
     var fragment = scenarioBuilder.Given("foo");
     var whenFragment = fragment.When("bar");
     var thenFragment = whenFragment.Then("moo");
     thenFragment.And("moo-moo");
     var scenario = feature.Scenarios[0].ToString();
     Assert.AreEqual(
         "Scenario: " + Environment.NewLine +
         "  Given foo" + Environment.NewLine +
         "  When bar" + Environment.NewLine +
         "  Then moo" + Environment.NewLine +
         "  And moo-moo", scenario);
 }
 public void Should_use_And_for_second_Given()
 {
     var feature = new Feature("Hello");
     var scenarioBuilder = feature.AddScenario();
     var fragment = scenarioBuilder.Given("foo");
     fragment.And("bar");
     var scenario = feature.Scenarios[0].ToString();
     Assert.AreEqual(
         "Scenario: " + Environment.NewLine +
         "  Given foo" + Environment.NewLine +
         "  And bar", scenario);
 }
        public void Should_call_method_with_attribute_in_ActionStepsClass()
        {
            bool givenWasCalled = false;
            bool andWasCalled = false;
            bool whenWasCalled = false;
            bool thenWasCalled = false;

            var feature = new Feature("Hello");
            feature.AddScenario()
                .Given("something to call", () => givenWasCalled = true)
                .And("something else", () => andWasCalled = true)
                .When("method should be called", () => whenWasCalled = true)
                .Then("this should work", () => thenWasCalled = true);

            Assert.IsTrue(givenWasCalled, "Given step was not invoked");
            Assert.IsTrue(andWasCalled, "And step was not invoked");
            Assert.IsTrue(whenWasCalled, "When step was not invoked");
            Assert.IsTrue(thenWasCalled, "Then step was not invoked");
        }