diff options
Diffstat (limited to 'OpenSim/Data/Tests/BasicAssetTest.cs')
-rw-r--r-- | OpenSim/Data/Tests/BasicAssetTest.cs | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs deleted file mode 100644 index 25aed61..0000000 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ /dev/null | |||
@@ -1,131 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using log4net.Config; | ||
31 | using NUnit.Framework; | ||
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using log4net; | ||
36 | |||
37 | namespace OpenSim.Data.Tests | ||
38 | { | ||
39 | public class BasicAssetTest | ||
40 | { | ||
41 | public IAssetDataPlugin db; | ||
42 | public UUID uuid1; | ||
43 | public UUID uuid2; | ||
44 | public UUID uuid3; | ||
45 | public byte[] asset1; | ||
46 | |||
47 | public void SuperInit() | ||
48 | { | ||
49 | OpenSim.Tests.Common.TestLogging.LogToConsole(); | ||
50 | |||
51 | uuid1 = UUID.Random(); | ||
52 | uuid2 = UUID.Random(); | ||
53 | uuid3 = UUID.Random(); | ||
54 | asset1 = new byte[100]; | ||
55 | asset1.Initialize(); | ||
56 | } | ||
57 | |||
58 | [Test] | ||
59 | public void T001_LoadEmpty() | ||
60 | { | ||
61 | Assert.That(db.ExistsAsset(uuid1), Is.False); | ||
62 | Assert.That(db.ExistsAsset(uuid2), Is.False); | ||
63 | Assert.That(db.ExistsAsset(uuid3), Is.False); | ||
64 | } | ||
65 | |||
66 | [Test] | ||
67 | public void T010_StoreSimpleAsset() | ||
68 | { | ||
69 | AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); | ||
70 | AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture); | ||
71 | AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture); | ||
72 | a1.Data = asset1; | ||
73 | a2.Data = asset1; | ||
74 | a3.Data = asset1; | ||
75 | |||
76 | PropertyScrambler<AssetBase> scrambler = new PropertyScrambler<AssetBase>() | ||
77 | .DontScramble(x => x.Data) | ||
78 | .DontScramble(x => x.ID) | ||
79 | .DontScramble(x => x.FullID) | ||
80 | .DontScramble(x => x.Metadata.ID) | ||
81 | .DontScramble(x => x.Metadata.FullID); | ||
82 | |||
83 | scrambler.Scramble(a1); | ||
84 | scrambler.Scramble(a2); | ||
85 | scrambler.Scramble(a3); | ||
86 | |||
87 | db.StoreAsset(a1); | ||
88 | db.StoreAsset(a2); | ||
89 | db.StoreAsset(a3); | ||
90 | |||
91 | AssetBase a1a = db.GetAsset(uuid1); | ||
92 | Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); | ||
93 | |||
94 | AssetBase a2a = db.GetAsset(uuid2); | ||
95 | Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); | ||
96 | |||
97 | AssetBase a3a = db.GetAsset(uuid3); | ||
98 | Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); | ||
99 | |||
100 | scrambler.Scramble(a1a); | ||
101 | scrambler.Scramble(a2a); | ||
102 | scrambler.Scramble(a3a); | ||
103 | |||
104 | db.StoreAsset(a1a); | ||
105 | db.StoreAsset(a2a); | ||
106 | db.StoreAsset(a3a); | ||
107 | |||
108 | AssetBase a1b = db.GetAsset(uuid1); | ||
109 | Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a)); | ||
110 | |||
111 | AssetBase a2b = db.GetAsset(uuid2); | ||
112 | Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a)); | ||
113 | |||
114 | AssetBase a3b = db.GetAsset(uuid3); | ||
115 | Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); | ||
116 | |||
117 | Assert.That(db.ExistsAsset(uuid1), Is.True); | ||
118 | Assert.That(db.ExistsAsset(uuid2), Is.True); | ||
119 | Assert.That(db.ExistsAsset(uuid3), Is.True); | ||
120 | |||
121 | List<AssetMetadata> metadatas = db.FetchAssetMetadataSet(0, 1000); | ||
122 | |||
123 | AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1); | ||
124 | Assert.That(metadata.Name, Is.EqualTo(a1b.Name)); | ||
125 | Assert.That(metadata.Description, Is.EqualTo(a1b.Description)); | ||
126 | Assert.That(metadata.Type, Is.EqualTo(a1b.Type)); | ||
127 | Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary)); | ||
128 | Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID)); | ||
129 | } | ||
130 | } | ||
131 | } | ||