From 1c7fe908b68a313302f555c3e25a3665f18339be Mon Sep 17 00:00:00 2001 From: Zack Piispanen Date: Wed, 3 Sep 2014 02:41:53 -0400 Subject: [PATCH] Delete a bunch of cruft that has gone unmaintained for too long. Fix warps to have an auto-increment primary key column, and unique on name/WorldID Same for regions. Changed SqliteTableCreator to do proper unique syntax. --- Local.testsettings | 10 - TShock.sln | 12 - TShockAPI/DB/IQueryBuilder.cs | 13 +- TShockAPI/DB/RegionManager.cs | 62 +- TShockAPI/DB/WarpsManager.cs | 5 +- Terraria.vsmdi | 14 - TraceAndTestImpact.testsettings | 9 - UnitTests/BanManagerTest.cs | 68 - UnitTests/BanManagerTest.orderedtest | 8 - UnitTests/GroupManagerTest.cs | 80 -- UnitTests/GroupManagerTest.orderedtest | 8 - UnitTests/ItemManagerTest.cs | 97 -- UnitTests/ItemManagerTest.orderedtest | 7 - UnitTests/Properties/AssemblyInfo.cs | 52 - UnitTests/RegionManagerTest.cs | 141 --- UnitTests/RegionManagerTest.orderedtest | 14 - UnitTests/RestApiTests.webtest | 1542 ----------------------- UnitTests/UnitTests.csproj | 176 --- UnitTests/UnitTests.licenseheader | 18 - 19 files changed, 15 insertions(+), 2321 deletions(-) delete mode 100644 Local.testsettings delete mode 100644 Terraria.vsmdi delete mode 100644 TraceAndTestImpact.testsettings delete mode 100644 UnitTests/BanManagerTest.cs delete mode 100644 UnitTests/BanManagerTest.orderedtest delete mode 100644 UnitTests/GroupManagerTest.cs delete mode 100644 UnitTests/GroupManagerTest.orderedtest delete mode 100644 UnitTests/ItemManagerTest.cs delete mode 100644 UnitTests/ItemManagerTest.orderedtest delete mode 100644 UnitTests/Properties/AssemblyInfo.cs delete mode 100644 UnitTests/RegionManagerTest.cs delete mode 100644 UnitTests/RegionManagerTest.orderedtest delete mode 100644 UnitTests/RestApiTests.webtest delete mode 100644 UnitTests/UnitTests.csproj delete mode 100644 UnitTests/UnitTests.licenseheader diff --git a/Local.testsettings b/Local.testsettings deleted file mode 100644 index 24250d4b..00000000 --- a/Local.testsettings +++ /dev/null @@ -1,10 +0,0 @@ - - - These are default test settings for a local test run. - - - - - - - \ No newline at end of file diff --git a/TShock.sln b/TShock.sln index 904e7dcd..5044784e 100644 --- a/TShock.sln +++ b/TShock.sln @@ -2,15 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2010 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{755F5B05-0924-47E9-9563-26EB20FE3F67}" - ProjectSection(SolutionItems) = preProject - Local.testsettings = Local.testsettings - Terraria.vsmdi = Terraria.vsmdi - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockAPI", "TShockAPI\TShockAPI.csproj", "{49606449-072B-4CF5-8088-AA49DA586694}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{F3742F51-D7BF-4754-A68A-CD944D2A21FF}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockRestTestPlugin", "TShockRestTestPlugin\TShockRestTestPlugin.csproj", "{F2FEDAFB-58DE-4611-9168-A86112C346C7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrariaAPI-Server", "TerrariaServerAPI\TerrariaAPI-Server.csproj", "{549A7941-D9C9-4544-BAC8-D9EEEAB4D777}" @@ -38,12 +32,6 @@ Global {49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.Build.0 = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Release|x86.ActiveCfg = Release|Any CPU - {F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|x86.ActiveCfg = Debug|Any CPU - {F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|x86.ActiveCfg = Release|Any CPU {F2FEDAFB-58DE-4611-9168-A86112C346C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F2FEDAFB-58DE-4611-9168-A86112C346C7}.Debug|Any CPU.Build.0 = Debug|Any CPU {F2FEDAFB-58DE-4611-9168-A86112C346C7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU diff --git a/TShockAPI/DB/IQueryBuilder.cs b/TShockAPI/DB/IQueryBuilder.cs index 6dc372b4..64988c7c 100644 --- a/TShockAPI/DB/IQueryBuilder.cs +++ b/TShockAPI/DB/IQueryBuilder.cs @@ -44,10 +44,15 @@ namespace TShockAPI.DB var columns = table.Columns.Select( c => - "'{0}' {1} {2} {3} {4} {5}".SFormat(c.Name, DbTypeToString(c.Type, c.Length), c.Primary ? "PRIMARY KEY" : "", - c.AutoIncrement ? "AUTOINCREMENT" : "", c.NotNull ? "NOT NULL" : "", - c.Unique ? "UNIQUE" : "")); - return "CREATE TABLE {0} ({1})".SFormat(EscapeTableName(table.Name), string.Join(", ", columns)); + "'{0}' {1} {2} {3} {4}".SFormat(c.Name, + DbTypeToString(c.Type, c.Length), + c.Primary ? "PRIMARY KEY" : "", + c.AutoIncrement ? "AUTOINCREMENT" : "", + c.NotNull ? "NOT NULL" : "")); + var uniques = table.Columns.Where(c => c.Unique).Select(c => c.Name); + return "CREATE TABLE {0} ({1} {2})".SFormat(EscapeTableName(table.Name), + string.Join(", ", columns), + uniques.Count() > 0 ? ", UNIQUE({0})".SFormat(string.Join(", ", uniques)) : ""); } public override string RenameTable(string from, string to) diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs index 097424d9..dd6d73e2 100644 --- a/TShockAPI/DB/RegionManager.cs +++ b/TShockAPI/DB/RegionManager.cs @@ -38,12 +38,13 @@ namespace TShockAPI.DB { database = db; var table = new SqlTable("Regions", + new SqlColumn("Id", MySqlDbType.Int32) {Primary = true, AutoIncrement = true}, new SqlColumn("X1", MySqlDbType.Int32), new SqlColumn("Y1", MySqlDbType.Int32), new SqlColumn("width", MySqlDbType.Int32), new SqlColumn("height", MySqlDbType.Int32), - new SqlColumn("RegionName", MySqlDbType.VarChar, 50) {Primary = true}, - new SqlColumn("WorldID", MySqlDbType.Text), + new SqlColumn("RegionName", MySqlDbType.VarChar, 50) {Unique = true}, + new SqlColumn("WorldID", MySqlDbType.Text) {Unique = true}, new SqlColumn("UserIds", MySqlDbType.Text), new SqlColumn("Protected", MySqlDbType.Int32), new SqlColumn("Groups", MySqlDbType.Text), @@ -114,53 +115,6 @@ namespace TShockAPI.DB } } - public void ReloadForUnitTest(String n) - { - using (var reader = database.QueryReader("SELECT * FROM Regions WHERE WorldID=@0", n)) - { - Regions.Clear(); - while (reader.Read()) - { - int X1 = reader.Get("X1"); - int Y1 = reader.Get("Y1"); - int height = reader.Get("height"); - int width = reader.Get("width"); - int Protected = reader.Get("Protected"); - string MergedIDs = reader.Get("UserIds"); - string name = reader.Get("RegionName"); - string[] SplitIDs = MergedIDs.Split(','); - string owner = reader.Get("Owner"); - string groups = reader.Get("Groups"); - int z = reader.Get("Z"); - - Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString(), z); - r.SetAllowedGroups(groups); - try - { - for (int i = 0; i < SplitIDs.Length; i++) - { - int id; - - if (Int32.TryParse(SplitIDs[i], out id)) // if unparsable, it's not an int, so silently skip - r.AllowedIDs.Add(id); - else if (SplitIDs[i] == "") // Split gotcha, can return an empty string with certain conditions - // but we only want to let the user know if it's really a nonparsable integer. - Log.Warn("UnitTest: One of your UserIDs is not a usable integer: " + SplitIDs[i]); - } - } - catch (Exception e) - { - Log.Error("Your database contains invalid UserIDs (they should be ints)."); - Log.Error("A lot of things will fail because of this. You must manually delete and re-create the allowed field."); - Log.Error(e.Message); - Log.Error(e.StackTrace); - } - - Regions.Add(r); - } - } - } - public bool AddRegion(int tx, int ty, int width, int height, string regionname, string owner, string worldid, int z = 0) { if (GetRegionByName(regionname) != null) @@ -469,16 +423,6 @@ namespace TShockAPI.DB return Regions.FirstOrDefault(r => r.Name.Equals(name) && r.WorldID == Main.worldID.ToString()); } - public Region ZacksGetRegionByName(String name) - { - foreach (Region r in Regions) - { - if (r.Name.Equals(name)) - return r; - } - return null; - } - public bool ChangeOwner(string regionName, string newOwner) { var region = GetRegionByName(regionName); diff --git a/TShockAPI/DB/WarpsManager.cs b/TShockAPI/DB/WarpsManager.cs index 04166277..317f1730 100644 --- a/TShockAPI/DB/WarpsManager.cs +++ b/TShockAPI/DB/WarpsManager.cs @@ -40,10 +40,11 @@ namespace TShockAPI.DB database = db; var table = new SqlTable("Warps", - new SqlColumn("WarpName", MySqlDbType.VarChar, 50) {Primary = true}, + new SqlColumn("Id", MySqlDbType.Int32){Primary = true, AutoIncrement = true}, + new SqlColumn("WarpName", MySqlDbType.VarChar, 50) {Unique = true}, new SqlColumn("X", MySqlDbType.Int32), new SqlColumn("Y", MySqlDbType.Int32), - new SqlColumn("WorldID", MySqlDbType.Text), + new SqlColumn("WorldID", MySqlDbType.Text) {Unique = true}, new SqlColumn("Private", MySqlDbType.Text) ); var creator = new SqlTableCreator(db, diff --git a/Terraria.vsmdi b/Terraria.vsmdi deleted file mode 100644 index 5024fe82..00000000 --- a/Terraria.vsmdi +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TraceAndTestImpact.testsettings b/TraceAndTestImpact.testsettings deleted file mode 100644 index de2742ce..00000000 --- a/TraceAndTestImpact.testsettings +++ /dev/null @@ -1,9 +0,0 @@ - - - These are test settings for Trace and Test Impact. - - - - - - \ No newline at end of file diff --git a/UnitTests/BanManagerTest.cs b/UnitTests/BanManagerTest.cs deleted file mode 100644 index b1eabc0c..00000000 --- a/UnitTests/BanManagerTest.cs +++ /dev/null @@ -1,68 +0,0 @@ -/* -TShock, a server mod for Terraria -Copyright (C) 2011-2012 The TShock Team - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -using System; -using System.Data; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Mono.Data.Sqlite; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using TShockAPI; -using TShockAPI.DB; - -namespace UnitTests -{ - [TestClass] - public class BanManagerTest - { - public static IDbConnection DB; - private BanManager Bans; - - [TestInitialize] - public void Initialize() - { - TShock.Config = new ConfigFile(); - TShock.Config.StorageType = "sqlite"; - - DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", "tshock.test.sqlite")); - DB.Open(); - - Bans = new BanManager(DB); - } - - [TestMethod] - public void TestBansDBNotNull() - { - Assert.IsNotNull(Bans); - } - - [TestMethod] - public void AddBanTest() - { - Assert.IsTrue(Bans.AddBan("127.0.0.1", "BanTest", "BanTest2", "Ban Testing")); - } - - [TestMethod] - public void FindBanTest() - { - Assert.IsNotNull(Bans.GetBanByIp("127.0.0.1")); - Assert.IsNotNull(Bans.GetBanByName("BanTest")); - Assert.IsNotNull(Bans.GetBanByUUID("BanTest2")); - } - } -} diff --git a/UnitTests/BanManagerTest.orderedtest b/UnitTests/BanManagerTest.orderedtest deleted file mode 100644 index 646da342..00000000 --- a/UnitTests/BanManagerTest.orderedtest +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/UnitTests/GroupManagerTest.cs b/UnitTests/GroupManagerTest.cs deleted file mode 100644 index 64d23622..00000000 --- a/UnitTests/GroupManagerTest.cs +++ /dev/null @@ -1,80 +0,0 @@ -/* -TShock, a server mod for Terraria -Copyright (C) 2011-2012 The TShock Team - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -using System; -using System.Data; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Mono.Data.Sqlite; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using TShockAPI; -using TShockAPI.DB; - -namespace UnitTests -{ - [TestClass] - public class GroupManagerTest - { - public static IDbConnection DB; - private GroupManager Groups; - - [TestInitialize] - public void Initialize() - { - TShock.Config = new ConfigFile(); - TShock.Config.StorageType = "sqlite"; - - DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", "tshock.test.sqlite")); - DB.Open(); - - Groups = new GroupManager(DB); - TShock.Groups = this.Groups; - } - - [TestMethod] - public void TestGroupsDBNotNull() - { - Assert.IsNotNull(Groups); - } - - [TestMethod] - public void CreateGroup() - { - Assert.IsTrue(Groups.AddGroup("test1", "heal") != ""); - Assert.IsTrue(Groups.GroupExists("test1")); - Assert.IsTrue(TShock.Utils.GetGroup("test1").HasPermission("heal")); - } - - [TestMethod] - public void DeleteGroup() - { - Assert.IsTrue(Groups.AddGroup("test1", "heal") != ""); - Assert.IsTrue(Groups.GroupExists("test1")); - Assert.IsTrue(Groups.DeleteGroup("test1") != ""); - Assert.IsFalse( Groups.GroupExists( "test1") ); - } - - /*[TestMethod] - public void CreateGroup() - { - Assert.IsTrue(Groups.AddGroup("test1", "heal") != ""); - Assert.IsTrue(Groups.GroupExists("test1")); - Assert.IsTrue(Tools.GetGroup("test1").HasPermission("heal")); - }*/ - } -} diff --git a/UnitTests/GroupManagerTest.orderedtest b/UnitTests/GroupManagerTest.orderedtest deleted file mode 100644 index b7c5c255..00000000 --- a/UnitTests/GroupManagerTest.orderedtest +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/UnitTests/ItemManagerTest.cs b/UnitTests/ItemManagerTest.cs deleted file mode 100644 index febd62ab..00000000 --- a/UnitTests/ItemManagerTest.cs +++ /dev/null @@ -1,97 +0,0 @@ -/* -TShock, a server mod for Terraria -Copyright (C) 2011-2012 The TShock Team - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.IO; -using System.Data; -using System.ComponentModel; -using System.Diagnostics; -using System.Net; -using System.Reflection; -using System.Threading; -using Mono.Data.Sqlite; -using TShockAPI.DB; -using TShockAPI; - -namespace UnitTests -{ - - /// - /// Summary description for UnitTest1 - /// - [TestClass] - public class ItemManagerTest - { - public static IDbConnection DB; - public static ItemManager manager; - [TestInitialize] - public void Initialize() - { - TShock.Config = new ConfigFile(); - TShock.Config.StorageType = "sqlite"; - - DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", "tshock.test.sqlite")); - DB.Open(); - manager = new ItemManager(DB); - } - - [TestMethod] - public void SQLiteItemTest_AddBan() - { - Assert.IsNotNull(manager); - Assert.IsFalse( manager.ItemIsBanned("Dirt Block"), "Item isn't banned" ); - manager.AddNewBan("Dirt Block"); - Assert.IsTrue( manager.ItemIsBanned("Dirt Block"), "New item is added"); - Assert.IsFalse( manager.ItemIsBanned("Green Brick"), "Item isn't banned"); - manager.AddNewBan("Green Brick"); - Assert.IsTrue( manager.ItemIsBanned("Green Brick"), "New item is added"); - Assert.AreEqual(2, manager.ItemBans.Count, "Adding both items"); - manager.AddNewBan("Green Brick" ); - Assert.AreEqual(2, manager.ItemBans.Count, "Adding duplicate items"); - } - - [TestMethod] - public void SQLiteItemTest_RemoveBan() - { - manager = new ItemManager(DB); - Assert.IsNotNull(manager); - Assert.AreEqual(2, manager.ItemBans.Count); - manager.AddNewBan("Dirt Block"); - Assert.AreEqual(2, manager.ItemBans.Count); - Assert.AreEqual(true, manager.ItemIsBanned("Dirt Block")); - manager.RemoveBan("Dirt Block"); - manager.UpdateItemBans(); - Assert.AreEqual(1, manager.ItemBans.Count); - Assert.AreEqual(false, manager.ItemIsBanned("Dirt Block")); - manager.RemoveBan("Dirt Block"); - Assert.AreEqual(false, manager.ItemIsBanned("Dirt Block")); - Assert.AreEqual(true, manager.ItemIsBanned("Green Brick")); - manager.RemoveBan("Green Brick"); - Assert.AreEqual(false, manager.ItemIsBanned("Green Brick")); - } - - [TestCleanup] - public void Cleanup() - { - DB.Close(); - } - } -} diff --git a/UnitTests/ItemManagerTest.orderedtest b/UnitTests/ItemManagerTest.orderedtest deleted file mode 100644 index eeb19a9e..00000000 --- a/UnitTests/ItemManagerTest.orderedtest +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/UnitTests/Properties/AssemblyInfo.cs b/UnitTests/Properties/AssemblyInfo.cs deleted file mode 100644 index 9f57e16a..00000000 --- a/UnitTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* -TShock, a server mod for Terraria -Copyright (C) 2011-2012 The TShock Team - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("UnitTests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("UnitTests")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("edd69981-21b0-42af-bb55-25088efab253")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UnitTests/RegionManagerTest.cs b/UnitTests/RegionManagerTest.cs deleted file mode 100644 index 6c4d3ed9..00000000 --- a/UnitTests/RegionManagerTest.cs +++ /dev/null @@ -1,141 +0,0 @@ -/* -TShock, a server mod for Terraria -Copyright (C) 2011-2012 The TShock Team - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Data; -using TShockAPI; -using Mono.Data.Sqlite; -using TShockAPI.DB; -using Region = TShockAPI.DB.Region; - -namespace UnitTests -{ - /// - /// Summary description for RegionManagerTest - /// - [TestClass] - public class RegionManagerTest - { - public static IDbConnection DB; - public static RegionManager manager; - [TestInitialize] - public void Initialize() - { - TShock.Config = new ConfigFile(); - TShock.Config.StorageType = "sqlite"; - - DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", "tshock.test.sqlite")); - DB.Open(); - - manager = new RegionManager(DB); - TShock.Regions = manager; - manager.ReloadForUnitTest("test"); - } - - - [TestMethod] - public void AddRegion() - { - Region r = new Region( new Rectangle(100,100,100,100), "test", "test", true, "test", 0); - Assert.IsTrue(manager.AddRegion(r.Area.X, r.Area.Y, r.Area.Width, r.Area.Height, r.Name, r.Owner, r.WorldID)); - Assert.AreEqual(1, manager.Regions.Count); - Assert.IsNotNull(manager.ZacksGetRegionByName("test")); - - Region r2 = new Region(new Rectangle(201, 201, 100, 100), "test2", "test2", true, "test", 0); - manager.AddRegion(r2.Area.X, r2.Area.Y, r2.Area.Width, r2.Area.Height, r2.Name, r2.Owner, r2.WorldID); - Assert.AreEqual(2, manager.Regions.Count); - Assert.IsNotNull(manager.ZacksGetRegionByName("test2")); - } - - [TestMethod] - public void DeleteRegion() - { - Assert.IsTrue(2 == manager.Regions.Count); - Assert.IsTrue(manager.DeleteRegion("test")); - Assert.IsTrue(1 == manager.Regions.Count); - Assert.IsTrue(manager.DeleteRegion("test2")); - Assert.IsTrue(0 == manager.Regions.Count); - } - - [TestMethod] - public void InRegion() - { - Assert.IsTrue(manager.InArea(100, 100)); - Assert.IsTrue(manager.InArea(150, 150)); - Assert.IsTrue(manager.InArea(200, 200)); - Assert.IsTrue(manager.InArea(201, 201)); - Assert.IsTrue(manager.InArea(251, 251)); - Assert.IsTrue(manager.InArea(301, 301)); - Assert.IsFalse(manager.InArea(311, 311)); - Assert.IsFalse(manager.InArea(99, 99)); - } - - [TestMethod] - public void SetRegionState() - { - Assert.IsTrue(manager.ZacksGetRegionByName("test").DisableBuild); - manager.SetRegionStateTest("test", "test", false); - Assert.IsTrue(!manager.ZacksGetRegionByName("test").DisableBuild); - manager.SetRegionStateTest("test", "test", true); - Assert.IsTrue(manager.ZacksGetRegionByName("test").DisableBuild); - Assert.IsTrue(manager.ZacksGetRegionByName("test2").DisableBuild); - manager.SetRegionStateTest("test2", "test", false); - Assert.IsTrue(!manager.ZacksGetRegionByName("test2").DisableBuild); - manager.SetRegionStateTest("test2", "test", true); - Assert.IsTrue(manager.ZacksGetRegionByName("test2").DisableBuild); - } - - [TestMethod] - public void CanBuild() - { - /** - * For now, this test is useless. Need to implement user groups so we can alter Canbuild permission. - */ - } - - [TestMethod] - public void AddUser() - { - /** - * For now, this test is useless. Need to implement users so we have names to get ids from. - */ - } - - [TestMethod] - public void ListID() - { - Assert.IsTrue(RegionManager.ListIDs("1,2,3,4,5").Count == 5); - Assert.IsTrue(RegionManager.ListIDs("").Count == 0); - } - - [TestMethod] - public void ListRegions() - { - //needs a little more work. - } - - [TestCleanup] - public void Cleanup() - { - DB.Close(); - } - } -} diff --git a/UnitTests/RegionManagerTest.orderedtest b/UnitTests/RegionManagerTest.orderedtest deleted file mode 100644 index 980cc5da..00000000 --- a/UnitTests/RegionManagerTest.orderedtest +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/UnitTests/RestApiTests.webtest b/UnitTests/RestApiTests.webtest deleted file mode 100644 index 29e27981..00000000 --- a/UnitTests/RestApiTests.webtest +++ /dev/null @@ -1,1542 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj deleted file mode 100644 index 1ca30566..00000000 --- a/UnitTests/UnitTests.csproj +++ /dev/null @@ -1,176 +0,0 @@ - - - - Debug - AnyCPU - - - 2.0 - {F3742F51-D7BF-4754-A68A-CD944D2A21FF} - Library - Properties - UnitTests - UnitTests - v4.0 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - false - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - WebTest - - - - - 4.0 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - ..\SqlBins\Mono.Data.Sqlite.dll - - - ..\SqlBins\MySql.Data.dll - - - ..\SqlBins\MySql.Web.dll - - - - 3.5 - - - - - False - .exe - ..\TerrariaServerBins\TerrariaServer.exe - - - - - False - - - - - - - - - - - - {49606449-072B-4CF5-8088-AA49DA586694} - TShockAPI - - - {F2FEDAFB-58DE-4611-9168-A86112C346C7} - TShockRestTestPlugin - - - - - Always - - - Always - - - Always - - - Always - - - - Always - - - - - False - Microsoft .NET Framework 4 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - False - Windows Installer 3.1 - true - - - - - - - False - - - False - - - False - - - False - - - - - - - - xcopy .\..\..\..\SqlBins\sqlite3.dll . /Y - - - \ No newline at end of file diff --git a/UnitTests/UnitTests.licenseheader b/UnitTests/UnitTests.licenseheader deleted file mode 100644 index 12ed0ea9..00000000 --- a/UnitTests/UnitTests.licenseheader +++ /dev/null @@ -1,18 +0,0 @@ -extensions: .cs -/* -TShock, a server mod for Terraria -Copyright (C) 2011-2012 The TShock Team - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ \ No newline at end of file