mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-29 21:29:17 +08:00
This eliminates the dual solutions and brings Contrib into the project.json fold. - Tests are ported to xUnit though SQLite is disabled on DNX due to Issue #375 (Interop loads fail in the VS runner and params are busted regardless). - Projects are consolidated down to what's currently possible with project.json. - Contrib moved to: Dapper.Contrib and Dapper.Tests.Contrib (so tests appear at the end, no other reason vs. Dapper.Contrib.Tests) - EF moved to: Dapper.EntityFramework(.StrongName) - Rainbow moved to: Dapper.Rainbow - SqlBuilder moved to: Dapper.SqlBuilder - Packages are removed since it's not current-tooling friendly to keep them (nor was it using them). - xUnit implemented in Contrib via abstracts - this allow us to very quickly add any database provider to the rig in a very concise way. - Contrib unit tests fixed in various places - they were not parallel-runner friendly - Nuspecs removed, since they aren't used anymore (to eliminate confusion) - Removed speed tests for libraries that aren't on current versions of .Net (what would we be comparing?) - Perf tests moved to Dapper.Tests (consolidation from Dapper.DNX.Tests), but aren't activated yet (no define)
93 lines
2.9 KiB
C#
93 lines
2.9 KiB
C#
using Dapper;
|
|
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using Xunit;
|
|
|
|
#if COREFX
|
|
using IDbCommand = System.Data.Common.DbCommand;
|
|
using IDbDataParameter = System.Data.Common.DbParameter;
|
|
using IDbConnection = System.Data.Common.DbConnection;
|
|
using IDbTransaction = System.Data.Common.DbTransaction;
|
|
using IDataReader = System.Data.Common.DbDataReader;
|
|
#endif
|
|
|
|
namespace Dapper.Tests
|
|
{
|
|
public partial class TestSuite
|
|
{
|
|
[Fact]
|
|
public void TestEnumWeirdness()
|
|
{
|
|
connection.Query<TestEnumClass>("select null as [EnumEnum]").First().EnumEnum.IsEqualTo(null);
|
|
connection.Query<TestEnumClass>("select cast(1 as tinyint) as [EnumEnum]").First().EnumEnum.IsEqualTo(TestEnum.Bla);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestEnumStrings()
|
|
{
|
|
connection.Query<TestEnumClassNoNull>("select 'BLA' as [EnumEnum]").First().EnumEnum.IsEqualTo(TestEnum.Bla);
|
|
connection.Query<TestEnumClassNoNull>("select 'bla' as [EnumEnum]").First().EnumEnum.IsEqualTo(TestEnum.Bla);
|
|
|
|
connection.Query<TestEnumClass>("select 'BLA' as [EnumEnum]").First().EnumEnum.IsEqualTo(TestEnum.Bla);
|
|
connection.Query<TestEnumClass>("select 'bla' as [EnumEnum]").First().EnumEnum.IsEqualTo(TestEnum.Bla);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestEnumParamsWithNullable()
|
|
{
|
|
EnumParam a = EnumParam.A;
|
|
EnumParam? b = EnumParam.B, c = null;
|
|
var obj = connection.Query<EnumParamObject>("select @a as A, @b as B, @c as C",
|
|
new { a, b, c }).Single();
|
|
obj.A.IsEqualTo(EnumParam.A);
|
|
obj.B.IsEqualTo(EnumParam.B);
|
|
obj.C.IsEqualTo(null);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestEnumParamsWithoutNullable()
|
|
{
|
|
EnumParam a = EnumParam.A;
|
|
EnumParam b = EnumParam.B, c = 0;
|
|
var obj = connection.Query<EnumParamObjectNonNullable>("select @a as A, @b as B, @c as C",
|
|
new { a, b, c }).Single();
|
|
obj.A.IsEqualTo(EnumParam.A);
|
|
obj.B.IsEqualTo(EnumParam.B);
|
|
obj.C.IsEqualTo((EnumParam)0);
|
|
}
|
|
enum EnumParam : short
|
|
{
|
|
None, A, B
|
|
}
|
|
class EnumParamObject
|
|
{
|
|
public EnumParam A { get; set; }
|
|
public EnumParam? B { get; set; }
|
|
public EnumParam? C { get; set; }
|
|
}
|
|
class EnumParamObjectNonNullable
|
|
{
|
|
public EnumParam A { get; set; }
|
|
public EnumParam? B { get; set; }
|
|
public EnumParam? C { get; set; }
|
|
}
|
|
|
|
|
|
|
|
|
|
enum TestEnum : byte
|
|
{
|
|
Bla = 1
|
|
}
|
|
class TestEnumClass
|
|
{
|
|
public TestEnum? EnumEnum { get; set; }
|
|
}
|
|
class TestEnumClassNoNull
|
|
{
|
|
public TestEnum EnumEnum { get; set; }
|
|
}
|
|
}
|
|
}
|