From de88227bc486788197b3a7c842c8b60f82b0a29b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 23 Mar 2011 22:29:27 +0000 Subject: [PATCH] refactor: simplify part of AddSceneObject() test setup by moving sog construction into SceneSetupHelpers.CreateSceneObject() --- .../World/Land/Tests/PrimCountModuleTests.cs | 11 +------ .../Tests/Common/Setup/SceneSetupHelpers.cs | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 8c1b6a3370..72f74fa5c9 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -62,16 +62,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests lmm.AddLandObject(lo); //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); - SceneObjectPart part1 - = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = "obj1", UUID = new UUID("00000000-0000-0000-0000-000000000001") }; - SceneObjectGroup sog = new SceneObjectGroup(part1); - sog.AddPart( - new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = "obj2", UUID = new UUID("00000000-0000-0000-0000-000000000002") }); - sog.AddPart( - new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = "obj3", UUID = new UUID("00000000-0000-0000-0000-000000000003") }); + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, userId); Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0)); Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index aa4b285981..b7b7383bfc 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -465,5 +465,37 @@ namespace OpenSim.Tests.Common.Setup return part; } + + /// + /// Create a scene object but do not add it to the scene. + /// + /// + /// UUID always starts at 00000000-0000-0000-0000-000000000001 + /// + /// The number of parts that should be in the scene object + /// + /// + public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) + { + SceneObjectPart rootPart + = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { Name = "part1", UUID = new UUID("00000000-0000-0000-0000-000000000001") }; + SceneObjectGroup sog = new SceneObjectGroup(rootPart); + + if (parts > 1) + { + for (int i = 2; i <= parts; i++) + { + sog.AddPart( + new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { + Name = string.Format("obj{0}", i), + UUID = new UUID(string.Format("00000000-0000-0000-0000-{0:D12}", i)) + }); + } + } + + return sog; + } } }