public void WriteWithNullJsonTextWriter() { JsonTextWriter writer = null; ResourceSchema resourceSchema = new ResourceSchema(); Assert.Throws <ArgumentNullException>(() => { ResourceSchemaWriter.Write(writer, resourceSchema); }); }
public void WriteWithJsonTextWriterAndNullResourceSchema() { StringWriter stringWriter = new StringWriter(); JsonTextWriter writer = new JsonTextWriter(stringWriter); ResourceSchema resourceSchema = null; Assert.Throws <ArgumentNullException>(() => { ResourceSchemaWriter.Write(writer, resourceSchema); }); }
public void WriteWithEmptyResourceSchema() { StringWriter stringWriter = new StringWriter(); JsonTextWriter writer = new JsonTextWriter(stringWriter); ResourceSchema resourceSchema = new ResourceSchema(); ResourceSchemaWriter.Write(writer, resourceSchema); Assert.Equal("{}", stringWriter.ToString()); }
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()); }
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()); }
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()); }
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()); }