diff --git a/UnitTests/Properties/AssemblyInfo.cs b/UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..29bd9c2b --- /dev/null +++ b/UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +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/UnitTest1.cs b/UnitTests/UnitTest1.cs new file mode 100644 index 00000000..4f6d826c --- /dev/null +++ b/UnitTests/UnitTest1.cs @@ -0,0 +1,79 @@ +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 Community.CsharpSqlite.SQLiteClient; +using TShockAPI.DB; +using TShockAPI; + +namespace UnitTests +{ + + /// + /// Summary description for UnitTest1 + /// + [TestClass] + public class UnitTest1 + { + public static IDbConnection DB; + [TestInitialize] + public void Initialize() + { + TShock.Config = new ConfigFile(); + TShock.Config.StorageType = "sqlite"; + + UnitTest1.DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", "tshock.test.sqlite")); + UnitTest1.DB.Open(); + /*try + { + var hostport = Config.MySqlHost.Split(':'); + DB = new MySqlConnection(); + DB.ConnectionString = String.Format("Server='{0}'; Port='{1}'; Database='{2}'; Uid='{3}'; Pwd='{4}';", + hostport[0], + hostport.Length > 1 ? hostport[1] : "3306", + Config.MySqlDbName, + Config.MySqlUsername, + Config.MySqlPassword + ); + DB.Open(); + } + catch (MySqlException ex) + { + Log.Error(ex.ToString()); + throw new Exception("MySql not setup correctly"); + }*/ + } + + [TestMethod] + public void SQLiteItemTest() + { + // + // TODO: Add test logic here + // + ItemManager manager = new ItemManager(DB); + Assert.IsNotNull(manager); + Assert.AreEqual( false, manager.ItemIsBanned("Dirt Block") ); + manager.AddNewBan("Dirt Block"); + Assert.AreEqual(true, manager.ItemIsBanned("Dirt Block")); + Assert.AreEqual(false, manager.ItemIsBanned("Green Brick")); + manager.AddNewBan("Green Brick"); + Assert.AreEqual(true, manager.ItemIsBanned("Green Brick")); + //manager.UpdateItemBans(); + //Assert.AreEqual(false, manager.ItemIsBanned("Dirt Block")); + DB.Close(); + } + + [TestCleanup] + public void Cleanup() + { + } + } +} diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj new file mode 100644 index 00000000..6f78bf1e --- /dev/null +++ b/UnitTests/UnitTests.csproj @@ -0,0 +1,83 @@ + + + + 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} + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\TShockAPI\SqlBins\Community.CsharpSqlite.dll + + + ..\TShockAPI\SqlBins\Community.CsharpSqlite.SQLiteClient.dll + + + + ..\TShockAPI\SqlBins\MySql.Data.dll + + + ..\TShockAPI\SqlBins\MySql.Web.dll + + + + 3.5 + + + + + False + ..\TShockAPI\TerrariaServerBins\TerrariaServerAPI.dll + + + + + False + + + + + + + + + {49606449-072B-4CF5-8088-AA49DA586694} + TShockAPI + + + + + \ No newline at end of file