Exemplo n.º 1
0
        public async Task Children(ChildrenDataRow row)
        {
            var children = row.Children.Select(childRow => {
                var child = Substitute.For <IRValueInfo>();
                child.Name.Returns((string)childRow[0]);
                child.Expression.Returns((string)childRow[1]);
                child.Representation.Returns((string)childRow[2]);
                return(child);
            }).ToArray();

            var frame = (await _session.TracebackAsync()).Single();

            await _session.ExecuteAsync("PARENT <- {" + row.Expression + "}");

            var res = (await frame.TryEvaluateAndDescribeAsync("PARENT", AllFields, null))
                      .Should().BeAssignableTo <IRValueInfo>().Which;

            res.Length.Should().Be(row.Length);
            res.NameCount.Should().Be(row.NameCount);
            res.AttributeCount.Should().Be(row.AttrCount);
            res.SlotCount.Should().Be(row.SlotCount);

            var actualChildren = (await res.DescribeChildrenAsync(AllFields, RValueRepresentations.Deparse()))
                                 .Cast <IRValueInfo>()
                                 .ToArray();

            res.HasChildren.Should().Be(children.Any());

            if (row.Sorted)
            {
                actualChildren = actualChildren.OrderBy(er => er.Name).ToArray();
            }

            actualChildren.ShouldAllBeEquivalentTo(children, options => options
                                                   .Including(child => child.Name)
                                                   .Including(child => child.Expression)
                                                   .Including(child => child.Representation)
                                                   .WithStrictOrdering());
        }
Exemplo n.º 2
0
        public async Task Children(ChildrenDataRow row) {
            var children = row.Children.Select(childRow => {
                var child = Substitute.For<IRValueInfo>();
                child.Name.Returns((string)childRow[0]);
                child.Expression.Returns((string)childRow[1]);
                child.Representation.Returns((string)childRow[2]);
                return child;
            }).ToArray();

            var frame = (await _session.TracebackAsync()).Single();

            await _session.ExecuteAsync("PARENT <- {" + row.Expression + "}");

            var res = (await frame.TryEvaluateAndDescribeAsync("PARENT", AllFields, null))
                .Should().BeAssignableTo<IRValueInfo>().Which;
            res.Length.Should().Be(row.Length);
            res.NameCount.Should().Be(row.NameCount);
            res.AttributeCount.Should().Be(row.AttrCount);
            res.SlotCount.Should().Be(row.SlotCount);

            var actualChildren = (await res.DescribeChildrenAsync(AllFields, RValueRepresentations.Deparse()))
                .Cast<IRValueInfo>()
                .ToArray();
            res.HasChildren.Should().Be(children.Any());

            if (row.Sorted) {
                actualChildren = actualChildren.OrderBy(er => er.Name).ToArray();
            }

            actualChildren.ShouldAllBeEquivalentTo(children, options => options
                .Including(child => child.Name)
                .Including(child => child.Expression)
                .Including(child => child.Representation)
                .WithStrictOrdering());
        }