public JsonStep Map(Step step)
        {
            if (step == null)
            {
                return(null);
            }

            var result = new JsonStep
            {
                Keyword               = this.keywordMapper.Map(step.Keyword),
                NativeKeyword         = step.NativeKeyword,
                Name                  = step.Name,
                TableArgument         = this.tableMapper.Map(step.TableArgument),
                DocStringArgument     = step.DocStringArgument,
                StepComments          = new List <JsonComment>(),
                AfterLastStepComments = new List <JsonComment>()
            };

            var comments = (step.Comments ?? new List <Comment>()).ToArray();

            result.StepComments.AddRange(comments.Where(s => s.Type == CommentType.StepComment).Select(this.commentMapper.Map));
            result.AfterLastStepComments.AddRange(comments.Where(s => s.Type == CommentType.AfterLastStepComment).Select(this.commentMapper.Map));

            return(result);
        }
        public void Map_NullStep_ReturnsNull()
        {
            var mapper = CreateMapper();

            JsonStep actual = mapper.Map(null);

            Check.That(actual).IsNull();
        }
Пример #3
0
        public void Text(FormDataSetEntry entry, String value)
        {
            var item    = CreateValue(entry.Type, value);
            var steps   = JsonStep.Parse(entry.Name);
            var context = (JsonElement)_context;

            foreach (var step in steps)
            {
                context = step.Run(context, item, file: false);
            }
        }
Пример #4
0
        public void File(FormDataSetEntry entry, String fileName, String contentType, IFile file)
        {
            var context = (JsonElement)_context;
            var stream  = file != null && file.Body != null && file.Type != null ? file.Body : Stream.Null;
            var content = new MemoryStream();

            stream.CopyTo(content);
            var data  = content.ToArray();
            var steps = JsonStep.Parse(entry.Name);
            var value = new JsonObject();

            value[AttributeNames.Type] = new JsonValue(contentType);
            value[AttributeNames.Name] = new JsonValue(fileName);
            value[AttributeNames.Body] = new JsonValue(Convert.ToBase64String(data));

            foreach (var step in steps)
            {
                context = step.Run(context, value, file: true);
            }
        }
Пример #5
0
        public JsonStep Map(Step step)
        {
            if (step == null)
            {
                return null;
            }

            var result = new JsonStep
            {
                Keyword = this.keywordMapper.Map(step.Keyword),
                NativeKeyword = step.NativeKeyword,
                Name = step.Name,
                TableArgument = this.tableMapper.Map(step.TableArgument),
                DocStringArgument = step.DocStringArgument,
                StepComments = new List<JsonComment>(),
                AfterLastStepComments = new List<JsonComment>()
            };

            var comments = (step.Comments ?? new List<Comment>()).ToArray();
            result.StepComments.AddRange(comments.Where(s => s.Type == CommentType.StepComment).Select(this.commentMapper.Map));
            result.AfterLastStepComments.AddRange(comments.Where(s => s.Type == CommentType.AfterLastStepComment).Select(this.commentMapper.Map));

            return result;
        }