public void TakeHint( [Values(TakeHints.Percent, TakeHints.WithTies, TakeHints.Percent | TakeHints.WithTies)] TakeHints takeHint ) { if (!UserProviders.ContainsKey(ProviderName.SqlServer)) { return; } using (var db = GetDataContext(ProviderName.SqlServer)) { var query = from c1 in db.Child from c2 in db.Child.Take(10, takeHint) select new { c1, c2 }; var sql = query.ToString(); Console.WriteLine(sql); if (takeHint.HasFlag(TakeHints.Percent)) { Assert.That(sql, Contains.Substring("PERCENT")); } if (takeHint.HasFlag(TakeHints.WithTies)) { Assert.That(sql, Contains.Substring("WITH TIES")); } } }
public void TestInlined( [Values("tableName1", "tableName2")] string tableName, [Values("database1", "database2")] string databaseName, [Values("owner1", "owner2")] string ownerName, [Values("schema1", "schema2")] string schemaName ) { if (!UserProviders.ContainsKey(ProviderName.SqlServer)) { return; } using (var db = GetDataContext(ProviderName.SqlServer)) { var query = from c in db.Child from cc in ( from c1 in db.Child.DatabaseName(databaseName).OwnerName(ownerName).SchemaName(schemaName) .TableName(tableName) from c2 in db.Child.DatabaseName(databaseName).OwnerName(ownerName).SchemaName(schemaName) .TableName(tableName) select new { c1, c2 } ) select cc; var sql = query.ToString(); Console.WriteLine(sql); Assert.That(CountOccurences(sql, tableName), Is.EqualTo(2)); Assert.That(CountOccurences(sql, databaseName), Is.EqualTo(2)); // Assert.That(CountOccurences(sql, ownerName), Is.EqualTo(2)); Assert.That(CountOccurences(sql, schemaName), Is.EqualTo(2)); } }
public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite) { var builder = new NUnitTestCaseBuilder(); TestMethod test = null; var hasTest = false; foreach (var provider in _providerNames) { var isIgnore = !UserProviders.ContainsKey(provider); var data = new TestCaseParameters(new object[] { provider }); test = builder.BuildTestMethod(method, suite, data); test.Properties.Set(PropertyNames.Category, provider); SetName(test, method, provider, false); if (isIgnore) { test.RunState = RunState.Ignored; test.Properties.Set(PropertyNames.SkipReason, "Provider is disabled. See UserDataProviders.txt"); continue; } hasTest = true; yield return(test); if (_includeLinqService) { data = new TestCaseParameters(new object[] { provider + ".LinqService" }); test = builder.BuildTestMethod(method, suite, data); test.Properties.Set(PropertyNames.Category, provider); SetName(test, method, provider, true); yield return(test); } } if (!hasTest) { yield return(test); } }
public void TesSqlQueryDependent( [Values( "MIN", "MAX", "AVG", "COUNT" )] string funcName, [Values( nameof(ALLTYPE.ID), nameof(ALLTYPE.BIGINTDATATYPE), nameof(ALLTYPE.SMALLINTDATATYPE), nameof(ALLTYPE.DECIMALDATATYPE), nameof(ALLTYPE.DECFLOATDATATYPE), nameof(ALLTYPE.INTDATATYPE), nameof(ALLTYPE.REALDATATYPE), nameof(ALLTYPE.TIMEDATATYPE) )] string fieldName) { if (!UserProviders.ContainsKey(ProviderName.SQLite)) { return; } using (var db = GetDataContext(ProviderName.SQLite)) { var query = from t in db.GetTable <ALLTYPE>() from c in db.GetTable <Child>() select new { Aggregate = AggregateFunc(funcName, fieldName) }; var sql = query.ToString(); Console.WriteLine(sql); Assert.That(sql, Contains.Substring(funcName).And.Contains(fieldName)); } }
public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite) { var explic = method.GetCustomAttributes <ExplicitAttribute>(true) .Cast <IApplyToTest>() .Union(method.GetCustomAttributes <IgnoreAttribute>(true)) .ToList(); var builder = new NUnitTestCaseBuilder(); TestMethod test = null; var hasTest = false; foreach (var provider in _providerNames) { var isIgnore = !UserProviders.ContainsKey(provider); foreach (var parameters in GetParameters(provider)) { var data = new TestCaseParameters(parameters); test = builder.BuildTestMethod(method, suite, data); foreach (var attr in explic) { attr.ApplyToTest(test); } test.Properties.Set(PropertyNames.Order, GetOrder(method)); //test.Properties.Set(PropertyNames.ParallelScope, ParallelScope); test.Properties.Set(PropertyNames.Category, provider); SetName(test, method, provider, false); if (isIgnore) { if (test.RunState != RunState.NotRunnable && test.RunState != RunState.Explicit) { test.RunState = RunState.Ignored; } test.Properties.Set(PropertyNames.SkipReason, "Provider is disabled. See UserDataProviders.txt"); continue; } hasTest = true; yield return(test); } #if !NETSTANDARD && !MONO if (!isIgnore && _includeLinqService) { foreach (var paremeters in GetParameters(provider + ".LinqService")) { var data = new TestCaseParameters(paremeters); test = builder.BuildTestMethod(method, suite, data); foreach (var attr in explic) { attr.ApplyToTest(test); } test.Properties.Set(PropertyNames.Order, GetOrder(method)); //test.Properties.Set(PropertyNames.ParallelScope, ParallelScope); test.Properties.Set(PropertyNames.Category, provider); SetName(test, method, provider, true); yield return(test); } } #endif } if (!hasTest) { yield return(test); } }
public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite) { var tests = UserProviders.ContainsKey(_providerName) ? new[] { new TypeTestData("bigintDataType", 0, (n, t, c) => t.TestTypeEx <long?> (c, n, DataType.Int64), 1000000), new TypeTestData("bigintDataType", 1, (n, t, c) => t.TestTypeEx <long?> (c, n, DataType.Int64), 1000000), new TypeTestData("numericDataType", (n, t, c) => t.TestTypeEx <decimal?> (c, n, DataType.Decimal), 9999999m), new TypeTestData("smallintDataType", (n, t, c) => t.TestTypeEx <short?> (c, n, DataType.Int16), 25555), new TypeTestData("intDataType", (n, t, c) => t.TestTypeEx <int?> (c, n, DataType.Int32), 7777777), // new TypeTestData("moneyDataType", (n,t,c) => t.TestTypeEx<decimal?> (c, n, DataType.Money), 100000m), new TypeTestData("doubleDataType", (n, t, c) => t.TestTypeEx <double?> (c, n, DataType.Double), 20.31d), new TypeTestData("realDataType", (n, t, c) => t.TestTypeEx <float?> (c, n, DataType.Single), 16.2f), #if NPG2 new TypeTestData("timestampDataType", (n, t, c) => t.TestTypeEx <NpgsqlTimeStamp?> (c, n), new NpgsqlTimeStamp(2012, 12, 12, 12, 12, 12)), new TypeTestData("timestampTZDataType", (n, t, c) => t.TestTypeEx <NpgsqlTimeStampTZ?>(c, n), new NpgsqlTimeStampTZ(2012, 12, 12, 11, 12, 12, new NpgsqlTimeZone(-5, 0))), new TypeTestData("timeDataType", (n, t, c) => t.TestTypeEx <NpgsqlTime?> (c, n), new NpgsqlTime(12, 12, 12)), new TypeTestData("timeTZDataType", (n, t, c) => t.TestTypeEx <NpgsqlTimeTZ?> (c, n), new NpgsqlTimeTZ(12, 12, 12)), new TypeTestData("intervalDataType", (n, t, c) => t.TestTypeEx <NpgsqlInterval?> (c, n), new NpgsqlInterval(1, 3, 5, 20)), new TypeTestData("bitDataType", (n, t, c) => t.TestTypeEx <BitString?> (c, n), new BitString(new[] { true, false, true })), new TypeTestData("macaddrDataType", (n, t, c) => t.TestTypeEx <NpgsqlMacAddress?> (c, n), new NpgsqlMacAddress("01:02:03:04:05:06")), #else // new TypeTestData("timestampDataType", (n,t,c) => t.TestTypeEx<NpgsqlTimeStamp?> (c, n), new NpgsqlTimeStamp(2012, 12, 12, 12, 12, 12)), // new TypeTestData("timestampTZDataType", (n,t,c) => t.TestTypeEx<NpgsqlTimeStampTZ?>(c, n), new NpgsqlTimeStampTZ(2012, 12, 12, 11, 12, 12, new NpgsqlTimeZone(-5, 0))), new TypeTestData("timeDataType", (n, t, c) => t.TestTypeEx <TimeSpan?> (c, n), new TimeSpan(12, 12, 12)), // new TypeTestData("timeTZDataType", (n,t,c) => t.TestTypeEx<NpgsqlTimeTZ?> (c, n), new NpgsqlTimeTZ(12, 12, 12)), // new TypeTestData("intervalDataType", (n,t,c) => t.TestTypeEx<TimeSpan?> (c, n), new TimeSpan(1, 3, 5, 20)), new TypeTestData("bitDataType", (n, t, c) => t.TestTypeEx <BitArray> (c, n), new BitArray(new[] { true, false, true })), new TypeTestData("varBitDataType", (n, t, c) => t.TestTypeEx <BitArray> (c, n), new BitArray(new[] { true, false, true, true })), new TypeTestData("macaddrDataType", (n, t, c) => t.TestTypeEx <PhysicalAddress> (c, n, skipDefaultNull: true), new PhysicalAddress(new byte[] { 1, 2, 3, 4, 5, 6 })), #endif new TypeTestData("timestampDataType", (n, t, c) => t.TestTypeEx <DateTime?> (c, n, DataType.DateTime2), new DateTime(2012, 12, 12, 12, 12, 12)), new TypeTestData("timestampTZDataType", (n, t, c) => t.TestTypeEx <DateTimeOffset?> (c, n, DataType.DateTimeOffset), new DateTimeOffset(2012, 12, 12, 11, 12, 12, new TimeSpan(-5, 0, 0))), new TypeTestData("dateDataType", 0, (n, t, c) => t.TestTypeEx <NpgsqlDate?> (c, n, skipDefaultNull: true), new NpgsqlDate(2012, 12, 12)), new TypeTestData("dateDataType", 1, (n, t, c) => t.TestTypeEx <DateTime?> (c, n, DataType.Date), new DateTime(2012, 12, 12)), new TypeTestData("charDataType", 0, (n, t, c) => t.TestTypeEx <char?> (c, n, DataType.Char), '1'), new TypeTestData("charDataType", 1, (n, t, c) => t.TestTypeEx <string> (c, n, DataType.Char, skipDefaultNull: true), "1"), new TypeTestData("charDataType", 2, (n, t, c) => t.TestTypeEx <string> (c, n, DataType.NChar, skipDefaultNull: true), "1"), new TypeTestData("varcharDataType", 0, (n, t, c) => t.TestTypeEx <string> (c, n, DataType.VarChar, skipDefaultNull: true), "234"), new TypeTestData("varcharDataType", 1, (n, t, c) => t.TestTypeEx <string> (c, n, DataType.NVarChar, skipDefaultNull: true), "234"), new TypeTestData("textDataType", (n, t, c) => t.TestTypeEx <string> (c, n, DataType.Text, skipDefaultNull: true), "567"), new TypeTestData("binaryDataType", 0, (n, t, c) => t.TestTypeEx <byte[]> (c, n, DataType.Binary), new byte[] { 42 }), new TypeTestData("binaryDataType", 1, (n, t, c) => t.TestTypeEx <byte[]> (c, n, DataType.VarBinary), new byte[] { 42 }), new TypeTestData("binaryDataType", 2, (n, t, c) => t.TestTypeEx <Binary> (c, n, DataType.VarBinary).ToArray(), new byte[] { 42 }), new TypeTestData("uuidDataType", (n, t, c) => t.TestTypeEx <Guid?> (c, n, DataType.Guid), new Guid("6F9619FF-8B86-D011-B42D-00C04FC964FF")), new TypeTestData("booleanDataType", (n, t, c) => t.TestTypeEx <bool?> (c, n, DataType.Boolean), true), // new TypeTestData("colorDataType", (n,t,c) => t.TestTypeEx<string> (c, n, skipDefaultNull:true, skipDefault:true,skipUndefined:true), "Green"), new TypeTestData("pointDataType", (n, t, c) => t.TestTypeEx <NpgsqlPoint?> (c, n, skipNull: true, skipNotNull: true), new NpgsqlPoint(1, 2)), new TypeTestData("lsegDataType", (n, t, c) => t.TestTypeEx <NpgsqlLSeg?> (c, n, skipDefaultNull: true), new NpgsqlLSeg(new NpgsqlPoint(1, 2), new NpgsqlPoint(3, 4))), new TypeTestData("boxDataType", (n, t, c) => t.TestTypeEx <NpgsqlBox?> (c, n, skipDefaultNull: true).ToString(), new NpgsqlBox(new NpgsqlPoint(3, 4), new NpgsqlPoint(1, 2)).ToString()), new TypeTestData("pathDataType", (n, t, c) => t.TestTypeEx <NpgsqlPath?> (c, n, skipDefaultNull: true), new NpgsqlPath(new NpgsqlPoint(1, 2), new NpgsqlPoint(3, 4))), new TypeTestData("polygonDataType", (n, t, c) => t.TestTypeEx <NpgsqlPolygon?> (c, n, skipNull: true, skipNotNull: true), new NpgsqlPolygon(new NpgsqlPoint(1, 2), new NpgsqlPoint(3, 4))), new TypeTestData("circleDataType", (n, t, c) => t.TestTypeEx <NpgsqlCircle?> (c, n, skipDefaultNull: true), new NpgsqlCircle(new NpgsqlPoint(1, 2), 3)), new TypeTestData("inetDataType", (n, t, c) => t.TestTypeEx <NpgsqlInet?> (c, n, skipDefaultNull: true), new NpgsqlInet(new IPAddress(new byte[] { 192, 168, 1, 1 }))), new TypeTestData("xmlDataType", 0, (n, t, c) => t.TestTypeEx <string> (c, n, DataType.Xml, skipNull: true, skipNotNull: true), "<root><element strattr=\"strvalue\" intattr=\"12345\"/></root>"), new TypeTestData("xmlDataType", 1, (n, t, c) => t.TestTypeEx <XDocument> (c, n, DataType.Xml, skipNull: true, skipNotNull: true).ToString(), XDocument.Parse("<root><element strattr=\"strvalue\" intattr=\"12345\"/></root>").ToString()), new TypeTestData("xmlDataType", 2, (n, t, c) => t.TestTypeEx <XmlDocument> (c, n, DataType.Xml, skipNull: true, skipNotNull: true).InnerXml, ConvertTo <XmlDocument> .From("<root><element strattr=\"strvalue\" intattr=\"12345\"/></root>").InnerXml), } : new[] { new TypeTestData("ignore", (n, t, c) => t.TestTypeEx <long?>(c, n, DataType.Int64), 1000000) }; var builder = new NUnitTestCaseBuilder(); var data = tests.Select(t => new TestCaseParameters(new object[] { t.Name, t.ID, t, _providerName })); foreach (var item in data) { var test = builder.BuildTestMethod(method, suite, item); test.Properties.Set(PropertyNames.Category, _providerName); if (!UserProviders.ContainsKey(_providerName)) { test.RunState = RunState.Ignored; test.Properties.Set(PropertyNames.SkipReason, "Provider is disabled. See UserDataProviders.txt"); } yield return(test); } }