diff --git a/ChaosBot.UnitTests/ChaosBot.UnitTests.csproj b/ChaosBot.UnitTests/ChaosBot.UnitTests.csproj index cdada84..ac58135 100644 --- a/ChaosBot.UnitTests/ChaosBot.UnitTests.csproj +++ b/ChaosBot.UnitTests/ChaosBot.UnitTests.csproj @@ -7,15 +7,9 @@ - - - - - - diff --git a/ChaosBot.UnitTests/DataBaseTests.cs b/ChaosBot.UnitTests/DataBaseTests.cs deleted file mode 100644 index 22a7a05..0000000 --- a/ChaosBot.UnitTests/DataBaseTests.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Data; -using System.Linq; -using System.Threading; -using ChaosBot.Attribute; -using ChaosBot.Database; -using ChaosBot.Database.Entity; -using ChaosBot.Database.Repository; -using Microsoft.Extensions.Configuration; -using NUnit.Framework; - -namespace ChaosBot.UnitTests -{ - public class DataBaseTests - { - [SetUp] - public void SetUp() - { - IConfiguration configuration = Program.LoadConfiguration("./appsettings.json"); - Dependency.Initialize(configuration); - ConfigurationRepository.AppSettingsHandler = configuration; - AssemblyController.RegisterDBEntityType(typeof(TestEntity)); - } - - [TearDown] - public void TearDown() - { - Controller.RawQuery("DROP TABLE TestTable;", readOutput: false); - } - - [Test] - public void Insert_CanInsertDataToDBAndDeleteFromDB_True() - { - var testEntity = new TestEntity(1); - - Assert.AreEqual(0, TestEntity.Query().Count()); - - TestEntity.Query().Insert(testEntity); - - Assert.AreEqual(1, TestEntity.Query().Count()); - - TestEntity.Query().Delete(); - - Assert.AreEqual(0, TestEntity.Query().Count()); - } - - [Test] - public void InsertUpdateDelete_CheckCanInsertUpdateAndDeleteFromDB_True() - { - Assert.AreEqual("", GetDBContent()); - TestEntity.Query().Insert(new TestEntity(5)); - Assert.AreEqual("5", GetDBContent()); - TestEntity.Query().Where("id", 5).Set("id", 6).Update(); - Assert.AreEqual("6", GetDBContent()); - TestEntity.Query().Where("id", 6).Delete(); - Assert.AreEqual("", GetDBContent()); - } - - public string GetDBContent() - { - return string.Join(" ", TestEntity.Query().Distinct().Get().Select(o => o.id).ToArray()); - } - } - - [DBEntity("TestTable")] - public class TestEntity : BaseEntity - { - public long id { get; private set; } - - public TestEntity() {} - - public TestEntity(int id) - { - this.id = id; - } - - public static QueryBuilder Query() - { - return BaseEntity.Query(); - } - - public override void SetFromRow(DataRow row) - { - id = (long)row["id"]; - } - } -} \ No newline at end of file diff --git a/ChaosBot/ChaosBot.csproj b/ChaosBot/ChaosBot.csproj index 851f962..23db4ed 100644 --- a/ChaosBot/ChaosBot.csproj +++ b/ChaosBot/ChaosBot.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + +