forked from DapperLib/Dapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
95 lines (82 loc) · 3.48 KB
/
Program.cs
File metadata and controls
95 lines (82 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using System.Collections.Generic;
using System.Data.SqlServerCe;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Dapper.Contrib.Tests_NET45
{
class Program
{
static void Main(string[] args)
{
Setup();
RunTests();
Setup();
RunAsyncTests();
Console.ReadKey();
}
private static void Setup()
{
var projLoc = Assembly.GetAssembly(typeof(Program)).Location;
var projFolder = Path.GetDirectoryName(projLoc);
if (File.Exists(projFolder + "\\Test.sdf"))
File.Delete(projFolder + "\\Test.sdf");
var connectionString = "Data Source = " + projFolder + "\\Test.sdf;";
var engine = new SqlCeEngine(connectionString);
engine.CreateDatabase();
using (var connection = new SqlCeConnection(connectionString))
{
connection.Open();
connection.Execute(@" create table Users (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null, Age int not null) ");
connection.Execute(@" create table Automobiles (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null) ");
connection.Execute(@" create table Results (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null, [Order] int not null) ");
}
Console.WriteLine("Created database");
}
private static void RunTests()
{
var tester = new Tests();
foreach (var method in typeof(Tests).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
{
if (method.ReturnType != typeof(Task))
{
Console.Write("Running " + method.Name);
method.Invoke(tester, null);
Console.WriteLine(" - OK!");
}
}
}
private static void RunAsyncTests()
{
var tester = new TestsAsync();
Console.Write("Running TableNameAsync");
Task.WaitAll(tester.TableNameAsync());
Console.WriteLine(" - OK!");
Console.Write("Running TestSimpleGetAsync");
Task.WaitAll(tester.TestSimpleGetAsync());
Console.WriteLine(" - OK!");
Console.Write("Running InsertGetUpdateAsync");
Task.WaitAll(tester.InsertGetUpdateAsync());
Console.WriteLine(" - OK!");
Console.Write("Running InsertCheckKeyAsync");
Task.WaitAll(tester.InsertCheckKeyAsync());
Console.WriteLine(" - OK!");
Console.Write("Running BuilderSelectClauseAsync");
Task.WaitAll(tester.BuilderSelectClauseAsync());
Console.WriteLine(" - OK!");
Console.Write("Running BuilderTemplateWOCompositionAsync");
Task.WaitAll(tester.BuilderTemplateWOCompositionAsync());
Console.WriteLine(" - OK!");
Console.Write("Running InsertFieldWithReservedNameAsync");
Task.WaitAll(tester.InsertFieldWithReservedNameAsync());
Console.WriteLine(" - OK!");
Console.Write("Running DeleteAllAsync");
Task.WaitAll(tester.DeleteAllAsync());
Console.WriteLine(" - OK!");
}
}
}