diff options
author | AlexRa | 2010-05-21 15:59:26 +0300 |
---|---|---|
committer | AlexRa | 2010-05-23 11:48:10 +0300 |
commit | 2537acc04db736cdc885e23bbfaade690d56fa5f (patch) | |
tree | 7078384e80246b6e55191782194bfa7c17ab63a5 /OpenSim/Data/Tests/BasicAssetTest.cs | |
parent | Added MS SQL test conn to INI - only as an example, modify before use!!! (diff) | |
download | opensim-SC-2537acc04db736cdc885e23bbfaade690d56fa5f.zip opensim-SC-2537acc04db736cdc885e23bbfaade690d56fa5f.tar.gz opensim-SC-2537acc04db736cdc885e23bbfaade690d56fa5f.tar.bz2 opensim-SC-2537acc04db736cdc885e23bbfaade690d56fa5f.tar.xz |
Unitests: Asset, Estate, Region (the "legacy" one), Inventory
The tests have been modified to work under NUnit 2.4.6
(the one currently used in the project).
They will also work with NUnit 2.5+ as is, but will look better
if you #define NUNIT25 for them.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/Tests/BasicAssetTest.cs | 166 |
1 files changed, 0 insertions, 166 deletions
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs deleted file mode 100644 index 71d6314..0000000 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ /dev/null | |||
@@ -1,166 +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 string critter1 = UUID.Random().ToString(); | ||
46 | public string critter2 = UUID.Random().ToString(); | ||
47 | public string critter3 = UUID.Random().ToString(); | ||
48 | public byte[] asset1; | ||
49 | PropertyScrambler<AssetBase> scrambler; | ||
50 | |||
51 | public void SuperInit() | ||
52 | { | ||
53 | OpenSim.Tests.Common.TestLogging.LogToConsole(); | ||
54 | |||
55 | uuid1 = UUID.Random(); | ||
56 | uuid2 = UUID.Random(); | ||
57 | uuid3 = UUID.Random(); | ||
58 | asset1 = new byte[100]; | ||
59 | asset1.Initialize(); | ||
60 | |||
61 | |||
62 | scrambler = new PropertyScrambler<AssetBase>() | ||
63 | .DontScramble(x => x.ID) | ||
64 | .DontScramble(x => x.FullID) | ||
65 | .DontScramble(x => x.Metadata.ID) | ||
66 | .DontScramble(x => x.Metadata.Type) | ||
67 | .DontScramble(x => x.Metadata.CreatorID) | ||
68 | .DontScramble(x => x.Metadata.ContentType) | ||
69 | .DontScramble(x => x.Metadata.FullID); | ||
70 | } | ||
71 | |||
72 | [Test] | ||
73 | public void T001_LoadEmpty() | ||
74 | { | ||
75 | Assert.That(db.ExistsAsset(uuid1), Is.False); | ||
76 | Assert.That(db.ExistsAsset(uuid2), Is.False); | ||
77 | Assert.That(db.ExistsAsset(uuid3), Is.False); | ||
78 | } | ||
79 | |||
80 | [Test] | ||
81 | public void T010_StoreSimpleAsset() | ||
82 | { | ||
83 | AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1); | ||
84 | AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2); | ||
85 | AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, critter3); | ||
86 | a1.Data = asset1; | ||
87 | a2.Data = asset1; | ||
88 | a3.Data = asset1; | ||
89 | |||
90 | scrambler.Scramble(a1); | ||
91 | scrambler.Scramble(a2); | ||
92 | scrambler.Scramble(a3); | ||
93 | |||
94 | db.StoreAsset(a1); | ||
95 | db.StoreAsset(a2); | ||
96 | db.StoreAsset(a3); | ||
97 | |||
98 | AssetBase a1a = db.GetAsset(uuid1); | ||
99 | Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); | ||
100 | |||
101 | AssetBase a2a = db.GetAsset(uuid2); | ||
102 | Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); | ||
103 | |||
104 | AssetBase a3a = db.GetAsset(uuid3); | ||
105 | Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); | ||
106 | |||
107 | scrambler.Scramble(a1a); | ||
108 | scrambler.Scramble(a2a); | ||
109 | scrambler.Scramble(a3a); | ||
110 | |||
111 | db.StoreAsset(a1a); | ||
112 | db.StoreAsset(a2a); | ||
113 | db.StoreAsset(a3a); | ||
114 | |||
115 | AssetBase a1b = db.GetAsset(uuid1); | ||
116 | Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a)); | ||
117 | |||
118 | AssetBase a2b = db.GetAsset(uuid2); | ||
119 | Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a)); | ||
120 | |||
121 | AssetBase a3b = db.GetAsset(uuid3); | ||
122 | Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); | ||
123 | |||
124 | Assert.That(db.ExistsAsset(uuid1), Is.True); | ||
125 | Assert.That(db.ExistsAsset(uuid2), Is.True); | ||
126 | Assert.That(db.ExistsAsset(uuid3), Is.True); | ||
127 | |||
128 | List<AssetMetadata> metadatas = db.FetchAssetMetadataSet(0, 1000); | ||
129 | |||
130 | AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1); | ||
131 | Assert.That(metadata.Name, Is.EqualTo(a1b.Name)); | ||
132 | Assert.That(metadata.Description, Is.EqualTo(a1b.Description)); | ||
133 | Assert.That(metadata.Type, Is.EqualTo(a1b.Type)); | ||
134 | Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary)); | ||
135 | Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID)); | ||
136 | } | ||
137 | |||
138 | |||
139 | [Test] | ||
140 | public void T020_CheckForWeirdCreatorID() | ||
141 | { | ||
142 | // It is expected that eventually the CreatorID might be an arbitrary string (an URI) | ||
143 | // rather than a valid UUID (?). This test is to make sure that the database layer does not | ||
144 | // attempt to convert CreatorID to GUID, but just passes it both ways as a string. | ||
145 | AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1); | ||
146 | AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, "This is not a GUID!"); | ||
147 | AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, ""); | ||
148 | a1.Data = asset1; | ||
149 | a2.Data = asset1; | ||
150 | a3.Data = asset1; | ||
151 | |||
152 | db.StoreAsset(a1); | ||
153 | db.StoreAsset(a2); | ||
154 | db.StoreAsset(a3); | ||
155 | |||
156 | AssetBase a1a = db.GetAsset(uuid1); | ||
157 | Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); | ||
158 | |||
159 | AssetBase a2a = db.GetAsset(uuid2); | ||
160 | Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); | ||
161 | |||
162 | AssetBase a3a = db.GetAsset(uuid3); | ||
163 | Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); | ||
164 | } | ||
165 | } | ||
166 | } | ||