mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-23 00:58:32 +08:00
bdebedea41
This change: - Removes the Assert shim - Uses recommended xUnit methods (improving fail errors) - Cleans up exception tests - General test formatting fixes - Removes the netcoerapp1.0 only testing (oops commit)
77 lines
2.2 KiB
C#
77 lines
2.2 KiB
C#
using System;
|
|
using System.Data.SqlClient;
|
|
using Xunit;
|
|
|
|
namespace Dapper.Tests
|
|
{
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
|
public sealed class FactLongRunningAttribute : FactAttribute
|
|
{
|
|
public FactLongRunningAttribute()
|
|
{
|
|
#if !LONG_RUNNING
|
|
Skip = "Long running";
|
|
#endif
|
|
}
|
|
|
|
public string Url { get; private set; }
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
|
public class FactRequiredCompatibilityLevelAttribute : FactAttribute
|
|
{
|
|
public FactRequiredCompatibilityLevelAttribute(int level) : base()
|
|
{
|
|
if (DetectedLevel < level)
|
|
{
|
|
Skip = $"Compatibility level {level} required; detected {DetectedLevel}";
|
|
}
|
|
}
|
|
|
|
public const int SqlServer2016 = 130;
|
|
public static readonly int DetectedLevel;
|
|
static FactRequiredCompatibilityLevelAttribute()
|
|
{
|
|
using (var conn = TestBase.GetOpenConnection())
|
|
{
|
|
try
|
|
{
|
|
DetectedLevel = conn.QuerySingle<int>("SELECT compatibility_level FROM sys.databases where name = DB_NAME()");
|
|
}
|
|
catch { /* don't care */ }
|
|
}
|
|
}
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
|
public class FactUnlessCaseSensitiveDatabaseAttribute : FactAttribute
|
|
{
|
|
public FactUnlessCaseSensitiveDatabaseAttribute() : base()
|
|
{
|
|
if (IsCaseSensitive)
|
|
{
|
|
Skip = "Case sensitive database";
|
|
}
|
|
}
|
|
|
|
public static readonly bool IsCaseSensitive;
|
|
static FactUnlessCaseSensitiveDatabaseAttribute()
|
|
{
|
|
using (var conn = TestBase.GetOpenConnection())
|
|
{
|
|
try
|
|
{
|
|
conn.Execute("declare @i int; set @I = 1;");
|
|
}
|
|
catch (SqlException s)
|
|
{
|
|
if (s.Number == 137)
|
|
IsCaseSensitive = true;
|
|
else
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|