123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using OpenMetaverse;
- using NUnit.Framework;
- using NUnit.Framework.Constraints;
- namespace OpenSim.Tests.Common
- {
- public class VectorToleranceConstraint : ANumericalToleranceConstraint
- {
- private Vector3 _baseValue;
- private Vector3 _valueToBeTested;
- public VectorToleranceConstraint(Vector3 baseValue, double tolerance) : base(tolerance)
- {
- _baseValue = baseValue;
- }
-
-
-
-
-
-
-
- public override bool Matches(object valueToBeTested)
- {
- if (valueToBeTested == null)
- {
- throw new ArgumentException("Constraint cannot be used upon null values.");
- }
- if (valueToBeTested.GetType() != typeof (Vector3))
- {
- throw new ArgumentException("Constraint cannot be used upon non vector values.");
- }
- _valueToBeTested = (Vector3) valueToBeTested;
- return (IsWithinDoubleConstraint(_valueToBeTested.X, _baseValue.X) &&
- IsWithinDoubleConstraint(_valueToBeTested.Y, _baseValue.Y) &&
- IsWithinDoubleConstraint(_valueToBeTested.Z, _baseValue.Z));
- }
- public override void WriteDescriptionTo(MessageWriter writer)
- {
- writer.WriteExpectedValue(
- string.Format("A value {0} within tolerance of plus or minus {1}", _baseValue, _tolerance));
- }
- public override void WriteActualValueTo(MessageWriter writer)
- {
- writer.WriteActualValue(_valueToBeTested);
- }
- }
- }
|