• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Scenario类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Scenario的典型用法代码示例。如果您正苦于以下问题:C# Scenario类的具体用法?C# Scenario怎么用?C# Scenario使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Scenario类属于命名空间,在下文中一共展示了Scenario类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Format

        public void Format(Body body, Scenario background)
        {
            var headerParagraph   = new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Heading2" }));
            var backgroundKeyword = GetLocalizedBackgroundKeyword();
            headerParagraph.Append(new Run(new RunProperties(new Bold()), new Text(backgroundKeyword)));

            var table = new Table();
            table.Append(GenerateTableProperties());
            var row = new TableRow();
            var cell = new TableCell();
            cell.Append(headerParagraph);

            foreach (var descriptionSentence in WordDescriptionFormatter.SplitDescription(background.Description))
            {
                cell.Append(CreateNormalParagraph(descriptionSentence));
            }

            foreach (var step in background.Steps)
            {
                cell.Append(WordStepFormatter.GenerateStepParagraph(step));
            }

            cell.Append(CreateNormalParagraph("")); // Is there a better way to generate a new empty line?
            row.Append(cell);
            table.Append(row);

            body.Append(table);
        }
开发者ID:Jaykul,项目名称:pickles,代码行数:28,代码来源:WordBackgroundFormatter.cs


示例2: Format

        public void Format(XElement parentElement, Scenario scenario)
        {
            var section = new XElement("section",
                                       new XElement("title", scenario.Name));

            if (this.configuration.HasTestResults)
            {
                TestResult testResult = this.nunitResults.GetScenarioResult(scenario);
                if (testResult.WasExecuted && testResult.WasSuccessful)
                {
                    section.Add(new XElement("note", "This scenario passed"));
                }
                else if (testResult.WasExecuted && !testResult.WasSuccessful)
                {
                    section.Add(new XElement("note", "This scenario failed"));
                }
            }

            if (!string.IsNullOrEmpty(scenario.Description))
            {
                section.Add(new XElement("p", scenario.Description));
            }

            foreach (Step step in scenario.Steps)
            {
                this.ditaStepFormatter.Format(section, step);
            }

            parentElement.Add(section);
        }
开发者ID:Jaykul,项目名称:pickles,代码行数:30,代码来源:DitaScenarioFormatter.cs


示例3: Scenario

 /// <summary>
 /// Create a new scenario with the given title, ensuring the previous scenario was properly
 /// cleaned up. Suggested if you use MBUnit or NUnit to
 /// create a base class with a method 'Scenario()' which uses the current test's naame. E.g.
 /// 
 /// protected Scenario(){
 ///    return Scenario(TestContext.CurrentContext.Test.Name);
 /// }
 /// </summary>
 /// <param name="title">the scenario title. Can not be empty or null</param>
 /// <returns>a newly created scenario</returns>
 public Scenario Scenario(String title)
 {
     //ensure previous scenario has completed to prevent dangling scenarios
     //i.e. those which look like they have passed but haven't actually run
     if (CurrentScenario != null) 
     { 
         try
         {
             AfterTest();
         }
         catch (AssertionFailedException e)
         {
             throw new AssertionFailedException("Previous Scenario failed", e);
         }
         BeforeTest();
     }
     if (String.IsNullOrWhiteSpace(title))
     {
         TestFirstAssert.Fail("Scenario's require a title");
     } 
     //Console.WriteLine("New Scenario:" + title);
     OnBeforeNewScenario();
     CurrentScenario = new Scenario(title, Injector);      
     return CurrentScenario;
 }
开发者ID:andreasetti,项目名称:TestFirst.Net,代码行数:36,代码来源:AbstractScenarioTest.cs


示例4: ThenSingleScenarioWithStepsAddedSuccessfully

        public void ThenSingleScenarioWithStepsAddedSuccessfully()
        {
            var excelScenarioFormatter = Container.Resolve<ExcelScenarioFormatter>();
            var scenario = new Scenario
                               {
                                   Name = "Test Feature",
                                   Description =
                                       "In order to test this feature,\nAs a developer\nI want to test this feature"
                               };
            var given = new Step {NativeKeyword = "Given", Name = "a precondition"};
            var when = new Step {NativeKeyword = "When", Name = "an event occurs"};
            var then = new Step {NativeKeyword = "Then", Name = "a postcondition"};
            scenario.Steps = new List<Step>(new[] {given, when, then});

            using (var workbook = new XLWorkbook())
            {
                IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1");
                int row = 3;
                excelScenarioFormatter.Format(worksheet, scenario, ref row);

                worksheet.Cell("B3").Value.ShouldEqual(scenario.Name);
                worksheet.Cell("C4").Value.ShouldEqual(scenario.Description);
                row.ShouldEqual(8);
            }
        }
开发者ID:Jaykul,项目名称:pickles,代码行数:25,代码来源:WhenAddingAScenarioToAWorksheet.cs


示例5: GetScenarioId

 public string GetScenarioId(Scenario scenario)
 {
     var id = string.Format("scenario-{0}", _currentScenarioNumber);
    _currentScenarioNumber++;
     _currentStepNumber = 1;
     return id;
 }
开发者ID:rajeshpillai,项目名称:TestStack.BDDfy,代码行数:7,代码来源:SequentialKeyGenerator.cs


示例6: Format

        public XElement Format(Scenario scenario, int id)
        {
          var header = new XElement(
            this.xmlns + "div", 
            new XAttribute("class", "scenario-heading"), 
            new XElement(this.xmlns + "h2", scenario.Name));

          var tags = RetrieveTags(scenario);
          if (tags.Length > 0)
          {
            var paragraph = new XElement(this.xmlns + "p", CreateTagElements(tags.OrderBy(t => t).ToArray(), this.xmlns));
            paragraph.Add(new XAttribute("class", "tags"));
            header.Add(paragraph);
          }

          header.Add(this.htmlDescriptionFormatter.Format(scenario.Description));

          return new XElement(
            this.xmlns + "li",
            new XAttribute("class", "scenario"),
            this.htmlImageResultFormatter.Format(scenario),
            header,
            new XElement(
              this.xmlns + "div",
              new XAttribute("class", "steps"),
              new XElement(
                this.xmlns + "ul",
                scenario.Steps.Select(step => this.htmlStepFormatter.Format(step))))
            );
        }
开发者ID:Jaykul,项目名称:pickles,代码行数:30,代码来源:HtmlScenarioFormatter.cs


示例7: NoTags

        public void NoTags()
        {
            var configuration = Container.Resolve<Configuration>();
              configuration.TestResultsFiles = null;

              var scenario = new Scenario
              {
            Name = "A Scenario",
            Description = @"This scenario has no tags",
            Tags = { }
              };

              var htmlFeatureFormatter = Container.Resolve<HtmlScenarioFormatter>();
              XElement featureElement = htmlFeatureFormatter.Format(scenario, 1);
              XElement header = featureElement.Elements().FirstOrDefault(element => element.Name.LocalName == "div");

              Assert.NotNull(header);
              header.ShouldBeNamed("div");
              header.ShouldBeInInNamespace("http://www.w3.org/1999/xhtml");
              header.ShouldHaveAttribute("class", "scenario-heading");
              Assert.AreEqual(2, header.Elements().Count());

              header.Elements().ElementAt(0).ShouldBeNamed("h2");
              header.Elements().ElementAt(1).ShouldBeNamed("div");
        }
开发者ID:Wowbies,项目名称:pickles,代码行数:25,代码来源:WhenFormattingScenario.cs


示例8: Should_update_scenarioContext_with_info_from_ScenarioCreated

 public void Should_update_scenarioContext_with_info_from_ScenarioCreated()
 {
     const string scenarioTitle = "scenario title";
     var scenario = new Scenario(scenarioTitle, "", new Feature("ignored"));
     sut.OnScenarioStartedEvent(scenario);
     Assert.That(scenarioContext.ScenarioTitle, Is.EqualTo(scenarioTitle));
 }
开发者ID:AngelPortal,项目名称:NBehave,代码行数:7,代码来源:ContextHandlerSpec.cs


示例9: DictDeserialize

 public override void DictDeserialize(IDictionary<string, object> docu, Scenario scenario = Scenario.Database)
 {
     base.DictDeserialize(docu);
     TableSelector.SelectItem =
         dataManager.DataCollections.FirstOrDefault(d => d.Name == docu["Table"].ToString());
     TableSelector.InformPropertyChanged("");
 }
开发者ID:CHERRISHGRY,项目名称:Hawk,代码行数:7,代码来源:TableGE.cs


示例10: Matches

        protected override bool Matches(Scenario scenario)
        {
            RunScenario runScenario = scenario as RunScenario;
            if (runScenario == null) return false;

            return (mPersonality == runScenario.mPersonality);
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:7,代码来源:RunScenario.cs


示例11: ThenCanRenderTags

        public void ThenCanRenderTags()
        {
            var configuration = Container.Resolve<Configuration>();

            var scenario = new Scenario
                              {
                                  Name = "A Scenario",
                                  Description = @"This scenario has tags",
                                  Tags = { "tag1", "tag2" }
                              };

            var htmlFeatureFormatter = Container.Resolve<HtmlScenarioFormatter>();
            XElement featureElement = htmlFeatureFormatter.Format(scenario, 1);
            XElement header = featureElement.Elements().FirstOrDefault(element => element.Name.LocalName == "div");

            Check.That(header).IsNotNull();
            Check.That(header).IsNamed("div");
            Check.That(header).IsInNamespace("http://www.w3.org/1999/xhtml");
            Check.That(header).HasAttribute("class", "scenario-heading");
            Check.That(header.Elements().Count()).IsEqualTo(3);

            Check.That(header.Elements().ElementAt(0)).IsNamed("h2");
            Check.That(header.Elements().ElementAt(1)).IsNamed("p");
            Check.That(header.Elements().ElementAt(2)).IsNamed("div");

            var tagsParagraph = header.Elements().ElementAt(1);

            Check.That(tagsParagraph.ToString()).IsEqualTo(
              @"<p class=""tags"" xmlns=""http://www.w3.org/1999/xhtml"">Tags: <span>tag1</span>, <span>tag2</span></p>");
        }
开发者ID:testpulse,项目名称:pickles,代码行数:30,代码来源:WhenFormattingScenario.cs


示例12: RunBackground

 private IEnumerable<StepResult> RunBackground(Scenario background)
 {
     return RunSteps(background.Steps, ctx => { }, ctx => { })
         .Select(_ => new BackgroundStepResult(background.Title, _))
         .Cast<StepResult>()
         .ToList();
 }
开发者ID:smhabdoli,项目名称:NBehave,代码行数:7,代码来源:FeatureRunner.cs


示例13: Execute

        public static void Execute(Scenario scenario, Actor actor)
        {
            Precondition.Requires(
                scenario != null,
                Properties.Resources.USE_CASE_SCENARIO_CANNOT_BE_NULL
                );

            Precondition.Requires(
                actor != null,
                Properties.Resources.USE_CASE_ACTOR_CANNOT_BE_NULL
                );

            try
            {
                if (!scenario.Authorize(actor))
                {
                    throw new AuthorizationException(Properties.Resources.USER_AUTHORIZATION_FAILED);
                }

                scenario.Execute();
            }
            catch (DomainException)
            {
                throw;
            }
            catch (Exception exc)
            {
                throw new DomainException(exc.Message, exc);
            }
        }
开发者ID:renatius,项目名称:ClearCut,代码行数:30,代码来源:UseCase.cs


示例14: LoadScenario

        private void LoadScenario(XmlReader reader, Scenario scenario)
        {
            while (!reader.EOF && reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "Stack")
                {
                    var stack = new Stack();
                    scenario.Stacks[reader.GetAttribute("name")] = stack;

                    var stackAttributes = new Dictionary<string, string>();
                    if (reader.MoveToFirstAttribute())
                    {
                        for (; ; )
                        {
                            if (reader.Name != "name")
                                stackAttributes.Add(reader.Name, reader.Value);
                            if (!reader.MoveToNextAttribute())
                                break;
                        }
                        reader.MoveToElement();
                    }

                    reader.ReadStartElement("Stack");
                    LoadStack(reader, stack);
                    reader.ReadEndElement();

                    foreach (var attr in stackAttributes)
                        _stackDecorator[attr.Key](stack, attr.Value);
                }
                else
                {
                    reader.Read();
                }
            }
        }
开发者ID:loudej,项目名称:civcalc,代码行数:35,代码来源:ScenarioLoader.cs


示例15: RunExamples

 private ScenarioResult RunExamples(Scenario scenario)
 {
     var runner = new ExampleRunner();
     Func<IEnumerable<StringStep>, IEnumerable<StepResult>> runSteps = steps => RunSteps(steps, BeforeStep, AfterStep);
     var exampleResults = runner.RunExamples(scenario, runSteps, BeforeScenario, AfterScenario);
     return exampleResults;
 }
开发者ID:smhabdoli,项目名称:NBehave,代码行数:7,代码来源:FeatureRunner.cs


示例16: Should_add_table_steps_to_scenario

        public void Should_add_table_steps_to_scenario()
        {
            var gherkinEvents = MockRepository.GenerateStub<IGherkinParserEvents>();
            var stepBuilder = new StepBuilder(gherkinEvents);
            var feature = new Feature("title");
            var scenario = new Scenario("title", "source", feature);
            gherkinEvents.Raise(_ => _.FeatureEvent += null, this, new EventArgs<Feature>(feature));
            gherkinEvents.Raise(_ => _.ScenarioEvent += null, this, new EventArgs<Scenario>(scenario));
            gherkinEvents.Raise(_ => _.StepEvent += null, this, new EventArgs<StringStep>(new StringStep("step 1", "source")));
            gherkinEvents.Raise(_ => _.StepEvent += null, this, new EventArgs<StringStep>(new StringStep("step 2", "source")));
            gherkinEvents.Raise(_ => _.TableEvent += null, this,
                                new EventArgs<IList<IList<Token>>>(new List<IList<Token>>
                                                                       {
                                                                           new List<Token>
                                                                               {
                                                                                   new Token("A", new LineInFile(1)),
                                                                                   new Token("B", new LineInFile(1))
                                                                               },
                                                                           new List<Token>
                                                                               {
                                                                                   new Token("1", new LineInFile(2)),
                                                                                   new Token("2", new LineInFile(2))
                                                                               },

                                                                       }));
            gherkinEvents.Raise(_ => _.EofEvent += null, this, new EventArgs());

            Assert.That(scenario.Steps.Count(), Is.EqualTo(2));
            Assert.That(scenario.Steps.ToList()[0], Is.TypeOf<StringStep>());
            Assert.That(scenario.Steps.ToList()[1], Is.TypeOf<StringTableStep>());
        }
开发者ID:smhabdoli,项目名称:NBehave,代码行数:31,代码来源:StepBuilderSpec.cs


示例17: ScenarioCodeFrom

        string ScenarioCodeFrom(Scenario Scenario)
        {
            var StepCode = Scenario.Steps.Aggregate("",
                (Steps, Step) => Steps + ExecuteStep(Step));

            return string.Format(ScenarioDeclaration, Scenario.Name, StepCode);
        }
开发者ID:dawnTestCode,项目名称:raconteur,代码行数:7,代码来源:RunnerGenerator.cs


示例18: ReportOnStep

        void ReportOnStep(Scenario scenario, Step step)
        {
            var message =
                string.Format
                    ("\t{0}  [{1}] ",
                    PrefixWithSpaceIfRequired(step).PadRight(_longestStepSentence + 5),
                    Configurator.Scanners.Humanize(step.Result.ToString()));

            // if all the steps have passed, there is no reason to make noise
            if (scenario.Result == Result.Passed)
                message = "\t" + PrefixWithSpaceIfRequired(step);

            if (step.Exception != null)
            {
                _exceptions.Add(step.Exception);

                var exceptionReference = string.Format("[Details at {0} below]", _exceptions.Count);
                if (!string.IsNullOrEmpty(step.Exception.Message))
                    message += string.Format("[{0}] {1}", FlattenExceptionMessage(step.Exception.Message), exceptionReference);
                else
                    message += string.Format("{0}", exceptionReference);
            }

            if (step.Result == Result.Inconclusive || step.Result == Result.NotImplemented)
                Console.ForegroundColor = ConsoleColor.Yellow;
            else if (step.Result == Result.Failed)
                Console.ForegroundColor = ConsoleColor.Red;
            else if (step.Result == Result.NotExecuted)
                Console.ForegroundColor = ConsoleColor.Gray;

            Console.WriteLine(message);
            Console.ForegroundColor = ConsoleColor.White;
        }
开发者ID:rajeshpillai,项目名称:TestStack.BDDfy,代码行数:33,代码来源:ConsoleReporter.cs


示例19: AddFirstLevel

        //missing:
        //- action can't be before first observation -> interface validation!
        public int AddFirstLevel(World.WorldDescription WorldDescription, Scenario.ScenarioDescription ScenarioDescription, out int numberOfImpossibleLeaf)
        {
            numberOfImpossibleLeaf = 0;
            int t = 0;

            //states
            List<string> fluentNames = WorldDescription.GetFluentNames().ToList<string>();
            List<State> states = CreateStatesBasedOnObservations(fluentNames, ScenarioDescription, ref t);

            if (states.Count == 0)
            {
                numberOfImpossibleLeaf = 0;
                return 0;
            }

            foreach (var state in states)
            {
                Vertex newVertex = new Vertex(state, null, t, null);
                LastLevel.Add(newVertex);
            }

            //action
            WorldAction worldAction = ScenarioDescription.GetActionAtTime(t);
            if (worldAction != null)
                for (int i = 0; i < LastLevel.Count; ++i)
                {
                    LastLevel[i].ActualWorldAction = (WorldAction)worldAction.Clone();
                    if (!WorldDescription.Validate(LastLevel[i]))
                    {
                        ++numberOfImpossibleLeaf;
                    }
                }
            return t;
        }
开发者ID:upstreamfall,项目名称:knowledgerepresentation,代码行数:36,代码来源:Tree.cs


示例20: StepBuilder

 public StepBuilder(IGherkinParserEvents gherkinEvents)
 {
     gherkinEvents.ScenarioEvent += (s, e) =>
                                        {
                                            HandlePreviousEvent();
                                            scenario = e.EventInfo;
                                        };
     gherkinEvents.StepEvent += (s, e) =>
                                    {
                                        HandlePreviousEvent();
                                        previousStep = e.EventInfo;
                                    };
     gherkinEvents.DocStringEvent += (s, e) => HandleDocString(e.EventInfo);
     gherkinEvents.FeatureEvent += (s, e) => HandlePreviousEventAndCleanUp();
     gherkinEvents.ExamplesEvent += (s, e) => HandlePreviousEvent();
     gherkinEvents.BackgroundEvent += (s, e) =>
                                          {
                                              HandlePreviousEvent();
                                              scenario = e.EventInfo;
                                          };
     gherkinEvents.TableEvent += (s, e) =>
                                     {
                                         HandleTableEvent(e.EventInfo);
                                         previousStep = null;
                                     };
     gherkinEvents.TagEvent += (s, e) => HandlePreviousEvent();
     gherkinEvents.EofEvent += (s, e) => HandlePreviousEventAndCleanUp();
 }
开发者ID:AngelPortal,项目名称:NBehave,代码行数:28,代码来源:StepBuilder.cs



注:本文中的Scenario类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ScenarioOptions类代码示例发布时间:2022-05-24
下一篇:
C# ScatterViewItem类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap