public void Ctor_StringEmpty_Error() { CustomAssert.ThrowsException<CodedArgumentNullOrWhiteSpaceException>(() => { AllowedSchemeConstraint c = new AllowedSchemeConstraint(string.Empty); }); }
public void Ctor_IEnumerableString_Success() { AllowedSchemeConstraint c = new AllowedSchemeConstraint(Constants.SchemeNames); Assert.AreEqual(Constraint.AllowedSchemeConstraintName, c.Name); Assert.IsNotNull(c.AllowedSchemes); List<string> TempSchemas = new List<string>(c.AllowedSchemes); Assert.AreEqual(3, TempSchemas.Count); }
public void Ctor_IEnumerableNull_Error() { CustomAssert.ThrowsException<CodedArgumentNullException>(() => { AllowedSchemeConstraint c = new AllowedSchemeConstraint((IEnumerable<string>)null); }); }
public void Ctor_Void_Success() { AllowedSchemeConstraint c = new AllowedSchemeConstraint(); Assert.AreEqual(Constraint.AllowedSchemeConstraintName, c.Name); Assert.IsNull(c.AllowedSchemes); }
public void Validate_UnknownSchema_Success() { AllowedSchemeConstraint c = new AllowedSchemeConstraint(Constants.SchemeNames); IEnumerable<ParameterValidationResult> res = c.Validate(new Uri("ftp://ftp.contoso.com"), ParameterDataType.Uri, Constants.MemberName); Assert.IsNotNull(res); Assert.IsTrue(res.GetEnumerator().MoveNext()); }
public void Validate_SchemasNull_Error() { CustomAssert.ThrowsException<ConstraintConfigurationException>(() => { AllowedSchemeConstraint c = new AllowedSchemeConstraint(); IEnumerable<ParameterValidationResult> res = c.Validate(new Uri("http://www.contoso.com"), ParameterDataType.Uri, Constants.MemberName); }); }
public void SetParameters_NoParamsOrNull_Error() { CustomAssert.ThrowsException<ConstraintConfigurationException>(() => { AllowedSchemeConstraint c = new AllowedSchemeConstraint(); c.SetParametersInternal(new string[0], ParameterDataType.Uri); }); CustomAssert.ThrowsException<ConstraintConfigurationException>(() => { AllowedSchemeConstraint c = new AllowedSchemeConstraint(); c.SetParametersInternal(new string[] { "1", "2", null, "4" }, ParameterDataType.Uri); }); }
public void SetParameters_Success() { AllowedSchemeConstraint c = new AllowedSchemeConstraint(); c.SetParametersInternal(new string[] { Constants.SchemeNames[0], Constants.SchemeNames[1], Constants.SchemeNames[2] }, ParameterDataType.Uri); Assert.IsNotNull(c.AllowedSchemes); List<string> TempSchemas = new List<string>(c.AllowedSchemes); Assert.AreEqual(3, TempSchemas.Count); }
public void ToString_Success() { AllowedSchemeConstraint c = new AllowedSchemeConstraint(Constants.SchemeNames); Assert.AreEqual(string.Format("[AllowedScheme({0},{1},{2})]", Constants.SchemeNames[0], Constants.SchemeNames[1], Constants.SchemeNames[2]), c.ToString()); }
public void Ctor_SerializationInfo_Success() { AllowedSchemeConstraint c = new AllowedSchemeConstraint(Constants.SchemeNames); System.IO.MemoryStream Buffer = SerializationHelper.Serialize(c); AllowedSchemeConstraint c2 = SerializationHelper.Deserialize<AllowedSchemeConstraint>(Buffer); Assert.AreEqual(Constraint.AllowedSchemeConstraintName, c2.Name); Assert.IsNotNull(c2.AllowedSchemes); List<string> TempSchemas = new List<string>(c2.AllowedSchemes); Assert.AreEqual(3, TempSchemas.Count); }
public void AssertDataType_DataType_Error() { CustomAssert.ThrowsException<InvalidDataTypeException>(() => { AllowedSchemeConstraint c = new AllowedSchemeConstraint(Constants.SchemeName); c.Validate(42, ParameterDataType.Int32, Constants.MemberName); }); }