Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Dapper
提交
4603c26c
D
Dapper
项目概览
int
/
Dapper
11 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dapper
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4603c26c
编写于
5月 05, 2015
作者:
M
Marc Gravell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge async+sync tests for DNX; allow async for CoreCLR; 1.41-beta4
上级
f32d318f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
114 addition
and
67 deletion
+114
-67
Dapper NET45/SqlMapperAsync.cs
Dapper NET45/SqlMapperAsync.cs
+13
-0
Dapper.DNX.Tests/project.json
Dapper.DNX.Tests/project.json
+2
-2
Dapper.DNX.sln
Dapper.DNX.sln
+1
-0
Dapper/project.json
Dapper/project.json
+2
-2
DapperTests NET45/DapperTests NET45.csproj
DapperTests NET45/DapperTests NET45.csproj
+3
-2
DapperTests NET45/Tests.cs
DapperTests NET45/Tests.cs
+14
-3
Tests/Program.cs
Tests/Program.cs
+79
-58
未找到文件。
Dapper NET45/SqlMapperAsync.cs
浏览文件 @
4603c26c
...
...
@@ -8,6 +8,19 @@
using
System.Threading
;
using
System.Threading.Tasks
;
#if DNXCORE50
using
IDbDataParameter
=
global
::
System
.
Data
.
Common
.
DbParameter
;
using
IDataParameter
=
global
::
System
.
Data
.
Common
.
DbParameter
;
using
IDbTransaction
=
global
::
System
.
Data
.
Common
.
DbTransaction
;
using
IDbConnection
=
global
::
System
.
Data
.
Common
.
DbConnection
;
using
IDbCommand
=
global
::
System
.
Data
.
Common
.
DbCommand
;
using
IDataReader
=
global
::
System
.
Data
.
Common
.
DbDataReader
;
using
IDataRecord
=
global
::
System
.
Data
.
Common
.
DbDataReader
;
using
IDataParameterCollection
=
global
::
System
.
Data
.
Common
.
DbParameterCollection
;
using
DataException
=
global
::
System
.
InvalidOperationException
;
using
ApplicationException
=
global
::
System
.
InvalidOperationException
;
#endif
namespace
Dapper
{
...
...
Dapper.DNX.Tests/project.json
浏览文件 @
4603c26c
...
...
@@ -6,7 +6,7 @@
"commands"
:
{
"Dapper.DNX.Tests"
:
"Dapper.DNX.Tests"
},
"compile"
:
[
"../Tests/Tests.cs"
,
"../Tests/Program.cs"
,
"../Tests/Assert.cs"
],
"compile"
:
[
"../Tests/Tests.cs"
,
"../Tests/Program.cs"
,
"../Tests/Assert.cs"
,
"../DapperTests NET45/Tests.cs"
],
"compilationOptions"
:
{
"define"
:
[
"NOEXTERNALS"
]
},
"frameworks"
:
{
"net45"
:
{
...
...
@@ -36,7 +36,7 @@
},
"dnxcore50"
:
{
"compilationOptions"
:
{
"define"
:
[
],
"warningsAsErrors"
:
true
},
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"dependencies"
:
{
"System.Console"
:
"4.0.0-beta-*"
,
"System.Reflection"
:
"4.0.10-beta-*"
,
...
...
Dapper.DNX.sln
浏览文件 @
4603c26c
...
...
@@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Dapper NET40\SqlMapper.cs = Dapper NET40\SqlMapper.cs
Dapper NET45\SqlMapperAsync.cs = Dapper NET45\SqlMapperAsync.cs
Tests\Tests.cs = Tests\Tests.cs
DapperTests NET45\Tests.cs = DapperTests NET45\Tests.cs
EndProjectSection
EndProject
Global
...
...
Dapper/project.json
浏览文件 @
4603c26c
...
...
@@ -5,7 +5,7 @@
"licenseUrl"
:
"http://www.apache.org/licenses/LICENSE-2.0"
,
"summary"
:
"A high performance Micro-ORM"
,
"description"
:
"A high performance Micro-ORM supporting Sql Server, MySQL, Sqlite, SqlCE, Firebird etc.."
,
"version"
:
"1.41-beta
3
"
,
"version"
:
"1.41-beta
4
"
,
"compile"
:
[
"../Dapper NET40/*.cs"
,
"../Dapper NET45/*.cs"
],
"title"
:
"Dapper dot net"
,
"tags"
:
[
"orm"
,
"sql"
,
"micro-orm"
],
...
...
@@ -44,7 +44,7 @@
}
},
"dnxcore50"
:
{
"compilationOptions"
:
{
"define"
:
[
],
"warningsAsErrors"
:
true
},
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"dependencies"
:
{
"System.Text.RegularExpressions"
:
"4.0.10-beta-*"
,
"System.Collections"
:
"4.0.10-beta-*"
,
...
...
DapperTests NET45/DapperTests NET45.csproj
浏览文件 @
4603c26c
...
...
@@ -19,7 +19,7 @@
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
TRACE;DEBUG;EXTERNALS
</DefineConstants>
<DefineConstants>
TRACE;DEBUG;EXTERNALS
ASYNC
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
...
...
@@ -28,9 +28,10 @@
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE;EXTERNALS
</DefineConstants>
<DefineConstants>
TRACE;EXTERNALS
ASYNC
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<AllowUnsafeBlocks>
false
</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"System"
/>
...
...
DapperTests NET45/Tests.cs
浏览文件 @
4603c26c
using
System.Linq
;
#
if
ASYNC
using
System.Linq
;
using
Dapper
;
using
SqlMapper
;
using
System.Data
;
...
...
@@ -8,6 +9,14 @@
using
System.Threading
;
using
System.Data.SqlClient
;
#if DNXCORE50
using
IDbCommand
=
global
::
System
.
Data
.
Common
.
DbCommand
;
using
IDbDataParameter
=
global
::
System
.
Data
.
Common
.
DbParameter
;
using
IDbConnection
=
global
::
System
.
Data
.
Common
.
DbConnection
;
using
IDbTransaction
=
global
::
System
.
Data
.
Common
.
DbTransaction
;
using
IDataReader
=
global
::
System
.
Data
.
Common
.
DbDataReader
;
#endif
namespace
DapperTests_NET45
{
public
class
Tests
...
...
@@ -180,7 +189,7 @@ public void TestMultiClosedConnAsync()
}
}
}
#if EXTERNALS
public
void
ExecuteReaderOpenAsync
()
{
using
(
var
conn
=
Program
.
GetOpenConnection
())
...
...
@@ -209,6 +218,7 @@ public void ExecuteReaderClosedAsync()
((
int
)
dt
.
Rows
[
0
][
1
]).
IsEqualTo
(
4
);
}
}
#endif
public
void
LiteralReplacementOpen
()
{
...
...
@@ -765,4 +775,5 @@ select @@Name
}
}
}
}
\ No newline at end of file
}
#
endif
\ No newline at end of file
Tests/Program.cs
浏览文件 @
4603c26c
...
...
@@ -37,12 +37,23 @@ class Program
public
const
string
ConnectionString
=
"Data Source=.;Initial Catalog=tempdb;Integrated Security=True"
,
OleDbConnectionString
=
"Provider=SQLOLEDB;Data Source=.;Initial Catalog=tempdb;Integrated Security=SSPI"
;
public
static
SqlConnection
GetOpenConnection
()
public
static
SqlConnection
GetOpenConnection
(
bool
mars
=
false
)
{
var
connection
=
new
SqlConnection
(
ConnectionString
);
var
cs
=
ConnectionString
;
if
(
mars
)
{
SqlConnectionStringBuilder
scsb
=
new
SqlConnectionStringBuilder
(
cs
);
scsb
.
MultipleActiveResultSets
=
true
;
cs
=
scsb
.
ConnectionString
;
}
var
connection
=
new
SqlConnection
(
cs
);
connection
.
Open
();
return
connection
;
}
public
static
SqlConnection
GetClosedConnection
()
{
return
new
SqlConnection
(
ConnectionString
);
}
static
void
RunPerformanceTests
()
{
...
...
@@ -63,8 +74,28 @@ static void Main()
#else
Console
.
WriteLine
(
Environment
.
Version
);
#endif
int
fail
=
0
,
skip
=
0
,
pass
=
0
,
frameworkFail
=
0
;
var
failNames
=
new
List
<
string
>();
#if DEBUG
RunTests
();
RunTests
<
SqlMapper
.
Tests
>(
ref
fail
,
ref
skip
,
ref
pass
,
ref
frameworkFail
,
failNames
);
#if ASYNC
RunTests
<
DapperTests_NET45
.
Tests
>(
ref
fail
,
ref
skip
,
ref
pass
,
ref
frameworkFail
,
failNames
);
#endif
if
(
fail
==
0
)
{
Console
.
WriteLine
(
"(all tests successful)"
);
}
else
{
Console
.
WriteLine
(
"Failures:"
);
foreach
(
var
failName
in
failNames
)
{
Console
.
WriteLine
(
failName
);
}
}
Console
.
WriteLine
(
"Passed: {0}, Failed: {1}, Skipped: {2}, Framework-fail: {3}"
,
pass
,
fail
,
skip
,
frameworkFail
);
#else
EnsureDBSetup
();
RunPerformanceTests
();
...
...
@@ -136,76 +167,66 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000),
#endif
}
private
static
void
RunTests
()
private
static
void
RunTests
<
T
>(
ref
int
fail
,
ref
int
skip
,
ref
int
pass
,
ref
int
frameworkFail
,
List
<
string
>
failNames
)
where
T
:
class
,
new
()
{
var
tester
=
new
Tests
();
int
fail
=
0
,
skip
=
0
,
pass
=
0
,
frameworkFail
=
0
;
MethodInfo
[]
methods
=
typeof
(
Tests
).
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
DeclaredOnly
);
var
activeTests
=
methods
.
Where
(
m
=>
HasAttribute
<
ActiveTestAttribute
>(
m
)).
ToArray
();
if
(
activeTests
.
Length
!=
0
)
methods
=
activeTests
;
List
<
string
>
failNames
=
new
List
<
string
>();
foreach
(
var
method
in
methods
)
var
tester
=
new
T
();
using
(
tester
as
IDisposable
)
{
if
(
HasAttribute
<
SkipTestAttribute
>(
method
))
{
Console
.
Write
(
"Skipping "
+
method
.
Name
);
skip
++;
continue
;
}
bool
expectFrameworkFail
=
HasAttribute
<
FrameworkFail
>(
method
);
Console
.
Write
(
"Running "
+
method
.
Name
);
try
MethodInfo
[]
methods
=
typeof
(
T
).
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
DeclaredOnly
);
var
activeTests
=
methods
.
Where
(
m
=>
HasAttribute
<
ActiveTestAttribute
>(
m
)).
ToArray
();
if
(
activeTests
.
Length
!=
0
)
methods
=
activeTests
;
foreach
(
var
method
in
methods
)
{
method
.
Invoke
(
tester
,
null
);
if
(
expectFrameworkFail
)
if
(
HasAttribute
<
SkipTestAttribute
>(
method
))
{
Console
.
Write
Line
(
" - was expected to framework-fail, but didn't"
);
fail
++;
failNames
.
Add
(
method
.
Name
)
;
Console
.
Write
(
"Skipping "
+
method
.
Name
);
skip
++;
continue
;
}
else
bool
expectFrameworkFail
=
HasAttribute
<
FrameworkFail
>(
method
);
Console
.
Write
(
"Running "
+
method
.
Name
);
try
{
Console
.
WriteLine
(
" - OK!"
);
pass
++;
method
.
Invoke
(
tester
,
null
);
if
(
expectFrameworkFail
)
{
Console
.
WriteLine
(
" - was expected to framework-fail, but didn't"
);
fail
++;
failNames
.
Add
(
method
.
Name
);
}
else
{
Console
.
WriteLine
(
" - OK!"
);
pass
++;
}
}
}
catch
(
TargetInvocationException
tie
)
{
Console
.
WriteLine
(
" - "
+
tie
.
InnerException
.
Message
);
if
(
expectFrameworkFail
)
catch
(
TargetInvocationException
tie
)
{
frameworkFail
++;
Console
.
WriteLine
(
" - "
+
tie
.
InnerException
.
Message
);
if
(
expectFrameworkFail
)
{
frameworkFail
++;
}
else
{
fail
++;
failNames
.
Add
(
method
.
Name
);
if
(
tie
.
InnerException
is
TypeInitializationException
)
{
Console
.
WriteLine
(
"> "
+
tie
.
InnerException
.
InnerException
.
Message
);
}
}
}
else
catch
(
Exception
ex
)
{
fail
++;
Console
.
WriteLine
(
" - "
+
ex
.
Message
);
failNames
.
Add
(
method
.
Name
);
if
(
tie
.
InnerException
is
TypeInitializationException
)
{
Console
.
WriteLine
(
"> "
+
tie
.
InnerException
.
InnerException
.
Message
);
}
}
}
catch
(
Exception
ex
)
{
fail
++;
Console
.
WriteLine
(
" - "
+
ex
.
Message
);
failNames
.
Add
(
method
.
Name
);
}
}
Console
.
WriteLine
();
Console
.
WriteLine
(
"Passed: {0}, Failed: {1}, Skipped: {2}, Framework-fail: {3}"
,
pass
,
fail
,
skip
,
frameworkFail
);
if
(
fail
==
0
)
{
Console
.
WriteLine
(
"(all tests successful)"
);
}
else
{
Console
.
WriteLine
(
"Failures:"
);
foreach
(
var
failName
in
failNames
)
{
Console
.
WriteLine
(
failName
);
}
Console
.
WriteLine
();
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录