Esempio n. 1
0
        public void TestSimpleSingleProperty()
        {
            var schemaExtractor = new SchemaExtractor(new HandlebarsParser());
            var schema          = schemaExtractor.Run("test", new StreamReader(Path.Combine(TestContext.DeploymentDirectory, "simpleSingleProperty.mustache")), null, null);

            SchemaAssertions.AssertSingleProperty(schema, "Name", JSchemaType.String);
        }
Esempio n. 2
0
        public void TestNoRequiredPropertys()
        {
            var schemaExtractor = new SchemaExtractor(new HandlebarsParser());
            var schema          = schemaExtractor.Run("test", new StreamReader(Path.Combine(TestContext.DeploymentDirectory, "noRequiredProperty.mustache")), null, null);

            SchemaAssertions.AssertSingleProperty(schema, "Customer", JSchemaType.Object);
            SchemaAssertions.AssertSingleProperty(schema.Properties["Customer"], "Name", JSchemaType.String, false);
        }
        public void TestMoreSpecific()
        {
            var comparer     = new SchemaComparer();
            var resultSchema = comparer.Apply(GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/moreSpecific.json")),
                                              GetSchema(Path.Combine(TestContext.DeploymentDirectory, "Comparisions/moreSpecific_base.json")),
                                              new SchemaComparisionReport());

            Assert.IsNotNull(resultSchema);
            Assert.AreEqual("TestModel", resultSchema.Title, "Expected the title for the base schema");
            SchemaAssertions.AssertSingleProperty(resultSchema, "name", JSchemaType.Integer);
        }
Esempio n. 4
0
        public void TestMultipleProperties()
        {
            var schemaExtractor = new SchemaExtractor(new HandlebarsParser());
            var schema          = schemaExtractor.Run("test", new StreamReader(Path.Combine(TestContext.DeploymentDirectory, "multipleProperties.mustache")), null, null);

            SchemaAssertions.AssertSingleProperty(schema, "Title", JSchemaType.String);
            SchemaAssertions.AssertSingleProperty(schema, "Customer", JSchemaType.Object);
            SchemaAssertions.AssertSingleProperty(schema.Properties["Customer"], "Name", JSchemaType.String);
            SchemaAssertions.AssertSingleProperty(schema.Properties["Customer"], "Age", JSchemaType.String);
            SchemaAssertions.AssertSingleProperty(schema.Properties["Customer"], "Order", JSchemaType.Object);
            SchemaAssertions.AssertSingleProperty(schema.Properties["Customer"].Properties["Order"], "Count", JSchemaType.String);
        }
Esempio n. 5
0
        public void TestArrayProperty()
        {
            var schemaExtractor = new SchemaExtractor(new HandlebarsParser());
            var schema          = schemaExtractor.Run("test", new StreamReader(Path.Combine(TestContext.DeploymentDirectory, "arrayProperty.mustache")), null, null);

            SchemaAssertions.AssertSingleProperty(schema, "Customer", JSchemaType.Object);
            SchemaAssertions.AssertSingleProperty(schema.Properties["Customer"], "Addresses", JSchemaType.Array);
            Assert.IsNotNull(schema.Properties["Customer"].Properties["Addresses"].Items, "an items array should be given for an array type.");
            Assert.AreEqual(1, schema.Properties["Customer"].Properties["Addresses"].Items.Count, "expectects exactly on item inside items");

            SchemaAssertions.AssertSingleProperty(schema.Properties["Customer"].Properties["Addresses"].Items[0], "Street", JSchemaType.String);
            SchemaAssertions.AssertSingleProperty(schema.Properties["Customer"].Properties["Addresses"].Items[0], "ZipCode", JSchemaType.String);
        }
Esempio n. 6
0
        public void TestIgnoreHelpers()
        {
            var schemaExtractor = new SchemaExtractor(new HandlebarsParser());

            var helper = new Mock <IHelperHandler>();

            helper.Setup(m => m.IsSupported(It.IsAny <string>())).Returns((string s) => s.StartsWith("helper"));

            var helperHandlers = new [] { helper.Object };
            var schema         = schemaExtractor.Run("test", new StreamReader(Path.Combine(TestContext.DeploymentDirectory, "ignoreHelpers.mustache")), null, helperHandlers);

            SchemaAssertions.AssertSingleProperty(schema, "Customer", JSchemaType.Object);
            SchemaAssertions.AssertSingleProperty(schema.Properties["Customer"], "Name", JSchemaType.String);

            Assert.IsFalse(schema.Properties.ContainsKey("helper param=\"val1\""), "No property helper should be inside the schema.");
            //Assert.IsTrue(schema.Properties.ContainsKey("noregistredHelper param=\"val1\""), "The none registred helpers should be still included.");
            SchemaAssertions.AssertSingleProperty(schema, "variableExpressionWithWhitespace", JSchemaType.String);
        }