30 using NUnit.Framework;
31 using NUnit.Framework.Constraints;
33 namespace OpenSim.Tests.Common
37 private Quaternion _baseValue;
38 private Quaternion _valueToBeTested;
42 _baseValue = baseValue;
52 public override bool Matches(
object valueToBeTested)
54 if (valueToBeTested == null)
56 throw new ArgumentException(
"Constraint cannot be used upon null values.");
58 if (valueToBeTested.GetType() != typeof (Quaternion))
60 throw new ArgumentException(
"Constraint cannot be used upon non quaternion values.");
63 _valueToBeTested = (Quaternion)valueToBeTested;
65 return (IsWithinDoubleConstraint(_valueToBeTested.X, _baseValue.X) &&
66 IsWithinDoubleConstraint(_valueToBeTested.Y, _baseValue.Y) &&
67 IsWithinDoubleConstraint(_valueToBeTested.Z, _baseValue.Z) &&
68 IsWithinDoubleConstraint(_valueToBeTested.W, _baseValue.W));
73 writer.WriteExpectedValue(
74 string.Format(
"A value {0} within tolerance of plus or minus {1}", _baseValue, _tolerance));
79 writer.WriteActualValue(_valueToBeTested);
override void WriteDescriptionTo(MessageWriter writer)
override void WriteActualValueTo(MessageWriter writer)
QuaternionToleranceConstraint(Quaternion baseValue, double tolerance)
override bool Matches(object valueToBeTested)
Test whether the constraint is satisfied by a given value