Пример #1
0
        public void NamedTypeTest()
        {
            var address = new BifoqlNamedType("Address", BifoqlType.Map(BifoqlType.Property("street", BifoqlType.String)));
            var person  = new BifoqlNamedType("Person", BifoqlType.Map(BifoqlType.Property("name", BifoqlType.String), BifoqlType.Property("address", BifoqlType.Named(() => address))));

            var optionalPerson = BifoqlType.Map(BifoqlType.Property("p",
                                                                    BifoqlType.Index(BifoqlType.Named(() => person),
                                                                                     BifoqlType.IndexParameter("id", BifoqlType.Number),
                                                                                     BifoqlType.IndexParameter("locale", BifoqlType.String, optional: true))));

            var s = new Schema(optionalPerson, address, person);

            var schema =
                @"{
    p: (id: number, locale?: string) => Person
}

Address = {
    street: string
}

Person = {
    name: string,
    address: Address
}
";

            Assert.Equal(schema, s.BuildDocumentation());
        }
Пример #2
0
        public void NamedTypeWithDocumentationTest()
        {
            var person = new BifoqlNamedType("Person", BifoqlType.Map(BifoqlType.Property("name", BifoqlType.String)), "A human being");

            var optionalPerson = BifoqlType.Map(BifoqlType.Property("p",
                                                                    BifoqlType.Index(BifoqlType.Named(() => person),
                                                                                     BifoqlType.IndexParameter("id", BifoqlType.Number),
                                                                                     BifoqlType.IndexParameter("locale", BifoqlType.String, optional: true))));

            var s = new Schema(optionalPerson, person);

            var schema =
                @"{
    p: (id: number, locale?: string) => Person
}

// A human being
Person = {
    name: string
}
";

            Assert.Equal(schema, s.BuildDocumentation());
        }