Пример #1
0
        public void SliceSelectorOnlyTo()
        {
            // Arrange
            var data = "[1, 2, 3]".AsJson();
            var op   = new SliceSelector {
                From = new Literal(1),
            };

            // Act
            var result = op.RunAsSequence(data);

            // Assert
            Json.Array(result)
            .DeepEqual("[[2, 3]]".AsJson())
            .Should().BeTrue();
        }
Пример #2
0
        public void SliceSelectorFullNegative()
        {
            // Arrange
            var data = "[1, 2, 3]".AsJson();
            var op   = new SliceSelector {
                From = new Literal(-3),
                To   = new Literal(-1)
            };

            // Act
            var result = op.RunAsSequence(data);

            // Assert
            Json.Array(result)
            .DeepEqual("[[1, 2]]".AsJson())
            .Should().BeTrue();
        }
Пример #3
0
        public void SliceSelectorOptional()
        {
            // Arrange
            var data = "{}".AsJson();
            var op   = new SliceSelector {
                From       = new Literal(1),
                To         = new Literal(3),
                IsOptional = true
            };

            // Act
            var result = op.RunAsSequence(data);

            // Assert
            Json.Array(result)
            .DeepEqual("[]".AsJson())
            .Should().BeTrue();
        }