diff options
author | Adam Frisby | 2008-05-01 13:59:58 +0000 |
---|---|---|
committer | Adam Frisby | 2008-05-01 13:59:58 +0000 |
commit | 4ef6f53a11b8a8af6bac045abe7dedaaae236819 (patch) | |
tree | 7afb946058e44c0d9a85d89773072c5510556d0a /OpenSim/Region | |
parent | * Add more class cast exceptions to mysql read inventory item to cover all ne... (diff) | |
download | opensim-SC-4ef6f53a11b8a8af6bac045abe7dedaaae236819.zip opensim-SC-4ef6f53a11b8a8af6bac045abe7dedaaae236819.tar.gz opensim-SC-4ef6f53a11b8a8af6bac045abe7dedaaae236819.tar.bz2 opensim-SC-4ef6f53a11b8a8af6bac045abe7dedaaae236819.tar.xz |
* Adding unit test support to Environment for modules.
* Written some unit tests for Terrain Module as an example.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs new file mode 100644 index 0000000..ccb0561 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs | |||
@@ -0,0 +1,59 @@ | |||
1 | using System; | ||
2 | using NUnit.Framework; | ||
3 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; | ||
4 | |||
5 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests | ||
6 | { | ||
7 | [TestFixture] | ||
8 | public class TerrainTest | ||
9 | { | ||
10 | [Test] | ||
11 | public void BrushTest() | ||
12 | { | ||
13 | TerrainChannel x = new TerrainChannel(256, 256); | ||
14 | ITerrainPaintableEffect effect = new RaiseSphere(); | ||
15 | |||
16 | effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); | ||
17 | Assert.That(x[128, 128] > 0.0, "Raise brush not raising values."); | ||
18 | Assert.That(x[0, 128] > 0.0, "Raise brush lowering edge values."); | ||
19 | |||
20 | x = new TerrainChannel(256, 256); | ||
21 | effect = new LowerSphere(); | ||
22 | |||
23 | effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); | ||
24 | Assert.That(x[128, 128] < 0.0, "Lower not lowering values."); | ||
25 | Assert.That(x[0, 128] < 0.0, "Lower brush affecting edge values."); | ||
26 | } | ||
27 | |||
28 | [Test] | ||
29 | public void TerrainChannelTest() | ||
30 | { | ||
31 | TerrainChannel x = new TerrainChannel(256, 256); | ||
32 | Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly."); | ||
33 | |||
34 | x[0, 0] = 1.0; | ||
35 | Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly."); | ||
36 | |||
37 | x[0, 0] = 0; | ||
38 | x[0, 0] += 5.0; | ||
39 | x[0, 0] -= 1.0; | ||
40 | Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error."); | ||
41 | |||
42 | x[0, 0] = Math.PI; | ||
43 | double[,] doublesExport = x.GetDoubles(); | ||
44 | Assert.That(doublesExport[0, 0] == Math.PI, "Export to double[,] array not working correctly."); | ||
45 | |||
46 | x[0, 0] = 1.0; | ||
47 | float[] floatsExport = x.GetFloatsSerialised(); | ||
48 | Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly."); | ||
49 | |||
50 | x[0, 0] = 1.0; | ||
51 | Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly."); | ||
52 | Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly."); | ||
53 | |||
54 | TerrainChannel y = x.Copy(); | ||
55 | Assert.That(!ReferenceEquals(x, y), "Terrain copy not duplicating correctly."); | ||
56 | Assert.That(!ReferenceEquals(x.GetDoubles(), y.GetDoubles()), "Terrain array not duplicating correctly."); | ||
57 | } | ||
58 | } | ||
59 | } \ No newline at end of file | ||