From 721c1085da22229f4d40529dd2738a2cf62a91b7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 21 May 2010 20:43:11 +0100 Subject: make oar object filename/pathname creation a helper method reused in both tests and oar code reduction in checking is outweighed by greater test clarity --- .../World/Archiver/Tests/ArchiverTests.cs | 37 ++++++---------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/CoreModules/World/Archiver/Tests') diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index f3e5458..4d04af1 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.IO; using System.Reflection; using System.Threading; @@ -129,7 +130,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests //log4net.Config.XmlConfigurator.Configure(); SceneObjectPart part1 = CreateSceneObjectPart1(); - m_scene.AddNewSceneObject(new SceneObjectGroup(part1), false); + SceneObjectGroup sog1 = new SceneObjectGroup(part1); + m_scene.AddNewSceneObject(sog1, false); SceneObjectPart part2 = CreateSceneObjectPart2(); @@ -169,20 +171,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests bool gotControlFile = false; bool gotNcAssetFile = false; - bool gotObject1File = false; - bool gotObject2File = false; string expectedNcAssetFileName = string.Format("{0}_{1}", ncAssetUuid, "notecard.txt"); - string expectedObject1FileName = string.Format( - "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", - part1.Name, - Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z), - part1.UUID); - string expectedObject2FileName = string.Format( - "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", - part2.Name, - Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z), - part2.UUID); + + List foundPaths = new List(); + List expectedPaths = new List(); + expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog1)); + expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2)); string filePath; TarArchiveReader.TarEntryType tarEntryType; @@ -202,25 +197,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests } else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) { - string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length); - - if (fileName.StartsWith(part1.Name)) - { - Assert.That(fileName, Is.EqualTo(expectedObject1FileName)); - gotObject1File = true; - } - else if (fileName.StartsWith(part2.Name)) - { - Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); - gotObject2File = true; - } + foundPaths.Add(filePath); } } Assert.That(gotControlFile, Is.True, "No control file in archive"); Assert.That(gotNcAssetFile, Is.True, "No notecard asset file in archive"); - Assert.That(gotObject1File, Is.True, "No object1 file in archive"); - Assert.That(gotObject2File, Is.True, "No object2 file in archive"); + Assert.That(foundPaths, Is.EquivalentTo(expectedPaths)); // TODO: Test presence of more files and contents of files. } -- cgit v1.1