TerrainTest.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using NUnit.Framework;
  3. using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes;
  4. namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests
  5. {
  6. [TestFixture]
  7. public class TerrainTest
  8. {
  9. [Test]
  10. public void BrushTest()
  11. {
  12. TerrainChannel x = new TerrainChannel(256, 256);
  13. ITerrainPaintableEffect effect = new RaiseSphere();
  14. effect.PaintEffect(x, 128.0, 128.0, 50, 0.1);
  15. Assert.That(x[128, 128] > 0.0, "Raise brush not raising values.");
  16. Assert.That(x[0, 128] > 0.0, "Raise brush lowering edge values.");
  17. x = new TerrainChannel(256, 256);
  18. effect = new LowerSphere();
  19. effect.PaintEffect(x, 128.0, 128.0, 50, 0.1);
  20. Assert.That(x[128, 128] < 0.0, "Lower not lowering values.");
  21. Assert.That(x[0, 128] < 0.0, "Lower brush affecting edge values.");
  22. }
  23. [Test]
  24. public void TerrainChannelTest()
  25. {
  26. TerrainChannel x = new TerrainChannel(256, 256);
  27. Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly.");
  28. x[0, 0] = 1.0;
  29. Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly.");
  30. x[0, 0] = 0;
  31. x[0, 0] += 5.0;
  32. x[0, 0] -= 1.0;
  33. Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error.");
  34. x[0, 0] = Math.PI;
  35. double[,] doublesExport = x.GetDoubles();
  36. Assert.That(doublesExport[0, 0] == Math.PI, "Export to double[,] array not working correctly.");
  37. x[0, 0] = 1.0;
  38. float[] floatsExport = x.GetFloatsSerialised();
  39. Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly.");
  40. x[0, 0] = 1.0;
  41. Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly.");
  42. Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly.");
  43. TerrainChannel y = x.Copy();
  44. Assert.That(!ReferenceEquals(x, y), "Terrain copy not duplicating correctly.");
  45. Assert.That(!ReferenceEquals(x.GetDoubles(), y.GetDoubles()), "Terrain array not duplicating correctly.");
  46. }
  47. }
  48. }