public void CreateRegexPatternConstraintValueWithEscapedForwardSlash() { Assert.AreEqual( "/^([0-9]{1,3}\\.){3}[0-9]{1,3}(\\/([0-9]|[1-2][0-9]|3[0-2]))?$/", ClientModelExtensions.CreateRegexPatternConstraintValue( "^([0-9]{1,3}\\.){3}[0-9]{1,3}(\\/([0-9]|[1-2][0-9]|3[0-2]))?$")); }
public void CreateSerializerExpressionWithNoMappersAndXML() { CodeModelTS codeModel = Models.CodeModel( modelTypes: new[] { Models.CompositeType(name: "FakeModelType") }); Assert.AreEqual("new coreHttp.Serializer(Mappers)", ClientModelExtensions.CreateSerializerExpression(codeModel)); }
public bool Equals(ParameterTS x, ParameterTS y) { TSBuilder xBuilder = new TSBuilder(); xBuilder.Object(obj => ClientModelExtensions.ConstructParameterMapper(obj, x)); TSBuilder yBuilder = new TSBuilder(); yBuilder.Object(obj => ClientModelExtensions.ConstructParameterMapper(obj, y)); return(xBuilder.ToString() == yBuilder.ToString()); }
public void ConstructMapperWithTypeXMLPrefix() { TSBuilder builder = new TSBuilder(); IModelType type = Models.CompositeType(xmlPrefix: "blah"); ClientModelExtensions.ConstructMapper(builder, type, "fakeSerializedName", null, false, false, true); AssertEx.EqualLines( new[] { "{", " serializedName: \"blah:fakeSerializedName\",", " type: {", " name: \"Composite\",", " className: \"\"", " }", "}" }, builder); }
public void ConstructMapperWithXMLNameParameterEqualToSerializedNameParameter() { TSBuilder builder = new TSBuilder(); IModelType type = Models.CompositeType(); ClientModelExtensions.ConstructMapper(builder, type, "fakeSerializedName", null, false, false, true, xmlName: "fakeSerializedName"); AssertEx.EqualLines( new[] { "{", " serializedName: \"fakeSerializedName\",", " type: {", " name: \"Composite\",", " className: \"\"", " }", "}" }, builder); }
public void ConstructMapperWithXMLNameParameterEqualToSerializedNameParameterWithTypeAndParameterXMLPrefix() { TSBuilder builder = new TSBuilder(); IModelType type = Models.CompositeType(xmlPrefix: "bananas"); Property parameter = Models.Property(type: type, xmlPrefix: "mangos"); ClientModelExtensions.ConstructMapper(builder, type, "fakeSerializedName", parameter, false, false, true, xmlName: "fakeSerializedName"); AssertEx.EqualLines( new[] { "{", " serializedName: \"mangos:fakeSerializedName\",", " type: {", " name: \"Composite\",", " className: \"\"", " }", "}" }, builder); }
public void ConstructMapperWithTypeAndParameterXMLPrefixWithFalseIsXML() { TSBuilder builder = new TSBuilder(); CompositeType type = Models.CompositeType(xmlPrefix: "a"); Property parameter = Models.Property(type: type, xmlPrefix: "b"); ClientModelExtensions.ConstructMapper(builder, type, "fakeSerializedName", parameter, false, false, false); AssertEx.EqualLines( new[] { "{", " serializedName: \"fakeSerializedName\",", " type: {", " name: \"Composite\",", " className: \"\"", " }", "}" }, builder); }
public void ConstructMapperWithPropertyXMLNameDifferentThanSerializedNameParameterWithParameterXMLPrefix() { TSBuilder builder = new TSBuilder(); IModelType type = Models.CompositeType(); Property parameter = Models.Property(type: type, xmlPrefix: "oranges", xmlName: "fakeXMLSerializedName"); ClientModelExtensions.ConstructMapper(builder, type, "fakeSerializedName", parameter, false, false, true); AssertEx.EqualLines( new[] { "{", " xmlName: \"oranges:fakeXMLSerializedName\",", " serializedName: \"oranges:fakeSerializedName\",", " type: {", " name: \"Composite\",", " className: \"\"", " }", "}" }, builder); }
public void CreateSerializerExpressionWithNoMappersAndNoXML() { CodeModelTS codeModel = Models.CodeModel(); Assert.AreEqual("new coreHttp.Serializer()", ClientModelExtensions.CreateSerializerExpression(codeModel)); }
public void CreateRegexPatternConstraintValueWithWhitespace() { Assert.AreEqual("/ \t /", ClientModelExtensions.CreateRegexPatternConstraintValue(" \t ")); }
public void CreateRegexPatternConstraintValueWithEmpty() { Assert.AreEqual("", ClientModelExtensions.CreateRegexPatternConstraintValue("")); }