public void Ctor_IntNegative_Error() { CustomAssert.ThrowsException<CodedArgumentOutOfRangeException>(() => { MinimumLengthConstraint c = new MinimumLengthConstraint(-1); }); }
public void Ctor_SerializationInfo_Success() { MinimumLengthConstraint c = new MinimumLengthConstraint(2); System.IO.MemoryStream Buffer = SerializationHelper.Serialize(c); MinimumLengthConstraint c2 = SerializationHelper.Deserialize<MinimumLengthConstraint>(Buffer); Assert.AreEqual(Constraint.MinimumLengthConstraintName, c2.Name); Assert.AreEqual(2, c2.MinimumLength); }
public void ToString_Success() { MinimumLengthConstraint c = new MinimumLengthConstraint(1); Assert.AreEqual("[MinLength(1)]", c.ToString()); }
public void Validate_InvalidData_Success() { CustomAssert.ThrowsException<CodedArgumentException>(() => { MinimumLengthConstraint c = new MinimumLengthConstraint(4); IEnumerable<ParameterValidationResult> result = c.Validate(42, ParameterDataType.Bytes, Constants.MemberName); }); }
public void Ctor_Int_Success() { MinimumLengthConstraint c = new MinimumLengthConstraint(2); Assert.AreEqual(Constraint.MinimumLengthConstraintName, c.Name); Assert.AreEqual(2, c.MinimumLength); }
public void Validate_UriTooShort_Success() { MinimumLengthConstraint c = new MinimumLengthConstraint(15); IEnumerable<ParameterValidationResult> result = c.Validate(new Uri("http://co"), ParameterDataType.Uri, Constants.MemberName); Assert.IsNotNull(result); Assert.IsTrue(result.GetEnumerator().MoveNext()); }
public void Validate_BytesTooShort_Success() { MinimumLengthConstraint c = new MinimumLengthConstraint(4); IEnumerable<ParameterValidationResult> result = c.Validate(new byte[] { 1, 2, 3 }, ParameterDataType.Bytes, Constants.MemberName); Assert.IsNotNull(result); Assert.IsTrue(result.GetEnumerator().MoveNext()); }
public void Validate_StringTooShort_Success() { MinimumLengthConstraint c = new MinimumLengthConstraint(6); IEnumerable<ParameterValidationResult> result = c.Validate("four", ParameterDataType.String, Constants.MemberName); Assert.IsNotNull(result); Assert.IsTrue(result.GetEnumerator().MoveNext()); }
public void SetParameters_ParamInv_Error() { CustomAssert.ThrowsException<ConstraintConfigurationException>(() => { MinimumLengthConstraint c = new MinimumLengthConstraint(); c.SetParametersInternal(new string[] { "narf" }, ParameterDataType.String); }); }
public void SetParameters_Success() { MinimumLengthConstraint c = new MinimumLengthConstraint(); c.SetParametersInternal(new string[] { "1" }, ParameterDataType.String); Assert.AreEqual(1, c.MinimumLength); }