diff options
author | Sean Dague | 2008-09-12 18:13:43 +0000 |
---|---|---|
committer | Sean Dague | 2008-09-12 18:13:43 +0000 |
commit | 9349cf314963a2b74727b86e37b41642c7212d6d (patch) | |
tree | e52240f71b1bce3531649ce1629e1b62219f6827 | |
parent | change order in prebuild.xml so this works in nant on a clean (diff) | |
download | opensim-SC-9349cf314963a2b74727b86e37b41642c7212d6d.zip opensim-SC-9349cf314963a2b74727b86e37b41642c7212d6d.tar.gz opensim-SC-9349cf314963a2b74727b86e37b41642c7212d6d.tar.bz2 opensim-SC-9349cf314963a2b74727b86e37b41642c7212d6d.tar.xz |
move the actual [Test] methods for databases to OpenSim.Data.Tests
classes. This did mean loosing 1 unit test that was actually testing
an sqlite function directly instead of the interface.
-rw-r--r-- | OpenSim/Data/SQLite/Tests/SQLiteAssetTest.cs | 63 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs | 95 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/Tests/SQLiteUserTest.cs | 18 | ||||
-rw-r--r-- | OpenSim/Data/Tests/BasicAssetTest.cs | 104 | ||||
-rw-r--r-- | OpenSim/Data/Tests/BasicInventoryTest.cs (renamed from OpenSim/Data/Tests/BasicInventoryTests.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Data/Tests/BasicRegionTest.cs | 132 | ||||
-rw-r--r-- | OpenSim/Data/Tests/BasicUserTest.cs | 63 |
7 files changed, 308 insertions, 167 deletions
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteAssetTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteAssetTest.cs index b88e29a..b399543 100644 --- a/OpenSim/Data/SQLite/Tests/SQLiteAssetTest.cs +++ b/OpenSim/Data/SQLite/Tests/SQLiteAssetTest.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using NUnit.Framework.SyntaxHelpers; | 31 | using NUnit.Framework.SyntaxHelpers; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Data.Tests; | ||
33 | using OpenSim.Data.SQLite; | 34 | using OpenSim.Data.SQLite; |
34 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
@@ -37,26 +38,19 @@ using OpenMetaverse; | |||
37 | namespace OpenSim.Data.SQLite.Tests | 38 | namespace OpenSim.Data.SQLite.Tests |
38 | { | 39 | { |
39 | [TestFixture] | 40 | [TestFixture] |
40 | public class SQLiteAssetTest | 41 | public class SQLiteAssetTest : BasicAssetTest |
41 | { | 42 | { |
42 | public string file = "assettest.db"; | 43 | public string file = "assettest.db"; |
43 | public string connect; | 44 | public string connect; |
44 | public SQLiteAssetData db; | ||
45 | public UUID uuid1; | ||
46 | public UUID uuid2; | ||
47 | public UUID uuid3; | ||
48 | |||
49 | 45 | ||
50 | [TestFixtureSetUp] | 46 | [TestFixtureSetUp] |
51 | public void Init() | 47 | public void Init() |
52 | { | 48 | { |
49 | SuperInit(); | ||
53 | System.Console.WriteLine("SQLiteAssetTest"); | 50 | System.Console.WriteLine("SQLiteAssetTest"); |
54 | connect = "URI=file:" + file + ",version=3"; | 51 | connect = "URI=file:" + file + ",version=3"; |
55 | db = new SQLiteAssetData(); | 52 | db = new SQLiteAssetData(); |
56 | db.Initialise(connect); | 53 | db.Initialise(connect); |
57 | uuid1 = UUID.Random(); | ||
58 | uuid2 = UUID.Random(); | ||
59 | uuid3 = UUID.Random(); | ||
60 | } | 54 | } |
61 | 55 | ||
62 | [TestFixtureTearDown] | 56 | [TestFixtureTearDown] |
@@ -64,56 +58,5 @@ namespace OpenSim.Data.SQLite.Tests | |||
64 | { | 58 | { |
65 | System.IO.File.Delete(file); | 59 | System.IO.File.Delete(file); |
66 | } | 60 | } |
67 | |||
68 | [Test] | ||
69 | public void T001_LoadEmpty() | ||
70 | { | ||
71 | Assert.That(db.ExistsAsset(uuid1), Is.False); | ||
72 | Assert.That(db.ExistsAsset(uuid2), Is.False); | ||
73 | Assert.That(db.ExistsAsset(uuid3), Is.False); | ||
74 | } | ||
75 | |||
76 | [Test] | ||
77 | public void T010_StoreSimpleAsset() | ||
78 | { | ||
79 | AssetBase a1 = new AssetBase(uuid1, "asset one"); | ||
80 | AssetBase a2 = new AssetBase(uuid2, "asset two"); | ||
81 | AssetBase a3 = new AssetBase(uuid3, "asset three"); | ||
82 | db.CreateAsset(a1); | ||
83 | db.CreateAsset(a2); | ||
84 | db.CreateAsset(a3); | ||
85 | |||
86 | AssetBase a1a = db.FetchAsset(uuid1); | ||
87 | Assert.That(a1.ID.ToString(), Text.Matches(a1a.ID.ToString())); | ||
88 | Assert.That(a1.Name, Text.Matches(a1a.Name)); | ||
89 | |||
90 | AssetBase a2a = db.FetchAsset(uuid2); | ||
91 | Assert.That(a2.ID.ToString(), Text.Matches(a2a.ID.ToString())); | ||
92 | Assert.That(a2.Name, Text.Matches(a2a.Name)); | ||
93 | |||
94 | AssetBase a3a = db.FetchAsset(uuid3); | ||
95 | Assert.That(a3.ID.ToString(), Text.Matches(a3a.ID.ToString())); | ||
96 | Assert.That(a3.Name, Text.Matches(a3a.Name)); | ||
97 | } | ||
98 | |||
99 | [Test] | ||
100 | public void T011_ExistsSimpleAsset() | ||
101 | { | ||
102 | Assert.That(db.ExistsAsset(uuid1), Is.True); | ||
103 | Assert.That(db.ExistsAsset(uuid2), Is.True); | ||
104 | Assert.That(db.ExistsAsset(uuid3), Is.True); | ||
105 | } | ||
106 | |||
107 | // this has questionable use, but it is in the interface at the moment. | ||
108 | [Test] | ||
109 | public void T012_DeleteAsset() | ||
110 | { | ||
111 | db.DeleteAsset(uuid1); | ||
112 | db.DeleteAsset(uuid2); | ||
113 | db.DeleteAsset(uuid3); | ||
114 | Assert.That(db.ExistsAsset(uuid1), Is.False); | ||
115 | Assert.That(db.ExistsAsset(uuid2), Is.False); | ||
116 | Assert.That(db.ExistsAsset(uuid3), Is.False); | ||
117 | } | ||
118 | } | 61 | } |
119 | } \ No newline at end of file | 62 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs index 2e93fd6..94b5bf1 100644 --- a/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs +++ b/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using NUnit.Framework.SyntaxHelpers; | 31 | using NUnit.Framework.SyntaxHelpers; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Data.Tests; | ||
33 | using OpenSim.Data.SQLite; | 34 | using OpenSim.Data.SQLite; |
34 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
@@ -37,16 +38,15 @@ using OpenMetaverse; | |||
37 | namespace OpenSim.Data.SQLite.Tests | 38 | namespace OpenSim.Data.SQLite.Tests |
38 | { | 39 | { |
39 | [TestFixture] | 40 | [TestFixture] |
40 | public class SQLiteRegionTest | 41 | public class SQLiteRegionTest : BasicRegionTest |
41 | { | 42 | { |
42 | public string file = "regiontest.db"; | 43 | public string file = "regiontest.db"; |
43 | public string connect; | 44 | public string connect; |
44 | public SQLiteRegionData db; | ||
45 | public UUID region = UUID.Zero; | ||
46 | 45 | ||
47 | [TestFixtureSetUp] | 46 | [TestFixtureSetUp] |
48 | public void Init() | 47 | public void Init() |
49 | { | 48 | { |
49 | SuperInit(); | ||
50 | connect = "URI=file:" + file + ",version=3"; | 50 | connect = "URI=file:" + file + ",version=3"; |
51 | db = new SQLiteRegionData(); | 51 | db = new SQLiteRegionData(); |
52 | db.Initialise(connect); | 52 | db.Initialise(connect); |
@@ -57,94 +57,5 @@ namespace OpenSim.Data.SQLite.Tests | |||
57 | { | 57 | { |
58 | System.IO.File.Delete(file); | 58 | System.IO.File.Delete(file); |
59 | } | 59 | } |
60 | |||
61 | [Test] | ||
62 | public void T001_LoadEmpty() | ||
63 | { | ||
64 | List<SceneObjectGroup> objs = db.LoadObjects(region); | ||
65 | Assert.AreEqual(0, objs.Count); | ||
66 | } | ||
67 | |||
68 | // SOG round trips | ||
69 | // * store objects, make sure they save | ||
70 | // * update | ||
71 | |||
72 | [Test] | ||
73 | public void T010_StoreSimpleObject() | ||
74 | { | ||
75 | SceneObjectGroup sog = NewSOG("object1"); | ||
76 | SceneObjectGroup sog2 = NewSOG("object2"); | ||
77 | |||
78 | db.StoreObject(sog, region); | ||
79 | db.StoreObject(sog2, region); | ||
80 | |||
81 | // This tests the ADO.NET driver | ||
82 | List<SceneObjectGroup> objs = db.LoadObjects(region); | ||
83 | Assert.AreEqual(2, objs.Count); | ||
84 | |||
85 | // This confirms things actually went to disk | ||
86 | db = new SQLiteRegionData(); | ||
87 | db.Initialise(connect); | ||
88 | |||
89 | List<SceneObjectGroup> objs2 = db.LoadObjects(region); | ||
90 | Assert.AreEqual(2, objs2.Count); | ||
91 | } | ||
92 | |||
93 | [Test] | ||
94 | public void T011_ObjectNames() | ||
95 | { | ||
96 | List<SceneObjectGroup> objs = db.LoadObjects(region); | ||
97 | foreach (SceneObjectGroup sog in objs) | ||
98 | { | ||
99 | SceneObjectPart p = sog.RootPart; | ||
100 | Assert.That("", Text.DoesNotMatch(p.Name)); | ||
101 | Assert.That(p.Name, Text.Matches(p.Description)); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | [Test] | ||
106 | public void T012_UpdateObject() | ||
107 | { | ||
108 | string text = "object1 text"; | ||
109 | SceneObjectGroup sog = FindSOG("object1", region); | ||
110 | sog.RootPart.Text = text; | ||
111 | db.StoreObject(sog, region); | ||
112 | |||
113 | sog = FindSOG("object1", region); | ||
114 | Assert.That(text, Text.Matches(sog.RootPart.Text)); | ||
115 | } | ||
116 | |||
117 | // Extra private methods | ||
118 | |||
119 | private SceneObjectGroup FindSOG(string name, UUID r) | ||
120 | { | ||
121 | List<SceneObjectGroup> objs = db.LoadObjects(r); | ||
122 | foreach (SceneObjectGroup sog in objs) | ||
123 | { | ||
124 | SceneObjectPart p = sog.RootPart; | ||
125 | if (p.Name == name) { | ||
126 | return sog; | ||
127 | } | ||
128 | } | ||
129 | return null; | ||
130 | } | ||
131 | |||
132 | private SceneObjectGroup NewSOG(string name) | ||
133 | { | ||
134 | SceneObjectGroup sog = new SceneObjectGroup(); | ||
135 | SceneObjectPart sop = new SceneObjectPart(); | ||
136 | sop.LocalId = 1; | ||
137 | sop.Name = name; | ||
138 | sop.Description = name; | ||
139 | sop.Text = ""; | ||
140 | sop.SitName = ""; | ||
141 | sop.TouchName = ""; | ||
142 | sop.UUID = UUID.Random(); | ||
143 | sop.Shape = PrimitiveBaseShape.Default; | ||
144 | sog.AddPart(sop); | ||
145 | sog.RootPart = sop; | ||
146 | return sog; | ||
147 | } | ||
148 | |||
149 | } | 60 | } |
150 | } \ No newline at end of file | 61 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteUserTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteUserTest.cs index d00a177..d4aaf99 100644 --- a/OpenSim/Data/SQLite/Tests/SQLiteUserTest.cs +++ b/OpenSim/Data/SQLite/Tests/SQLiteUserTest.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using NUnit.Framework.SyntaxHelpers; | 31 | using NUnit.Framework.SyntaxHelpers; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Data.Tests; | ||
33 | using OpenSim.Data.SQLite; | 34 | using OpenSim.Data.SQLite; |
34 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
@@ -37,25 +38,18 @@ using OpenMetaverse; | |||
37 | namespace OpenSim.Data.SQLite.Tests | 38 | namespace OpenSim.Data.SQLite.Tests |
38 | { | 39 | { |
39 | [TestFixture] | 40 | [TestFixture] |
40 | public class SQLiteUserTest | 41 | public class SQLiteUserTest : BasicUserTest |
41 | { | 42 | { |
42 | public string file = "usertest.db"; | 43 | public string file = "usertest.db"; |
43 | public string connect; | 44 | public string connect; |
44 | public SQLiteUserData db; | ||
45 | public UUID uuid1; | ||
46 | public UUID uuid2; | ||
47 | public UUID uuid3; | ||
48 | |||
49 | 45 | ||
50 | [TestFixtureSetUp] | 46 | [TestFixtureSetUp] |
51 | public void Init() | 47 | public void Init() |
52 | { | 48 | { |
49 | SuperInit(); | ||
53 | connect = "URI=file:" + file + ",version=3"; | 50 | connect = "URI=file:" + file + ",version=3"; |
54 | db = new SQLiteUserData(); | 51 | db = new SQLiteUserData(); |
55 | db.Initialise(connect); | 52 | db.Initialise(connect); |
56 | uuid1 = UUID.Random(); | ||
57 | uuid2 = UUID.Random(); | ||
58 | uuid3 = UUID.Random(); | ||
59 | } | 53 | } |
60 | 54 | ||
61 | [TestFixtureTearDown] | 55 | [TestFixtureTearDown] |
@@ -63,11 +57,5 @@ namespace OpenSim.Data.SQLite.Tests | |||
63 | { | 57 | { |
64 | System.IO.File.Delete(file); | 58 | System.IO.File.Delete(file); |
65 | } | 59 | } |
66 | |||
67 | [Test] | ||
68 | public void T001_LoadEmpty() | ||
69 | { | ||
70 | Assert.That(db.GetUserByUUID(uuid1), Is.Null); | ||
71 | } | ||
72 | } | 60 | } |
73 | } \ No newline at end of file | 61 | } \ No newline at end of file |
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs new file mode 100644 index 0000000..1e2069f --- /dev/null +++ b/OpenSim/Data/Tests/BasicAssetTest.cs | |||
@@ -0,0 +1,104 @@ | |||
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 OpenSim 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 NUnit.Framework; | ||
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Environment.Scenes; | ||
35 | using OpenMetaverse; | ||
36 | |||
37 | namespace OpenSim.Data.Tests | ||
38 | { | ||
39 | public class BasicAssetTest | ||
40 | { | ||
41 | public AssetDataBase db; | ||
42 | public UUID uuid1; | ||
43 | public UUID uuid2; | ||
44 | public UUID uuid3; | ||
45 | |||
46 | public void SuperInit() | ||
47 | { | ||
48 | uuid1 = UUID.Random(); | ||
49 | uuid2 = UUID.Random(); | ||
50 | uuid3 = UUID.Random(); | ||
51 | } | ||
52 | |||
53 | [Test] | ||
54 | public void T001_LoadEmpty() | ||
55 | { | ||
56 | Assert.That(db.ExistsAsset(uuid1), Is.False); | ||
57 | Assert.That(db.ExistsAsset(uuid2), Is.False); | ||
58 | Assert.That(db.ExistsAsset(uuid3), Is.False); | ||
59 | } | ||
60 | |||
61 | [Test] | ||
62 | public void T010_StoreSimpleAsset() | ||
63 | { | ||
64 | AssetBase a1 = new AssetBase(uuid1, "asset one"); | ||
65 | AssetBase a2 = new AssetBase(uuid2, "asset two"); | ||
66 | AssetBase a3 = new AssetBase(uuid3, "asset three"); | ||
67 | db.CreateAsset(a1); | ||
68 | db.CreateAsset(a2); | ||
69 | db.CreateAsset(a3); | ||
70 | |||
71 | AssetBase a1a = db.FetchAsset(uuid1); | ||
72 | Assert.That(a1.ID.ToString(), Text.Matches(a1a.ID.ToString())); | ||
73 | Assert.That(a1.Name, Text.Matches(a1a.Name)); | ||
74 | |||
75 | AssetBase a2a = db.FetchAsset(uuid2); | ||
76 | Assert.That(a2.ID.ToString(), Text.Matches(a2a.ID.ToString())); | ||
77 | Assert.That(a2.Name, Text.Matches(a2a.Name)); | ||
78 | |||
79 | AssetBase a3a = db.FetchAsset(uuid3); | ||
80 | Assert.That(a3.ID.ToString(), Text.Matches(a3a.ID.ToString())); | ||
81 | Assert.That(a3.Name, Text.Matches(a3a.Name)); | ||
82 | } | ||
83 | |||
84 | [Test] | ||
85 | public void T011_ExistsSimpleAsset() | ||
86 | { | ||
87 | Assert.That(db.ExistsAsset(uuid1), Is.True); | ||
88 | Assert.That(db.ExistsAsset(uuid2), Is.True); | ||
89 | Assert.That(db.ExistsAsset(uuid3), Is.True); | ||
90 | } | ||
91 | |||
92 | // this has questionable use, but it is in the interface at the moment. | ||
93 | // [Test] | ||
94 | // public void T012_DeleteAsset() | ||
95 | // { | ||
96 | // db.DeleteAsset(uuid1); | ||
97 | // db.DeleteAsset(uuid2); | ||
98 | // db.DeleteAsset(uuid3); | ||
99 | // Assert.That(db.ExistsAsset(uuid1), Is.False); | ||
100 | // Assert.That(db.ExistsAsset(uuid2), Is.False); | ||
101 | // Assert.That(db.ExistsAsset(uuid3), Is.False); | ||
102 | // } | ||
103 | } | ||
104 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/Tests/BasicInventoryTests.cs b/OpenSim/Data/Tests/BasicInventoryTest.cs index a6f81f9..a6f81f9 100644 --- a/OpenSim/Data/Tests/BasicInventoryTests.cs +++ b/OpenSim/Data/Tests/BasicInventoryTest.cs | |||
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs new file mode 100644 index 0000000..39692f1 --- /dev/null +++ b/OpenSim/Data/Tests/BasicRegionTest.cs | |||
@@ -0,0 +1,132 @@ | |||
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 OpenSim 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 NUnit.Framework; | ||
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Data; | ||
34 | using OpenSim.Region.Environment.Interfaces; | ||
35 | using OpenSim.Region.Environment.Scenes; | ||
36 | using OpenMetaverse; | ||
37 | |||
38 | namespace OpenSim.Data.Tests | ||
39 | { | ||
40 | public class BasicRegionTest | ||
41 | { | ||
42 | public IRegionDataStore db; | ||
43 | public UUID region; | ||
44 | |||
45 | public void SuperInit() | ||
46 | { | ||
47 | region = UUID.Random(); | ||
48 | } | ||
49 | |||
50 | [Test] | ||
51 | public void T001_LoadEmpty() | ||
52 | { | ||
53 | List<SceneObjectGroup> objs = db.LoadObjects(region); | ||
54 | Assert.AreEqual(0, objs.Count); | ||
55 | } | ||
56 | |||
57 | // SOG round trips | ||
58 | // * store objects, make sure they save | ||
59 | // * update | ||
60 | |||
61 | [Test] | ||
62 | public void T010_StoreSimpleObject() | ||
63 | { | ||
64 | SceneObjectGroup sog = NewSOG("object1"); | ||
65 | SceneObjectGroup sog2 = NewSOG("object2"); | ||
66 | |||
67 | db.StoreObject(sog, region); | ||
68 | db.StoreObject(sog2, region); | ||
69 | |||
70 | // This tests the ADO.NET driver | ||
71 | List<SceneObjectGroup> objs = db.LoadObjects(region); | ||
72 | Assert.AreEqual(2, objs.Count); | ||
73 | } | ||
74 | |||
75 | [Test] | ||
76 | public void T011_ObjectNames() | ||
77 | { | ||
78 | List<SceneObjectGroup> objs = db.LoadObjects(region); | ||
79 | foreach (SceneObjectGroup sog in objs) | ||
80 | { | ||
81 | SceneObjectPart p = sog.RootPart; | ||
82 | Assert.That("", Text.DoesNotMatch(p.Name)); | ||
83 | Assert.That(p.Name, Text.Matches(p.Description)); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | [Test] | ||
88 | public void T012_UpdateObject() | ||
89 | { | ||
90 | string text = "object1 text"; | ||
91 | SceneObjectGroup sog = FindSOG("object1", region); | ||
92 | sog.RootPart.Text = text; | ||
93 | db.StoreObject(sog, region); | ||
94 | |||
95 | sog = FindSOG("object1", region); | ||
96 | Assert.That(text, Text.Matches(sog.RootPart.Text)); | ||
97 | } | ||
98 | |||
99 | // Extra private methods | ||
100 | |||
101 | private SceneObjectGroup FindSOG(string name, UUID r) | ||
102 | { | ||
103 | List<SceneObjectGroup> objs = db.LoadObjects(r); | ||
104 | foreach (SceneObjectGroup sog in objs) | ||
105 | { | ||
106 | SceneObjectPart p = sog.RootPart; | ||
107 | if (p.Name == name) { | ||
108 | return sog; | ||
109 | } | ||
110 | } | ||
111 | return null; | ||
112 | } | ||
113 | |||
114 | private SceneObjectGroup NewSOG(string name) | ||
115 | { | ||
116 | SceneObjectGroup sog = new SceneObjectGroup(); | ||
117 | SceneObjectPart sop = new SceneObjectPart(); | ||
118 | sop.LocalId = 1; | ||
119 | sop.Name = name; | ||
120 | sop.Description = name; | ||
121 | sop.Text = ""; | ||
122 | sop.SitName = ""; | ||
123 | sop.TouchName = ""; | ||
124 | sop.UUID = UUID.Random(); | ||
125 | sop.Shape = PrimitiveBaseShape.Default; | ||
126 | sog.AddPart(sop); | ||
127 | sog.RootPart = sop; | ||
128 | return sog; | ||
129 | } | ||
130 | |||
131 | } | ||
132 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/Tests/BasicUserTest.cs b/OpenSim/Data/Tests/BasicUserTest.cs new file mode 100644 index 0000000..9e79193 --- /dev/null +++ b/OpenSim/Data/Tests/BasicUserTest.cs | |||
@@ -0,0 +1,63 @@ | |||
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 OpenSim 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 NUnit.Framework; | ||
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Environment.Scenes; | ||
35 | using OpenMetaverse; | ||
36 | |||
37 | namespace OpenSim.Data.Tests | ||
38 | { | ||
39 | public class BasicUserTest | ||
40 | { | ||
41 | public UserDataBase db; | ||
42 | public UUID uuid1; | ||
43 | public UUID uuid2; | ||
44 | public UUID uuid3; | ||
45 | |||
46 | public void SuperInit() | ||
47 | { | ||
48 | uuid1 = UUID.Random(); | ||
49 | uuid2 = UUID.Random(); | ||
50 | uuid3 = UUID.Random(); | ||
51 | } | ||
52 | |||
53 | [Test] | ||
54 | public void T001_LoadEmpty() | ||
55 | { | ||
56 | Assert.That(db.GetUserByUUID(UUID.Zero), Is.Null); | ||
57 | Assert.That(db.GetUserByUUID(uuid1), Is.Null); | ||
58 | Assert.That(db.GetUserByUUID(uuid2), Is.Null); | ||
59 | Assert.That(db.GetUserByUUID(uuid3), Is.Null); | ||
60 | Assert.That(db.GetUserByUUID(UUID.Random()), Is.Null); | ||
61 | } | ||
62 | } | ||
63 | } \ No newline at end of file | ||