public void RequestBodyJsonBuilder_ArrayTypeInput_ProducesJValue(string itemSchemaFormat, string itemSchemaType) { Schema schema = CreateSchemaInputForArrayType(name: "test", itemFormat: itemSchemaFormat, itemType: itemSchemaType); RequestBodyJsonBuilder converter = new RequestBodyJsonBuilder(new DefaultValueFactory()); JToken result = converter.GetJsonResult(schema, swaggerDocDefinitions: new Dictionary <string, Schema>()); Assert.IsType <JArray>(result); }
public void RequestBodyJsonBuilder_ComplexTypeWithNestedTypeInput_ProducesJObjectForNestedChild() { var inputResult = CreateSchemaInputForComplexTypeWithNestedTypes(); RequestBodyJsonBuilder converter = new RequestBodyJsonBuilder(new DefaultValueFactory()); JObject result = (JObject)converter.GetJsonResult(inputResult.schema, swaggerDocDefinitions: inputResult.references); Assert.IsType <JObject>(result["nestedChild"]); }
public void RequestBodyJsonBuilder_ComplexTypeInput_ProducesJObject() { Schema schema = CreateSchemaInputForComplexType(name: "test"); RequestBodyJsonBuilder converter = new RequestBodyJsonBuilder(new DefaultValueFactory()); JToken result = converter.GetJsonResult(schema, swaggerDocDefinitions: new Dictionary <string, Schema>()); Assert.IsType <JObject>(result); }
public void RequestBodyJsonBuilder_PrimitiveTypeInput_ProducesExpectedJObjectType(string schemaFormat, string schemaType, JTokenType expectedTokenType) { Schema schema = CreateSchemaInputForPrimitiveType(name: "test", format: schemaFormat, type: schemaType); RequestBodyJsonBuilder converter = new RequestBodyJsonBuilder(new DefaultValueFactory()); JToken result = converter.GetJsonResult(schema, swaggerDocDefinitions: new Dictionary <string, Schema>()); JValue jsonValue = (JValue)result; Assert.Equal(expectedTokenType, jsonValue.Type); }
public void RequestBodyJsonBuilder_ArrayTypeInput_ProducesExpectedJObjectType(string itemSchemaFormat, string itemSchemaType, JTokenType expectedItemTokenType) { Schema schema = CreateSchemaInputForArrayType(name: "test", itemFormat: itemSchemaFormat, itemType: itemSchemaType); RequestBodyJsonBuilder converter = new RequestBodyJsonBuilder(new DefaultValueFactory()); JToken result = converter.GetJsonResult(schema, swaggerDocDefinitions: new Dictionary <string, Schema>()); JArray array = (JArray)result; Assert.All(array, i => Assert.Equal(expectedItemTokenType, (i as JValue).Type)); }
public void RequestBodyJsonBuilder_ComplexTypeInput_ProducesJObjectWithCorrectPropertyTokenTypes() { Schema schema = CreateSchemaInputForComplexType(name: "test"); RequestBodyJsonBuilder converter = new RequestBodyJsonBuilder(new DefaultValueFactory()); JObject result = (JObject)converter.GetJsonResult(schema, swaggerDocDefinitions: new Dictionary <string, Schema>()); JValue idElement = result["id"] as JValue; JValue nameElement = result["name"] as JValue; Assert.Equal(JTokenType.Integer, idElement.Type); Assert.Equal(JTokenType.String, nameElement.Type); }
public void RequestBodyJsonBuilder_ComplexTypeInput_ProducesJObjectWithCorrectProperties() { Schema schema = CreateSchemaInputForComplexType(name: "test"); RequestBodyJsonBuilder converter = new RequestBodyJsonBuilder(new DefaultValueFactory()); JObject result = (JObject)converter.GetJsonResult(schema, swaggerDocDefinitions: new Dictionary <string, Schema>()); Assert.NotNull(result["id"]); Assert.IsType <JValue>(result["id"]); Assert.NotNull(result["name"]); Assert.IsType <JValue>(result["name"]); }
public void RequestBodyJsonBuilder_ComplexTypeWithNestedTypeInput_ProducesJObjectForNestedChild_WithCorrectPropertyTypes() { var inputResult = CreateSchemaInputForComplexTypeWithNestedTypes(); RequestBodyJsonBuilder converter = new RequestBodyJsonBuilder(new DefaultValueFactory()); JObject result = (JObject)converter.GetJsonResult(inputResult.schema, swaggerDocDefinitions: inputResult.references); JObject nestedChildObject = result["nestedChild"] as JObject; object uuidValue = (nestedChildObject["uuid"] as JValue).Value; object codeValue = (nestedChildObject["code"] as JValue).Value; Assert.IsType <string>(uuidValue); Assert.IsType <string>(codeValue); }