diff --git a/Dapper NET45/SqlMapperAsync.cs b/Dapper NET45/SqlMapperAsync.cs
index 98a1819c981ba74f302d9cbf5ad09b6fb40deece..6b85e3bea5826a50a2ca6ac084980e05662b444e 100644
--- a/Dapper NET45/SqlMapperAsync.cs
+++ b/Dapper NET45/SqlMapperAsync.cs
@@ -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
{
diff --git a/Dapper.DNX.Tests/project.json b/Dapper.DNX.Tests/project.json
index 15303f370736ae3669880e329b17942987c677ce..ad1ddd1b4fc171a7b5ded1ed2baa0c4f438718b8 100644
--- a/Dapper.DNX.Tests/project.json
+++ b/Dapper.DNX.Tests/project.json
@@ -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-*",
diff --git a/Dapper.DNX.sln b/Dapper.DNX.sln
index 4c105e3408a4e53b56d6bced80c6bfe24fdf6c0b..10871b501a41310f6589d069d0416a667accc046 100644
--- a/Dapper.DNX.sln
+++ b/Dapper.DNX.sln
@@ -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
diff --git a/Dapper/project.json b/Dapper/project.json
index 84f33503a121a1aa190e1d515ed042310c59e6a4..b9b449f92c961b8766ea077f81a79af0fc0d9fa4 100644
--- a/Dapper/project.json
+++ b/Dapper/project.json
@@ -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-beta3",
+ "version": "1.41-beta4",
"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-*",
diff --git a/DapperTests NET45/DapperTests NET45.csproj b/DapperTests NET45/DapperTests NET45.csproj
index 60e8940691f5404a7e039e715e98c104ab31d5a8..fe5a9270f17a9f4aac4fd2e02c7efa6a91861e4f 100644
--- a/DapperTests NET45/DapperTests NET45.csproj
+++ b/DapperTests NET45/DapperTests NET45.csproj
@@ -19,7 +19,7 @@
full
false
bin\Debug\
- TRACE;DEBUG;EXTERNALS
+ TRACE;DEBUG;EXTERNALS ASYNC
prompt
4
@@ -28,9 +28,10 @@
pdbonly
true
bin\Release\
- TRACE;EXTERNALS
+ TRACE;EXTERNALS ASYNC
prompt
4
+ false
diff --git a/DapperTests NET45/Tests.cs b/DapperTests NET45/Tests.cs
index 58cc48d174c25a15dfa92ae91065ccafa7d17481..2902aa8398f51a660facf137b761fd30e6ab1066 100644
--- a/DapperTests NET45/Tests.cs
+++ b/DapperTests NET45/Tests.cs
@@ -1,4 +1,5 @@
-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
diff --git a/Tests/Program.cs b/Tests/Program.cs
index 7945eeb22031d993a605c1559c4fd08025b523b4..3627b09733b0a8de9f53461e8cf9899bb318bc04 100644
--- a/Tests/Program.cs
+++ b/Tests/Program.cs
@@ -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();
#if DEBUG
- RunTests();
+ RunTests(ref fail, ref skip, ref pass, ref frameworkFail, failNames);
+#if ASYNC
+ RunTests(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(ref int fail, ref int skip, ref int pass, ref int frameworkFail, List 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(m)).ToArray();
- if (activeTests.Length != 0) methods = activeTests;
- List failNames = new List();
- foreach (var method in methods)
+ var tester = new T();
+ using (tester as IDisposable)
{
- if (HasAttribute(method))
- {
- Console.Write("Skipping " + method.Name);
- skip++;
- continue;
- }
- bool expectFrameworkFail = HasAttribute(method);
- Console.Write("Running " + method.Name);
- try
+ MethodInfo[] methods = typeof(T).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
+ var activeTests = methods.Where(m => HasAttribute(m)).ToArray();
+ if (activeTests.Length != 0) methods = activeTests;
+ foreach (var method in methods)
{
- method.Invoke(tester, null);
- if (expectFrameworkFail)
+ if (HasAttribute(method))
{
- Console.WriteLine(" - was expected to framework-fail, but didn't");
- fail++;
- failNames.Add(method.Name);
+ Console.Write("Skipping " + method.Name);
+ skip++;
+ continue;
}
- else
+ bool expectFrameworkFail = HasAttribute(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();
}
}
}