diff options
Diffstat (limited to 'OpenSim/Data/Tests')
-rw-r--r-- | OpenSim/Data/Tests/AssetTests.cs | 212 | ||||
-rw-r--r-- | OpenSim/Data/Tests/BasicAssetTest.cs | 131 | ||||
-rw-r--r-- | OpenSim/Data/Tests/BasicDataServiceTest.cs | 261 | ||||
-rw-r--r-- | OpenSim/Data/Tests/BasicGridTest.cs | 173 | ||||
-rw-r--r-- | OpenSim/Data/Tests/BasicUserTest.cs | 703 | ||||
-rw-r--r-- | OpenSim/Data/Tests/DefaultTestConns.cs | 90 | ||||
-rw-r--r-- | OpenSim/Data/Tests/EstateTests.cs (renamed from OpenSim/Data/Tests/BasicEstateTest.cs) | 126 | ||||
-rw-r--r-- | OpenSim/Data/Tests/InventoryTests.cs (renamed from OpenSim/Data/Tests/BasicInventoryTest.cs) | 148 | ||||
-rw-r--r-- | OpenSim/Data/Tests/PropertyCompareConstraint.cs | 13 | ||||
-rw-r--r-- | OpenSim/Data/Tests/PropertyScrambler.cs | 6 | ||||
-rw-r--r-- | OpenSim/Data/Tests/RegionTests.cs (renamed from OpenSim/Data/Tests/BasicRegionTest.cs) | 317 | ||||
-rw-r--r-- | OpenSim/Data/Tests/Resources/TestDataConnections.ini | 24 |
12 files changed, 971 insertions, 1233 deletions
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs new file mode 100644 index 0000000..1174e2f --- /dev/null +++ b/OpenSim/Data/Tests/AssetTests.cs | |||
@@ -0,0 +1,212 @@ | |||
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.Constraints; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Tests.Common; | ||
36 | using System.Data.Common; | ||
37 | using log4net; | ||
38 | |||
39 | // DBMS-specific: | ||
40 | using MySql.Data.MySqlClient; | ||
41 | using OpenSim.Data.MySQL; | ||
42 | |||
43 | using System.Data.SqlClient; | ||
44 | using OpenSim.Data.MSSQL; | ||
45 | |||
46 | using Mono.Data.Sqlite; | ||
47 | using OpenSim.Data.SQLite; | ||
48 | |||
49 | namespace OpenSim.Data.Tests | ||
50 | { | ||
51 | [TestFixture(Description = "Asset store tests (SQLite)")] | ||
52 | public class SQLiteAssetTests : AssetTests<SqliteConnection, SQLiteAssetData> | ||
53 | { | ||
54 | } | ||
55 | |||
56 | [TestFixture(Description = "Asset store tests (MySQL)")] | ||
57 | public class MySqlAssetTests : AssetTests<MySqlConnection, MySQLAssetData> | ||
58 | { | ||
59 | } | ||
60 | |||
61 | [TestFixture(Description = "Asset store tests (MS SQL Server)")] | ||
62 | public class MSSQLAssetTests : AssetTests<SqlConnection, MSSQLAssetData> | ||
63 | { | ||
64 | } | ||
65 | |||
66 | public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData> | ||
67 | where TConn : DbConnection, new() | ||
68 | where TAssetData : AssetDataBase, new() | ||
69 | { | ||
70 | TAssetData m_db; | ||
71 | |||
72 | public UUID uuid1 = UUID.Random(); | ||
73 | public UUID uuid2 = UUID.Random(); | ||
74 | public UUID uuid3 = UUID.Random(); | ||
75 | |||
76 | public string critter1 = UUID.Random().ToString(); | ||
77 | public string critter2 = UUID.Random().ToString(); | ||
78 | public string critter3 = UUID.Random().ToString(); | ||
79 | |||
80 | public byte[] data1 = new byte[100]; | ||
81 | |||
82 | PropertyScrambler<AssetBase> scrambler = new PropertyScrambler<AssetBase>() | ||
83 | .DontScramble(x => x.ID) | ||
84 | .DontScramble(x => x.Type) | ||
85 | .DontScramble(x => x.FullID) | ||
86 | .DontScramble(x => x.Metadata.ID) | ||
87 | .DontScramble(x => x.Metadata.CreatorID) | ||
88 | .DontScramble(x => x.Metadata.ContentType) | ||
89 | .DontScramble(x => x.Metadata.FullID) | ||
90 | .DontScramble(x => x.Data); | ||
91 | |||
92 | protected override void InitService(object service) | ||
93 | { | ||
94 | ClearDB(); | ||
95 | m_db = (TAssetData)service; | ||
96 | m_db.Initialise(m_connStr); | ||
97 | } | ||
98 | |||
99 | private void ClearDB() | ||
100 | { | ||
101 | DropTables("assets"); | ||
102 | ResetMigrations("AssetStore"); | ||
103 | } | ||
104 | |||
105 | |||
106 | [Test] | ||
107 | public void T001_LoadEmpty() | ||
108 | { | ||
109 | TestHelpers.InMethod(); | ||
110 | |||
111 | Assert.That(m_db.ExistsAsset(uuid1), Is.False); | ||
112 | Assert.That(m_db.ExistsAsset(uuid2), Is.False); | ||
113 | Assert.That(m_db.ExistsAsset(uuid3), Is.False); | ||
114 | } | ||
115 | |||
116 | [Test] | ||
117 | public void T010_StoreReadVerifyAssets() | ||
118 | { | ||
119 | TestHelpers.InMethod(); | ||
120 | |||
121 | AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1.ToString()); | ||
122 | AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2.ToString()); | ||
123 | AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, critter3.ToString()); | ||
124 | a1.Data = data1; | ||
125 | a2.Data = data1; | ||
126 | a3.Data = data1; | ||
127 | |||
128 | scrambler.Scramble(a1); | ||
129 | scrambler.Scramble(a2); | ||
130 | scrambler.Scramble(a3); | ||
131 | |||
132 | m_db.StoreAsset(a1); | ||
133 | m_db.StoreAsset(a2); | ||
134 | m_db.StoreAsset(a3); | ||
135 | |||
136 | AssetBase a1a = m_db.GetAsset(uuid1); | ||
137 | Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); | ||
138 | |||
139 | AssetBase a2a = m_db.GetAsset(uuid2); | ||
140 | Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); | ||
141 | |||
142 | AssetBase a3a = m_db.GetAsset(uuid3); | ||
143 | Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); | ||
144 | |||
145 | scrambler.Scramble(a1a); | ||
146 | scrambler.Scramble(a2a); | ||
147 | scrambler.Scramble(a3a); | ||
148 | |||
149 | m_db.StoreAsset(a1a); | ||
150 | m_db.StoreAsset(a2a); | ||
151 | m_db.StoreAsset(a3a); | ||
152 | |||
153 | AssetBase a1b = m_db.GetAsset(uuid1); | ||
154 | Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a)); | ||
155 | |||
156 | AssetBase a2b = m_db.GetAsset(uuid2); | ||
157 | Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a)); | ||
158 | |||
159 | AssetBase a3b = m_db.GetAsset(uuid3); | ||
160 | Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); | ||
161 | |||
162 | Assert.That(m_db.ExistsAsset(uuid1), Is.True); | ||
163 | Assert.That(m_db.ExistsAsset(uuid2), Is.True); | ||
164 | Assert.That(m_db.ExistsAsset(uuid3), Is.True); | ||
165 | |||
166 | List<AssetMetadata> metadatas = m_db.FetchAssetMetadataSet(0, 1000); | ||
167 | |||
168 | Assert.That(metadatas.Count >= 3, "FetchAssetMetadataSet() should have returned at least 3 assets!"); | ||
169 | |||
170 | // It is possible that the Asset table is filled with data, in which case we don't try to find "our" | ||
171 | // assets there: | ||
172 | if (metadatas.Count < 1000) | ||
173 | { | ||
174 | AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1); | ||
175 | Assert.That(metadata.Name, Is.EqualTo(a1b.Name)); | ||
176 | Assert.That(metadata.Description, Is.EqualTo(a1b.Description)); | ||
177 | Assert.That(metadata.Type, Is.EqualTo(a1b.Type)); | ||
178 | Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary)); | ||
179 | Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID)); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | [Test] | ||
184 | public void T020_CheckForWeirdCreatorID() | ||
185 | { | ||
186 | TestHelpers.InMethod(); | ||
187 | |||
188 | // It is expected that eventually the CreatorID might be an arbitrary string (an URI) | ||
189 | // rather than a valid UUID (?). This test is to make sure that the database layer does not | ||
190 | // attempt to convert CreatorID to GUID, but just passes it both ways as a string. | ||
191 | AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1); | ||
192 | AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, "This is not a GUID!"); | ||
193 | AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, ""); | ||
194 | a1.Data = data1; | ||
195 | a2.Data = data1; | ||
196 | a3.Data = data1; | ||
197 | |||
198 | m_db.StoreAsset(a1); | ||
199 | m_db.StoreAsset(a2); | ||
200 | m_db.StoreAsset(a3); | ||
201 | |||
202 | AssetBase a1a = m_db.GetAsset(uuid1); | ||
203 | Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); | ||
204 | |||
205 | AssetBase a2a = m_db.GetAsset(uuid2); | ||
206 | Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); | ||
207 | |||
208 | AssetBase a3a = m_db.GetAsset(uuid3); | ||
209 | Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); | ||
210 | } | ||
211 | } | ||
212 | } \ No newline at end of file | ||
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 | } | ||
diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs new file mode 100644 index 0000000..7d85f0c --- /dev/null +++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs | |||
@@ -0,0 +1,261 @@ | |||
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.IO; | ||
30 | using System.Collections.Generic; | ||
31 | using log4net.Config; | ||
32 | using NUnit.Framework; | ||
33 | using NUnit.Framework.Constraints; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using log4net; | ||
37 | using System.Data; | ||
38 | using System.Data.Common; | ||
39 | using System.Reflection; | ||
40 | |||
41 | namespace OpenSim.Data.Tests | ||
42 | { | ||
43 | /// <summary>This is a base class for testing any Data service for any DBMS. | ||
44 | /// Requires NUnit 2.5 or better (to support the generics). | ||
45 | /// </summary> | ||
46 | /// <typeparam name="TConn"></typeparam> | ||
47 | /// <typeparam name="TService"></typeparam> | ||
48 | public class BasicDataServiceTest<TConn, TService> | ||
49 | where TConn : DbConnection, new() | ||
50 | where TService : class, new() | ||
51 | { | ||
52 | protected string m_connStr; | ||
53 | private TService m_service; | ||
54 | private string m_file; | ||
55 | |||
56 | // TODO: Is this in the right place here? | ||
57 | // Later: apparently it's not, but does it matter here? | ||
58 | // protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
59 | |||
60 | protected ILog m_log; // doesn't matter here that it's not static, init to correct type in instance .ctor | ||
61 | |||
62 | public BasicDataServiceTest() | ||
63 | : this("") | ||
64 | { | ||
65 | } | ||
66 | |||
67 | public BasicDataServiceTest(string conn) | ||
68 | { | ||
69 | m_connStr = !String.IsNullOrEmpty(conn) ? conn : DefaultTestConns.Get(typeof(TConn)); | ||
70 | |||
71 | m_log = LogManager.GetLogger(this.GetType()); | ||
72 | OpenSim.Tests.Common.TestLogging.LogToConsole(); // TODO: Is that right? | ||
73 | } | ||
74 | |||
75 | /// <summary> | ||
76 | /// To be overridden in derived classes. Do whatever init with the m_service, like setting the conn string to it. | ||
77 | /// You'd probably want to to cast the 'service' to a more specific type and store it in a member var. | ||
78 | /// This framework takes care of disposing it, if it's disposable. | ||
79 | /// </summary> | ||
80 | /// <param name="service">The service being tested</param> | ||
81 | protected virtual void InitService(object service) | ||
82 | { | ||
83 | } | ||
84 | |||
85 | [TestFixtureSetUp] | ||
86 | public void Init() | ||
87 | { | ||
88 | // Sorry, some SQLite-specific stuff goes here (not a big deal, as its just some file ops) | ||
89 | if (typeof(TConn).Name.StartsWith("Sqlite")) | ||
90 | { | ||
91 | // SQLite doesn't work on power or z linux | ||
92 | if (Directory.Exists("/proc/ppc64") || Directory.Exists("/proc/dasd")) | ||
93 | Assert.Ignore(); | ||
94 | |||
95 | // for SQLite, if no explicit conn string is specified, use a temp file | ||
96 | if (String.IsNullOrEmpty(m_connStr)) | ||
97 | { | ||
98 | m_file = Path.GetTempFileName() + ".db"; | ||
99 | m_connStr = "URI=file:" + m_file + ",version=3"; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | if (String.IsNullOrEmpty(m_connStr)) | ||
104 | { | ||
105 | string msg = String.Format("Connection string for {0} is not defined, ignoring tests", typeof(TConn).Name); | ||
106 | m_log.Warn(msg); | ||
107 | Assert.Ignore(msg); | ||
108 | } | ||
109 | |||
110 | // Try the connection, ignore tests if Open() fails | ||
111 | using (TConn conn = new TConn()) | ||
112 | { | ||
113 | conn.ConnectionString = m_connStr; | ||
114 | try | ||
115 | { | ||
116 | conn.Open(); | ||
117 | conn.Close(); | ||
118 | } | ||
119 | catch | ||
120 | { | ||
121 | string msg = String.Format("{0} is unable to connect to the database, ignoring tests", typeof(TConn).Name); | ||
122 | m_log.Warn(msg); | ||
123 | Assert.Ignore(msg); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | // If we manage to connect to the database with the user | ||
128 | // and password above it is our test database, and run | ||
129 | // these tests. If anything goes wrong, ignore these | ||
130 | // tests. | ||
131 | try | ||
132 | { | ||
133 | m_service = new TService(); | ||
134 | InitService(m_service); | ||
135 | } | ||
136 | catch (Exception e) | ||
137 | { | ||
138 | m_log.Error(e.ToString()); | ||
139 | Assert.Ignore(); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | [TestFixtureTearDown] | ||
144 | public void Cleanup() | ||
145 | { | ||
146 | if (m_service != null) | ||
147 | { | ||
148 | if (m_service is IDisposable) | ||
149 | ((IDisposable)m_service).Dispose(); | ||
150 | m_service = null; | ||
151 | } | ||
152 | |||
153 | if (!String.IsNullOrEmpty(m_file) && File.Exists(m_file)) | ||
154 | File.Delete(m_file); | ||
155 | } | ||
156 | |||
157 | protected virtual DbConnection Connect() | ||
158 | { | ||
159 | DbConnection cnn = new TConn(); | ||
160 | cnn.ConnectionString = m_connStr; | ||
161 | cnn.Open(); | ||
162 | return cnn; | ||
163 | } | ||
164 | |||
165 | protected virtual void ExecuteSql(string sql) | ||
166 | { | ||
167 | using (DbConnection dbcon = Connect()) | ||
168 | { | ||
169 | using (DbCommand cmd = dbcon.CreateCommand()) | ||
170 | { | ||
171 | cmd.CommandText = sql; | ||
172 | cmd.ExecuteNonQuery(); | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | |||
177 | protected delegate bool ProcessRow(IDataReader reader); | ||
178 | |||
179 | protected virtual int ExecQuery(string sql, bool bSingleRow, ProcessRow action) | ||
180 | { | ||
181 | int nRecs = 0; | ||
182 | using (DbConnection dbcon = Connect()) | ||
183 | { | ||
184 | using (DbCommand cmd = dbcon.CreateCommand()) | ||
185 | { | ||
186 | cmd.CommandText = sql; | ||
187 | CommandBehavior cb = bSingleRow ? CommandBehavior.SingleRow : CommandBehavior.Default; | ||
188 | using (DbDataReader rdr = cmd.ExecuteReader(cb)) | ||
189 | { | ||
190 | while (rdr.Read()) | ||
191 | { | ||
192 | nRecs++; | ||
193 | if (!action(rdr)) | ||
194 | break; | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | return nRecs; | ||
200 | } | ||
201 | |||
202 | /// <summary>Drop tables (listed as parameters). There is no "DROP IF EXISTS" syntax common for all | ||
203 | /// databases, so we just DROP and ignore an exception. | ||
204 | /// </summary> | ||
205 | /// <param name="tables"></param> | ||
206 | protected virtual void DropTables(params string[] tables) | ||
207 | { | ||
208 | foreach (string tbl in tables) | ||
209 | { | ||
210 | try | ||
211 | { | ||
212 | ExecuteSql("DROP TABLE " + tbl + ";"); | ||
213 | }catch | ||
214 | { | ||
215 | } | ||
216 | } | ||
217 | } | ||
218 | |||
219 | /// <summary>Clear tables listed as parameters (without dropping them). | ||
220 | /// </summary> | ||
221 | /// <param name="tables"></param> | ||
222 | protected virtual void ResetMigrations(params string[] stores) | ||
223 | { | ||
224 | string lst = ""; | ||
225 | foreach (string store in stores) | ||
226 | { | ||
227 | string s = "'" + store + "'"; | ||
228 | if (lst == "") | ||
229 | lst = s; | ||
230 | else | ||
231 | lst += ", " + s; | ||
232 | } | ||
233 | |||
234 | string sCond = stores.Length > 1 ? ("in (" + lst + ")") : ("=" + lst); | ||
235 | try | ||
236 | { | ||
237 | ExecuteSql("DELETE FROM migrations where name " + sCond); | ||
238 | } | ||
239 | catch | ||
240 | { | ||
241 | } | ||
242 | } | ||
243 | |||
244 | /// <summary>Clear tables listed as parameters (without dropping them). | ||
245 | /// </summary> | ||
246 | /// <param name="tables"></param> | ||
247 | protected virtual void ClearTables(params string[] tables) | ||
248 | { | ||
249 | foreach (string tbl in tables) | ||
250 | { | ||
251 | try | ||
252 | { | ||
253 | ExecuteSql("DELETE FROM " + tbl + ";"); | ||
254 | } | ||
255 | catch | ||
256 | { | ||
257 | } | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | } | ||
diff --git a/OpenSim/Data/Tests/BasicGridTest.cs b/OpenSim/Data/Tests/BasicGridTest.cs deleted file mode 100644 index df6c669..0000000 --- a/OpenSim/Data/Tests/BasicGridTest.cs +++ /dev/null | |||
@@ -1,173 +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 System.Text; | ||
31 | using NUnit.Framework; | ||
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenMetaverse; | ||
34 | |||
35 | namespace OpenSim.Data.Tests | ||
36 | { | ||
37 | public class BasicGridTest | ||
38 | { | ||
39 | public IGridDataPlugin db; | ||
40 | public UUID region1, region2, region3; | ||
41 | public UUID zero = UUID.Zero; | ||
42 | public static Random random = new Random(); | ||
43 | |||
44 | [TearDown] | ||
45 | public void removeAllRegions() | ||
46 | { | ||
47 | // Clean up all the regions. | ||
48 | List<RegionProfileData> regions = db.GetRegionsByName("", 100); | ||
49 | if (regions != null) | ||
50 | { | ||
51 | foreach (RegionProfileData region in regions) | ||
52 | { | ||
53 | db.DeleteProfile(region.Uuid.ToString()); | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
58 | public void SuperInit() | ||
59 | { | ||
60 | OpenSim.Tests.Common.TestLogging.LogToConsole(); | ||
61 | region1 = UUID.Random(); | ||
62 | region2 = UUID.Random(); | ||
63 | region3 = UUID.Random(); | ||
64 | } | ||
65 | |||
66 | protected RegionProfileData createRegion(UUID regionUUID, string regionName) | ||
67 | { | ||
68 | RegionProfileData reg = new RegionProfileData(); | ||
69 | new PropertyScrambler<RegionProfileData>().Scramble(reg); | ||
70 | reg.Uuid = regionUUID; | ||
71 | reg.RegionName = regionName; | ||
72 | |||
73 | db.StoreProfile(reg); | ||
74 | |||
75 | return reg; | ||
76 | } | ||
77 | |||
78 | [Test] | ||
79 | public void T001_LoadEmpty() | ||
80 | { | ||
81 | Assert.That(db.GetProfileByUUID(region1),Is.Null); | ||
82 | Assert.That(db.GetProfileByUUID(region2),Is.Null); | ||
83 | Assert.That(db.GetProfileByUUID(region3),Is.Null); | ||
84 | Assert.That(db.GetProfileByUUID(zero),Is.Null); | ||
85 | } | ||
86 | |||
87 | [Test] | ||
88 | public void T011_AddRetrieveCompleteTest() | ||
89 | { | ||
90 | RegionProfileData newreg = createRegion(region2, "|<Goth@m Ci1y>|"); | ||
91 | RegionProfileData retreg = db.GetProfileByUUID(region2); | ||
92 | |||
93 | Assert.That(retreg, Constraints.PropertyCompareConstraint(newreg).IgnoreProperty(x => x.RegionOnline)); | ||
94 | |||
95 | retreg = db.GetProfileByHandle(newreg.RegionHandle); | ||
96 | Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))"); | ||
97 | |||
98 | retreg = db.GetProfileByString(newreg.RegionName); | ||
99 | Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))"); | ||
100 | |||
101 | RegionProfileData[] retregs = db.GetProfilesInRange(newreg.RegionLocX,newreg.RegionLocY,newreg.RegionLocX,newreg.RegionLocY); | ||
102 | Assert.That(retregs[0].Uuid, Is.EqualTo(region2), "Assert.That(retregs[0].Uuid, Is.EqualTo(region2))"); | ||
103 | } | ||
104 | |||
105 | [Test] | ||
106 | public void T012_DeleteProfile() | ||
107 | { | ||
108 | createRegion(region1, "doesn't matter"); | ||
109 | |||
110 | db.DeleteProfile(region1.ToString()); | ||
111 | RegionProfileData retreg = db.GetProfileByUUID(region1); | ||
112 | Assert.That(retreg,Is.Null); | ||
113 | } | ||
114 | |||
115 | [Test] | ||
116 | public void T013_UpdateProfile() | ||
117 | { | ||
118 | createRegion(region2, "|<Goth@m Ci1y>|"); | ||
119 | |||
120 | RegionProfileData retreg = db.GetProfileByUUID(region2); | ||
121 | retreg.regionName = "Gotham City"; | ||
122 | |||
123 | db.StoreProfile(retreg); | ||
124 | |||
125 | retreg = db.GetProfileByUUID(region2); | ||
126 | Assert.That(retreg.RegionName, Is.EqualTo("Gotham City"), "Assert.That(retreg.RegionName, Is.EqualTo(\"Gotham City\"))"); | ||
127 | } | ||
128 | |||
129 | [Test] | ||
130 | public void T014_RegionList() | ||
131 | { | ||
132 | createRegion(region2, "Gotham City"); | ||
133 | |||
134 | RegionProfileData retreg = db.GetProfileByUUID(region2); | ||
135 | retreg.RegionName = "Gotham Town"; | ||
136 | retreg.Uuid = region1; | ||
137 | |||
138 | db.StoreProfile(retreg); | ||
139 | |||
140 | retreg = db.GetProfileByUUID(region2); | ||
141 | retreg.RegionName = "Gothan Town"; | ||
142 | retreg.Uuid = region3; | ||
143 | |||
144 | db.StoreProfile(retreg); | ||
145 | |||
146 | List<RegionProfileData> listreg = db.GetRegionsByName("Gotham",10); | ||
147 | |||
148 | Assert.That(listreg.Count,Is.EqualTo(2), "Assert.That(listreg.Count,Is.EqualTo(2))"); | ||
149 | Assert.That(listreg[0].Uuid,Is.Not.EqualTo(listreg[1].Uuid), "Assert.That(listreg[0].Uuid,Is.Not.EqualTo(listreg[1].Uuid))"); | ||
150 | Assert.That(listreg[0].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[0].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))"); | ||
151 | Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))"); | ||
152 | } | ||
153 | |||
154 | [Test] | ||
155 | public void T999_StillNull() | ||
156 | { | ||
157 | Assert.That(db.GetProfileByUUID(zero), Is.Null); | ||
158 | } | ||
159 | |||
160 | protected static string RandomName() | ||
161 | { | ||
162 | StringBuilder name = new StringBuilder(); | ||
163 | int size = random.Next(5,12); | ||
164 | char ch ; | ||
165 | for (int i=0; i<size; i++) | ||
166 | { | ||
167 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
168 | name.Append(ch); | ||
169 | } | ||
170 | return name.ToString(); | ||
171 | } | ||
172 | } | ||
173 | } | ||
diff --git a/OpenSim/Data/Tests/BasicUserTest.cs b/OpenSim/Data/Tests/BasicUserTest.cs deleted file mode 100644 index d3b6041..0000000 --- a/OpenSim/Data/Tests/BasicUserTest.cs +++ /dev/null | |||
@@ -1,703 +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 | // TODO: Money Transfer, Inventory Transfer and UpdateUserRegion once they exist | ||
29 | |||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Text; | ||
33 | using log4net.Config; | ||
34 | using NUnit.Framework; | ||
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using log4net; | ||
39 | using System.Reflection; | ||
40 | |||
41 | namespace OpenSim.Data.Tests | ||
42 | { | ||
43 | public class BasicUserTest | ||
44 | { | ||
45 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | public IUserDataPlugin db; | ||
47 | public UUID user1; | ||
48 | public UUID user2; | ||
49 | public UUID user3; | ||
50 | public UUID user4; | ||
51 | public UUID user5; | ||
52 | public UUID webkey; | ||
53 | public UUID zero = UUID.Zero; | ||
54 | public static Random random; | ||
55 | |||
56 | public UUID agent1; | ||
57 | public UUID agent2; | ||
58 | public UUID agent3; | ||
59 | public UUID agent4; | ||
60 | |||
61 | public UUID region1; | ||
62 | |||
63 | public string fname0; | ||
64 | public string lname0; | ||
65 | public string fname1; | ||
66 | public string lname1; | ||
67 | public string fname2; | ||
68 | public string lname2; | ||
69 | public string fname3; | ||
70 | public string lname3; | ||
71 | |||
72 | public void SuperInit() | ||
73 | { | ||
74 | OpenSim.Tests.Common.TestLogging.LogToConsole(); | ||
75 | random = new Random(); | ||
76 | user1 = UUID.Random(); | ||
77 | user2 = UUID.Random(); | ||
78 | user3 = UUID.Random(); | ||
79 | user4 = UUID.Random(); | ||
80 | user5 = UUID.Random(); | ||
81 | agent1 = UUID.Random(); | ||
82 | agent2 = UUID.Random(); | ||
83 | agent3 = UUID.Random(); | ||
84 | agent4 = UUID.Random(); | ||
85 | webkey = UUID.Random(); | ||
86 | region1 = UUID.Random(); | ||
87 | fname0 = RandomName(); | ||
88 | lname0 = RandomName(); | ||
89 | fname1 = RandomName(); | ||
90 | lname1 = RandomName(); | ||
91 | fname2 = RandomName(); | ||
92 | lname2 = RandomName(); | ||
93 | fname3 = RandomName(); | ||
94 | lname3 = RandomName(); | ||
95 | } | ||
96 | |||
97 | [Test] | ||
98 | public void T001_LoadEmpty() | ||
99 | { | ||
100 | Assert.That(db.GetUserByUUID(zero), Is.Null); | ||
101 | Assert.That(db.GetUserByUUID(user1), Is.Null); | ||
102 | Assert.That(db.GetUserByUUID(user2), Is.Null); | ||
103 | Assert.That(db.GetUserByUUID(user3), Is.Null); | ||
104 | Assert.That(db.GetUserByUUID(UUID.Random()), Is.Null); | ||
105 | |||
106 | Assert.That(db.GetAgentByUUID(zero), Is.Null); | ||
107 | Assert.That(db.GetAgentByUUID(agent1), Is.Null); | ||
108 | Assert.That(db.GetAgentByUUID(agent2), Is.Null); | ||
109 | Assert.That(db.GetAgentByUUID(agent3), Is.Null); | ||
110 | Assert.That(db.GetAgentByUUID(UUID.Random()), Is.Null); | ||
111 | } | ||
112 | |||
113 | [Test] | ||
114 | public void T010_CreateUser() | ||
115 | { | ||
116 | UserProfileData u1 = NewUser(user1,fname1,lname1); | ||
117 | UserProfileData u2 = NewUser(user2,fname2,lname2); | ||
118 | UserProfileData u3 = NewUser(user3,fname3,lname3); | ||
119 | // this is used to check whether null works here | ||
120 | u3.Email = null; | ||
121 | |||
122 | db.AddNewUserProfile(u1); | ||
123 | db.AddNewUserProfile(u2); | ||
124 | db.AddNewUserProfile(u3); | ||
125 | UserProfileData u1a = db.GetUserByUUID(user1); | ||
126 | UserProfileData u2a = db.GetUserByUUID(user2); | ||
127 | UserProfileData u3a = db.GetUserByUUID(user3); | ||
128 | Assert.That(user1,Is.EqualTo(u1a.ID), "Assert.That(user1,Is.EqualTo(u1a.ID))"); | ||
129 | Assert.That(user2,Is.EqualTo(u2a.ID), "Assert.That(user2,Is.EqualTo(u2a.ID))"); | ||
130 | Assert.That(user3,Is.EqualTo(u3a.ID), "Assert.That(user3,Is.EqualTo(u3a.ID))"); | ||
131 | |||
132 | // and one email test | ||
133 | Assert.That(u3.Email, Is.Null); | ||
134 | } | ||
135 | |||
136 | [Test] | ||
137 | public void T011_FetchUserByName() | ||
138 | { | ||
139 | UserProfileData u1 = db.GetUserByName(fname1,lname1); | ||
140 | UserProfileData u2 = db.GetUserByName(fname2,lname2); | ||
141 | UserProfileData u3 = db.GetUserByName(fname3,lname3); | ||
142 | Assert.That(user1,Is.EqualTo(u1.ID), "Assert.That(user1,Is.EqualTo(u1.ID))"); | ||
143 | Assert.That(user2,Is.EqualTo(u2.ID), "Assert.That(user2,Is.EqualTo(u2.ID))"); | ||
144 | Assert.That(user3,Is.EqualTo(u3.ID), "Assert.That(user3,Is.EqualTo(u3.ID))"); | ||
145 | } | ||
146 | |||
147 | [Test] | ||
148 | public void T012_UpdateUserProfile() | ||
149 | { | ||
150 | UserProfileData u1 = db.GetUserByUUID(user1); | ||
151 | Assert.That(fname1,Is.EqualTo(u1.FirstName), "Assert.That(fname1,Is.EqualTo(u1.FirstName))"); | ||
152 | u1.FirstName = "Ugly"; | ||
153 | |||
154 | db.UpdateUserProfile(u1); | ||
155 | Assert.That("Ugly",Is.EqualTo(u1.FirstName), "Assert.That(\"Ugly\",Is.EqualTo(u1.FirstName))"); | ||
156 | } | ||
157 | |||
158 | [Test] | ||
159 | public void T013_StoreUserWebKey() | ||
160 | { | ||
161 | UserProfileData u1 = db.GetUserByUUID(user1); | ||
162 | Assert.That(u1.WebLoginKey,Is.EqualTo(zero), "Assert.That(u1.WebLoginKey,Is.EqualTo(zero))"); | ||
163 | db.StoreWebLoginKey(user1, webkey); | ||
164 | u1 = db.GetUserByUUID(user1); | ||
165 | Assert.That(u1.WebLoginKey,Is.EqualTo(webkey), "Assert.That(u1.WebLoginKey,Is.EqualTo(webkey))"); | ||
166 | } | ||
167 | |||
168 | [Test] | ||
169 | public void T014_ExpectedNullReferenceReturns() | ||
170 | { | ||
171 | UserProfileData u0 = NewUser(zero,fname0,lname0); | ||
172 | UserProfileData u4 = NewUser(user4,fname2,lname2); | ||
173 | db.AddNewUserProfile(u0); //UserID 0 should fail to save. | ||
174 | db.AddNewUserProfile(u4); //The first name and last name are already in use (from T010), so this should fail too | ||
175 | Assert.That(db.GetUserByUUID(zero),Is.Null); | ||
176 | Assert.That(db.GetUserByUUID(user4),Is.Null); | ||
177 | } | ||
178 | |||
179 | [Test] | ||
180 | public void T015_UserPersistency() | ||
181 | { | ||
182 | UserProfileData u = new UserProfileData(); | ||
183 | UUID id = user5; | ||
184 | string fname = RandomName(); | ||
185 | string lname = RandomName(); | ||
186 | string email = RandomName(); | ||
187 | string passhash = RandomName(); | ||
188 | string passsalt = RandomName(); | ||
189 | UUID homeregion = UUID.Random(); | ||
190 | UUID webloginkey = UUID.Random(); | ||
191 | uint homeregx = (uint) random.Next(); | ||
192 | uint homeregy = (uint) random.Next(); | ||
193 | Vector3 homeloc | ||
194 | = new Vector3( | ||
195 | (float)Math.Round(random.NextDouble(), 5), | ||
196 | (float)Math.Round(random.NextDouble(), 5), | ||
197 | (float)Math.Round(random.NextDouble(), 5)); | ||
198 | Vector3 homelookat | ||
199 | = new Vector3( | ||
200 | (float)Math.Round(random.NextDouble(), 5), | ||
201 | (float)Math.Round(random.NextDouble(), 5), | ||
202 | (float)Math.Round(random.NextDouble(), 5)); | ||
203 | int created = random.Next(); | ||
204 | int lastlogin = random.Next(); | ||
205 | string userinvuri = RandomName(); | ||
206 | string userasseturi = RandomName(); | ||
207 | uint candomask = (uint) random.Next(); | ||
208 | uint wantdomask = (uint) random.Next(); | ||
209 | string abouttext = RandomName(); | ||
210 | string flabouttext = RandomName(); | ||
211 | UUID image = UUID.Random(); | ||
212 | UUID firstimage = UUID.Random(); | ||
213 | UserAgentData agent = NewAgent(id,UUID.Random()); | ||
214 | int userflags = random.Next(); | ||
215 | int godlevel = random.Next(); | ||
216 | string customtype = RandomName(); | ||
217 | UUID partner = UUID.Random(); | ||
218 | |||
219 | //HomeRegionX and HomeRegionY must only use 24 bits | ||
220 | homeregx = ((homeregx << 8) >> 8); | ||
221 | homeregy = ((homeregy << 8) >> 8); | ||
222 | |||
223 | u.ID = id; | ||
224 | u.WebLoginKey = webloginkey; | ||
225 | u.HomeRegionID = homeregion; | ||
226 | u.FirstName = fname; | ||
227 | u.SurName = lname; | ||
228 | u.Email = email; | ||
229 | u.PasswordHash = passhash; | ||
230 | u.PasswordSalt = passsalt; | ||
231 | u.HomeRegionX = homeregx; | ||
232 | u.HomeRegionY = homeregy; | ||
233 | ulong homereg = u.HomeRegion; | ||
234 | u.HomeLocation = homeloc; | ||
235 | u.HomeLookAt = homelookat; | ||
236 | u.Created = created; | ||
237 | u.LastLogin = lastlogin; | ||
238 | u.UserInventoryURI = userinvuri; | ||
239 | u.UserAssetURI = userasseturi; | ||
240 | u.CanDoMask = candomask; | ||
241 | u.WantDoMask = wantdomask; | ||
242 | u.AboutText = abouttext; | ||
243 | u.FirstLifeAboutText = flabouttext; | ||
244 | u.Image = image; | ||
245 | u.FirstLifeImage = firstimage; | ||
246 | u.CurrentAgent = agent; | ||
247 | u.UserFlags = userflags; | ||
248 | u.GodLevel = godlevel; | ||
249 | u.CustomType = customtype; | ||
250 | u.Partner = partner; | ||
251 | |||
252 | db.AddNewUserProfile(u); | ||
253 | UserProfileData u1a = db.GetUserByUUID(id); | ||
254 | Assert.That(u1a,Is.Not.Null); | ||
255 | Assert.That(id,Is.EqualTo(u1a.ID), "Assert.That(id,Is.EqualTo(u1a.ID))"); | ||
256 | Assert.That(homeregion,Is.EqualTo(u1a.HomeRegionID), "Assert.That(homeregion,Is.EqualTo(u1a.HomeRegionID))"); | ||
257 | Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey), "Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey))"); | ||
258 | Assert.That(fname,Is.EqualTo(u1a.FirstName), "Assert.That(fname,Is.EqualTo(u1a.FirstName))"); | ||
259 | Assert.That(lname,Is.EqualTo(u1a.SurName), "Assert.That(lname,Is.EqualTo(u1a.SurName))"); | ||
260 | Assert.That(email,Is.EqualTo(u1a.Email), "Assert.That(email,Is.EqualTo(u1a.Email))"); | ||
261 | Assert.That(passhash,Is.EqualTo(u1a.PasswordHash), "Assert.That(passhash,Is.EqualTo(u1a.PasswordHash))"); | ||
262 | Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt), "Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt))"); | ||
263 | Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX), "Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX))"); | ||
264 | Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY), "Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY))"); | ||
265 | Assert.That(homereg,Is.EqualTo(u1a.HomeRegion), "Assert.That(homereg,Is.EqualTo(u1a.HomeRegion))"); | ||
266 | Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation), "Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation))"); | ||
267 | Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt), "Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt))"); | ||
268 | Assert.That(created,Is.EqualTo(u1a.Created), "Assert.That(created,Is.EqualTo(u1a.Created))"); | ||
269 | Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin), "Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin))"); | ||
270 | Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI), "Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI))"); | ||
271 | Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI), "Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI))"); | ||
272 | Assert.That(candomask,Is.EqualTo(u1a.CanDoMask), "Assert.That(candomask,Is.EqualTo(u1a.CanDoMask))"); | ||
273 | Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask), "Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask))"); | ||
274 | Assert.That(abouttext,Is.EqualTo(u1a.AboutText), "Assert.That(abouttext,Is.EqualTo(u1a.AboutText))"); | ||
275 | Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText), "Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText))"); | ||
276 | Assert.That(image,Is.EqualTo(u1a.Image), "Assert.That(image,Is.EqualTo(u1a.Image))"); | ||
277 | Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage), "Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage))"); | ||
278 | Assert.That(u1a.CurrentAgent,Is.Null); | ||
279 | Assert.That(userflags,Is.EqualTo(u1a.UserFlags), "Assert.That(userflags,Is.EqualTo(u1a.UserFlags))"); | ||
280 | Assert.That(godlevel,Is.EqualTo(u1a.GodLevel), "Assert.That(godlevel,Is.EqualTo(u1a.GodLevel))"); | ||
281 | Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))"); | ||
282 | Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))"); | ||
283 | } | ||
284 | |||
285 | [Test] | ||
286 | public void T016_UserUpdatePersistency() | ||
287 | { | ||
288 | UUID id = user5; | ||
289 | UserProfileData u = db.GetUserByUUID(id); | ||
290 | string fname = RandomName(); | ||
291 | string lname = RandomName(); | ||
292 | string email = RandomName(); | ||
293 | string passhash = RandomName(); | ||
294 | string passsalt = RandomName(); | ||
295 | UUID homeregionid = UUID.Random(); | ||
296 | UUID webloginkey = UUID.Random(); | ||
297 | uint homeregx = (uint) random.Next(); | ||
298 | uint homeregy = (uint) random.Next(); | ||
299 | Vector3 homeloc = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5)); | ||
300 | Vector3 homelookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5)); | ||
301 | int created = random.Next(); | ||
302 | int lastlogin = random.Next(); | ||
303 | string userinvuri = RandomName(); | ||
304 | string userasseturi = RandomName(); | ||
305 | uint candomask = (uint) random.Next(); | ||
306 | uint wantdomask = (uint) random.Next(); | ||
307 | string abouttext = RandomName(); | ||
308 | string flabouttext = RandomName(); | ||
309 | UUID image = UUID.Random(); | ||
310 | UUID firstimage = UUID.Random(); | ||
311 | UserAgentData agent = NewAgent(id,UUID.Random()); | ||
312 | int userflags = random.Next(); | ||
313 | int godlevel = random.Next(); | ||
314 | string customtype = RandomName(); | ||
315 | UUID partner = UUID.Random(); | ||
316 | |||
317 | //HomeRegionX and HomeRegionY must only use 24 bits | ||
318 | homeregx = ((homeregx << 8) >> 8); | ||
319 | homeregy = ((homeregy << 8) >> 8); | ||
320 | |||
321 | u.WebLoginKey = webloginkey; | ||
322 | u.HomeRegionID = homeregionid; | ||
323 | u.FirstName = fname; | ||
324 | u.SurName = lname; | ||
325 | u.Email = email; | ||
326 | u.PasswordHash = passhash; | ||
327 | u.PasswordSalt = passsalt; | ||
328 | u.HomeRegionX = homeregx; | ||
329 | u.HomeRegionY = homeregy; | ||
330 | ulong homereg = u.HomeRegion; | ||
331 | u.HomeLocation = homeloc; | ||
332 | u.HomeLookAt = homelookat; | ||
333 | u.Created = created; | ||
334 | u.LastLogin = lastlogin; | ||
335 | u.UserInventoryURI = userinvuri; | ||
336 | u.UserAssetURI = userasseturi; | ||
337 | u.CanDoMask = candomask; | ||
338 | u.WantDoMask = wantdomask; | ||
339 | u.AboutText = abouttext; | ||
340 | u.FirstLifeAboutText = flabouttext; | ||
341 | u.Image = image; | ||
342 | u.FirstLifeImage = firstimage; | ||
343 | u.CurrentAgent = agent; | ||
344 | u.UserFlags = userflags; | ||
345 | u.GodLevel = godlevel; | ||
346 | u.CustomType = customtype; | ||
347 | u.Partner = partner; | ||
348 | |||
349 | db.UpdateUserProfile(u); | ||
350 | UserProfileData u1a = db.GetUserByUUID(id); | ||
351 | Assert.That(u1a,Is.Not.Null); | ||
352 | Assert.That(id,Is.EqualTo(u1a.ID), "Assert.That(id,Is.EqualTo(u1a.ID))"); | ||
353 | Assert.That(homeregionid,Is.EqualTo(u1a.HomeRegionID), "Assert.That(homeregionid,Is.EqualTo(u1a.HomeRegionID))"); | ||
354 | Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey), "Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey))"); | ||
355 | Assert.That(fname,Is.EqualTo(u1a.FirstName), "Assert.That(fname,Is.EqualTo(u1a.FirstName))"); | ||
356 | Assert.That(lname,Is.EqualTo(u1a.SurName), "Assert.That(lname,Is.EqualTo(u1a.SurName))"); | ||
357 | Assert.That(email,Is.EqualTo(u1a.Email), "Assert.That(email,Is.EqualTo(u1a.Email))"); | ||
358 | Assert.That(passhash,Is.EqualTo(u1a.PasswordHash), "Assert.That(passhash,Is.EqualTo(u1a.PasswordHash))"); | ||
359 | Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt), "Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt))"); | ||
360 | Assert.That(homereg,Is.EqualTo(u1a.HomeRegion), "Assert.That(homereg,Is.EqualTo(u1a.HomeRegion))"); | ||
361 | Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX), "Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX))"); | ||
362 | Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY), "Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY))"); | ||
363 | Assert.That(homereg,Is.EqualTo(u1a.HomeRegion), "Assert.That(homereg,Is.EqualTo(u1a.HomeRegion))"); | ||
364 | Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation), "Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation))"); | ||
365 | Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt), "Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt))"); | ||
366 | Assert.That(created,Is.EqualTo(u1a.Created), "Assert.That(created,Is.EqualTo(u1a.Created))"); | ||
367 | Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin), "Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin))"); | ||
368 | Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI), "Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI))"); | ||
369 | Assert.That(candomask,Is.EqualTo(u1a.CanDoMask), "Assert.That(candomask,Is.EqualTo(u1a.CanDoMask))"); | ||
370 | Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask), "Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask))"); | ||
371 | Assert.That(abouttext,Is.EqualTo(u1a.AboutText), "Assert.That(abouttext,Is.EqualTo(u1a.AboutText))"); | ||
372 | Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText), "Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText))"); | ||
373 | Assert.That(image,Is.EqualTo(u1a.Image), "Assert.That(image,Is.EqualTo(u1a.Image))"); | ||
374 | Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage), "Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage))"); | ||
375 | Assert.That(u1a.CurrentAgent,Is.Null); | ||
376 | Assert.That(userflags,Is.EqualTo(u1a.UserFlags), "Assert.That(userflags,Is.EqualTo(u1a.UserFlags))"); | ||
377 | Assert.That(godlevel,Is.EqualTo(u1a.GodLevel), "Assert.That(godlevel,Is.EqualTo(u1a.GodLevel))"); | ||
378 | Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))"); | ||
379 | Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))"); | ||
380 | } | ||
381 | |||
382 | [Test] | ||
383 | public void T017_UserUpdateRandomPersistency() | ||
384 | { | ||
385 | UUID id = user5; | ||
386 | UserProfileData u = db.GetUserByUUID(id); | ||
387 | new PropertyScrambler<UserProfileData>().DontScramble(x=>x.ID).Scramble(u); | ||
388 | |||
389 | db.UpdateUserProfile(u); | ||
390 | UserProfileData u1a = db.GetUserByUUID(id); | ||
391 | Assert.That(u1a, Constraints.PropertyCompareConstraint(u) | ||
392 | .IgnoreProperty(x=>x.HomeRegionX) | ||
393 | .IgnoreProperty(x=>x.HomeRegionY) | ||
394 | ); | ||
395 | } | ||
396 | |||
397 | [Test] | ||
398 | public void T020_CreateAgent() | ||
399 | { | ||
400 | UserAgentData a1 = NewAgent(user1,agent1); | ||
401 | UserAgentData a2 = NewAgent(user2,agent2); | ||
402 | UserAgentData a3 = NewAgent(user3,agent3); | ||
403 | db.AddNewUserAgent(a1); | ||
404 | db.AddNewUserAgent(a2); | ||
405 | db.AddNewUserAgent(a3); | ||
406 | UserAgentData a1a = db.GetAgentByUUID(user1); | ||
407 | UserAgentData a2a = db.GetAgentByUUID(user2); | ||
408 | UserAgentData a3a = db.GetAgentByUUID(user3); | ||
409 | Assert.That(agent1,Is.EqualTo(a1a.SessionID), "Assert.That(agent1,Is.EqualTo(a1a.SessionID))"); | ||
410 | Assert.That(user1,Is.EqualTo(a1a.ProfileID), "Assert.That(user1,Is.EqualTo(a1a.ProfileID))"); | ||
411 | Assert.That(agent2,Is.EqualTo(a2a.SessionID), "Assert.That(agent2,Is.EqualTo(a2a.SessionID))"); | ||
412 | Assert.That(user2,Is.EqualTo(a2a.ProfileID), "Assert.That(user2,Is.EqualTo(a2a.ProfileID))"); | ||
413 | Assert.That(agent3,Is.EqualTo(a3a.SessionID), "Assert.That(agent3,Is.EqualTo(a3a.SessionID))"); | ||
414 | Assert.That(user3,Is.EqualTo(a3a.ProfileID), "Assert.That(user3,Is.EqualTo(a3a.ProfileID))"); | ||
415 | } | ||
416 | |||
417 | [Test] | ||
418 | public void T021_FetchAgentByName() | ||
419 | { | ||
420 | String name3 = fname3 + " " + lname3; | ||
421 | UserAgentData a2 = db.GetAgentByName(fname2,lname2); | ||
422 | UserAgentData a3 = db.GetAgentByName(name3); | ||
423 | Assert.That(user2,Is.EqualTo(a2.ProfileID), "Assert.That(user2,Is.EqualTo(a2.ProfileID))"); | ||
424 | Assert.That(user3,Is.EqualTo(a3.ProfileID), "Assert.That(user3,Is.EqualTo(a3.ProfileID))"); | ||
425 | } | ||
426 | |||
427 | [Test] | ||
428 | public void T022_ExceptionalCases() | ||
429 | { | ||
430 | UserAgentData a0 = NewAgent(user4,zero); | ||
431 | UserAgentData a4 = NewAgent(zero,agent4); | ||
432 | db.AddNewUserAgent(a0); | ||
433 | db.AddNewUserAgent(a4); | ||
434 | |||
435 | Assert.That(db.GetAgentByUUID(user4),Is.Null); | ||
436 | Assert.That(db.GetAgentByUUID(zero),Is.Null); | ||
437 | } | ||
438 | |||
439 | [Test] | ||
440 | public void T023_AgentPersistency() | ||
441 | { | ||
442 | UUID user = user4; | ||
443 | UUID agent = agent4; | ||
444 | UUID secureagent = UUID.Random(); | ||
445 | string agentip = RandomName(); | ||
446 | uint agentport = (uint)random.Next(); | ||
447 | bool agentonline = (random.NextDouble() > 0.5); | ||
448 | int logintime = random.Next(); | ||
449 | int logouttime = random.Next(); | ||
450 | UUID regionid = UUID.Random(); | ||
451 | ulong regionhandle = (ulong) random.Next(); | ||
452 | Vector3 currentpos = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5)); | ||
453 | Vector3 currentlookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5)); | ||
454 | UUID orgregionid = UUID.Random(); | ||
455 | |||
456 | UserAgentData a = new UserAgentData(); | ||
457 | a.ProfileID = user; | ||
458 | a.SessionID = agent; | ||
459 | a.SecureSessionID = secureagent; | ||
460 | a.AgentIP = agentip; | ||
461 | a.AgentPort = agentport; | ||
462 | a.AgentOnline = agentonline; | ||
463 | a.LoginTime = logintime; | ||
464 | a.LogoutTime = logouttime; | ||
465 | a.Region = regionid; | ||
466 | a.Handle = regionhandle; | ||
467 | a.Position = currentpos; | ||
468 | a.LookAt = currentlookat; | ||
469 | a.InitialRegion = orgregionid; | ||
470 | |||
471 | db.AddNewUserAgent(a); | ||
472 | |||
473 | UserAgentData a1 = db.GetAgentByUUID(user4); | ||
474 | Assert.That(user,Is.EqualTo(a1.ProfileID), "Assert.That(user,Is.EqualTo(a1.ProfileID))"); | ||
475 | Assert.That(agent,Is.EqualTo(a1.SessionID), "Assert.That(agent,Is.EqualTo(a1.SessionID))"); | ||
476 | Assert.That(secureagent,Is.EqualTo(a1.SecureSessionID), "Assert.That(secureagent,Is.EqualTo(a1.SecureSessionID))"); | ||
477 | Assert.That(agentip,Is.EqualTo(a1.AgentIP), "Assert.That(agentip,Is.EqualTo(a1.AgentIP))"); | ||
478 | Assert.That(agentport,Is.EqualTo(a1.AgentPort), "Assert.That(agentport,Is.EqualTo(a1.AgentPort))"); | ||
479 | Assert.That(agentonline,Is.EqualTo(a1.AgentOnline), "Assert.That(agentonline,Is.EqualTo(a1.AgentOnline))"); | ||
480 | Assert.That(logintime,Is.EqualTo(a1.LoginTime), "Assert.That(logintime,Is.EqualTo(a1.LoginTime))"); | ||
481 | Assert.That(logouttime,Is.EqualTo(a1.LogoutTime), "Assert.That(logouttime,Is.EqualTo(a1.LogoutTime))"); | ||
482 | Assert.That(regionid,Is.EqualTo(a1.Region), "Assert.That(regionid,Is.EqualTo(a1.Region))"); | ||
483 | Assert.That(regionhandle,Is.EqualTo(a1.Handle), "Assert.That(regionhandle,Is.EqualTo(a1.Handle))"); | ||
484 | Assert.That(currentpos,Is.EqualTo(a1.Position), "Assert.That(currentpos,Is.EqualTo(a1.Position))"); | ||
485 | Assert.That(currentlookat,Is.EqualTo(a1.LookAt), "Assert.That(currentlookat,Is.EqualTo(a1.LookAt))"); | ||
486 | } | ||
487 | |||
488 | [Test] | ||
489 | public void T030_CreateFriendList() | ||
490 | { | ||
491 | Dictionary<UUID, uint> perms = new Dictionary<UUID,uint>(); | ||
492 | Dictionary<UUID, int> friends = new Dictionary<UUID,int>(); | ||
493 | uint temp; | ||
494 | int tempu1, tempu2; | ||
495 | db.AddNewUserFriend(user1,user2, 1); | ||
496 | db.AddNewUserFriend(user1,user3, 2); | ||
497 | db.AddNewUserFriend(user1,user2, 4); | ||
498 | List<FriendListItem> fl1 = db.GetUserFriendList(user1); | ||
499 | Assert.That(fl1.Count,Is.EqualTo(2), "Assert.That(fl1.Count,Is.EqualTo(2))"); | ||
500 | perms.Add(user2,1); | ||
501 | perms.Add(user3,2); | ||
502 | for (int i = 0; i < fl1.Count; i++) | ||
503 | { | ||
504 | Assert.That(user1,Is.EqualTo(fl1[i].FriendListOwner), "Assert.That(user1,Is.EqualTo(fl1[i].FriendListOwner))"); | ||
505 | friends.Add(fl1[i].Friend,1); | ||
506 | temp = perms[fl1[i].Friend]; | ||
507 | Assert.That(temp,Is.EqualTo(fl1[i].FriendPerms), "Assert.That(temp,Is.EqualTo(fl1[i].FriendPerms))"); | ||
508 | } | ||
509 | tempu1 = friends[user2]; | ||
510 | tempu2 = friends[user3]; | ||
511 | Assert.That(1,Is.EqualTo(tempu1) & Is.EqualTo(tempu2), "Assert.That(1,Is.EqualTo(tempu1) & Is.EqualTo(tempu2))"); | ||
512 | } | ||
513 | |||
514 | [Test] | ||
515 | public void T031_RemoveUserFriend() | ||
516 | // user1 has 2 friends, user2 and user3. | ||
517 | { | ||
518 | List<FriendListItem> fl1 = db.GetUserFriendList(user1); | ||
519 | List<FriendListItem> fl2 = db.GetUserFriendList(user2); | ||
520 | |||
521 | Assert.That(fl1.Count,Is.EqualTo(2), "Assert.That(fl1.Count,Is.EqualTo(2))"); | ||
522 | Assert.That(fl1[0].Friend,Is.EqualTo(user2) | Is.EqualTo(user3), "Assert.That(fl1[0].Friend,Is.EqualTo(user2) | Is.EqualTo(user3))"); | ||
523 | Assert.That(fl2[0].Friend,Is.EqualTo(user1), "Assert.That(fl2[0].Friend,Is.EqualTo(user1))"); | ||
524 | db.RemoveUserFriend(user2, user1); | ||
525 | |||
526 | fl1 = db.GetUserFriendList(user1); | ||
527 | fl2 = db.GetUserFriendList(user2); | ||
528 | Assert.That(fl1.Count,Is.EqualTo(1), "Assert.That(fl1.Count,Is.EqualTo(1))"); | ||
529 | Assert.That(fl1[0].Friend, Is.EqualTo(user3), "Assert.That(fl1[0].Friend, Is.EqualTo(user3))"); | ||
530 | Assert.That(fl2, Is.Empty); | ||
531 | } | ||
532 | |||
533 | [Test] | ||
534 | public void T032_UpdateFriendPerms() | ||
535 | // user1 has 1 friend, user3, who has permission 2 in T030. | ||
536 | { | ||
537 | List<FriendListItem> fl1 = db.GetUserFriendList(user1); | ||
538 | Assert.That(fl1[0].FriendPerms,Is.EqualTo(2), "Assert.That(fl1[0].FriendPerms,Is.EqualTo(2))"); | ||
539 | db.UpdateUserFriendPerms(user1, user3, 4); | ||
540 | |||
541 | fl1 = db.GetUserFriendList(user1); | ||
542 | Assert.That(fl1[0].FriendPerms,Is.EqualTo(4), "Assert.That(fl1[0].FriendPerms,Is.EqualTo(4))"); | ||
543 | } | ||
544 | |||
545 | [Test] | ||
546 | public void T040_UserAppearance() | ||
547 | { | ||
548 | AvatarAppearance appear = new AvatarAppearance(); | ||
549 | appear.Owner = user1; | ||
550 | db.UpdateUserAppearance(user1, appear); | ||
551 | AvatarAppearance user1app = db.GetUserAppearance(user1); | ||
552 | Assert.That(user1,Is.EqualTo(user1app.Owner), "Assert.That(user1,Is.EqualTo(user1app.Owner))"); | ||
553 | } | ||
554 | |||
555 | [Test] | ||
556 | public void T041_UserAppearancePersistency() | ||
557 | { | ||
558 | AvatarAppearance appear = new AvatarAppearance(); | ||
559 | UUID owner = UUID.Random(); | ||
560 | int serial = random.Next(); | ||
561 | byte[] visualp = new byte[218]; | ||
562 | random.NextBytes(visualp); | ||
563 | UUID bodyitem = UUID.Random(); | ||
564 | UUID bodyasset = UUID.Random(); | ||
565 | UUID skinitem = UUID.Random(); | ||
566 | UUID skinasset = UUID.Random(); | ||
567 | UUID hairitem = UUID.Random(); | ||
568 | UUID hairasset = UUID.Random(); | ||
569 | UUID eyesitem = UUID.Random(); | ||
570 | UUID eyesasset = UUID.Random(); | ||
571 | UUID shirtitem = UUID.Random(); | ||
572 | UUID shirtasset = UUID.Random(); | ||
573 | UUID pantsitem = UUID.Random(); | ||
574 | UUID pantsasset = UUID.Random(); | ||
575 | UUID shoesitem = UUID.Random(); | ||
576 | UUID shoesasset = UUID.Random(); | ||
577 | UUID socksitem = UUID.Random(); | ||
578 | UUID socksasset = UUID.Random(); | ||
579 | UUID jacketitem = UUID.Random(); | ||
580 | UUID jacketasset = UUID.Random(); | ||
581 | UUID glovesitem = UUID.Random(); | ||
582 | UUID glovesasset = UUID.Random(); | ||
583 | UUID ushirtitem = UUID.Random(); | ||
584 | UUID ushirtasset = UUID.Random(); | ||
585 | UUID upantsitem = UUID.Random(); | ||
586 | UUID upantsasset = UUID.Random(); | ||
587 | UUID skirtitem = UUID.Random(); | ||
588 | UUID skirtasset = UUID.Random(); | ||
589 | Primitive.TextureEntry texture = AvatarAppearance.GetDefaultTexture(); | ||
590 | float avatarheight = (float) (Math.Round(random.NextDouble(),5)); | ||
591 | |||
592 | appear.Owner = owner; | ||
593 | appear.Serial = serial; | ||
594 | appear.VisualParams = visualp; | ||
595 | appear.BodyItem = bodyitem; | ||
596 | appear.BodyAsset = bodyasset; | ||
597 | appear.SkinItem = skinitem; | ||
598 | appear.SkinAsset = skinasset; | ||
599 | appear.HairItem = hairitem; | ||
600 | appear.HairAsset = hairasset; | ||
601 | appear.EyesItem = eyesitem; | ||
602 | appear.EyesAsset = eyesasset; | ||
603 | appear.ShirtItem = shirtitem; | ||
604 | appear.ShirtAsset = shirtasset; | ||
605 | appear.PantsItem = pantsitem; | ||
606 | appear.PantsAsset = pantsasset; | ||
607 | appear.ShoesItem = shoesitem; | ||
608 | appear.ShoesAsset = shoesasset; | ||
609 | appear.SocksItem = socksitem; | ||
610 | appear.SocksAsset = socksasset; | ||
611 | appear.JacketItem = jacketitem; | ||
612 | appear.JacketAsset = jacketasset; | ||
613 | appear.GlovesItem = glovesitem; | ||
614 | appear.GlovesAsset = glovesasset; | ||
615 | appear.UnderShirtItem = ushirtitem; | ||
616 | appear.UnderShirtAsset = ushirtasset; | ||
617 | appear.UnderPantsItem = upantsitem; | ||
618 | appear.UnderPantsAsset = upantsasset; | ||
619 | appear.SkirtItem = skirtitem; | ||
620 | appear.SkirtAsset = skirtasset; | ||
621 | appear.Texture = texture; | ||
622 | appear.AvatarHeight = avatarheight; | ||
623 | |||
624 | db.UpdateUserAppearance(owner, appear); | ||
625 | AvatarAppearance app = db.GetUserAppearance(owner); | ||
626 | |||
627 | Assert.That(owner,Is.EqualTo(app.Owner), "Assert.That(owner,Is.EqualTo(app.Owner))"); | ||
628 | Assert.That(serial,Is.EqualTo(app.Serial), "Assert.That(serial,Is.EqualTo(app.Serial))"); | ||
629 | Assert.That(visualp,Is.EqualTo(app.VisualParams), "Assert.That(visualp,Is.EqualTo(app.VisualParams))"); | ||
630 | Assert.That(bodyitem,Is.EqualTo(app.BodyItem), "Assert.That(bodyitem,Is.EqualTo(app.BodyItem))"); | ||
631 | Assert.That(bodyasset,Is.EqualTo(app.BodyAsset), "Assert.That(bodyasset,Is.EqualTo(app.BodyAsset))"); | ||
632 | Assert.That(skinitem,Is.EqualTo(app.SkinItem), "Assert.That(skinitem,Is.EqualTo(app.SkinItem))"); | ||
633 | Assert.That(skinasset,Is.EqualTo(app.SkinAsset), "Assert.That(skinasset,Is.EqualTo(app.SkinAsset))"); | ||
634 | Assert.That(hairitem,Is.EqualTo(app.HairItem), "Assert.That(hairitem,Is.EqualTo(app.HairItem))"); | ||
635 | Assert.That(hairasset,Is.EqualTo(app.HairAsset), "Assert.That(hairasset,Is.EqualTo(app.HairAsset))"); | ||
636 | Assert.That(eyesitem,Is.EqualTo(app.EyesItem), "Assert.That(eyesitem,Is.EqualTo(app.EyesItem))"); | ||
637 | Assert.That(eyesasset,Is.EqualTo(app.EyesAsset), "Assert.That(eyesasset,Is.EqualTo(app.EyesAsset))"); | ||
638 | Assert.That(shirtitem,Is.EqualTo(app.ShirtItem), "Assert.That(shirtitem,Is.EqualTo(app.ShirtItem))"); | ||
639 | Assert.That(shirtasset,Is.EqualTo(app.ShirtAsset), "Assert.That(shirtasset,Is.EqualTo(app.ShirtAsset))"); | ||
640 | Assert.That(pantsitem,Is.EqualTo(app.PantsItem), "Assert.That(pantsitem,Is.EqualTo(app.PantsItem))"); | ||
641 | Assert.That(pantsasset,Is.EqualTo(app.PantsAsset), "Assert.That(pantsasset,Is.EqualTo(app.PantsAsset))"); | ||
642 | Assert.That(shoesitem,Is.EqualTo(app.ShoesItem), "Assert.That(shoesitem,Is.EqualTo(app.ShoesItem))"); | ||
643 | Assert.That(shoesasset,Is.EqualTo(app.ShoesAsset), "Assert.That(shoesasset,Is.EqualTo(app.ShoesAsset))"); | ||
644 | Assert.That(socksitem,Is.EqualTo(app.SocksItem), "Assert.That(socksitem,Is.EqualTo(app.SocksItem))"); | ||
645 | Assert.That(socksasset,Is.EqualTo(app.SocksAsset), "Assert.That(socksasset,Is.EqualTo(app.SocksAsset))"); | ||
646 | Assert.That(jacketitem,Is.EqualTo(app.JacketItem), "Assert.That(jacketitem,Is.EqualTo(app.JacketItem))"); | ||
647 | Assert.That(jacketasset,Is.EqualTo(app.JacketAsset), "Assert.That(jacketasset,Is.EqualTo(app.JacketAsset))"); | ||
648 | Assert.That(glovesitem,Is.EqualTo(app.GlovesItem), "Assert.That(glovesitem,Is.EqualTo(app.GlovesItem))"); | ||
649 | Assert.That(glovesasset,Is.EqualTo(app.GlovesAsset), "Assert.That(glovesasset,Is.EqualTo(app.GlovesAsset))"); | ||
650 | Assert.That(ushirtitem,Is.EqualTo(app.UnderShirtItem), "Assert.That(ushirtitem,Is.EqualTo(app.UnderShirtItem))"); | ||
651 | Assert.That(ushirtasset,Is.EqualTo(app.UnderShirtAsset), "Assert.That(ushirtasset,Is.EqualTo(app.UnderShirtAsset))"); | ||
652 | Assert.That(upantsitem,Is.EqualTo(app.UnderPantsItem), "Assert.That(upantsitem,Is.EqualTo(app.UnderPantsItem))"); | ||
653 | Assert.That(upantsasset,Is.EqualTo(app.UnderPantsAsset), "Assert.That(upantsasset,Is.EqualTo(app.UnderPantsAsset))"); | ||
654 | Assert.That(skirtitem,Is.EqualTo(app.SkirtItem), "Assert.That(skirtitem,Is.EqualTo(app.SkirtItem))"); | ||
655 | Assert.That(skirtasset,Is.EqualTo(app.SkirtAsset), "Assert.That(skirtasset,Is.EqualTo(app.SkirtAsset))"); | ||
656 | Assert.That(texture.ToString(),Is.EqualTo(app.Texture.ToString()), "Assert.That(texture.ToString(),Is.EqualTo(app.Texture.ToString()))"); | ||
657 | Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight), "Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight))"); | ||
658 | } | ||
659 | |||
660 | [Test] | ||
661 | public void T999_StillNull() | ||
662 | { | ||
663 | Assert.That(db.GetUserByUUID(zero), Is.Null); | ||
664 | Assert.That(db.GetAgentByUUID(zero), Is.Null); | ||
665 | } | ||
666 | |||
667 | public UserProfileData NewUser(UUID id,string fname,string lname) | ||
668 | { | ||
669 | UserProfileData u = new UserProfileData(); | ||
670 | u.ID = id; | ||
671 | u.FirstName = fname; | ||
672 | u.SurName = lname; | ||
673 | u.PasswordHash = "NOTAHASH"; | ||
674 | u.PasswordSalt = "NOTSALT"; | ||
675 | // MUST specify at least these 5 parameters or an exception is raised | ||
676 | |||
677 | return u; | ||
678 | } | ||
679 | |||
680 | public UserAgentData NewAgent(UUID user_profile, UUID agent) | ||
681 | { | ||
682 | UserAgentData a = new UserAgentData(); | ||
683 | a.ProfileID = user_profile; | ||
684 | a.SessionID = agent; | ||
685 | a.SecureSessionID = UUID.Random(); | ||
686 | a.AgentIP = RandomName(); | ||
687 | return a; | ||
688 | } | ||
689 | |||
690 | public static string RandomName() | ||
691 | { | ||
692 | StringBuilder name = new StringBuilder(); | ||
693 | int size = random.Next(5,12); | ||
694 | char ch ; | ||
695 | for (int i=0; i<size; i++) | ||
696 | { | ||
697 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
698 | name.Append(ch); | ||
699 | } | ||
700 | return name.ToString(); | ||
701 | } | ||
702 | } | ||
703 | } | ||
diff --git a/OpenSim/Data/Tests/DefaultTestConns.cs b/OpenSim/Data/Tests/DefaultTestConns.cs new file mode 100644 index 0000000..7c47bdd --- /dev/null +++ b/OpenSim/Data/Tests/DefaultTestConns.cs | |||
@@ -0,0 +1,90 @@ | |||
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 System.Linq; | ||
31 | using System.Text; | ||
32 | using System.Reflection; | ||
33 | using System.IO; | ||
34 | using Nini.Config; | ||
35 | |||
36 | namespace OpenSim.Data.Tests | ||
37 | { | ||
38 | /// <summary>This static class looks for TestDataConnections.ini file in the /bin directory to obtain | ||
39 | /// a connection string for testing one of the supported databases. | ||
40 | /// The connections must be in the section [TestConnections] with names matching the connection class | ||
41 | /// name for the specific database, e.g.: | ||
42 | /// | ||
43 | /// [TestConnections] | ||
44 | /// MySqlConnection="..." | ||
45 | /// SqlConnection="..." | ||
46 | /// SqliteConnection="..." | ||
47 | /// | ||
48 | /// Note that the conn string may also be set explicitly in the [TestCase()] attribute of test classes | ||
49 | /// based on BasicDataServiceTest.cs. | ||
50 | /// </summary> | ||
51 | |||
52 | static class DefaultTestConns | ||
53 | { | ||
54 | private static Dictionary<Type, string> conns = new Dictionary<Type, string>(); | ||
55 | |||
56 | public static string Get(Type connType) | ||
57 | { | ||
58 | string sConn; | ||
59 | |||
60 | if (conns.TryGetValue(connType, out sConn)) | ||
61 | return sConn; | ||
62 | |||
63 | Assembly asm = Assembly.GetExecutingAssembly(); | ||
64 | string sType = connType.Name; | ||
65 | |||
66 | // Note: when running from NUnit, the DLL is located in some temp dir, so how do we get | ||
67 | // to the INI file? Ok, so put it into the resources! | ||
68 | // string iniName = Path.Combine(Path.GetDirectoryName(asm.Location), "TestDataConnections.ini"); | ||
69 | |||
70 | string[] allres = asm.GetManifestResourceNames(); | ||
71 | string sResFile = Array.Find(allres, s => s.Contains("TestDataConnections.ini")); | ||
72 | |||
73 | if (String.IsNullOrEmpty(sResFile)) | ||
74 | throw new Exception(String.Format("Please add resource TestDataConnections.ini, with section [TestConnections] and settings like {0}=\"...\"", | ||
75 | sType)); | ||
76 | |||
77 | using (Stream resource = asm.GetManifestResourceStream(sResFile)) | ||
78 | { | ||
79 | IConfigSource source = new IniConfigSource(resource); | ||
80 | var cfg = source.Configs["TestConnections"]; | ||
81 | sConn = cfg.Get(sType, ""); | ||
82 | } | ||
83 | |||
84 | if (!String.IsNullOrEmpty(sConn)) | ||
85 | conns[connType] = sConn; | ||
86 | |||
87 | return sConn; | ||
88 | } | ||
89 | } | ||
90 | } | ||
diff --git a/OpenSim/Data/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/EstateTests.cs index 907bb38..3e47bcf 100644 --- a/OpenSim/Data/Tests/BasicEstateTest.cs +++ b/OpenSim/Data/Tests/EstateTests.cs | |||
@@ -28,20 +28,47 @@ | |||
28 | using System; | 28 | using System; |
29 | using log4net.Config; | 29 | using log4net.Config; |
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | 31 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
34 | using OpenSim.Region.Framework.Interfaces; | 33 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Tests.Common; | ||
35 | using System.Text; | 35 | using System.Text; |
36 | using log4net; | 36 | using log4net; |
37 | using System.Reflection; | 37 | using System.Reflection; |
38 | using System.Data.Common; | ||
39 | |||
40 | // DBMS-specific: | ||
41 | using MySql.Data.MySqlClient; | ||
42 | using OpenSim.Data.MySQL; | ||
43 | |||
44 | using System.Data.SqlClient; | ||
45 | using OpenSim.Data.MSSQL; | ||
46 | |||
47 | using Mono.Data.Sqlite; | ||
48 | using OpenSim.Data.SQLite; | ||
38 | 49 | ||
39 | namespace OpenSim.Data.Tests | 50 | namespace OpenSim.Data.Tests |
40 | { | 51 | { |
41 | public class BasicEstateTest | 52 | [TestFixture(Description = "Estate store tests (SQLite)")] |
53 | public class SQLiteEstateTests : EstateTests<SqliteConnection, SQLiteEstateStore> | ||
54 | { | ||
55 | } | ||
56 | |||
57 | [TestFixture(Description = "Estate store tests (MySQL)")] | ||
58 | public class MySqlEstateTests : EstateTests<MySqlConnection, MySQLEstateStore> | ||
59 | { | ||
60 | } | ||
61 | |||
62 | [TestFixture(Description = "Estate store tests (MS SQL Server)")] | ||
63 | public class MSSQLEstateTests : EstateTests<SqlConnection, MSSQLEstateStore> | ||
64 | { | ||
65 | } | ||
66 | |||
67 | public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore> | ||
68 | where TConn : DbConnection, new() | ||
69 | where TEstateStore : class, IEstateDataStore, new() | ||
42 | { | 70 | { |
43 | public IEstateDataStore db; | 71 | public IEstateDataStore db; |
44 | public IRegionDataStore regionDb; | ||
45 | 72 | ||
46 | public static UUID REGION_ID = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed7"); | 73 | public static UUID REGION_ID = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed7"); |
47 | 74 | ||
@@ -54,9 +81,25 @@ namespace OpenSim.Data.Tests | |||
54 | public static UUID GROUP_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed5"); | 81 | public static UUID GROUP_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed5"); |
55 | public static UUID GROUP_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed6"); | 82 | public static UUID GROUP_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed6"); |
56 | 83 | ||
57 | public void SuperInit() | 84 | protected override void InitService(object service) |
85 | { | ||
86 | ClearDB(); | ||
87 | db = (IEstateDataStore)service; | ||
88 | db.Initialise(m_connStr); | ||
89 | } | ||
90 | |||
91 | private void ClearDB() | ||
58 | { | 92 | { |
59 | OpenSim.Tests.Common.TestLogging.LogToConsole(); | 93 | // if a new table is added, it has to be dropped here |
94 | DropTables( | ||
95 | "estate_managers", | ||
96 | "estate_groups", | ||
97 | "estate_users", | ||
98 | "estateban", | ||
99 | "estate_settings", | ||
100 | "estate_map" | ||
101 | ); | ||
102 | ResetMigrations("EstateStore"); | ||
60 | } | 103 | } |
61 | 104 | ||
62 | #region 0Tests | 105 | #region 0Tests |
@@ -64,6 +107,8 @@ namespace OpenSim.Data.Tests | |||
64 | [Test] | 107 | [Test] |
65 | public void T010_EstateSettingsSimpleStorage_MinimumParameterSet() | 108 | public void T010_EstateSettingsSimpleStorage_MinimumParameterSet() |
66 | { | 109 | { |
110 | TestHelpers.InMethod(); | ||
111 | |||
67 | EstateSettingsSimpleStorage( | 112 | EstateSettingsSimpleStorage( |
68 | REGION_ID, | 113 | REGION_ID, |
69 | DataTestUtil.STRING_MIN, | 114 | DataTestUtil.STRING_MIN, |
@@ -95,6 +140,8 @@ namespace OpenSim.Data.Tests | |||
95 | [Test] | 140 | [Test] |
96 | public void T011_EstateSettingsSimpleStorage_MaximumParameterSet() | 141 | public void T011_EstateSettingsSimpleStorage_MaximumParameterSet() |
97 | { | 142 | { |
143 | TestHelpers.InMethod(); | ||
144 | |||
98 | EstateSettingsSimpleStorage( | 145 | EstateSettingsSimpleStorage( |
99 | REGION_ID, | 146 | REGION_ID, |
100 | DataTestUtil.STRING_MAX(64), | 147 | DataTestUtil.STRING_MAX(64), |
@@ -126,6 +173,8 @@ namespace OpenSim.Data.Tests | |||
126 | [Test] | 173 | [Test] |
127 | public void T012_EstateSettingsSimpleStorage_AccurateParameterSet() | 174 | public void T012_EstateSettingsSimpleStorage_AccurateParameterSet() |
128 | { | 175 | { |
176 | TestHelpers.InMethod(); | ||
177 | |||
129 | EstateSettingsSimpleStorage( | 178 | EstateSettingsSimpleStorage( |
130 | REGION_ID, | 179 | REGION_ID, |
131 | DataTestUtil.STRING_MAX(1), | 180 | DataTestUtil.STRING_MAX(1), |
@@ -157,8 +206,10 @@ namespace OpenSim.Data.Tests | |||
157 | [Test] | 206 | [Test] |
158 | public void T012_EstateSettingsRandomStorage() | 207 | public void T012_EstateSettingsRandomStorage() |
159 | { | 208 | { |
209 | TestHelpers.InMethod(); | ||
210 | |||
160 | // Letting estate store generate rows to database for us | 211 | // Letting estate store generate rows to database for us |
161 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); | 212 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); |
162 | new PropertyScrambler<EstateSettings>() | 213 | new PropertyScrambler<EstateSettings>() |
163 | .DontScramble(x=>x.EstateID) | 214 | .DontScramble(x=>x.EstateID) |
164 | .Scramble(originalSettings); | 215 | .Scramble(originalSettings); |
@@ -167,7 +218,7 @@ namespace OpenSim.Data.Tests | |||
167 | db.StoreEstateSettings(originalSettings); | 218 | db.StoreEstateSettings(originalSettings); |
168 | 219 | ||
169 | // Loading settings to another instance variable. | 220 | // Loading settings to another instance variable. |
170 | EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); | 221 | EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true); |
171 | 222 | ||
172 | // Checking that loaded values are correct. | 223 | // Checking that loaded values are correct. |
173 | Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings)); | 224 | Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings)); |
@@ -176,8 +227,10 @@ namespace OpenSim.Data.Tests | |||
176 | [Test] | 227 | [Test] |
177 | public void T020_EstateSettingsManagerList() | 228 | public void T020_EstateSettingsManagerList() |
178 | { | 229 | { |
230 | TestHelpers.InMethod(); | ||
231 | |||
179 | // Letting estate store generate rows to database for us | 232 | // Letting estate store generate rows to database for us |
180 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); | 233 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); |
181 | 234 | ||
182 | originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 }; | 235 | originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 }; |
183 | 236 | ||
@@ -185,7 +238,7 @@ namespace OpenSim.Data.Tests | |||
185 | db.StoreEstateSettings(originalSettings); | 238 | db.StoreEstateSettings(originalSettings); |
186 | 239 | ||
187 | // Loading settings to another instance variable. | 240 | // Loading settings to another instance variable. |
188 | EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); | 241 | EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true); |
189 | 242 | ||
190 | Assert.AreEqual(2, loadedSettings.EstateManagers.Length); | 243 | Assert.AreEqual(2, loadedSettings.EstateManagers.Length); |
191 | Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]); | 244 | Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]); |
@@ -195,8 +248,10 @@ namespace OpenSim.Data.Tests | |||
195 | [Test] | 248 | [Test] |
196 | public void T021_EstateSettingsUserList() | 249 | public void T021_EstateSettingsUserList() |
197 | { | 250 | { |
251 | TestHelpers.InMethod(); | ||
252 | |||
198 | // Letting estate store generate rows to database for us | 253 | // Letting estate store generate rows to database for us |
199 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); | 254 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); |
200 | 255 | ||
201 | originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 }; | 256 | originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 }; |
202 | 257 | ||
@@ -204,7 +259,7 @@ namespace OpenSim.Data.Tests | |||
204 | db.StoreEstateSettings(originalSettings); | 259 | db.StoreEstateSettings(originalSettings); |
205 | 260 | ||
206 | // Loading settings to another instance variable. | 261 | // Loading settings to another instance variable. |
207 | EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); | 262 | EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true); |
208 | 263 | ||
209 | Assert.AreEqual(2, loadedSettings.EstateAccess.Length); | 264 | Assert.AreEqual(2, loadedSettings.EstateAccess.Length); |
210 | Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]); | 265 | Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]); |
@@ -214,8 +269,10 @@ namespace OpenSim.Data.Tests | |||
214 | [Test] | 269 | [Test] |
215 | public void T022_EstateSettingsGroupList() | 270 | public void T022_EstateSettingsGroupList() |
216 | { | 271 | { |
272 | TestHelpers.InMethod(); | ||
273 | |||
217 | // Letting estate store generate rows to database for us | 274 | // Letting estate store generate rows to database for us |
218 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); | 275 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); |
219 | 276 | ||
220 | originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 }; | 277 | originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 }; |
221 | 278 | ||
@@ -223,7 +280,7 @@ namespace OpenSim.Data.Tests | |||
223 | db.StoreEstateSettings(originalSettings); | 280 | db.StoreEstateSettings(originalSettings); |
224 | 281 | ||
225 | // Loading settings to another instance variable. | 282 | // Loading settings to another instance variable. |
226 | EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); | 283 | EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true); |
227 | 284 | ||
228 | Assert.AreEqual(2, loadedSettings.EstateAccess.Length); | 285 | Assert.AreEqual(2, loadedSettings.EstateAccess.Length); |
229 | Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]); | 286 | Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]); |
@@ -233,8 +290,10 @@ namespace OpenSim.Data.Tests | |||
233 | [Test] | 290 | [Test] |
234 | public void T022_EstateSettingsBanList() | 291 | public void T022_EstateSettingsBanList() |
235 | { | 292 | { |
293 | TestHelpers.InMethod(); | ||
294 | |||
236 | // Letting estate store generate rows to database for us | 295 | // Letting estate store generate rows to database for us |
237 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); | 296 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); |
238 | 297 | ||
239 | EstateBan estateBan1 = new EstateBan(); | 298 | EstateBan estateBan1 = new EstateBan(); |
240 | estateBan1.BannedUserID = DataTestUtil.UUID_MIN; | 299 | estateBan1.BannedUserID = DataTestUtil.UUID_MIN; |
@@ -248,7 +307,7 @@ namespace OpenSim.Data.Tests | |||
248 | db.StoreEstateSettings(originalSettings); | 307 | db.StoreEstateSettings(originalSettings); |
249 | 308 | ||
250 | // Loading settings to another instance variable. | 309 | // Loading settings to another instance variable. |
251 | EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); | 310 | EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true); |
252 | 311 | ||
253 | Assert.AreEqual(2, loadedSettings.EstateBans.Length); | 312 | Assert.AreEqual(2, loadedSettings.EstateBans.Length); |
254 | Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID); | 313 | Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID); |
@@ -290,10 +349,9 @@ namespace OpenSim.Data.Tests | |||
290 | { | 349 | { |
291 | 350 | ||
292 | // Letting estate store generate rows to database for us | 351 | // Letting estate store generate rows to database for us |
293 | EstateSettings originalSettings = db.LoadEstateSettings(regionId); | 352 | EstateSettings originalSettings = db.LoadEstateSettings(regionId, true); |
294 | 353 | ||
295 | SetEstateSettings( | 354 | SetEstateSettings(originalSettings, |
296 | originalSettings, | ||
297 | estateName, | 355 | estateName, |
298 | parentEstateID, | 356 | parentEstateID, |
299 | billableFactor, | 357 | billableFactor, |
@@ -319,39 +377,14 @@ namespace OpenSim.Data.Tests | |||
319 | estateOwner | 377 | estateOwner |
320 | ); | 378 | ); |
321 | 379 | ||
322 | originalSettings.EstateName = estateName; | ||
323 | originalSettings.ParentEstateID = parentEstateID; | ||
324 | originalSettings.BillableFactor = billableFactor; | ||
325 | originalSettings.PricePerMeter = pricePerMeter; | ||
326 | originalSettings.RedirectGridX = redirectGridX; | ||
327 | originalSettings.RedirectGridY = redirectGridY; | ||
328 | originalSettings.UseGlobalTime = useGlobalTime; | ||
329 | originalSettings.FixedSun = fixedSun; | ||
330 | originalSettings.SunPosition = sunPosition; | ||
331 | originalSettings.AllowVoice = allowVoice; | ||
332 | originalSettings.AllowDirectTeleport = allowDirectTeleport; | ||
333 | originalSettings.ResetHomeOnTeleport = resetHomeOnTeleport; | ||
334 | originalSettings.DenyAnonymous = denyAnonymous; | ||
335 | originalSettings.DenyIdentified = denyIdentified; | ||
336 | originalSettings.DenyTransacted = denyTransacted; | ||
337 | originalSettings.DenyMinors = denyMinors; | ||
338 | originalSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner; | ||
339 | originalSettings.BlockDwell = blockDwell; | ||
340 | originalSettings.EstateSkipScripts = estateSkipScripts; | ||
341 | originalSettings.TaxFree = taxFree; | ||
342 | originalSettings.PublicAccess = publicAccess; | ||
343 | originalSettings.AbuseEmail = abuseEmail; | ||
344 | originalSettings.EstateOwner = estateOwner; | ||
345 | |||
346 | // Saving settings. | 380 | // Saving settings. |
347 | db.StoreEstateSettings(originalSettings); | 381 | db.StoreEstateSettings(originalSettings); |
348 | 382 | ||
349 | // Loading settings to another instance variable. | 383 | // Loading settings to another instance variable. |
350 | EstateSettings loadedSettings = db.LoadEstateSettings(regionId); | 384 | EstateSettings loadedSettings = db.LoadEstateSettings(regionId, true); |
351 | 385 | ||
352 | // Checking that loaded values are correct. | 386 | // Checking that loaded values are correct. |
353 | ValidateEstateSettings( | 387 | ValidateEstateSettings(loadedSettings, |
354 | loadedSettings, | ||
355 | estateName, | 388 | estateName, |
356 | parentEstateID, | 389 | parentEstateID, |
357 | billableFactor, | 390 | billableFactor, |
@@ -492,6 +525,5 @@ namespace OpenSim.Data.Tests | |||
492 | } | 525 | } |
493 | 526 | ||
494 | #endregion | 527 | #endregion |
495 | |||
496 | } | 528 | } |
497 | } | 529 | } \ No newline at end of file |
diff --git a/OpenSim/Data/Tests/BasicInventoryTest.cs b/OpenSim/Data/Tests/InventoryTests.cs index 900186b..5b6b61b 100644 --- a/OpenSim/Data/Tests/BasicInventoryTest.cs +++ b/OpenSim/Data/Tests/InventoryTests.cs | |||
@@ -28,72 +28,94 @@ | |||
28 | using System; | 28 | using System; |
29 | using log4net.Config; | 29 | using log4net.Config; |
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | 31 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Tests.Common; | ||
34 | using log4net; | 34 | using log4net; |
35 | using System.Reflection; | 35 | using System.Reflection; |
36 | using System.Data.Common; | ||
37 | |||
38 | // DBMS-specific: | ||
39 | using MySql.Data.MySqlClient; | ||
40 | using OpenSim.Data.MySQL; | ||
41 | |||
42 | using System.Data.SqlClient; | ||
43 | using OpenSim.Data.MSSQL; | ||
44 | |||
45 | using Mono.Data.Sqlite; | ||
46 | using OpenSim.Data.SQLite; | ||
36 | 47 | ||
37 | namespace OpenSim.Data.Tests | 48 | namespace OpenSim.Data.Tests |
38 | { | 49 | { |
39 | public class BasicInventoryTest | 50 | [TestFixture(Description = "Inventory store tests (SQLite)")] |
51 | public class SQLiteInventoryTests : InventoryTests<SqliteConnection, SQLiteInventoryStore> | ||
52 | { | ||
53 | } | ||
54 | |||
55 | [TestFixture(Description = "Inventory store tests (MySQL)")] | ||
56 | public class MySqlInventoryTests : InventoryTests<MySqlConnection, MySQLInventoryData> | ||
57 | { | ||
58 | } | ||
59 | |||
60 | [TestFixture(Description = "Inventory store tests (MS SQL Server)")] | ||
61 | public class MSSQLInventoryTests : InventoryTests<SqlConnection, MSSQLInventoryData> | ||
62 | { | ||
63 | } | ||
64 | |||
65 | public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore> | ||
66 | where TConn : DbConnection, new() | ||
67 | where TInvStore : class, IInventoryDataPlugin, new() | ||
40 | { | 68 | { |
41 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | public IInventoryDataPlugin db; | 69 | public IInventoryDataPlugin db; |
70 | |||
43 | public UUID zero = UUID.Zero; | 71 | public UUID zero = UUID.Zero; |
44 | 72 | ||
45 | public UUID folder1; | 73 | public UUID folder1 = UUID.Random(); |
46 | public UUID folder2; | 74 | public UUID folder2 = UUID.Random(); |
47 | public UUID folder3; | 75 | public UUID folder3 = UUID.Random(); |
48 | public UUID owner1; | 76 | public UUID owner1 = UUID.Random(); |
49 | public UUID owner2; | 77 | public UUID owner2 = UUID.Random(); |
50 | public UUID owner3; | 78 | public UUID owner3 = UUID.Random(); |
51 | 79 | ||
52 | public UUID item1; | 80 | public UUID item1 = UUID.Random(); |
53 | public UUID item2; | 81 | public UUID item2 = UUID.Random(); |
54 | public UUID item3; | 82 | public UUID item3 = UUID.Random(); |
55 | public UUID asset1; | 83 | public UUID asset1 = UUID.Random(); |
56 | public UUID asset2; | 84 | public UUID asset2 = UUID.Random(); |
57 | public UUID asset3; | 85 | public UUID asset3 = UUID.Random(); |
58 | 86 | ||
59 | public string name1; | 87 | public string name1; |
60 | public string name2; | 88 | public string name2 = "First Level folder"; |
61 | public string name3; | 89 | public string name3 = "First Level folder 2"; |
62 | public string niname1; | 90 | public string niname1 = "My Shirt"; |
63 | public string iname1; | 91 | public string iname1 = "Shirt"; |
64 | public string iname2; | 92 | public string iname2 = "Text Board"; |
65 | public string iname3; | 93 | public string iname3 = "No Pants Barrel"; |
66 | 94 | ||
67 | public void SuperInit() | 95 | public InventoryTests(string conn) : base(conn) |
68 | { | 96 | { |
69 | OpenSim.Tests.Common.TestLogging.LogToConsole(); | ||
70 | |||
71 | folder1 = UUID.Random(); | ||
72 | folder2 = UUID.Random(); | ||
73 | folder3 = UUID.Random(); | ||
74 | owner1 = UUID.Random(); | ||
75 | owner2 = UUID.Random(); | ||
76 | owner3 = UUID.Random(); | ||
77 | item1 = UUID.Random(); | ||
78 | item2 = UUID.Random(); | ||
79 | item3 = UUID.Random(); | ||
80 | asset1 = UUID.Random(); | ||
81 | asset2 = UUID.Random(); | ||
82 | asset3 = UUID.Random(); | ||
83 | |||
84 | name1 = "Root Folder for " + owner1.ToString(); | 97 | name1 = "Root Folder for " + owner1.ToString(); |
85 | name2 = "First Level folder"; | 98 | } |
86 | name3 = "First Level folder 2"; | 99 | public InventoryTests() : this("") { } |
87 | niname1 = "My Shirt"; | 100 | |
88 | iname1 = "Shirt"; | 101 | protected override void InitService(object service) |
89 | iname2 = "Text Board"; | 102 | { |
90 | iname3 = "No Pants Barrel"; | 103 | ClearDB(); |
104 | db = (IInventoryDataPlugin)service; | ||
105 | db.Initialise(m_connStr); | ||
106 | } | ||
91 | 107 | ||
108 | private void ClearDB() | ||
109 | { | ||
110 | DropTables("inventoryitems", "inventoryfolders"); | ||
111 | ResetMigrations("InventoryStore"); | ||
92 | } | 112 | } |
93 | 113 | ||
94 | [Test] | 114 | [Test] |
95 | public void T001_LoadEmpty() | 115 | public void T001_LoadEmpty() |
96 | { | 116 | { |
117 | TestHelpers.InMethod(); | ||
118 | |||
97 | Assert.That(db.getInventoryFolder(zero), Is.Null); | 119 | Assert.That(db.getInventoryFolder(zero), Is.Null); |
98 | Assert.That(db.getInventoryFolder(folder1), Is.Null); | 120 | Assert.That(db.getInventoryFolder(folder1), Is.Null); |
99 | Assert.That(db.getInventoryFolder(folder2), Is.Null); | 121 | Assert.That(db.getInventoryFolder(folder2), Is.Null); |
@@ -112,6 +134,8 @@ namespace OpenSim.Data.Tests | |||
112 | [Test] | 134 | [Test] |
113 | public void T010_FolderNonParent() | 135 | public void T010_FolderNonParent() |
114 | { | 136 | { |
137 | TestHelpers.InMethod(); | ||
138 | |||
115 | InventoryFolderBase f1 = NewFolder(folder2, folder1, owner1, name2); | 139 | InventoryFolderBase f1 = NewFolder(folder2, folder1, owner1, name2); |
116 | // the folder will go in | 140 | // the folder will go in |
117 | db.addInventoryFolder(f1); | 141 | db.addInventoryFolder(f1); |
@@ -122,6 +146,8 @@ namespace OpenSim.Data.Tests | |||
122 | [Test] | 146 | [Test] |
123 | public void T011_FolderCreate() | 147 | public void T011_FolderCreate() |
124 | { | 148 | { |
149 | TestHelpers.InMethod(); | ||
150 | |||
125 | InventoryFolderBase f1 = NewFolder(folder1, zero, owner1, name1); | 151 | InventoryFolderBase f1 = NewFolder(folder1, zero, owner1, name1); |
126 | // TODO: this is probably wrong behavior, but is what we have | 152 | // TODO: this is probably wrong behavior, but is what we have |
127 | // db.updateInventoryFolder(f1); | 153 | // db.updateInventoryFolder(f1); |
@@ -134,7 +160,7 @@ namespace OpenSim.Data.Tests | |||
134 | db.addInventoryFolder(f1); | 160 | db.addInventoryFolder(f1); |
135 | InventoryFolderBase f1a = db.getUserRootFolder(owner1); | 161 | InventoryFolderBase f1a = db.getUserRootFolder(owner1); |
136 | Assert.That(folder1, Is.EqualTo(f1a.ID), "Assert.That(folder1, Is.EqualTo(f1a.ID))"); | 162 | Assert.That(folder1, Is.EqualTo(f1a.ID), "Assert.That(folder1, Is.EqualTo(f1a.ID))"); |
137 | Assert.That(name1, Text.Matches(f1a.Name), "Assert.That(name1, Text.Matches(f1a.Name))"); | 163 | Assert.That(name1, Is.StringMatching(f1a.Name), "Assert.That(name1, Text.Matches(f1a.Name))"); |
138 | } | 164 | } |
139 | 165 | ||
140 | // we now have the following tree | 166 | // we now have the following tree |
@@ -145,6 +171,8 @@ namespace OpenSim.Data.Tests | |||
145 | [Test] | 171 | [Test] |
146 | public void T012_FolderList() | 172 | public void T012_FolderList() |
147 | { | 173 | { |
174 | TestHelpers.InMethod(); | ||
175 | |||
148 | InventoryFolderBase f2 = NewFolder(folder3, folder1, owner1, name3); | 176 | InventoryFolderBase f2 = NewFolder(folder3, folder1, owner1, name3); |
149 | db.addInventoryFolder(f2); | 177 | db.addInventoryFolder(f2); |
150 | 178 | ||
@@ -159,8 +187,12 @@ namespace OpenSim.Data.Tests | |||
159 | [Test] | 187 | [Test] |
160 | public void T013_FolderHierarchy() | 188 | public void T013_FolderHierarchy() |
161 | { | 189 | { |
162 | Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))"); | 190 | TestHelpers.InMethod(); |
163 | Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))"); | 191 | |
192 | int n = db.getFolderHierarchy(zero).Count; // (for dbg - easier to see what's returned) | ||
193 | Assert.That(n, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))"); | ||
194 | n = db.getFolderHierarchy(folder1).Count; | ||
195 | Assert.That(n, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))"); | ||
164 | Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))"); | 196 | Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))"); |
165 | Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0))"); | 197 | Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0))"); |
166 | Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0))"); | 198 | Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0))"); |
@@ -170,6 +202,8 @@ namespace OpenSim.Data.Tests | |||
170 | [Test] | 202 | [Test] |
171 | public void T014_MoveFolder() | 203 | public void T014_MoveFolder() |
172 | { | 204 | { |
205 | TestHelpers.InMethod(); | ||
206 | |||
173 | InventoryFolderBase f2 = db.getInventoryFolder(folder2); | 207 | InventoryFolderBase f2 = db.getInventoryFolder(folder2); |
174 | f2.ParentID = folder3; | 208 | f2.ParentID = folder3; |
175 | db.moveInventoryFolder(f2); | 209 | db.moveInventoryFolder(f2); |
@@ -184,6 +218,8 @@ namespace OpenSim.Data.Tests | |||
184 | [Test] | 218 | [Test] |
185 | public void T015_FolderHierarchy() | 219 | public void T015_FolderHierarchy() |
186 | { | 220 | { |
221 | TestHelpers.InMethod(); | ||
222 | |||
187 | Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))"); | 223 | Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))"); |
188 | Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))"); | 224 | Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))"); |
189 | Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))"); | 225 | Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))"); |
@@ -195,6 +231,8 @@ namespace OpenSim.Data.Tests | |||
195 | [Test] | 231 | [Test] |
196 | public void T100_NoItems() | 232 | public void T100_NoItems() |
197 | { | 233 | { |
234 | TestHelpers.InMethod(); | ||
235 | |||
198 | Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))"); | 236 | Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))"); |
199 | Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0))"); | 237 | Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0))"); |
200 | Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0))"); | 238 | Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0))"); |
@@ -207,6 +245,8 @@ namespace OpenSim.Data.Tests | |||
207 | [Test] | 245 | [Test] |
208 | public void T101_CreatItems() | 246 | public void T101_CreatItems() |
209 | { | 247 | { |
248 | TestHelpers.InMethod(); | ||
249 | |||
210 | db.addInventoryItem(NewItem(item1, folder3, owner1, iname1, asset1)); | 250 | db.addInventoryItem(NewItem(item1, folder3, owner1, iname1, asset1)); |
211 | db.addInventoryItem(NewItem(item2, folder3, owner1, iname2, asset2)); | 251 | db.addInventoryItem(NewItem(item2, folder3, owner1, iname2, asset2)); |
212 | db.addInventoryItem(NewItem(item3, folder3, owner1, iname3, asset3)); | 252 | db.addInventoryItem(NewItem(item3, folder3, owner1, iname3, asset3)); |
@@ -216,6 +256,8 @@ namespace OpenSim.Data.Tests | |||
216 | [Test] | 256 | [Test] |
217 | public void T102_CompareItems() | 257 | public void T102_CompareItems() |
218 | { | 258 | { |
259 | TestHelpers.InMethod(); | ||
260 | |||
219 | InventoryItemBase i1 = db.getInventoryItem(item1); | 261 | InventoryItemBase i1 = db.getInventoryItem(item1); |
220 | InventoryItemBase i2 = db.getInventoryItem(item2); | 262 | InventoryItemBase i2 = db.getInventoryItem(item2); |
221 | InventoryItemBase i3 = db.getInventoryItem(item3); | 263 | InventoryItemBase i3 = db.getInventoryItem(item3); |
@@ -233,6 +275,8 @@ namespace OpenSim.Data.Tests | |||
233 | [Test] | 275 | [Test] |
234 | public void T103_UpdateItem() | 276 | public void T103_UpdateItem() |
235 | { | 277 | { |
278 | TestHelpers.InMethod(); | ||
279 | |||
236 | // TODO: probably shouldn't have the ability to have an | 280 | // TODO: probably shouldn't have the ability to have an |
237 | // owner of an item in a folder not owned by the user | 281 | // owner of an item in a folder not owned by the user |
238 | 282 | ||
@@ -251,6 +295,8 @@ namespace OpenSim.Data.Tests | |||
251 | [Test] | 295 | [Test] |
252 | public void T104_RandomUpdateItem() | 296 | public void T104_RandomUpdateItem() |
253 | { | 297 | { |
298 | TestHelpers.InMethod(); | ||
299 | |||
254 | PropertyScrambler<InventoryFolderBase> folderScrambler = | 300 | PropertyScrambler<InventoryFolderBase> folderScrambler = |
255 | new PropertyScrambler<InventoryFolderBase>() | 301 | new PropertyScrambler<InventoryFolderBase>() |
256 | .DontScramble(x => x.Owner) | 302 | .DontScramble(x => x.Owner) |
@@ -290,7 +336,8 @@ namespace OpenSim.Data.Tests | |||
290 | .IgnoreProperty(x => x.InvType) | 336 | .IgnoreProperty(x => x.InvType) |
291 | .IgnoreProperty(x => x.CreatorIdAsUuid) | 337 | .IgnoreProperty(x => x.CreatorIdAsUuid) |
292 | .IgnoreProperty(x => x.Description) | 338 | .IgnoreProperty(x => x.Description) |
293 | .IgnoreProperty(x => x.CreatorId)); | 339 | .IgnoreProperty(x => x.CreatorIdentification) |
340 | .IgnoreProperty(x => x.CreatorData)); | ||
294 | 341 | ||
295 | inventoryScrambler.Scramble(expected); | 342 | inventoryScrambler.Scramble(expected); |
296 | db.updateInventoryItem(expected); | 343 | db.updateInventoryItem(expected); |
@@ -300,12 +347,15 @@ namespace OpenSim.Data.Tests | |||
300 | .IgnoreProperty(x => x.InvType) | 347 | .IgnoreProperty(x => x.InvType) |
301 | .IgnoreProperty(x => x.CreatorIdAsUuid) | 348 | .IgnoreProperty(x => x.CreatorIdAsUuid) |
302 | .IgnoreProperty(x => x.Description) | 349 | .IgnoreProperty(x => x.Description) |
303 | .IgnoreProperty(x => x.CreatorId)); | 350 | .IgnoreProperty(x => x.CreatorIdentification) |
351 | .IgnoreProperty(x => x.CreatorData)); | ||
304 | } | 352 | } |
305 | 353 | ||
306 | [Test] | 354 | [Test] |
307 | public void T999_StillNull() | 355 | public void T999_StillNull() |
308 | { | 356 | { |
357 | TestHelpers.InMethod(); | ||
358 | |||
309 | // After all tests are run, these should still return no results | 359 | // After all tests are run, these should still return no results |
310 | Assert.That(db.getInventoryFolder(zero), Is.Null); | 360 | Assert.That(db.getInventoryFolder(zero), Is.Null); |
311 | Assert.That(db.getInventoryItem(zero), Is.Null); | 361 | Assert.That(db.getInventoryItem(zero), Is.Null); |
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs index 5b1f935..6c79bda 100644 --- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs +++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs | |||
@@ -34,7 +34,6 @@ using System.Linq.Expressions; | |||
34 | using System.Reflection; | 34 | using System.Reflection; |
35 | using NUnit.Framework; | 35 | using NUnit.Framework; |
36 | using NUnit.Framework.Constraints; | 36 | using NUnit.Framework.Constraints; |
37 | using NUnit.Framework.SyntaxHelpers; | ||
38 | using OpenMetaverse; | 37 | using OpenMetaverse; |
39 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
40 | 39 | ||
@@ -297,8 +296,8 @@ namespace OpenSim.Data.Tests | |||
297 | public void AssetShouldMatch() | 296 | public void AssetShouldMatch() |
298 | { | 297 | { |
299 | UUID uuid1 = UUID.Random(); | 298 | UUID uuid1 = UUID.Random(); |
300 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); | 299 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, UUID.Zero.ToString()); |
301 | AssetBase expected = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); | 300 | AssetBase expected = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, UUID.Zero.ToString()); |
302 | 301 | ||
303 | var constraint = Constraints.PropertyCompareConstraint(expected); | 302 | var constraint = Constraints.PropertyCompareConstraint(expected); |
304 | 303 | ||
@@ -309,8 +308,8 @@ namespace OpenSim.Data.Tests | |||
309 | public void AssetShouldNotMatch() | 308 | public void AssetShouldNotMatch() |
310 | { | 309 | { |
311 | UUID uuid1 = UUID.Random(); | 310 | UUID uuid1 = UUID.Random(); |
312 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); | 311 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, UUID.Zero.ToString()); |
313 | AssetBase expected = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture); | 312 | AssetBase expected = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture, UUID.Zero.ToString()); |
314 | 313 | ||
315 | var constraint = Constraints.PropertyCompareConstraint(expected); | 314 | var constraint = Constraints.PropertyCompareConstraint(expected); |
316 | 315 | ||
@@ -321,8 +320,8 @@ namespace OpenSim.Data.Tests | |||
321 | public void AssetShouldNotMatch2() | 320 | public void AssetShouldNotMatch2() |
322 | { | 321 | { |
323 | UUID uuid1 = UUID.Random(); | 322 | UUID uuid1 = UUID.Random(); |
324 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); | 323 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, UUID.Zero.ToString()); |
325 | AssetBase expected = new AssetBase(uuid1, "asset two", (sbyte)AssetType.Texture); | 324 | AssetBase expected = new AssetBase(uuid1, "asset two", (sbyte)AssetType.Texture, UUID.Zero.ToString()); |
326 | 325 | ||
327 | var constraint = Constraints.PropertyCompareConstraint(expected); | 326 | var constraint = Constraints.PropertyCompareConstraint(expected); |
328 | 327 | ||
diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs index c968364..c5d40c2 100644 --- a/OpenSim/Data/Tests/PropertyScrambler.cs +++ b/OpenSim/Data/Tests/PropertyScrambler.cs | |||
@@ -32,13 +32,11 @@ using System.Linq.Expressions; | |||
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text; | 33 | using System.Text; |
34 | using NUnit.Framework; | 34 | using NUnit.Framework; |
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | 35 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
38 | 37 | ||
39 | namespace OpenSim.Data.Tests | 38 | namespace OpenSim.Data.Tests |
40 | { | 39 | { |
41 | |||
42 | //This is generic so that the lambda expressions will work right in IDEs. | 40 | //This is generic so that the lambda expressions will work right in IDEs. |
43 | public class PropertyScrambler<T> | 41 | public class PropertyScrambler<T> |
44 | { | 42 | { |
@@ -165,7 +163,7 @@ namespace OpenSim.Data.Tests | |||
165 | [Test] | 163 | [Test] |
166 | public void TestScramble() | 164 | public void TestScramble() |
167 | { | 165 | { |
168 | AssetBase actual = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture); | 166 | AssetBase actual = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture, UUID.Zero.ToString()); |
169 | new PropertyScrambler<AssetBase>().Scramble(actual); | 167 | new PropertyScrambler<AssetBase>().Scramble(actual); |
170 | } | 168 | } |
171 | 169 | ||
@@ -173,7 +171,7 @@ namespace OpenSim.Data.Tests | |||
173 | public void DontScramble() | 171 | public void DontScramble() |
174 | { | 172 | { |
175 | UUID uuid = UUID.Random(); | 173 | UUID uuid = UUID.Random(); |
176 | AssetBase asset = new AssetBase(uuid, "asset", (sbyte)AssetType.Texture); | 174 | AssetBase asset = new AssetBase(uuid, "asset", (sbyte)AssetType.Texture, UUID.Zero.ToString()); |
177 | new PropertyScrambler<AssetBase>() | 175 | new PropertyScrambler<AssetBase>() |
178 | .DontScramble(x => x.Metadata) | 176 | .DontScramble(x => x.Metadata) |
179 | .DontScramble(x => x.FullID) | 177 | .DontScramble(x => x.FullID) |
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/RegionTests.cs index dfbf522..1b93176 100644 --- a/OpenSim/Data/Tests/BasicRegionTest.cs +++ b/OpenSim/Data/Tests/RegionTests.cs | |||
@@ -31,64 +31,106 @@ using System.Drawing; | |||
31 | using System.Text; | 31 | using System.Text; |
32 | using log4net.Config; | 32 | using log4net.Config; |
33 | using NUnit.Framework; | 33 | using NUnit.Framework; |
34 | using NUnit.Framework.SyntaxHelpers; | ||
35 | using OpenMetaverse; | 34 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
37 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Tests.Common; | ||
39 | using log4net; | 39 | using log4net; |
40 | using System.Reflection; | 40 | using System.Reflection; |
41 | using System.Data.Common; | ||
42 | |||
43 | // DBMS-specific: | ||
44 | using MySql.Data.MySqlClient; | ||
45 | using OpenSim.Data.MySQL; | ||
46 | |||
47 | using System.Data.SqlClient; | ||
48 | using OpenSim.Data.MSSQL; | ||
49 | |||
50 | using Mono.Data.Sqlite; | ||
51 | using OpenSim.Data.SQLite; | ||
41 | 52 | ||
42 | namespace OpenSim.Data.Tests | 53 | namespace OpenSim.Data.Tests |
43 | { | 54 | { |
44 | public class BasicRegionTest | 55 | [TestFixture(Description = "Region store tests (SQLite)")] |
56 | public class SQLiteRegionTests : RegionTests<SqliteConnection, SQLiteSimulationData> | ||
57 | { | ||
58 | } | ||
59 | |||
60 | [TestFixture(Description = "Region store tests (MySQL)")] | ||
61 | public class MySqlRegionTests : RegionTests<MySqlConnection, MySQLSimulationData> | ||
62 | { | ||
63 | } | ||
64 | |||
65 | [TestFixture(Description = "Region store tests (MS SQL Server)")] | ||
66 | public class MSSQLRegionTests : RegionTests<SqlConnection, MSSQLSimulationData> | ||
45 | { | 67 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 68 | } |
47 | public IRegionDataStore db; | 69 | |
70 | public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore> | ||
71 | where TConn : DbConnection, new() | ||
72 | where TRegStore : class, ISimulationDataStore, new() | ||
73 | { | ||
74 | bool m_rebuildDB; | ||
75 | |||
76 | public ISimulationDataStore db; | ||
48 | public UUID zero = UUID.Zero; | 77 | public UUID zero = UUID.Zero; |
49 | public UUID region1; | 78 | public UUID region1 = UUID.Random(); |
50 | public UUID region2; | 79 | public UUID region2 = UUID.Random(); |
51 | public UUID region3; | 80 | public UUID region3 = UUID.Random(); |
52 | public UUID region4; | 81 | public UUID region4 = UUID.Random(); |
53 | public UUID prim1; | 82 | public UUID prim1 = UUID.Random(); |
54 | public UUID prim2; | 83 | public UUID prim2 = UUID.Random(); |
55 | public UUID prim3; | 84 | public UUID prim3 = UUID.Random(); |
56 | public UUID prim4; | 85 | public UUID prim4 = UUID.Random(); |
57 | public UUID prim5; | 86 | public UUID prim5 = UUID.Random(); |
58 | public UUID prim6; | 87 | public UUID prim6 = UUID.Random(); |
59 | public UUID item1; | 88 | public UUID item1 = UUID.Random(); |
60 | public UUID item2; | 89 | public UUID item2 = UUID.Random(); |
61 | public UUID item3; | 90 | public UUID item3 = UUID.Random(); |
62 | 91 | ||
63 | public static Random random; | 92 | public static Random random = new Random(); |
64 | 93 | ||
65 | public string itemname1 = "item1"; | 94 | public string itemname1 = "item1"; |
66 | 95 | ||
67 | public uint localID; | 96 | public uint localID = 1; |
68 | |||
69 | public double height1; | ||
70 | public double height2; | ||
71 | 97 | ||
72 | public void SuperInit() | 98 | public double height1 = 20; |
99 | public double height2 = 100; | ||
100 | |||
101 | public RegionTests(string conn, bool rebuild) | ||
102 | : base(conn) | ||
103 | { | ||
104 | m_rebuildDB = rebuild; | ||
105 | } | ||
106 | |||
107 | public RegionTests() : this("", true) { } | ||
108 | public RegionTests(string conn) : this(conn, true) {} | ||
109 | public RegionTests(bool rebuild): this("", rebuild) {} | ||
110 | |||
111 | |||
112 | protected override void InitService(object service) | ||
113 | { | ||
114 | ClearDB(); | ||
115 | db = (ISimulationDataStore)service; | ||
116 | db.Initialise(m_connStr); | ||
117 | } | ||
118 | |||
119 | private void ClearDB() | ||
73 | { | 120 | { |
74 | OpenSim.Tests.Common.TestLogging.LogToConsole(); | 121 | string[] reg_tables = new string[] { |
75 | 122 | "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings" | |
76 | region1 = UUID.Random(); | 123 | }; |
77 | region3 = UUID.Random(); | 124 | |
78 | region4 = UUID.Random(); | 125 | if (m_rebuildDB) |
79 | prim1 = UUID.Random(); | 126 | { |
80 | prim2 = UUID.Random(); | 127 | DropTables(reg_tables); |
81 | prim3 = UUID.Random(); | 128 | ResetMigrations("RegionStore"); |
82 | prim4 = UUID.Random(); | 129 | } |
83 | prim5 = UUID.Random(); | 130 | else |
84 | prim6 = UUID.Random(); | 131 | { |
85 | item1 = UUID.Random(); | 132 | ClearTables(reg_tables); |
86 | item2 = UUID.Random(); | 133 | } |
87 | item3 = UUID.Random(); | ||
88 | random = new Random(); | ||
89 | localID = 1; | ||
90 | height1 = 20; | ||
91 | height2 = 100; | ||
92 | } | 134 | } |
93 | 135 | ||
94 | // Test Plan | 136 | // Test Plan |
@@ -109,6 +151,8 @@ namespace OpenSim.Data.Tests | |||
109 | [Test] | 151 | [Test] |
110 | public void T001_LoadEmpty() | 152 | public void T001_LoadEmpty() |
111 | { | 153 | { |
154 | TestHelpers.InMethod(); | ||
155 | |||
112 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | 156 | List<SceneObjectGroup> objs = db.LoadObjects(region1); |
113 | List<SceneObjectGroup> objs3 = db.LoadObjects(region3); | 157 | List<SceneObjectGroup> objs3 = db.LoadObjects(region3); |
114 | List<LandData> land = db.LoadLandObjects(region1); | 158 | List<LandData> land = db.LoadLandObjects(region1); |
@@ -125,6 +169,8 @@ namespace OpenSim.Data.Tests | |||
125 | [Test] | 169 | [Test] |
126 | public void T010_StoreSimpleObject() | 170 | public void T010_StoreSimpleObject() |
127 | { | 171 | { |
172 | TestHelpers.InMethod(); | ||
173 | |||
128 | SceneObjectGroup sog = NewSOG("object1", prim1, region1); | 174 | SceneObjectGroup sog = NewSOG("object1", prim1, region1); |
129 | SceneObjectGroup sog2 = NewSOG("object2", prim2, region1); | 175 | SceneObjectGroup sog2 = NewSOG("object2", prim2, region1); |
130 | 176 | ||
@@ -158,6 +204,8 @@ namespace OpenSim.Data.Tests | |||
158 | [Test] | 204 | [Test] |
159 | public void T011_ObjectNames() | 205 | public void T011_ObjectNames() |
160 | { | 206 | { |
207 | TestHelpers.InMethod(); | ||
208 | |||
161 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | 209 | List<SceneObjectGroup> objs = db.LoadObjects(region1); |
162 | foreach (SceneObjectGroup sog in objs) | 210 | foreach (SceneObjectGroup sog in objs) |
163 | { | 211 | { |
@@ -170,6 +218,8 @@ namespace OpenSim.Data.Tests | |||
170 | [Test] | 218 | [Test] |
171 | public void T012_SceneParts() | 219 | public void T012_SceneParts() |
172 | { | 220 | { |
221 | TestHelpers.InMethod(); | ||
222 | |||
173 | UUID tmp0 = UUID.Random(); | 223 | UUID tmp0 = UUID.Random(); |
174 | UUID tmp1 = UUID.Random(); | 224 | UUID tmp1 = UUID.Random(); |
175 | UUID tmp2 = UUID.Random(); | 225 | UUID tmp2 = UUID.Random(); |
@@ -183,15 +233,15 @@ namespace OpenSim.Data.Tests | |||
183 | sog.AddPart(p2); | 233 | sog.AddPart(p2); |
184 | sog.AddPart(p3); | 234 | sog.AddPart(p3); |
185 | 235 | ||
186 | SceneObjectPart[] parts = sog.GetParts(); | 236 | SceneObjectPart[] parts = sog.Parts; |
187 | Assert.That(parts.Length,Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); | 237 | Assert.That(parts.Length,Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); |
188 | 238 | ||
189 | db.StoreObject(sog, newregion); | 239 | db.StoreObject(sog, newregion); |
190 | List<SceneObjectGroup> sogs = db.LoadObjects(newregion); | 240 | List<SceneObjectGroup> sogs = db.LoadObjects(newregion); |
191 | Assert.That(sogs.Count,Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); | 241 | Assert.That(sogs.Count,Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); |
192 | SceneObjectGroup newsog = sogs[0]; | 242 | SceneObjectGroup newsog = sogs[0]; |
193 | 243 | ||
194 | SceneObjectPart[] newparts = newsog.GetParts(); | 244 | SceneObjectPart[] newparts = newsog.Parts; |
195 | Assert.That(newparts.Length,Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); | 245 | Assert.That(newparts.Length,Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); |
196 | 246 | ||
197 | Assert.That(newsog.HasChildPrim(tmp0), "Assert.That(newsog.HasChildPrim(tmp0))"); | 247 | Assert.That(newsog.HasChildPrim(tmp0), "Assert.That(newsog.HasChildPrim(tmp0))"); |
@@ -203,6 +253,8 @@ namespace OpenSim.Data.Tests | |||
203 | [Test] | 253 | [Test] |
204 | public void T013_DatabasePersistency() | 254 | public void T013_DatabasePersistency() |
205 | { | 255 | { |
256 | TestHelpers.InMethod(); | ||
257 | |||
206 | // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data | 258 | // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data |
207 | // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored | 259 | // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored |
208 | // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently. | 260 | // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently. |
@@ -245,16 +297,15 @@ namespace OpenSim.Data.Tests | |||
245 | pbshap.ProfileEnd = ushort.MaxValue; | 297 | pbshap.ProfileEnd = ushort.MaxValue; |
246 | pbshap.ProfileHollow = ushort.MaxValue; | 298 | pbshap.ProfileHollow = ushort.MaxValue; |
247 | Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); | 299 | Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); |
248 | byte updatef = (byte) random.Next(127); | ||
249 | 300 | ||
250 | RegionInfo regionInfo = new RegionInfo(); | 301 | RegionInfo regionInfo = new RegionInfo(); |
251 | regionInfo.RegionID = region3; | 302 | regionInfo.RegionID = region3; |
252 | regionInfo.RegionLocX = 0; | 303 | regionInfo.RegionLocX = 0; |
253 | regionInfo.RegionLocY = 0; | 304 | regionInfo.RegionLocY = 0; |
254 | 305 | ||
255 | // Scene scene = new Scene(regionInfo); | ||
256 | |||
257 | SceneObjectPart sop = new SceneObjectPart(); | 306 | SceneObjectPart sop = new SceneObjectPart(); |
307 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
308 | |||
258 | sop.RegionHandle = regionh; | 309 | sop.RegionHandle = regionh; |
259 | sop.UUID = uuid; | 310 | sop.UUID = uuid; |
260 | sop.LocalId = localid; | 311 | sop.LocalId = localid; |
@@ -264,7 +315,7 @@ namespace OpenSim.Data.Tests | |||
264 | sop.CreatorID = creator; | 315 | sop.CreatorID = creator; |
265 | sop.InventorySerial = iserial; | 316 | sop.InventorySerial = iserial; |
266 | sop.TaskInventory = dic; | 317 | sop.TaskInventory = dic; |
267 | sop.ObjectFlags = objf; | 318 | sop.Flags = (PrimFlags)objf; |
268 | sop.Name = name; | 319 | sop.Name = name; |
269 | sop.Material = material; | 320 | sop.Material = material; |
270 | sop.ScriptAccessPin = pin; | 321 | sop.ScriptAccessPin = pin; |
@@ -284,7 +335,6 @@ namespace OpenSim.Data.Tests | |||
284 | sop.LinkNum = linknum; | 335 | sop.LinkNum = linknum; |
285 | sop.ClickAction = clickaction; | 336 | sop.ClickAction = clickaction; |
286 | sop.Scale = scale; | 337 | sop.Scale = scale; |
287 | sop.UpdateFlag = updatef; | ||
288 | 338 | ||
289 | //Tests if local part accepted the parameters: | 339 | //Tests if local part accepted the parameters: |
290 | Assert.That(regionh,Is.EqualTo(sop.RegionHandle), "Assert.That(regionh,Is.EqualTo(sop.RegionHandle))"); | 340 | Assert.That(regionh,Is.EqualTo(sop.RegionHandle), "Assert.That(regionh,Is.EqualTo(sop.RegionHandle))"); |
@@ -297,7 +347,7 @@ namespace OpenSim.Data.Tests | |||
297 | // Modified in-class | 347 | // Modified in-class |
298 | // Assert.That(iserial,Is.EqualTo(sop.InventorySerial), "Assert.That(iserial,Is.EqualTo(sop.InventorySerial))"); | 348 | // Assert.That(iserial,Is.EqualTo(sop.InventorySerial), "Assert.That(iserial,Is.EqualTo(sop.InventorySerial))"); |
299 | Assert.That(dic,Is.EqualTo(sop.TaskInventory), "Assert.That(dic,Is.EqualTo(sop.TaskInventory))"); | 349 | Assert.That(dic,Is.EqualTo(sop.TaskInventory), "Assert.That(dic,Is.EqualTo(sop.TaskInventory))"); |
300 | Assert.That(objf,Is.EqualTo(sop.ObjectFlags), "Assert.That(objf,Is.EqualTo(sop.ObjectFlags))"); | 350 | Assert.That(objf, Is.EqualTo((uint)sop.Flags), "Assert.That(objf,Is.EqualTo(sop.Flags))"); |
301 | Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))"); | 351 | Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))"); |
302 | Assert.That(material,Is.EqualTo(sop.Material), "Assert.That(material,Is.EqualTo(sop.Material))"); | 352 | Assert.That(material,Is.EqualTo(sop.Material), "Assert.That(material,Is.EqualTo(sop.Material))"); |
303 | Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin))"); | 353 | Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin))"); |
@@ -317,12 +367,9 @@ namespace OpenSim.Data.Tests | |||
317 | Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))"); | 367 | Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))"); |
318 | Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))"); | 368 | Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))"); |
319 | Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))"); | 369 | Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))"); |
320 | Assert.That(updatef,Is.EqualTo(sop.UpdateFlag), "Assert.That(updatef,Is.EqualTo(sop.UpdateFlag))"); | ||
321 | 370 | ||
322 | // This is necessary or object will not be inserted in DB | 371 | // This is necessary or object will not be inserted in DB |
323 | sop.ObjectFlags = 0; | 372 | sop.Flags = PrimFlags.None; |
324 | |||
325 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
326 | 373 | ||
327 | // Inserts group in DB | 374 | // Inserts group in DB |
328 | db.StoreObject(sog,region3); | 375 | db.StoreObject(sog,region3); |
@@ -345,7 +392,7 @@ namespace OpenSim.Data.Tests | |||
345 | Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))"); | 392 | Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))"); |
346 | //Assert.That(iserial,Is.EqualTo(p.InventorySerial), "Assert.That(iserial,Is.EqualTo(p.InventorySerial))"); | 393 | //Assert.That(iserial,Is.EqualTo(p.InventorySerial), "Assert.That(iserial,Is.EqualTo(p.InventorySerial))"); |
347 | Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))"); | 394 | Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))"); |
348 | //Assert.That(objf,Is.EqualTo(p.ObjectFlags), "Assert.That(objf,Is.EqualTo(p.ObjectFlags))"); | 395 | //Assert.That(objf, Is.EqualTo((uint)p.Flags), "Assert.That(objf,Is.EqualTo(p.Flags))"); |
349 | Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); | 396 | Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); |
350 | Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))"); | 397 | Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))"); |
351 | Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))"); | 398 | Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))"); |
@@ -378,6 +425,8 @@ namespace OpenSim.Data.Tests | |||
378 | [Test] | 425 | [Test] |
379 | public void T014_UpdateObject() | 426 | public void T014_UpdateObject() |
380 | { | 427 | { |
428 | TestHelpers.InMethod(); | ||
429 | |||
381 | string text1 = "object1 text"; | 430 | string text1 = "object1 text"; |
382 | SceneObjectGroup sog = FindSOG("object1", region1); | 431 | SceneObjectGroup sog = FindSOG("object1", region1); |
383 | sog.RootPart.Text = text1; | 432 | sog.RootPart.Text = text1; |
@@ -417,7 +466,6 @@ namespace OpenSim.Data.Tests | |||
417 | PrimitiveBaseShape pbshap = new PrimitiveBaseShape(); | 466 | PrimitiveBaseShape pbshap = new PrimitiveBaseShape(); |
418 | pbshap = PrimitiveBaseShape.Default; | 467 | pbshap = PrimitiveBaseShape.Default; |
419 | Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); | 468 | Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); |
420 | byte updatef = (byte) random.Next(127); | ||
421 | 469 | ||
422 | // Updates the region with new values | 470 | // Updates the region with new values |
423 | SceneObjectGroup sog2 = FindSOG("Adam West", region3); | 471 | SceneObjectGroup sog2 = FindSOG("Adam West", region3); |
@@ -447,7 +495,6 @@ namespace OpenSim.Data.Tests | |||
447 | sog2.RootPart.LinkNum = linknum; | 495 | sog2.RootPart.LinkNum = linknum; |
448 | sog2.RootPart.ClickAction = clickaction; | 496 | sog2.RootPart.ClickAction = clickaction; |
449 | sog2.RootPart.Scale = scale; | 497 | sog2.RootPart.Scale = scale; |
450 | sog2.RootPart.UpdateFlag = updatef; | ||
451 | 498 | ||
452 | db.StoreObject(sog2, region3); | 499 | db.StoreObject(sog2, region3); |
453 | List<SceneObjectGroup> sogs = db.LoadObjects(region3); | 500 | List<SceneObjectGroup> sogs = db.LoadObjects(region3); |
@@ -479,15 +526,20 @@ namespace OpenSim.Data.Tests | |||
479 | Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); | 526 | Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); |
480 | Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); | 527 | Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); |
481 | } | 528 | } |
482 | 529 | ||
530 | /// <summary> | ||
531 | /// Test storage and retrieval of a scene object with a large number of parts. | ||
532 | /// </summary> | ||
483 | [Test] | 533 | [Test] |
484 | public void T015_LargeSceneObjects() | 534 | public void T015_LargeSceneObjects() |
485 | { | 535 | { |
536 | TestHelpers.InMethod(); | ||
537 | |||
486 | UUID id = UUID.Random(); | 538 | UUID id = UUID.Random(); |
487 | Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>(); | 539 | Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>(); |
488 | SceneObjectGroup sog = NewSOG("Test SOG", id, region4); | 540 | SceneObjectGroup sog = NewSOG("Test SOG", id, region4); |
489 | mydic.Add(sog.RootPart.UUID,sog.RootPart); | 541 | mydic.Add(sog.RootPart.UUID,sog.RootPart); |
490 | for (int i=0;i<30;i++) | 542 | for (int i = 0; i < 30; i++) |
491 | { | 543 | { |
492 | UUID tmp = UUID.Random(); | 544 | UUID tmp = UUID.Random(); |
493 | SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp); | 545 | SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp); |
@@ -506,13 +558,14 @@ namespace OpenSim.Data.Tests | |||
506 | sop.Acceleration = accel; | 558 | sop.Acceleration = accel; |
507 | 559 | ||
508 | mydic.Add(tmp,sop); | 560 | mydic.Add(tmp,sop); |
509 | sog.AddPart(sop); | 561 | sog.AddPart(sop); |
510 | db.StoreObject(sog, region4); | ||
511 | } | 562 | } |
512 | 563 | ||
564 | db.StoreObject(sog, region4); | ||
565 | |||
513 | SceneObjectGroup retsog = FindSOG("Test SOG", region4); | 566 | SceneObjectGroup retsog = FindSOG("Test SOG", region4); |
514 | SceneObjectPart[] parts = retsog.GetParts(); | 567 | SceneObjectPart[] parts = retsog.Parts; |
515 | for (int i=0;i<30;i++) | 568 | for (int i = 0; i < 30; i++) |
516 | { | 569 | { |
517 | SceneObjectPart cursop = mydic[parts[i].UUID]; | 570 | SceneObjectPart cursop = mydic[parts[i].UUID]; |
518 | Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition), "Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))"); | 571 | Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition), "Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))"); |
@@ -527,6 +580,8 @@ namespace OpenSim.Data.Tests | |||
527 | //[Test] | 580 | //[Test] |
528 | public void T016_RandomSogWithSceneParts() | 581 | public void T016_RandomSogWithSceneParts() |
529 | { | 582 | { |
583 | TestHelpers.InMethod(); | ||
584 | |||
530 | PropertyScrambler<SceneObjectPart> scrambler = | 585 | PropertyScrambler<SceneObjectPart> scrambler = |
531 | new PropertyScrambler<SceneObjectPart>() | 586 | new PropertyScrambler<SceneObjectPart>() |
532 | .DontScramble(x => x.UUID); | 587 | .DontScramble(x => x.UUID); |
@@ -558,7 +613,7 @@ namespace OpenSim.Data.Tests | |||
558 | sog.AddPart(p2); | 613 | sog.AddPart(p2); |
559 | sog.AddPart(p3); | 614 | sog.AddPart(p3); |
560 | 615 | ||
561 | SceneObjectPart[] parts = sog.GetParts(); | 616 | SceneObjectPart[] parts = sog.Parts; |
562 | Assert.That(parts.Length, Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); | 617 | Assert.That(parts.Length, Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); |
563 | 618 | ||
564 | db.StoreObject(sog, newregion); | 619 | db.StoreObject(sog, newregion); |
@@ -566,7 +621,7 @@ namespace OpenSim.Data.Tests | |||
566 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); | 621 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); |
567 | SceneObjectGroup newsog = sogs[0]; | 622 | SceneObjectGroup newsog = sogs[0]; |
568 | 623 | ||
569 | SceneObjectPart[] newparts = newsog.GetParts(); | 624 | SceneObjectPart[] newparts = newsog.Parts; |
570 | Assert.That(newparts.Length, Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); | 625 | Assert.That(newparts.Length, Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); |
571 | 626 | ||
572 | Assert.That(newsog, Constraints.PropertyCompareConstraint(sog) | 627 | Assert.That(newsog, Constraints.PropertyCompareConstraint(sog) |
@@ -576,76 +631,97 @@ namespace OpenSim.Data.Tests | |||
576 | .IgnoreProperty(x=>x.RegionHandle) | 631 | .IgnoreProperty(x=>x.RegionHandle) |
577 | .IgnoreProperty(x=>x.RegionUUID) | 632 | .IgnoreProperty(x=>x.RegionUUID) |
578 | .IgnoreProperty(x=>x.Scene) | 633 | .IgnoreProperty(x=>x.Scene) |
579 | .IgnoreProperty(x=>x.Children) | 634 | .IgnoreProperty(x=>x.Parts) |
580 | .IgnoreProperty(x=>x.PassCollision) | 635 | .IgnoreProperty(x=>x.PassCollision) |
581 | .IgnoreProperty(x=>x.RootPart)); | 636 | .IgnoreProperty(x=>x.RootPart)); |
582 | } | 637 | } |
638 | |||
639 | |||
640 | private SceneObjectGroup GetMySOG(string name) | ||
641 | { | ||
642 | SceneObjectGroup sog = FindSOG(name, region1); | ||
643 | if (sog == null) | ||
644 | { | ||
645 | sog = NewSOG(name, prim1, region1); | ||
646 | db.StoreObject(sog, region1); | ||
647 | } | ||
648 | return sog; | ||
649 | } | ||
650 | |||
651 | // NOTE: it is a bad practice to rely on some of the previous tests having been run before. | ||
652 | // If the tests are run manually, one at a time, each starts with full class init (DB cleared). | ||
653 | // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order. | ||
654 | // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*! | ||
583 | 655 | ||
584 | [Test] | 656 | [Test] |
585 | public void T020_PrimInventoryEmpty() | 657 | public void T020_PrimInventoryEmpty() |
586 | { | 658 | { |
587 | SceneObjectGroup sog = FindSOG("object1", region1); | 659 | TestHelpers.InMethod(); |
660 | |||
661 | SceneObjectGroup sog = GetMySOG("object1"); | ||
588 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | 662 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); |
589 | Assert.That(t, Is.Null); | 663 | Assert.That(t, Is.Null); |
590 | } | 664 | } |
591 | 665 | ||
592 | [Test] | 666 | // TODO: Is there any point to call StorePrimInventory on a list, rather than on the prim itself? |
593 | public void T021_PrimInventoryStore() | ||
594 | { | ||
595 | SceneObjectGroup sog = FindSOG("object1", region1); | ||
596 | InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); | ||
597 | |||
598 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); | ||
599 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | ||
600 | Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); | ||
601 | |||
602 | // TODO: seriously??? this is the way we need to loop to get this? | ||
603 | 667 | ||
668 | private void StoreInventory(SceneObjectGroup sog) | ||
669 | { | ||
604 | List<TaskInventoryItem> list = new List<TaskInventoryItem>(); | 670 | List<TaskInventoryItem> list = new List<TaskInventoryItem>(); |
671 | // TODO: seriously??? this is the way we need to loop to get this? | ||
605 | foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList()) | 672 | foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList()) |
606 | { | 673 | { |
607 | list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid)); | 674 | list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid)); |
608 | } | 675 | } |
609 | 676 | ||
610 | db.StorePrimInventory(prim1, list); | 677 | db.StorePrimInventory(sog.RootPart.UUID, list); |
611 | } | 678 | } |
612 | 679 | ||
613 | [Test] | 680 | [Test] |
614 | public void T022_PrimInventoryRetrieve() | 681 | public void T021_PrimInventoryBasic() |
615 | { | 682 | { |
616 | SceneObjectGroup sog = FindSOG("object1", region1); | 683 | TestHelpers.InMethod(); |
617 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | 684 | |
685 | SceneObjectGroup sog = GetMySOG("object1"); | ||
686 | InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); | ||
618 | 687 | ||
619 | Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); | 688 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); |
620 | } | ||
621 | |||
622 | [Test] | ||
623 | public void T023_PrimInventoryUpdate() | ||
624 | { | ||
625 | SceneObjectGroup sog = FindSOG("object1", region1); | ||
626 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | 689 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); |
690 | Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); | ||
627 | 691 | ||
628 | t.Name = "My New Name"; | 692 | StoreInventory(sog); |
629 | sog.UpdateInventoryItem(t); | ||
630 | 693 | ||
631 | Assert.That(t.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))"); | 694 | SceneObjectGroup sog1 = FindSOG("object1", region1); |
695 | Assert.That(sog1, Is.Not.Null); | ||
632 | 696 | ||
633 | } | 697 | TaskInventoryItem t1 = sog1.GetInventoryItem(sog1.RootPart.LocalId, item1); |
698 | Assert.That(t1, Is.Not.Null); | ||
699 | Assert.That(t1.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); | ||
634 | 700 | ||
635 | [Test] | 701 | // Updating inventory |
636 | public void T024_PrimInventoryRemove() | 702 | t1.Name = "My New Name"; |
637 | { | 703 | sog1.UpdateInventoryItem(t1); |
704 | |||
705 | StoreInventory(sog1); | ||
706 | |||
707 | SceneObjectGroup sog2 = FindSOG("object1", region1); | ||
708 | TaskInventoryItem t2 = sog2.GetInventoryItem(sog2.RootPart.LocalId, item1); | ||
709 | Assert.That(t2.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))"); | ||
710 | |||
711 | // Removing inventory | ||
638 | List<TaskInventoryItem> list = new List<TaskInventoryItem>(); | 712 | List<TaskInventoryItem> list = new List<TaskInventoryItem>(); |
639 | db.StorePrimInventory(prim1, list); | 713 | db.StorePrimInventory(prim1, list); |
640 | 714 | ||
641 | SceneObjectGroup sog = FindSOG("object1", region1); | 715 | sog = FindSOG("object1", region1); |
642 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | 716 | t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); |
643 | Assert.That(t, Is.Null); | 717 | Assert.That(t, Is.Null); |
644 | } | 718 | } |
645 | 719 | ||
646 | [Test] | 720 | [Test] |
647 | public void T025_PrimInventoryPersistency() | 721 | public void T025_PrimInventoryPersistency() |
648 | { | 722 | { |
723 | TestHelpers.InMethod(); | ||
724 | |||
649 | InventoryItemBase i = new InventoryItemBase(); | 725 | InventoryItemBase i = new InventoryItemBase(); |
650 | UUID id = UUID.Random(); | 726 | UUID id = UUID.Random(); |
651 | i.ID = id; | 727 | i.ID = id; |
@@ -685,7 +761,7 @@ namespace OpenSim.Data.Tests | |||
685 | int creationd = random.Next(); | 761 | int creationd = random.Next(); |
686 | i.CreationDate = creationd; | 762 | i.CreationDate = creationd; |
687 | 763 | ||
688 | SceneObjectGroup sog = FindSOG("object1", region1); | 764 | SceneObjectGroup sog = GetMySOG("object1"); |
689 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); | 765 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); |
690 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id); | 766 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id); |
691 | 767 | ||
@@ -708,7 +784,7 @@ namespace OpenSim.Data.Tests | |||
708 | // Ownership changes when you drop an object into an object | 784 | // Ownership changes when you drop an object into an object |
709 | // owned by someone else | 785 | // owned by someone else |
710 | Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID), "Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID))"); | 786 | Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID), "Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID))"); |
711 | Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8), "Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8))"); | 787 | // Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 16), "Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8))"); |
712 | Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))"); | 788 | Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))"); |
713 | Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))"); | 789 | Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))"); |
714 | } | 790 | } |
@@ -717,6 +793,8 @@ namespace OpenSim.Data.Tests | |||
717 | [ExpectedException(typeof(ArgumentException))] | 793 | [ExpectedException(typeof(ArgumentException))] |
718 | public void T026_PrimInventoryMany() | 794 | public void T026_PrimInventoryMany() |
719 | { | 795 | { |
796 | TestHelpers.InMethod(); | ||
797 | |||
720 | UUID i1,i2,i3,i4; | 798 | UUID i1,i2,i3,i4; |
721 | i1 = UUID.Random(); | 799 | i1 = UUID.Random(); |
722 | i2 = UUID.Random(); | 800 | i2 = UUID.Random(); |
@@ -747,15 +825,18 @@ namespace OpenSim.Data.Tests | |||
747 | [Test] | 825 | [Test] |
748 | public void T052_RemoveObject() | 826 | public void T052_RemoveObject() |
749 | { | 827 | { |
828 | TestHelpers.InMethod(); | ||
829 | |||
750 | db.RemoveObject(prim1, region1); | 830 | db.RemoveObject(prim1, region1); |
751 | SceneObjectGroup sog = FindSOG("object1", region1); | 831 | SceneObjectGroup sog = FindSOG("object1", region1); |
752 | Assert.That(sog, Is.Null); | 832 | Assert.That(sog, Is.Null); |
753 | } | 833 | } |
754 | 834 | ||
755 | |||
756 | [Test] | 835 | [Test] |
757 | public void T100_DefaultRegionInfo() | 836 | public void T100_DefaultRegionInfo() |
758 | { | 837 | { |
838 | TestHelpers.InMethod(); | ||
839 | |||
759 | RegionSettings r1 = db.LoadRegionSettings(region1); | 840 | RegionSettings r1 = db.LoadRegionSettings(region1); |
760 | Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))"); | 841 | Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))"); |
761 | 842 | ||
@@ -766,6 +847,8 @@ namespace OpenSim.Data.Tests | |||
766 | [Test] | 847 | [Test] |
767 | public void T101_UpdateRegionInfo() | 848 | public void T101_UpdateRegionInfo() |
768 | { | 849 | { |
850 | TestHelpers.InMethod(); | ||
851 | |||
769 | int agentlimit = random.Next(); | 852 | int agentlimit = random.Next(); |
770 | double objectbonus = random.Next(); | 853 | double objectbonus = random.Next(); |
771 | int maturity = random.Next(); | 854 | int maturity = random.Next(); |
@@ -864,13 +947,14 @@ namespace OpenSim.Data.Tests | |||
864 | //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))"); | 947 | //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))"); |
865 | Assert.That(r1a.FixedSun,Is.True); | 948 | Assert.That(r1a.FixedSun,Is.True); |
866 | Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))"); | 949 | Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))"); |
867 | Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))"); | 950 | Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))"); |
868 | |||
869 | } | 951 | } |
870 | 952 | ||
871 | [Test] | 953 | [Test] |
872 | public void T300_NoTerrain() | 954 | public void T300_NoTerrain() |
873 | { | 955 | { |
956 | TestHelpers.InMethod(); | ||
957 | |||
874 | Assert.That(db.LoadTerrain(zero), Is.Null); | 958 | Assert.That(db.LoadTerrain(zero), Is.Null); |
875 | Assert.That(db.LoadTerrain(region1), Is.Null); | 959 | Assert.That(db.LoadTerrain(region1), Is.Null); |
876 | Assert.That(db.LoadTerrain(region2), Is.Null); | 960 | Assert.That(db.LoadTerrain(region2), Is.Null); |
@@ -880,6 +964,8 @@ namespace OpenSim.Data.Tests | |||
880 | [Test] | 964 | [Test] |
881 | public void T301_CreateTerrain() | 965 | public void T301_CreateTerrain() |
882 | { | 966 | { |
967 | TestHelpers.InMethod(); | ||
968 | |||
883 | double[,] t1 = GenTerrain(height1); | 969 | double[,] t1 = GenTerrain(height1); |
884 | db.StoreTerrain(t1, region1); | 970 | db.StoreTerrain(t1, region1); |
885 | 971 | ||
@@ -892,6 +978,8 @@ namespace OpenSim.Data.Tests | |||
892 | [Test] | 978 | [Test] |
893 | public void T302_FetchTerrain() | 979 | public void T302_FetchTerrain() |
894 | { | 980 | { |
981 | TestHelpers.InMethod(); | ||
982 | |||
895 | double[,] baseterrain1 = GenTerrain(height1); | 983 | double[,] baseterrain1 = GenTerrain(height1); |
896 | double[,] baseterrain2 = GenTerrain(height2); | 984 | double[,] baseterrain2 = GenTerrain(height2); |
897 | double[,] t1 = db.LoadTerrain(region1); | 985 | double[,] t1 = db.LoadTerrain(region1); |
@@ -902,6 +990,8 @@ namespace OpenSim.Data.Tests | |||
902 | [Test] | 990 | [Test] |
903 | public void T303_UpdateTerrain() | 991 | public void T303_UpdateTerrain() |
904 | { | 992 | { |
993 | TestHelpers.InMethod(); | ||
994 | |||
905 | double[,] baseterrain1 = GenTerrain(height1); | 995 | double[,] baseterrain1 = GenTerrain(height1); |
906 | double[,] baseterrain2 = GenTerrain(height2); | 996 | double[,] baseterrain2 = GenTerrain(height2); |
907 | db.StoreTerrain(baseterrain2, region1); | 997 | db.StoreTerrain(baseterrain2, region1); |
@@ -914,6 +1004,8 @@ namespace OpenSim.Data.Tests | |||
914 | [Test] | 1004 | [Test] |
915 | public void T400_EmptyLand() | 1005 | public void T400_EmptyLand() |
916 | { | 1006 | { |
1007 | TestHelpers.InMethod(); | ||
1008 | |||
917 | Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))"); | 1009 | Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))"); |
918 | Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))"); | 1010 | Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))"); |
919 | Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))"); | 1011 | Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))"); |
@@ -949,25 +1041,12 @@ namespace OpenSim.Data.Tests | |||
949 | return true; | 1041 | return true; |
950 | } | 1042 | } |
951 | 1043 | ||
952 | |||
953 | private SceneObjectGroup FindSOG(string name, UUID r) | 1044 | private SceneObjectGroup FindSOG(string name, UUID r) |
954 | { | 1045 | { |
955 | List<SceneObjectGroup> objs = db.LoadObjects(r); | 1046 | List<SceneObjectGroup> objs = db.LoadObjects(r); |
956 | foreach (SceneObjectGroup sog in objs) | 1047 | foreach (SceneObjectGroup sog in objs) |
957 | { | 1048 | if (sog.Name == name) |
958 | SceneObjectPart p = sog.RootPart; | ||
959 | if (p.Name == name) { | ||
960 | RegionInfo regionInfo = new RegionInfo(); | ||
961 | regionInfo.RegionID = r; | ||
962 | regionInfo.RegionLocX = 0; | ||
963 | regionInfo.RegionLocY = 0; | ||
964 | |||
965 | Scene scene = new Scene(regionInfo); | ||
966 | sog.SetScene(scene); | ||
967 | |||
968 | return sog; | 1049 | return sog; |
969 | } | ||
970 | } | ||
971 | 1050 | ||
972 | return null; | 1051 | return null; |
973 | } | 1052 | } |
diff --git a/OpenSim/Data/Tests/Resources/TestDataConnections.ini b/OpenSim/Data/Tests/Resources/TestDataConnections.ini new file mode 100644 index 0000000..7b55467 --- /dev/null +++ b/OpenSim/Data/Tests/Resources/TestDataConnections.ini | |||
@@ -0,0 +1,24 @@ | |||
1 | ; The default connections to the test databases. Used by all data tests based on BasicDataServiceTest.cs. | ||
2 | ; This is read by code in DefaultTestConns.cs. | ||
3 | |||
4 | ; NOTE that this INI file is currently loaded as a embedded RESOURCE, which is weird and has a | ||
5 | ; disadvantage of having to rebuild the Tests whenever the conn strings are changed. | ||
6 | ; The only reason is that I couldn't figure out a reliable way to put this INI into the correct | ||
7 | ; dir at runtime. If somebody can do it, that would be cool. | ||
8 | |||
9 | ; I'm using a local MSDE server for testing. Obviously, you'll have to modify | ||
10 | ; the conn string to whatever MS SQL server is available to you. | ||
11 | |||
12 | ; If any of the conn strings is commented out, emty or not valid on your system, | ||
13 | ; the relevant tests will be ignored, rather than fail. | ||
14 | |||
15 | ; As to SQLite, if the conn string here is empty, it will work anyway using a temporary | ||
16 | ; file for the DB. If you want the resulting DB to persist (e.g. for performance testing, | ||
17 | ; when filling up the tables can take a long time), explicitly specify a conn string like this: | ||
18 | |||
19 | ; SqliteConnection="URI=file:<path_to_your_file>,version=3" | ||
20 | |||
21 | [TestConnections] | ||
22 | MySqlConnection="Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;" | ||
23 | SqlConnection="Server=.\SQL2008;Database=opensim-nunit;Trusted_Connection=True;" | ||
24 | SqliteConnection="URI=file:opensim-nunit.db,version=3" \ No newline at end of file | ||