Example #1
0
        public void CreateClassSingle()
        {
            var        empty     = new List <ISchemaDecorator>(0);
            var        schemaGen = new SchemaGenerator(empty);
            MockSchema schema    = new MockSchema
            {
                Id            = "mockSchemaObject",
                Name          = "mockSchemaObject",
                SchemaDetails = MockSchema.CreateSimpleSchema("mockSchemaObject")
            };
            var typeDeclaration = schemaGen.CreateClass(
                schema, new Dictionary <JsonSchema, SchemaImplementationDetails>(), Enumerable.Empty <string>());

            Assert.IsNotNull(typeDeclaration);
            Assert.AreEqual("MockSchemaObject", typeDeclaration.Name);
            Assert.IsEmpty(typeDeclaration.Members);
        }
Example #2
0
        public void CreateClassWithSingleDecorator()
        {
            var oneDecorator = new List <ISchemaDecorator>(1)
            {
                new CountingDecorator()
            };
            var        schemaGen = new SchemaGenerator(oneDecorator);
            MockSchema schema    = new MockSchema
            {
                Id            = "mockSchemaObject",
                Name          = "mockSchemaObject",
                SchemaDetails = MockSchema.CreateSimpleSchema("mockSchemaObject")
            };

            schemaGen.CreateClass(
                schema, new Dictionary <JsonSchema, SchemaImplementationDetails>(), Enumerable.Empty <string>());
            Assert.AreEqual(1, ((CountingDecorator)oneDecorator[0]).Count);
        }
Example #3
0
        public void CreateClassWithMultipleDecorators()
        {
            var once       = new CountingDecorator();
            var threeTimes = new CountingDecorator();
            var decorators = new List <ISchemaDecorator>(4)
            {
                once, threeTimes, threeTimes, threeTimes
            };
            var        schemaGen = new SchemaGenerator(decorators);
            MockSchema schema    = new MockSchema
            {
                Id            = "mockSchemaObject",
                Name          = "mockSchemaObject",
                SchemaDetails = MockSchema.CreateSimpleSchema("mockSchemaObject")
            };

            schemaGen.CreateClass(
                schema, new Dictionary <JsonSchema, SchemaImplementationDetails>(), Enumerable.Empty <string>());
            Assert.AreEqual(1, ((CountingDecorator)decorators[0]).Count);
            Assert.AreEqual(3, ((CountingDecorator)decorators[1]).Count);
            Assert.AreEqual(3, ((CountingDecorator)decorators[2]).Count);
            Assert.AreEqual(3, ((CountingDecorator)decorators[3]).Count);
        }