Пример #1
0
 public Scenario(string title, string source)
     : this(title, source, new Feature())
 {
     Feature = new Feature();
     Title = title;
     _steps = new List<StringStep>();
     _examples = new List<Example>();
 }
Пример #2
0
 public Scenario(string title, string source, Feature feature, int sourceLine)
 {
     Feature = feature;
     Title = title;
     Source = source;
     SourceLine = sourceLine;
     _steps = new List<StringStep>();
     _examples = new List<Example>();
 }
Пример #3
0
 public IEnumerable<ClassificationSpan> CreateScenarioClassification(Feature feature, ITextSnapshot snapshot)
 {
     return feature.Scenarios
         .Select(scenario =>
                     {
                         var snapshotSpan = CreateClassification(scenario.SourceLine, scenario.Title, snapshot);
                         return (snapshotSpan.HasValue) ? new ClassificationSpan(snapshotSpan.Value, ClassificationRegistry.ScenarioTitle) : null;
                     })
         .Where(c => c != null);
 }
Пример #4
0
//        public void SetupFeature(
//            NBehave.Narrator.Framework.Feature feature)
//        {
//            base.Feature = feature;
//        }

        protected override NBehave.Narrator.Framework.Feature CreateFeature()
        {
            NBehave.Narrator.Framework.Feature featureTest =
                new NBehave.Narrator.Framework.Feature(this.featureName)
                .AddStory()
                .AsA(this.asA)
                .IWant(this.iWant)
                .SoThat(this.soThat);

            return(featureTest);
        }
Пример #5
0
//        public void SetupFeature(
//            NBehave.Narrator.Framework.Feature feature)
//        {
//            base.Feature = feature;
//        }
        
        protected override NBehave.Narrator.Framework.Feature CreateFeature()
        {
            NBehave.Narrator.Framework.Feature featureTest =
                new NBehave.Narrator.Framework.Feature(this.featureName)
                .AddStory()
                .AsA(this.asA)
                .IWant(this.iWant)
                .SoThat(this.soThat);

            return featureTest;
        }
Пример #6
0
 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");
 }
Пример #7
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")));
		}
Пример #8
0
 public FeatureGherkinText(Feature feature)
 {
     this.feature = feature;
 }
Пример #9
0
 public virtual void FeatureStarted(Feature feature)
 {
 }
Пример #10
0
 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);
 }
Пример #11
0
 private IList<ClassificationSpan> SelectClassifiable(Feature feature, ITextSnapshot snapshot)
 {
     ClassificationSpan f = GherkinClassifier.CreateFeatureClassification(feature, snapshot);
     var classificationSpans = new List<ClassificationSpan>();
     //classificationSpans.Add(f);
     classificationSpans.AddRange(GherkinClassifier.CreateScenarioClassification(feature, snapshot).ToList());
     return classificationSpans;
 }
Пример #12
0
 public StoryBuilder(Feature feature)
 {
     _feature = feature;
 }
Пример #13
0
 public ClassificationSpan CreateFeatureClassification(Feature feature, ITextSnapshot snapshot)
 {
     var snapshotSpan = CreateClassification(feature.SourceLine, feature.Title, snapshot);
     return (snapshotSpan.HasValue) ? new ClassificationSpan(snapshotSpan.Value, ClassificationRegistry.FeatureTitle) : null;
 }
Пример #14
0
 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");
 }
Пример #15
0
 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);
 }
Пример #16
0
 public FeatureContext(Feature feature)
 {
     Feature = feature;
 }
Пример #17
0
 public FeatureContext(Feature feature, IEnumerable<string> tags)
     : this(feature)
 {
     AddTags(tags);
 }
Пример #18
0
 private void CreateFeatureElement(Feature feature)
 {
     IProjectFile featureFile = FindFile(feature);
     _parent = new NBehaveFeatureTestElement(feature.Title, featureFile, _unitTestProvider, _projectModel);
     Add(_parent);
 }
Пример #19
0
 public Scenario(string title, string source, Feature feature)
     : this(title, source, feature, -1)
 {
 }
Пример #20
0
        private IProjectFile FindFile(Feature feature)
        {
            ICollection<IProjectItem> proj = _solution.FindProjectItemsByLocation(new FileSystemPath(feature.Source));

            string featureFileName = Path.GetFileName(feature.Source.ToLower());
            foreach (var item in proj)
            {
                var project = item.GetProject();
                var file = project.GetAllProjectFiles().SingleOrDefault(_ => Path.GetFileName(_.Location.FullPath.ToLower()) == featureFileName);
                if (file != null)
                    return file;
            }
            return null;
        }
 public override void FeatureStarted(Feature feature)
 {
     listener.WriteLine("\tFeature: " + feature.Title, Category.Output);
 }
Пример #22
0
 private void BuildScenarios(Feature feature)
 {
     foreach (var scenario in feature.Scenarios)
     {
         BuildScenario(scenario);
     }
 }
Пример #23
0
 public AsAFragment(Feature feature)
 {
     _builder = new StoryBuilder(feature);
 }
Пример #24
0
 public ScenarioResult(Feature feature, string scenarioTitle)
 {
     FeatureTitle = feature.Title;
     ScenarioTitle = scenarioTitle;
     _actionStepResults = new List<StepResult>();
 }
Пример #25
0
 public ScenarioExampleResult(Feature feature, string scenarioTitle, IEnumerable<StringStep> stringSteps, IEnumerable<Example> examples)
     : base(feature, scenarioTitle)
 {
     AddSteps(stringSteps);
     Examples = examples;
 }
Пример #26
0
        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");
        }