コード例 #1
0
ファイル: Scenario.cs プロジェクト: smhabdoli/NBehave
 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
ファイル: Scenario.cs プロジェクト: smhabdoli/NBehave
 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
ファイル: EventListener.cs プロジェクト: AngelPortal/NBehave
 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
ファイル: StoryBuilder.cs プロジェクト: AngelPortal/NBehave
 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
ファイル: FeatureContext.cs プロジェクト: smhabdoli/NBehave
 public FeatureContext(Feature feature)
 {
     Feature = feature;
 }
コード例 #17
0
ファイル: FeatureContext.cs プロジェクト: smhabdoli/NBehave
 public FeatureContext(Feature feature, IEnumerable<string> tags)
     : this(feature)
 {
     AddTags(tags);
 }
コード例 #18
0
ファイル: FeatureMapper.cs プロジェクト: AngelPortal/NBehave
 private void CreateFeatureElement(Feature feature)
 {
     IProjectFile featureFile = FindFile(feature);
     _parent = new NBehaveFeatureTestElement(feature.Title, featureFile, _unitTestProvider, _projectModel);
     Add(_parent);
 }
コード例 #19
0
ファイル: Scenario.cs プロジェクト: smhabdoli/NBehave
 public Scenario(string title, string source, Feature feature)
     : this(title, source, feature, -1)
 {
 }
コード例 #20
0
ファイル: FeatureMapper.cs プロジェクト: AngelPortal/NBehave
        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;
        }
コード例 #21
0
 public override void FeatureStarted(Feature feature)
 {
     listener.WriteLine("\tFeature: " + feature.Title, Category.Output);
 }
コード例 #22
0
ファイル: FeatureMapper.cs プロジェクト: AngelPortal/NBehave
 private void BuildScenarios(Feature feature)
 {
     foreach (var scenario in feature.Scenarios)
     {
         BuildScenario(scenario);
     }
 }
コード例 #23
0
ファイル: StoryBuilder.cs プロジェクト: AngelPortal/NBehave
 public AsAFragment(Feature feature)
 {
     _builder = new StoryBuilder(feature);
 }
コード例 #24
0
ファイル: ScenarioResult.cs プロジェクト: smhabdoli/NBehave
 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");
        }