public void Ctor_Void_Success() { TypeConstraint c = new TypeConstraint(); Assert.AreEqual(Constraint.TypeConstraintName, c.Name); Assert.AreEqual(string.Empty, c.TypeName); Assert.IsNull(c.ResolvedType); }
public void Ctor_StringUnknownType_Success() { string type = typeof(System.UriKind).AssemblyQualifiedName.Replace("UriKind", "MyClass"); TypeConstraint c = new TypeConstraint(type); Assert.AreEqual(Constraint.TypeConstraintName, c.Name); Assert.AreEqual(type, c.TypeName); Assert.IsNull(c.ResolvedType); }
public void Ctor_String_Success() { string type = typeof(System.UriKind).AssemblyQualifiedName; TypeConstraint c = new TypeConstraint(type); Assert.AreEqual(Constraint.TypeConstraintName, c.Name); Assert.AreEqual(type, c.TypeName); Assert.IsNotNull(c.ResolvedType); Assert.IsNotNull(c.ResolvedType); // To trigger retrieval of already resolved type }
public void ToDataType_XmlInvType_Error() { TypeConstraint c = new TypeConstraint("Hi.I.Am.Not, A.Real.Type"); CustomAssert.ThrowsException<ParameterConversionException>(() => { object result = ParameterConvert.ToDataType(Constants.SerializedObjectString, ParameterDataType.Xml, new Constraint[] { c }); }); CustomAssert.ThrowsException<ParameterConversionException>(() => { object result = ParameterConvert.ToDataType(Constants.SerializedObjectString, ParameterDataType.Xml, new Constraint[0]); }); }
public void ToDataType_Xml_Success() { TypeConstraint c = new TypeConstraint(typeof(XmlSerializableObject).AssemblyQualifiedName); object result = ParameterConvert.ToDataType(Constants.SerializedObjectString, ParameterDataType.Xml, new Constraint[] { c }); Assert.IsNotNull(result); Assert.AreEqual("narf", ((XmlSerializableObject)result).MyValue); }
public void Ctor_SerializationInfo_Success() { string type = typeof(System.UriKind).AssemblyQualifiedName; TypeConstraint c = new TypeConstraint(type); System.IO.MemoryStream Buffer = SerializationHelper.Serialize(c); TypeConstraint c2 = SerializationHelper.Deserialize<TypeConstraint>(Buffer); Assert.AreEqual(Constraint.TypeConstraintName, c2.Name); Assert.AreEqual(type, c2.TypeName); Assert.IsNotNull(c2.ResolvedType); }
public void Ctor_StringNull_Error() { CustomAssert.ThrowsException<CodedArgumentNullOrWhiteSpaceException>(() => { TypeConstraint c = new TypeConstraint(null); }); }
public void Validate_Success() { string type = typeof(System.UriKind).AssemblyQualifiedName; TypeConstraint c = new TypeConstraint(type); IEnumerable<ParameterValidationResult> result = c.Validate(System.UriKind.Absolute, ParameterDataType.Xml, Constants.MemberName); Assert.IsNotNull(result); Assert.IsFalse(result.GetEnumerator().MoveNext()); }
public void SetParameters_ParamWhitespace_Error() { CustomAssert.ThrowsException<ConstraintConfigurationException>(() => { TypeConstraint c = new TypeConstraint(); c.SetParametersInternal(new string[] { " " }, ParameterDataType.Xml); }); }
public void SetParameters_Success() { string type = typeof(System.UriKind).AssemblyQualifiedName; TypeConstraint c = new TypeConstraint(); c.SetParametersInternal(new string[] { type }, ParameterDataType.Xml); Assert.AreEqual(type, c.TypeName); Assert.IsNotNull(c.ResolvedType); }
public void ToString_Success() { string type = typeof(System.UriKind).AssemblyQualifiedName; TypeConstraint c = new TypeConstraint(type); Assert.AreEqual(string.Format("[Type('{0}')]", type), c.ToString()); }