New tests

This commit is contained in:
Lucas Nicodemus 2011-07-23 15:14:27 -06:00
parent a2f2ea1500
commit f1ed9207c1
4 changed files with 67 additions and 2 deletions

View file

@ -0,0 +1,53 @@
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 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 TestDBNotNull()
{
Assert.IsNotNull(Bans);
}
[TestMethod]
public void AddBanTest()
{
Assert.IsTrue(Bans.AddBan("127.0.0.1", "BanTest", "Ban Testing"));
}
[TestMethod]
public void FindBanTest()
{
Assert.IsNotNull(Bans.GetBanByIp("127.0.0.1"));
TShock.Config.EnableBanOnUsernames = true;
Assert.IsNotNull(Bans.GetBanByName("BanTest"));
TShock.Config.EnableBanOnUsernames = false;
Assert.IsNull(Bans.GetBanByName("BanTest"));
}
}
}

View file

@ -0,0 +1,8 @@
<?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">
<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="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>
</OrderedTest>

View file

@ -63,6 +63,7 @@
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
<Compile Include="BanManagerTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ItemManagerTest.cs" />
</ItemGroup>
@ -73,6 +74,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="BanManagerTest.orderedtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ItemManagerTest.orderedtest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>