diff options
author | Justin Clark-Casey (justincc) | 2010-05-21 20:43:11 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-05-21 20:43:11 +0100 |
commit | 721c1085da22229f4d40529dd2738a2cf62a91b7 (patch) | |
tree | cae1c731191972cd0bf672bb2e42e312d4239a83 /OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |
parent | minor: refactor CreateAsset to eliminate dupe code (diff) | |
download | opensim-SC_OLD-721c1085da22229f4d40529dd2738a2cf62a91b7.zip opensim-SC_OLD-721c1085da22229f4d40529dd2738a2cf62a91b7.tar.gz opensim-SC_OLD-721c1085da22229f4d40529dd2738a2cf62a91b7.tar.bz2 opensim-SC_OLD-721c1085da22229f4d40529dd2738a2cf62a91b7.tar.xz |
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
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | 37 |
1 files changed, 10 insertions, 27 deletions
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 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.IO; | 30 | using System.IO; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Threading; | 32 | using System.Threading; |
@@ -129,7 +130,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
129 | //log4net.Config.XmlConfigurator.Configure(); | 130 | //log4net.Config.XmlConfigurator.Configure(); |
130 | 131 | ||
131 | SceneObjectPart part1 = CreateSceneObjectPart1(); | 132 | SceneObjectPart part1 = CreateSceneObjectPart1(); |
132 | m_scene.AddNewSceneObject(new SceneObjectGroup(part1), false); | 133 | SceneObjectGroup sog1 = new SceneObjectGroup(part1); |
134 | m_scene.AddNewSceneObject(sog1, false); | ||
133 | 135 | ||
134 | SceneObjectPart part2 = CreateSceneObjectPart2(); | 136 | SceneObjectPart part2 = CreateSceneObjectPart2(); |
135 | 137 | ||
@@ -169,20 +171,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
169 | 171 | ||
170 | bool gotControlFile = false; | 172 | bool gotControlFile = false; |
171 | bool gotNcAssetFile = false; | 173 | bool gotNcAssetFile = false; |
172 | bool gotObject1File = false; | ||
173 | bool gotObject2File = false; | ||
174 | 174 | ||
175 | string expectedNcAssetFileName = string.Format("{0}_{1}", ncAssetUuid, "notecard.txt"); | 175 | string expectedNcAssetFileName = string.Format("{0}_{1}", ncAssetUuid, "notecard.txt"); |
176 | string expectedObject1FileName = string.Format( | 176 | |
177 | "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", | 177 | List<string> foundPaths = new List<string>(); |
178 | part1.Name, | 178 | List<string> expectedPaths = new List<string>(); |
179 | Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z), | 179 | expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog1)); |
180 | part1.UUID); | 180 | expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2)); |
181 | string expectedObject2FileName = string.Format( | ||
182 | "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", | ||
183 | part2.Name, | ||
184 | Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z), | ||
185 | part2.UUID); | ||
186 | 181 | ||
187 | string filePath; | 182 | string filePath; |
188 | TarArchiveReader.TarEntryType tarEntryType; | 183 | TarArchiveReader.TarEntryType tarEntryType; |
@@ -202,25 +197,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
202 | } | 197 | } |
203 | else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) | 198 | else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) |
204 | { | 199 | { |
205 | string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length); | 200 | foundPaths.Add(filePath); |
206 | |||
207 | if (fileName.StartsWith(part1.Name)) | ||
208 | { | ||
209 | Assert.That(fileName, Is.EqualTo(expectedObject1FileName)); | ||
210 | gotObject1File = true; | ||
211 | } | ||
212 | else if (fileName.StartsWith(part2.Name)) | ||
213 | { | ||
214 | Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); | ||
215 | gotObject2File = true; | ||
216 | } | ||
217 | } | 201 | } |
218 | } | 202 | } |
219 | 203 | ||
220 | Assert.That(gotControlFile, Is.True, "No control file in archive"); | 204 | Assert.That(gotControlFile, Is.True, "No control file in archive"); |
221 | Assert.That(gotNcAssetFile, Is.True, "No notecard asset file in archive"); | 205 | Assert.That(gotNcAssetFile, Is.True, "No notecard asset file in archive"); |
222 | Assert.That(gotObject1File, Is.True, "No object1 file in archive"); | 206 | Assert.That(foundPaths, Is.EquivalentTo(expectedPaths)); |
223 | Assert.That(gotObject2File, Is.True, "No object2 file in archive"); | ||
224 | 207 | ||
225 | // TODO: Test presence of more files and contents of files. | 208 | // TODO: Test presence of more files and contents of files. |
226 | } | 209 | } |