Example #1
0
        public void WriteWithNullJsonTextWriter()
        {
            JsonTextWriter writer         = null;
            ResourceSchema resourceSchema = new ResourceSchema();

            Assert.Throws <ArgumentNullException>(() => { ResourceSchemaWriter.Write(writer, resourceSchema); });
        }
Example #2
0
        public void WriteWithJsonTextWriterAndNullResourceSchema()
        {
            StringWriter   stringWriter   = new StringWriter();
            JsonTextWriter writer         = new JsonTextWriter(stringWriter);
            ResourceSchema resourceSchema = null;

            Assert.Throws <ArgumentNullException>(() => { ResourceSchemaWriter.Write(writer, resourceSchema); });
        }
Example #3
0
        public void WriteWithEmptyResourceSchema()
        {
            StringWriter   stringWriter   = new StringWriter();
            JsonTextWriter writer         = new JsonTextWriter(stringWriter);
            ResourceSchema resourceSchema = new ResourceSchema();

            ResourceSchemaWriter.Write(writer, resourceSchema);
            Assert.Equal("{}", stringWriter.ToString());
        }
Example #4
0
        public void WriteWithId()
        {
            StringWriter   stringWriter = new StringWriter();
            JsonTextWriter writer       = new JsonTextWriter(stringWriter);

            writer.QuoteChar = '\'';

            ResourceSchema resourceSchema = new ResourceSchema();

            resourceSchema.Id = "MockId";

            ResourceSchemaWriter.Write(writer, resourceSchema);
            Assert.Equal("{'id':'MockId'}", stringWriter.ToString());
        }
Example #5
0
        public void WriteWithDescription()
        {
            StringWriter   stringWriter = new StringWriter();
            JsonTextWriter writer       = new JsonTextWriter(stringWriter);

            writer.QuoteChar = '\'';

            ResourceSchema resourceSchema = new ResourceSchema();

            resourceSchema.Title       = "MockTitle";
            resourceSchema.Description = "MockDescription";

            ResourceSchemaWriter.Write(writer, resourceSchema);
            Assert.Equal("{'title':'MockTitle','description':'MockDescription'}", stringWriter.ToString());
        }
Example #6
0
        public void WriteWithTitle()
        {
            StringWriter   stringWriter = new StringWriter();
            JsonTextWriter writer       = new JsonTextWriter(stringWriter);

            writer.QuoteChar = '\'';

            ResourceSchema resourceSchema = new ResourceSchema();

            resourceSchema.Schema = "MockSchema";
            resourceSchema.Title  = "MockTitle";

            ResourceSchemaWriter.Write(writer, resourceSchema);
            Assert.Equal("{'$schema':'MockSchema','title':'MockTitle'}", stringWriter.ToString());
        }
Example #7
0
        public void WriteWithOneDefinition()
        {
            StringWriter   stringWriter = new StringWriter();
            JsonTextWriter writer       = new JsonTextWriter(stringWriter);

            writer.QuoteChar = '\'';

            ResourceSchema resourceSchema = new ResourceSchema();

            resourceSchema.AddResourceDefinition("mockResource", new JsonSchema());
            resourceSchema.AddDefinition("mockDefinition", new JsonSchema());

            ResourceSchemaWriter.Write(writer, resourceSchema);
            Assert.Equal("{'resourceDefinitions':{'mockResource':{}},'definitions':{'mockDefinition':{}}}", stringWriter.ToString());
        }