예제 #1
0
    public void PathMustStartWithKey()
    {
        // arrange
        const string path = "variables.1.foo.bar";

        // act
        void Parse() => VariablePath.Parse(path);

        // assert
        Assert.Throws <InvalidOperationException>(Parse);
    }
예제 #2
0
    public void PathHasNoFields()
    {
        // arrange
        const string path = "variables";

        // act
        void Parse() => VariablePath.Parse(path);

        // assert
        Assert.Equal(
            ErrorCodes.Server.MultiPartInvalidPath,
            Assert.Throws <GraphQLRequestException>(Parse).Errors.Single().Code);
    }
예제 #3
0
    public void InvalidRoot()
    {
        // arrange
        const string path = "foo.bar";

        // act
        void Parse() => VariablePath.Parse(path);

        // assert
        Assert.Equal(
            ErrorCodes.Server.MultiPartPathMustStartWithVariable,
            Assert.Throws <GraphQLRequestException>(Parse).Errors.Single().Code);
    }
예제 #4
0
    public void ValidPath()
    {
        // arrange
        const string s = "variables.foo.bar.1.baz";

        // act
        var path = VariablePath.Parse(s);

        // assert
        Assert.Equal("foo", path.Key.Value);
        Assert.Equal("bar", Assert.IsType <KeyPathSegment>(path.Key.Next).Value);
        Assert.Equal(1, Assert.IsType <IndexPathSegment>(path.Key.Next.Next).Value);
        Assert.Equal("baz", Assert.IsType <KeyPathSegment>(path.Key.Next.Next.Next).Value);
    }