aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/SQLite/SQLiteUserAccountData.cs (renamed from OpenSim/Data/MySQL/Tests/MySQLUserTest.cs)82
1 files changed, 39 insertions, 43 deletions
diff --git a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
index cf8139a..50e8c23 100644
--- a/OpenSim/Data/MySQL/Tests/MySQLUserTest.cs
+++ b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
@@ -26,60 +26,56 @@
26 */ 26 */
27 27
28using System; 28using System;
29using NUnit.Framework; 29using System.Collections;
30using OpenSim.Data.Tests; 30using System.Collections.Generic;
31using log4net; 31using System.Data;
32using System.Reflection; 32using OpenMetaverse;
33using OpenSim.Tests.Common; 33using OpenSim.Framework;
34using Mono.Data.SqliteClient;
34 35
35namespace OpenSim.Data.MySQL.Tests 36namespace OpenSim.Data.SQLite
36{ 37{
37 [TestFixture, DatabaseTest] 38 public class SQLiteUserAccountData : SQLiteGenericTableHandler<UserAccountData>, IUserAccountData
38 public class MySQLUserTest : BasicUserTest
39 { 39 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 40 public SQLiteUserAccountData(string connectionString, string realm)
41 public string file; 41 : base(connectionString, realm, "UserAccount")
42 public MySQLManager database;
43 public string connect = "Server=localhost;Port=3306;Database=opensim-nunit;User ID=opensim-nunit;Password=opensim-nunit;Pooling=false;";
44
45 [TestFixtureSetUp]
46 public void Init()
47 { 42 {
48 SuperInit();
49 // If we manage to connect to the database with the user
50 // and password above it is our test database, and run
51 // these tests. If anything goes wrong, ignore these
52 // tests.
53 try
54 {
55 database = new MySQLManager(connect);
56 db = new MySQLUserData();
57 db.Initialise(connect);
58 }
59 catch (Exception e)
60 {
61 m_log.Error("Exception {0}", e);
62 Assert.Ignore();
63 }
64 } 43 }
65 44
66 [TestFixtureTearDown] 45 public UserAccountData[] GetUsers(UUID scopeID, string query)
67 public void Cleanup()
68 { 46 {
69 if (db != null) 47 string[] words = query.Split(new char[] {' '});
48
49 for (int i = 0 ; i < words.Length ; i++)
70 { 50 {
71 db.Dispose(); 51 if (words[i].Length < 3)
52 {
53 if (i != words.Length - 1)
54 Array.Copy(words, i + 1, words, i, words.Length - i - 1);
55 Array.Resize(ref words, words.Length - 1);
56 }
72 } 57 }
73 // if a new table is added, it has to be dropped here 58
74 if (database != null) 59 if (words.Length == 0)
60 return new UserAccountData[0];
61
62 if (words.Length > 2)
63 return new UserAccountData[0];
64
65 SqliteCommand cmd = new SqliteCommand();
66
67 if (words.Length == 1)
75 { 68 {
76 database.ExecuteSql("drop table migrations"); 69 cmd.CommandText = String.Format("select * from {0} where ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')",
77 database.ExecuteSql("drop table users"); 70 m_Realm, scopeID.ToString(), words[0]);
78 database.ExecuteSql("drop table userfriends");
79 database.ExecuteSql("drop table agents");
80 database.ExecuteSql("drop table avatarappearance");
81 database.ExecuteSql("drop table avatarattachments");
82 } 71 }
72 else
73 {
74 cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')",
75 m_Realm, scopeID.ToString(), words[0], words[1]);
76 }
77
78 return DoQuery(cmd);
83 } 79 }
84 } 80 }
85} 81}