Skip to content

Commit 96c43ca

Browse files
committed
Tests - Unknow DB
1 parent 601a09b commit 96c43ca

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

QueryDB.Core.Tests/QueryDBTests.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System.Collections.Generic;
3+
4+
namespace QueryDB.Core.Tests
5+
{
6+
[TestClass]
7+
public class QueryDBTests : TestBase
8+
{
9+
10+
#region Unknow DB Tests
11+
12+
[TestMethod]
13+
[TestCategory(DB_TESTS), TestCategory(UNKNOW_DB_TESTS)]
14+
public void ExecuteCommand_UnknownDB_ReturnsNegativeOne()
15+
{
16+
string sqlStatement = "DELETE FROM users";
17+
18+
var dbContext = new DBContext((DB)999, "some_invalid_connection_string");
19+
var result = dbContext.ExecuteCommand(sqlStatement);
20+
21+
Assert.AreEqual(-1, result);
22+
}
23+
24+
[TestMethod]
25+
[TestCategory(DB_TESTS), TestCategory(UNKNOW_DB_TESTS)]
26+
public void ExecuteTransaction_UnknownDB_ReturnsFalse()
27+
{
28+
var sqlStatements = new List<string>
29+
{
30+
"DELETE FROM users"
31+
};
32+
33+
var dbContext = new DBContext((DB)999, "some_invalid_connection_string");
34+
var result = dbContext.ExecuteTransaction(sqlStatements);
35+
36+
Assert.IsFalse(result);
37+
}
38+
39+
#endregion
40+
41+
}
42+
}

QueryDB.Core.Tests/TestBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class TestBase
2020
protected const string ORACLE_TESTS = "ORACLE-TESTS";
2121
protected const string POSTGRESQL_TESTS = "POSTGRESQL-TESTS";
2222
protected const string QUERY_DB_EXCEPTION_TESTS = "QUERY-DB-EXCEPTION-TESTS";
23+
protected const string UNKNOW_DB_TESTS = "UNKNOW-DB-TESTS";
2324

2425
[AssemblyInitialize]
2526
internal void CheckDockerImages()

0 commit comments

Comments
 (0)