diff options
Diffstat (limited to 'OpenSim/Tests/Common/VectorToleranceConstraint.cs')
-rw-r--r-- | OpenSim/Tests/Common/VectorToleranceConstraint.cs | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/OpenSim/Tests/Common/VectorToleranceConstraint.cs b/OpenSim/Tests/Common/VectorToleranceConstraint.cs index 1faf7dd..3f32830 100644 --- a/OpenSim/Tests/Common/VectorToleranceConstraint.cs +++ b/OpenSim/Tests/Common/VectorToleranceConstraint.cs | |||
@@ -1,58 +1,58 @@ | |||
1 | using System; | 1 | using System; |
2 | using libsecondlife; | 2 | using libsecondlife; |
3 | using NUnit.Framework; | 3 | using NUnit.Framework; |
4 | 4 | ||
5 | namespace OpenSim.Tests.Common | 5 | namespace OpenSim.Tests.Common |
6 | { | 6 | { |
7 | public class VectorToleranceConstraint : ANumericalToleranceConstraint | 7 | public class VectorToleranceConstraint : ANumericalToleranceConstraint |
8 | { | 8 | { |
9 | private LLVector3 _baseValue; | 9 | private LLVector3 _baseValue; |
10 | private LLVector3 _valueToBeTested; | 10 | private LLVector3 _valueToBeTested; |
11 | 11 | ||
12 | public VectorToleranceConstraint(LLVector3 baseValue, double tolerance) : base(tolerance) | 12 | public VectorToleranceConstraint(LLVector3 baseValue, double tolerance) : base(tolerance) |
13 | { | 13 | { |
14 | _baseValue = baseValue; | 14 | _baseValue = baseValue; |
15 | } | 15 | } |
16 | 16 | ||
17 | ///<summary> | 17 | ///<summary> |
18 | ///Test whether the constraint is satisfied by a given value | 18 | ///Test whether the constraint is satisfied by a given value |
19 | ///</summary> | 19 | ///</summary> |
20 | ///<param name="valueToBeTested">The value to be tested</param> | 20 | ///<param name="valueToBeTested">The value to be tested</param> |
21 | ///<returns> | 21 | ///<returns> |
22 | ///True for success, false for failure | 22 | ///True for success, false for failure |
23 | ///</returns> | 23 | ///</returns> |
24 | public override bool Matches(object valueToBeTested) | 24 | public override bool Matches(object valueToBeTested) |
25 | { | 25 | { |
26 | if (valueToBeTested == null) | 26 | if (valueToBeTested == null) |
27 | { | 27 | { |
28 | throw new ArgumentException("Constraint cannot be used upon null values."); | 28 | throw new ArgumentException("Constraint cannot be used upon null values."); |
29 | } | 29 | } |
30 | if (valueToBeTested.GetType() != typeof (LLVector3)) | 30 | if (valueToBeTested.GetType() != typeof (LLVector3)) |
31 | { | 31 | { |
32 | throw new ArgumentException("Constraint cannot be used upon non vector values."); | 32 | throw new ArgumentException("Constraint cannot be used upon non vector values."); |
33 | } | 33 | } |
34 | 34 | ||
35 | _valueToBeTested = (LLVector3) valueToBeTested; | 35 | _valueToBeTested = (LLVector3) valueToBeTested; |
36 | 36 | ||
37 | if ( IsWithinDoubleConstraint(_valueToBeTested.X,_baseValue.X) && | 37 | if ( IsWithinDoubleConstraint(_valueToBeTested.X,_baseValue.X) && |
38 | IsWithinDoubleConstraint(_valueToBeTested.Y,_baseValue.Y) && | 38 | IsWithinDoubleConstraint(_valueToBeTested.Y,_baseValue.Y) && |
39 | IsWithinDoubleConstraint(_valueToBeTested.Z,_baseValue.Z) ) | 39 | IsWithinDoubleConstraint(_valueToBeTested.Z,_baseValue.Z) ) |
40 | { | 40 | { |
41 | return true; | 41 | return true; |
42 | } | 42 | } |
43 | 43 | ||
44 | return false; | 44 | return false; |
45 | } | 45 | } |
46 | 46 | ||
47 | public override void WriteDescriptionTo(MessageWriter writer) | 47 | public override void WriteDescriptionTo(MessageWriter writer) |
48 | { | 48 | { |
49 | writer.WriteExpectedValue( | 49 | writer.WriteExpectedValue( |
50 | string.Format("A value {0} within tolerance of plus or minus {1}", _baseValue, _tolerance)); | 50 | string.Format("A value {0} within tolerance of plus or minus {1}", _baseValue, _tolerance)); |
51 | } | 51 | } |
52 | 52 | ||
53 | public override void WriteActualValueTo(MessageWriter writer) | 53 | public override void WriteActualValueTo(MessageWriter writer) |
54 | { | 54 | { |
55 | writer.WriteActualValue(_valueToBeTested); | 55 | writer.WriteActualValue(_valueToBeTested); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | } | 58 | } |