More unit tests for more fun!

This commit is contained in:
Zack Piispanen 2011-08-08 20:40:44 -04:00
parent 7e3a38c5c1
commit f89de33d01
5 changed files with 78 additions and 3 deletions

View file

@ -29,7 +29,7 @@ namespace UnitTests
}
[TestMethod]
public void TestDBNotNull()
public void TestBansDBNotNull()
{
Assert.IsNotNull(Bans);
}

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<OrderedTest name="BanManagerTest" storage="c:\users\shank\dropbox\design and development\csharp\tshock\unittests\banmanagertest.orderedtest" id="f28695ef-8181-4996-8783-b5059ce904b1" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<OrderedTest name="banmanagertest" storage="c:\users\virus\git\tshock\unittests\banmanagertest.orderedtest" id="f28695ef-8181-4996-8783-b5059ce904b1" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<TestLinks>
<TestLink id="58b9a622-39c1-640a-6713-3ee97b0d99e2" name="TestDBNotNull" storage="bin\debug\unittests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<TestLink id="7cc70e31-eeb8-f6b8-afa2-17bf975873ed" name="TestBansDBNotNull" storage="bin\debug\unittests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<TestLink id="67a76536-c5c2-4d99-515a-498708451061" name="AddBanTest" storage="bin\debug\unittests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<TestLink id="9265845c-1bec-1156-2e22-1a64c5bd689f" name="FindBanTest" storage="bin\debug\unittests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</TestLinks>

View file

@ -0,0 +1,63 @@
using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Community.CsharpSqlite.SQLiteClient;
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(Tools.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"));
}*/
}
}

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<OrderedTest name="groupmanagertest" storage="c:\users\virus\git\tshock\unittests\groupmanagertest.orderedtest" id="ec2aa146-8548-415b-a9f5-80472ce3c7d9" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<TestLinks>
<TestLink id="4b09514b-0cca-b305-b9af-a4ceaaaf12dd" name="TestGroupsDBNotNull" storage="bin\debug\unittests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<TestLink id="6ea1e597-9c3c-745b-5307-55ff47787810" name="DeleteGroup" storage="bin\debug\unittests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<TestLink id="a66f56ff-803a-ff91-0bca-9abde10363de" name="CreateGroup" storage="bin\debug\unittests.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</TestLinks>
</OrderedTest>

View file

@ -87,6 +87,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BanManagerTest.cs" />
<Compile Include="GroupManagerTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ItemManagerTest.cs" />
<Compile Include="RegionManagerTest.cs" />
@ -104,6 +105,9 @@
<None Include="ItemManagerTest.orderedtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="GroupManagerTest.orderedtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="RegionManagerTest.orderedtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>