Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Dapper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
Dapper
Commits
7cac3824
Commit
7cac3824
authored
Sep 22, 2019
by
Damir Ainullin
Committed by
Nick Craver
Sep 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced Connection with GetClosedConnection in some unit tests… (#1337)
…cording to their names.
parent
3b0cd9a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
18 deletions
+32
-18
AsyncTests.cs
Dapper.Tests/AsyncTests.cs
+32
-18
No files found.
Dapper.Tests/AsyncTests.cs
View file @
7cac3824
...
@@ -18,12 +18,14 @@ public sealed class MicrosoftSqlClientAsyncTests : AsyncTests<MicrosoftSqlClient
...
@@ -18,12 +18,14 @@ public sealed class MicrosoftSqlClientAsyncTests : AsyncTests<MicrosoftSqlClient
#endif
#endif
[
Collection
(
NonParallelDefinition
.
Name
)]
[
Collection
(
NonParallelDefinition
.
Name
)]
public
sealed
class
SystemSqlClientAsyncQueryCacheTests
:
AsyncQueryCacheTests
<
SystemSqlClientProvider
>
{
public
sealed
class
SystemSqlClientAsyncQueryCacheTests
:
AsyncQueryCacheTests
<
SystemSqlClientProvider
>
{
public
SystemSqlClientAsyncQueryCacheTests
(
ITestOutputHelper
log
)
:
base
(
log
)
{
}
public
SystemSqlClientAsyncQueryCacheTests
(
ITestOutputHelper
log
)
:
base
(
log
)
{
}
}
}
#if MSSQLCLIENT
#if MSSQLCLIENT
[
Collection
(
NonParallelDefinition
.
Name
)]
[
Collection
(
NonParallelDefinition
.
Name
)]
public
sealed
class
MicrosoftSqlClientAsyncQueryCacheTests
:
AsyncQueryCacheTests
<
MicrosoftSqlClientProvider
>
{
public
sealed
class
MicrosoftSqlClientAsyncQueryCacheTests
:
AsyncQueryCacheTests
<
MicrosoftSqlClientProvider
>
{
public
MicrosoftSqlClientAsyncQueryCacheTests
(
ITestOutputHelper
log
)
:
base
(
log
)
{
}
public
MicrosoftSqlClientAsyncQueryCacheTests
(
ITestOutputHelper
log
)
:
base
(
log
)
{
}
}
}
#endif
#endif
...
@@ -32,7 +34,7 @@ public sealed class MicrosoftSqlClientAsyncQueryCacheTests : AsyncQueryCacheTest
...
@@ -32,7 +34,7 @@ public sealed class MicrosoftSqlClientAsyncQueryCacheTests : AsyncQueryCacheTest
public
abstract
class
AsyncTests
<
TProvider
>
:
TestBase
<
TProvider
>
where
TProvider
:
SqlServerDatabaseProvider
public
abstract
class
AsyncTests
<
TProvider
>
:
TestBase
<
TProvider
>
where
TProvider
:
SqlServerDatabaseProvider
{
{
private
DbConnection
_marsConnection
;
private
DbConnection
_marsConnection
;
private
DbConnection
MarsConnection
=>
_marsConnection
??
(
_marsConnection
=
Provider
.
GetOpenConnection
(
true
));
private
DbConnection
MarsConnection
=>
_marsConnection
??
(
_marsConnection
=
Provider
.
GetOpenConnection
(
true
));
[
Fact
]
[
Fact
]
...
@@ -128,9 +130,12 @@ public void TestLongOperationWithCancellation()
...
@@ -128,9 +130,12 @@ public void TestLongOperationWithCancellation()
[
Fact
]
[
Fact
]
public
async
Task
TestBasicStringUsageClosedAsync
()
public
async
Task
TestBasicStringUsageClosedAsync
()
{
{
var
query
=
await
connection
.
QueryAsync
<
string
>(
"select 'abc' as [Value] union all select @txt"
,
new
{
txt
=
"def"
}).
ConfigureAwait
(
false
);
using
(
var
conn
=
GetClosedConnection
())
var
arr
=
query
.
ToArray
();
{
Assert
.
Equal
(
new
[]
{
"abc"
,
"def"
},
arr
);
var
query
=
await
conn
.
QueryAsync
<
string
>(
"select 'abc' as [Value] union all select @txt"
,
new
{
txt
=
"def"
}).
ConfigureAwait
(
false
);
var
arr
=
query
.
ToArray
();
Assert
.
Equal
(
new
[]
{
"abc"
,
"def"
},
arr
);
}
}
}
[
Fact
]
[
Fact
]
...
@@ -159,9 +164,12 @@ public async Task TestExecuteAsync()
...
@@ -159,9 +164,12 @@ public async Task TestExecuteAsync()
[
Fact
]
[
Fact
]
public
void
TestExecuteClosedConnAsyncInner
()
public
void
TestExecuteClosedConnAsyncInner
()
{
{
var
query
=
connection
.
ExecuteAsync
(
"declare @foo table(id int not null); insert @foo values(@id);"
,
new
{
id
=
1
});
using
(
var
conn
=
GetClosedConnection
())
var
val
=
query
.
Result
;
{
Assert
.
Equal
(
1
,
val
);
var
query
=
conn
.
ExecuteAsync
(
"declare @foo table(id int not null); insert @foo values(@id);"
,
new
{
id
=
1
});
var
val
=
query
.
Result
;
Assert
.
Equal
(
1
,
val
);
}
}
}
[
Fact
]
[
Fact
]
...
@@ -248,23 +256,29 @@ public async Task TestMultiAsyncViaFirstOrDefault()
...
@@ -248,23 +256,29 @@ public async Task TestMultiAsyncViaFirstOrDefault()
[
Fact
]
[
Fact
]
public
async
Task
TestMultiClosedConnAsync
()
public
async
Task
TestMultiClosedConnAsync
()
{
{
using
(
SqlMapper
.
GridReader
multi
=
await
connection
.
QueryMultipleAsync
(
"select 1; select 2"
).
ConfigureAwait
(
false
))
using
(
var
conn
=
GetClosedConnection
(
))
{
{
Assert
.
Equal
(
1
,
multi
.
ReadAsync
<
int
>().
Result
.
Single
());
using
(
SqlMapper
.
GridReader
multi
=
await
conn
.
QueryMultipleAsync
(
"select 1; select 2"
).
ConfigureAwait
(
false
))
Assert
.
Equal
(
2
,
multi
.
ReadAsync
<
int
>().
Result
.
Single
());
{
Assert
.
Equal
(
1
,
multi
.
ReadAsync
<
int
>().
Result
.
Single
());
Assert
.
Equal
(
2
,
multi
.
ReadAsync
<
int
>().
Result
.
Single
());
}
}
}
}
}
[
Fact
]
[
Fact
]
public
async
Task
TestMultiClosedConnAsyncViaFirstOrDefault
()
public
async
Task
TestMultiClosedConnAsyncViaFirstOrDefault
()
{
{
using
(
SqlMapper
.
GridReader
multi
=
await
connection
.
QueryMultipleAsync
(
"select 1; select 2; select 3; select 4; select 5;"
).
ConfigureAwait
(
false
))
using
(
var
conn
=
GetClosedConnection
(
))
{
{
Assert
.
Equal
(
1
,
multi
.
ReadFirstOrDefaultAsync
<
int
>().
Result
);
using
(
SqlMapper
.
GridReader
multi
=
await
conn
.
QueryMultipleAsync
(
"select 1; select 2; select 3; select 4; select 5"
).
ConfigureAwait
(
false
))
Assert
.
Equal
(
2
,
multi
.
ReadAsync
<
int
>().
Result
.
Single
());
{
Assert
.
Equal
(
3
,
multi
.
ReadFirstOrDefaultAsync
<
int
>().
Result
);
Assert
.
Equal
(
1
,
multi
.
ReadFirstOrDefaultAsync
<
int
>().
Result
);
Assert
.
Equal
(
4
,
multi
.
ReadAsync
<
int
>().
Result
.
Single
());
Assert
.
Equal
(
2
,
multi
.
ReadAsync
<
int
>().
Result
.
Single
());
Assert
.
Equal
(
5
,
multi
.
ReadFirstOrDefaultAsync
<
int
>().
Result
);
Assert
.
Equal
(
3
,
multi
.
ReadFirstOrDefaultAsync
<
int
>().
Result
);
Assert
.
Equal
(
4
,
multi
.
ReadAsync
<
int
>().
Result
.
Single
());
Assert
.
Equal
(
5
,
multi
.
ReadFirstOrDefaultAsync
<
int
>().
Result
);
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment