aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Tests/MundaneFrameworkTests.cs')
-rw-r--r--OpenSim/Framework/Tests/MundaneFrameworkTests.cs131
1 files changed, 131 insertions, 0 deletions
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
new file mode 100644
index 0000000..e2e08c0
--- /dev/null
+++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
@@ -0,0 +1,131 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using NUnit.Framework;
29using OpenSim.Framework;
30using OpenMetaverse;
31using OpenMetaverse.StructuredData;
32
33namespace OpenSim.Framework.Tests
34{
35 [TestFixture]
36 public class MundaneFrameworkTests
37 {
38 [Test]
39 public void ChildAgentDataUpdate01()
40 {
41 // code coverage
42 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
43 Assert.IsFalse(cadu.alwaysrun, "Default is false");
44 }
45
46 [Test]
47 public void AgentPositionTest01()
48 {
49 UUID AgentId1 = UUID.Random();
50 UUID SessionId1 = UUID.Random();
51 uint CircuitCode1 = uint.MinValue;
52 Vector3 Size1 = Vector3.UnitZ;
53 Vector3 Position1 = Vector3.UnitX;
54 Vector3 LeftAxis1 = Vector3.UnitY;
55 Vector3 UpAxis1 = Vector3.UnitZ;
56 Vector3 AtAxis1 = Vector3.UnitX;
57
58 ulong RegionHandle1 = ulong.MinValue;
59 byte[] Throttles1 = new byte[] {0, 1, 0};
60
61 Vector3 Velocity1 = Vector3.Zero;
62 float Far1 = 256;
63
64 bool ChangedGrid1 = false;
65 Vector3 Center1 = Vector3.Zero;
66
67 AgentPosition position1 = new AgentPosition();
68 position1.AgentID = AgentId1;
69 position1.SessionID = SessionId1;
70 position1.CircuitCode = CircuitCode1;
71 position1.Size = Size1;
72 position1.Position = Position1;
73 position1.LeftAxis = LeftAxis1;
74 position1.UpAxis = UpAxis1;
75 position1.AtAxis = AtAxis1;
76 position1.RegionHandle = RegionHandle1;
77 position1.Throttles = Throttles1;
78 position1.Velocity = Velocity1;
79 position1.Far = Far1;
80 position1.ChangedGrid = ChangedGrid1;
81 position1.Center = Center1;
82
83 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
84 cadu.AgentID = AgentId1.Guid;
85 cadu.ActiveGroupID = UUID.Zero.Guid;
86 cadu.throttles = Throttles1;
87 cadu.drawdistance = Far1;
88 cadu.Position = Position1;
89 cadu.Velocity = Velocity1;
90 cadu.regionHandle = RegionHandle1;
91 cadu.cameraPosition = Center1;
92 cadu.AVHeight = Size1.Z;
93
94 AgentPosition position2 = new AgentPosition();
95 position2.CopyFrom(cadu);
96
97 Assert.IsTrue(
98 position2.AgentID == position1.AgentID
99 && position2.Size == position1.Size
100 && position2.Position == position1.Position
101 && position2.Velocity == position1.Velocity
102 && position2.Center == position1.Center
103 && position2.RegionHandle == position1.RegionHandle
104 && position2.Far == position1.Far
105
106 ,"Copy From ChildAgentDataUpdate failed");
107
108 position2 = new AgentPosition();
109
110 Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition");
111 position2.Unpack(position1.Pack());
112
113 Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed");
114 Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed");
115 Assert.IsTrue(position2.Velocity == position1.Velocity, "Velocity didn't unpack the same way it packed");
116 Assert.IsTrue(position2.SessionID == position1.SessionID, "SessionID didn't unpack the same way it packed");
117 Assert.IsTrue(position2.CircuitCode == position1.CircuitCode, "CircuitCode didn't unpack the same way it packed");
118 Assert.IsTrue(position2.LeftAxis == position1.LeftAxis, "LeftAxis didn't unpack the same way it packed");
119 Assert.IsTrue(position2.UpAxis == position1.UpAxis, "UpAxis didn't unpack the same way it packed");
120 Assert.IsTrue(position2.AtAxis == position1.AtAxis, "AtAxis didn't unpack the same way it packed");
121 Assert.IsTrue(position2.RegionHandle == position1.RegionHandle, "RegionHandle didn't unpack the same way it packed");
122 Assert.IsTrue(position2.ChangedGrid == position1.ChangedGrid, "ChangedGrid didn't unpack the same way it packed");
123 Assert.IsTrue(position2.Center == position1.Center, "Center didn't unpack the same way it packed");
124 Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed");
125
126 }
127
128
129 }
130}
131