Пример #1
0
        public void MapToStep_StepWithTableArgument_ReturnStepWithTable()
        {
            var mapper = this.factory.CreateMapper();

            G.Step step = this.factory.CreateStep(
                "When",
                "I use this table",
                new[]
            {
                new[] { "Header 1", "Header 2" },
                new[] { "Value 1", "Value 2" },
            });

            var result = mapper.MapToStep(step);

            Check.That(result.Keyword).IsEqualTo(Keyword.When);
            Check.That(result.NativeKeyword).IsEqualTo("When");
            Check.That(result.Name).IsEqualTo("I use this table");
            Check.That(result.TableArgument.HeaderRow.Cells).ContainsExactly("Header 1", "Header 2");
            Check.That(result.TableArgument.DataRows).HasSize(1);
            Check.That(result.TableArgument.DataRows[0].Cells).ContainsExactly("Value 1", "Value 2");
            Check.That(result.DocStringArgument).IsNull();
            Check.That(result.Location).IsNull();
            Check.That(result.Comments).IsEmpty();
        }
Пример #2
0
 protected ScenarioDefinition(Location location, string keyword, string name, string description, Step[] steps)
 {
     Location = location;
     Keyword = keyword;
     Name = name;
     Description = description;
     Steps = steps;
 }
Пример #3
0
 public Background(Location location, string keyword, string name, string description, Step[] steps)
 {
     Location = location;
     Keyword = keyword;
     Name = name;
     Description = description;
     Steps = steps;
 }
Пример #4
0
        private void FormatStep(Step step, StringBuilder result)
        {
            result.Append(INDENT);
            FormatHasLocation(step, result);
            result.Append(step.Keyword);
            result.Append(step.Text);
            result.AppendLine();

            if (step.Argument is DocString)
                FormatDocString((DocString)step.Argument, result);
            else if (step.Argument is DataTable)
                FormatDataTable((DataTable)step.Argument, result);
        }
Пример #5
0
        public void MapToStep_StepWithWhen_ReturnStep()
        {
            var mapper = this.factory.CreateMapper();

            G.Step step = this.factory.CreateStep("When", "I press 'enter'");

            var result = mapper.MapToStep(step);

            Check.That(result.Keyword).IsEqualTo(Keyword.When);
            Check.That(result.NativeKeyword).IsEqualTo("When");
            Check.That(result.Name).IsEqualTo("I press 'enter'");
            Check.That(result.DocStringArgument).IsNull();
            Check.That(result.TableArgument).IsNull();
        }
Пример #6
0
        public void MapToStep_StepWithDocStringArgument_ReturnStepWithDocString()
        {
            var mapper = this.factory.CreateMapper();

            G.Step step = this.factory.CreateStep("Then", "I see this value on the screen", "120");

            var result = mapper.MapToStep(step);

            Check.That(result.Keyword).IsEqualTo(Keyword.Then);
            Check.That(result.NativeKeyword).IsEqualTo("Then");
            Check.That(result.Name).IsEqualTo("I see this value on the screen");
            Check.That(result.DocStringArgument).IsEqualTo("120");
            Check.That(result.TableArgument).IsNull();
        }
Пример #7
0
        public void MapToStep_StepWithoutArgument_ReturnStep()
        {
            var mapper = this.factory.CreateMapper();

            G.Step step = this.factory.CreateStep("Given", "I enter '50' in the calculator");

            var result = mapper.MapToStep(step);

            Check.That(result.Keyword).IsEqualTo(Keyword.Given);
            Check.That(result.NativeKeyword).IsEqualTo("Given");
            Check.That(result.Name).IsEqualTo("I enter '50' in the calculator");
            Check.That(result.DocStringArgument).IsNull();
            Check.That(result.TableArgument).IsNull();
        }
Пример #8
0
		public MethodInfo GetStepMethod (Step step, IEnumerable<MethodInfo> availableMethods)
		{
			MethodInfo result = null;
			foreach (var method in availableMethods) {
				var attrs = method.GetCustomAttributes <BaseStepAttribute> ();
				foreach (var a in attrs) {
					if (String.Compare(a.StepText, step.Text, true) == 0) {
						result = method;
					}
				}

			}

			return result;
		}
Пример #9
0
        public Step MapToStep(G.Step step)
        {
            if (step == null)
            {
                return(null);
            }

            return(new Step
            {
                Location = this.MapToLocation(step.Location),
                DocStringArgument = step.Argument is G.DocString ? this.MapToString((G.DocString)step.Argument) : null,
                Keyword = this.MapToKeyword(step.Keyword),
                NativeKeyword = step.Keyword,
                Name = step.Text,
                TableArgument = step.Argument is G.DataTable ? this.MapToTable((G.DataTable)step.Argument) : null,
            });
        }
Пример #10
0
        public void MapToStep_StepWithLocation_ReturnStepWithLocation()
        {
            var mapper = this.factory.CreateMapper();

            G.Step step = this.factory.CreateStep(
                "Given", "I am on a step", 3, 4
                );

            var result = mapper.MapToStep(step);

            Check.That(result.Keyword).IsEqualTo(Keyword.Given);
            Check.That(result.NativeKeyword).IsEqualTo("Given");
            Check.That(result.Name).IsEqualTo("I am on a step");
            Check.That(result.DocStringArgument).IsNull();
            Check.That(result.TableArgument).IsNull();
            Check.That(result.Location).IsNotNull();
            Check.That(result.Location.Line).IsEqualTo(3);
            Check.That(result.Location.Column).IsEqualTo(4);
            Check.That(result.Comments).IsEmpty();
        }
Пример #11
0
        public Step MapToStep(G.Step step)
        {
            if (step == null)
            {
                return(null);
            }

            var stepResult = new Step
            {
                Location          = this.MapToLocation(step.Location),
                DocStringArgument = step.Argument is G.DocString ? this.MapToString((G.DocString)step.Argument) : null,
                Keyword           = this.MapToKeyword(step.Keyword),
                NativeKeyword     = step.Keyword,
                Name          = step.Text,
                TableArgument = step.Argument is G.DataTable ? this.MapToTable((G.DataTable)step.Argument) : null
            };
            var comments = this.resourceFileMapper.MapFiles(step.Text, stepResult.Location);

            stepResult.Comments.AddRange(comments);

            return(stepResult);
        }
Пример #12
0
 public Background(Location location, string keyword, string name, string description, Step[] steps)
     : base(location, keyword, name, description, steps)
 {
 }
Пример #13
0
 public Step MapToStep(G.Step step)
 {
     return(this.mapper.Map <Step>(step));
 }
Пример #14
0
        internal G.Step CreateStep(string keyword, string text, int locationLine, int locationColumn)
        {
            var step = new G.Step(this.CreateLocation(locationLine, locationColumn), keyword, text, null);

            return(step);
        }
Пример #15
0
 internal G.Step CreateStep(string keyword, string text, int locationLine, int locationColumn)
 {
     var step =  new G.Step(this.CreateLocation(locationLine, locationColumn), keyword, text, null);
     return step;
 }
Пример #16
0
 public ScenarioOutline(Tag[] tags, Location location, string keyword, string name, string description, Step[] steps, Examples[] examples)
     : base(location, keyword, name, description, steps)
 {
     Tags = tags;
     Examples = examples;
 }
Пример #17
0
 public Scenario(Tag[] tags, Location location, string keyword, string name, string description, Step[] steps)
     : base(location, keyword, name, description, steps)
 {
     Tags = tags;
 }
Пример #18
0
		public void Log (Step step)
		{
			Console.WriteLine ("    {0}{1}", step.Keyword, step.Text);
		}
Пример #19
0
		Step CreateStep (string keyword, string text)
		{
			var location = new Location (0, 0);
			var arg = new StepArgumentMock ();

			var step = new Step (location, keyword, text, arg);

			return step;
		}