示例#1
0
        public void ParseListAsAnyShouldSucceed()
        {
            var input      = @"
- fooBar
- 10
- 2.34
- 2017-01-01
                ";
            var yamlStream = new YamlStream();

            yamlStream.Load(new StringReader(input));
            var yamlNode = yamlStream.Documents.First().RootNode;

            var diagnostic = new OpenApiDiagnostic();
            var context    = new ParsingContext(diagnostic);

            var node = new ListNode(context, (YamlSequenceNode)yamlNode);

            var any = node.CreateAny();

            diagnostic.Errors.Should().BeEmpty();

            any.Should().BeEquivalentTo(
                new OpenApiArray
            {
                new OpenApiString("fooBar"),
                new OpenApiString("10"),
                new OpenApiString("2.34"),
                new OpenApiString("2017-01-01")
            });
        }
示例#2
0
        public void ParseListAsAnyShouldSucceed()
        {
            var input      = @"
- fooBar
- 10
- 2.34
- 2017-01-01
                ";
            var yamlStream = new YamlStream();

            yamlStream.Load(new StringReader(input));
            var yamlNode = yamlStream.Documents.First().RootNode;

            var context    = new ParsingContext();
            var diagnostic = new OpenApiDiagnostic();

            var node = new ListNode(context, diagnostic, (YamlSequenceNode)yamlNode);

            var any = node.CreateAny();

            diagnostic.Errors.Should().BeEmpty();

            any.ShouldBeEquivalentTo(
                new OpenApiArray
            {
                new OpenApiString("fooBar"),
                new OpenApiInteger(10),
                new OpenApiDouble(2.34),
                new OpenApiDateTime(DateTimeOffset.Parse("2017-01-01", CultureInfo.InvariantCulture))
            });
        }