Skip to content

Commit a45ba4b

Browse files
committed
Add test by SqlLite
1 parent 245bad0 commit a45ba4b

4 files changed

Lines changed: 53 additions & 3 deletions

File tree

DirectSQL.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28307.102
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DirectSQL", "DirectSQL\DirectSQL.csproj", "{A6636FD9-B9C3-44A0-A000-B49FB7161005}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSqlLiteDatabase", "TestSqlLiteDatabase\TestSqlLiteDatabase.csproj", "{7374B388-0BA1-49FD-8051-F17044D01C39}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{A6636FD9-B9C3-44A0-A000-B49FB7161005}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{A6636FD9-B9C3-44A0-A000-B49FB7161005}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{A6636FD9-B9C3-44A0-A000-B49FB7161005}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{7374B388-0BA1-49FD-8051-F17044D01C39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{7374B388-0BA1-49FD-8051-F17044D01C39}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{7374B388-0BA1-49FD-8051-F17044D01C39}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{7374B388-0BA1-49FD-8051-F17044D01C39}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

DirectSQL/Database.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ namespace DirectSQL
77
public abstract class Database
88
{
99

10-
public delegate Task SqlExecution(IDbConnection connection, IDbTransaction transaction);
10+
public delegate void SqlExecution(IDbConnection connection, IDbTransaction transaction);
11+
public delegate Task AsyncSqlExecution(IDbConnection connection, IDbTransaction transaction);
1112

12-
public async Task ProcessAsync(SqlExecution execute)
13+
public async Task ProcessAsync(AsyncSqlExecution execute)
1314
{
1415

1516
using ( var connection = CreateConnection())
@@ -36,7 +37,8 @@ public async Task ProcessAsync(SqlExecution execute)
3637

3738
public void Process(SqlExecution execute)
3839
{
39-
Task task = ProcessAsync(execute);
40+
Task task =
41+
ProcessAsync( async( connection, transaction ) => { execute(connection, transaction); });
4042
task.Wait();
4143

4244
if (task.Exception == null)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
3+
using System.Data;
4+
using DirectSQL.SqlLite;
5+
6+
using System.Threading.Tasks;
7+
8+
namespace TestSqlLiteDatabase
9+
{
10+
[TestClass]
11+
public class ConnectionTest
12+
{
13+
[TestMethod]
14+
public void TestConnect()
15+
{
16+
SqlLiteDatabase db = new SqlLiteDatabase("Data Source=:memory:");
17+
db.Process( async (connection, transaction) =>
18+
{
19+
});
20+
}
21+
}
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
12+
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
13+
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.109.2" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\DirectSQL\DirectSQL.csproj" />
18+
</ItemGroup>
19+
20+
</Project>

0 commit comments

Comments
 (0)