This commit is contained in:
@@ -30,16 +30,16 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DynamORM.Builders;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace DynamORM.Tests.Select
|
||||
{
|
||||
/// <summary>Test standard dynamic access ORM.</summary>
|
||||
[TestFixture]
|
||||
[TestClass]
|
||||
public class DynamicAccessTests : TestsBase
|
||||
{
|
||||
/// <summary>Setup test parameters.</summary>
|
||||
[TestFixtureSetUp]
|
||||
[TestInitialize]
|
||||
public virtual void SetUp()
|
||||
{
|
||||
CreateTestDatabase();
|
||||
@@ -47,7 +47,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Tear down test objects.</summary>
|
||||
[TestFixtureTearDown]
|
||||
[TestCleanup]
|
||||
public virtual void TearDown()
|
||||
{
|
||||
DestroyDynamicDatabase();
|
||||
@@ -71,28 +71,28 @@ namespace DynamORM.Tests.Select
|
||||
#region Select
|
||||
|
||||
/// <summary>Test unknown op.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestUnknownOperation()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => GetTestTable().MakeMeASandwitch(with: "cheese"));
|
||||
Assert.ThrowsException<InvalidOperationException>(() => GetTestTable().MakeMeASandwitch(with: "cheese"));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Count</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestCount()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Count(columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Count</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestCount2()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestBuilder().Select(x => x.Count(x.id)).Scalar());
|
||||
Assert.AreEqual(200L, GetTestBuilder().Select(x => x.Count(x.id)).Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectInEnumerableCount()
|
||||
{
|
||||
Assert.AreEqual(4, GetTestTable().Count(last: new DynamicColumn
|
||||
@@ -103,17 +103,17 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectInEnumerableCount2()
|
||||
{
|
||||
Assert.AreEqual(4, GetTestBuilder()
|
||||
Assert.AreEqual(4L, GetTestBuilder()
|
||||
.Where(x => x.last.In(new object[] { "Hendricks", "Goodwin", "Freeman" }.Take(3)))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectInArrayCount()
|
||||
{
|
||||
Assert.AreEqual(4, GetTestTable().Count(last: new DynamicColumn
|
||||
@@ -124,24 +124,24 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectInArrayCount2()
|
||||
{
|
||||
Assert.AreEqual(4, GetTestBuilder()
|
||||
Assert.AreEqual(4L, GetTestBuilder()
|
||||
.Where(x => x.last.In(new object[] { "Hendricks", "Goodwin", "Freeman" }))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>First</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFirst()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().First(columns: "id").id);
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>First</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFirst2()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestBuilder()
|
||||
@@ -151,14 +151,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Last</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestLast()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Last(columns: "id").id);
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Last</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestLast2()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestBuilder()
|
||||
@@ -168,63 +168,63 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Count</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestCountSpecificRecord()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().Count(first: "Ori"));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Count</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestCountSpecificRecord2()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestBuilder()
|
||||
Assert.AreEqual(1L, GetTestBuilder()
|
||||
.Where(x => x.first == "Ori")
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestMin()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().Min(columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestMin2()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestBuilder()
|
||||
Assert.AreEqual(1L, GetTestBuilder()
|
||||
.Select(x => x.Min(x.id))
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestMax()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Max(columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestMax2()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestBuilder()
|
||||
Assert.AreEqual(200L, GetTestBuilder()
|
||||
.Select(x => x.Max(x.id))
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TesttAvg()
|
||||
{
|
||||
Assert.AreEqual(100.5, GetTestTable().Avg(columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TesttAvg2()
|
||||
{
|
||||
Assert.AreEqual(100.5, GetTestBuilder()
|
||||
@@ -233,37 +233,37 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Sum</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSum()
|
||||
{
|
||||
Assert.AreEqual(20100, GetTestTable().Sum(columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Sum</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSum2()
|
||||
{
|
||||
Assert.AreEqual(20100, GetTestBuilder()
|
||||
Assert.AreEqual(20100L, GetTestBuilder()
|
||||
.Select(x => x.Sum(x.id))
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Scalar</c> method for invalid operation exception.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestScalarException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => GetTestTable().Scalar(id: 19));
|
||||
Assert.ThrowsException<InvalidOperationException>(() => GetTestTable().Scalar(id: 19));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Scalar</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestScalar()
|
||||
{
|
||||
Assert.AreEqual("Ori", GetTestTable().Scalar(columns: "first", id: 19));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Scalar</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestScalar2()
|
||||
{
|
||||
Assert.AreEqual("Ori", GetTestBuilder()
|
||||
@@ -273,7 +273,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Scalar</c> method with SQLite specific aggregate.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestScalarGroupConcat()
|
||||
{
|
||||
// This test should produce something like this:
|
||||
@@ -283,7 +283,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Scalar</c> method with SQLite specific aggregate.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestScalarGroupConcat2()
|
||||
{
|
||||
// This test should produce something like this:
|
||||
@@ -296,7 +296,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Scalar</c> method with SQLite specific aggregate not using aggregate field.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestScalarGroupConcatNoAggregateField()
|
||||
{
|
||||
// This test should produce something like this:
|
||||
@@ -306,7 +306,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Scalar</c> method with SQLite specific aggregate not using aggregate field.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestScalarGroupConcatNoAggregateField2()
|
||||
{
|
||||
// This test should produce something like this:
|
||||
@@ -319,7 +319,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test something fancy... like: <code>select "first", count("first") occurs from "users" group by "first" order by 2 desc;</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFancyAggregateQuery()
|
||||
{
|
||||
var v = (GetTestTable().Query(columns: "first,first:occurs:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
|
||||
@@ -334,7 +334,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test something fancy... like: <code>select "first", count("first") occurs from "users" group by "first" order by 2 desc;</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFancyAggregateQuery2()
|
||||
{
|
||||
var v = GetTestBuilder()
|
||||
@@ -354,14 +354,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("login")) len from "users";</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestAggregateInAggregate()
|
||||
{
|
||||
Assert.AreEqual(12.77, GetTestTable().Scalar(columns: @"length(""login""):len:avg"));
|
||||
}
|
||||
|
||||
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("login")) len from "users";</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestAggregateInAggregate2()
|
||||
{
|
||||
Assert.AreEqual(12.77, GetTestBuilder()
|
||||
@@ -370,14 +370,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("email")) len from "users";</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestAggregateInAggregateMark2()
|
||||
{
|
||||
Assert.AreEqual(27.7, GetTestTable().Avg(columns: @"length(""email""):len"));
|
||||
}
|
||||
|
||||
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("email")) len from "users";</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestAggregateInAggregateMark3()
|
||||
{
|
||||
Assert.AreEqual(27.7, GetTestBuilder()
|
||||
@@ -409,7 +409,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Single</c> multi.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSingleObject()
|
||||
{
|
||||
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
||||
@@ -421,7 +421,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic <c>Single</c> multi.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSingleObject2()
|
||||
{
|
||||
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
||||
@@ -437,10 +437,10 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic duplicate column name occurrence.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestDuplicateColumnNameException()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => GetTestBuilder()
|
||||
Assert.ThrowsException<ArgumentException>(() => GetTestBuilder()
|
||||
.Where(x => x.id == 19)
|
||||
.Select(x => new
|
||||
{
|
||||
@@ -458,14 +458,14 @@ namespace DynamORM.Tests.Select
|
||||
#region Where
|
||||
|
||||
/// <summary>Test dynamic where expression equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereEq()
|
||||
{
|
||||
Assert.AreEqual("hoyt.tran", GetTestTable().Single(where: new DynamicColumn("id").Eq(100)).login);
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereEq2()
|
||||
{
|
||||
Assert.AreEqual("hoyt.tran", GetTestBuilder()
|
||||
@@ -473,31 +473,31 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression not equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereNot()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestTable().Count(where: new DynamicColumn("id").Not(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression not equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereNot2()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestBuilder()
|
||||
Assert.AreEqual(199L, GetTestBuilder()
|
||||
.Where(x => x.id != 100)
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereLike()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Single(where: new DynamicColumn("login").Like("Hoyt.%")).id);
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereLike2()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestBuilder()
|
||||
@@ -505,146 +505,146 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression not like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereNotLike()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestTable().Count(where: new DynamicColumn("login").NotLike("Hoyt.%")));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression not like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereNotLike2()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestBuilder()
|
||||
Assert.AreEqual(199L, GetTestBuilder()
|
||||
.Where(x => x.login.NotLike("Hoyt.%"))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression not like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereNotLike3()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestBuilder()
|
||||
Assert.AreEqual(199L, GetTestBuilder()
|
||||
.Where(x => !x.login.Like("Hoyt.%"))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression greater.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereGt()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Count(where: new DynamicColumn("id").Greater(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression greater.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereGt2()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestBuilder()
|
||||
Assert.AreEqual(100L, GetTestBuilder()
|
||||
.Where(x => x.id > 100)
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression greater or equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereGte()
|
||||
{
|
||||
Assert.AreEqual(101, GetTestTable().Count(where: new DynamicColumn("id").GreaterOrEqual(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression greater or equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereGte2()
|
||||
{
|
||||
Assert.AreEqual(101, GetTestBuilder()
|
||||
Assert.AreEqual(101L, GetTestBuilder()
|
||||
.Where(x => x.id >= 100)
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression less.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereLt()
|
||||
{
|
||||
Assert.AreEqual(99, GetTestTable().Count(where: new DynamicColumn("id").Less(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression less.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereLt2()
|
||||
{
|
||||
Assert.AreEqual(99, GetTestBuilder()
|
||||
Assert.AreEqual(99L, GetTestBuilder()
|
||||
.Where(x => x.id < 100)
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression less or equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereLte()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Count(where: new DynamicColumn("id").LessOrEqual(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression less or equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereLte2()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestBuilder()
|
||||
Assert.AreEqual(100L, GetTestBuilder()
|
||||
.Where(x => x.id <= 100)
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression between.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereBetween()
|
||||
{
|
||||
Assert.AreEqual(26, GetTestTable().Count(where: new DynamicColumn("id").Between(75, 100)));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression between.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereBetween2()
|
||||
{
|
||||
Assert.AreEqual(26, GetTestBuilder()
|
||||
Assert.AreEqual(26L, GetTestBuilder()
|
||||
.Where(x => x.id.Between(75, 100))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression in parameters.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereIn1()
|
||||
{
|
||||
Assert.AreEqual(3, GetTestTable().Count(where: new DynamicColumn("id").In(75, 99, 100)));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression in array.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereIn2()
|
||||
{
|
||||
Assert.AreEqual(3, GetTestTable().Count(where: new DynamicColumn("id").In(new[] { 75, 99, 100 })));
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression in parameters.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereIn3()
|
||||
{
|
||||
Assert.AreEqual(3, GetTestBuilder()
|
||||
Assert.AreEqual(3L, GetTestBuilder()
|
||||
.Where(x => x.id.In(75, 99, 100))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
}
|
||||
|
||||
/// <summary>Test dynamic where expression in parameters.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereIn4()
|
||||
{
|
||||
Assert.AreEqual(3, GetTestBuilder()
|
||||
Assert.AreEqual(3L, GetTestBuilder()
|
||||
.Where(x => x.id.In(new[] { 75, 99, 100 }))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
|
||||
@@ -26,16 +26,16 @@
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace DynamORM.Tests.Select
|
||||
{
|
||||
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
|
||||
[TestFixture]
|
||||
[TestClass]
|
||||
public class DynamicNoSchemaAccessTests : DynamicAccessTests
|
||||
{
|
||||
/// <summary>Setup test parameters.</summary>
|
||||
[TestFixtureSetUp]
|
||||
[TestInitialize]
|
||||
public override void SetUp()
|
||||
{
|
||||
CreateTestDatabase();
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
*/
|
||||
|
||||
using DynamORM.Tests.Helpers;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace DynamORM.Tests.Select
|
||||
{
|
||||
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
|
||||
[TestFixture]
|
||||
[TestClass]
|
||||
public class DynamicTypeSchemaAccessTests : DynamicNoSchemaAccessTests
|
||||
{
|
||||
/// <summary>Create table using specified method.</summary>
|
||||
|
||||
@@ -29,16 +29,16 @@
|
||||
using System.Linq;
|
||||
using DynamORM.Builders;
|
||||
using DynamORM.Builders.Implementation;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace DynamORM.Tests.Select
|
||||
{
|
||||
/// <summary>Tests of legacy parser methods.</summary>
|
||||
[TestFixture]
|
||||
[TestClass]
|
||||
public class LegacyParserTests : TestsBase
|
||||
{
|
||||
/// <summary>Setup test parameters.</summary>
|
||||
[TestFixtureSetUp]
|
||||
[TestInitialize]
|
||||
public virtual void SetUp()
|
||||
{
|
||||
CreateTestDatabase();
|
||||
@@ -49,7 +49,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Tear down test objects.</summary>
|
||||
[TestFixtureTearDown]
|
||||
[TestCleanup]
|
||||
public virtual void TearDown()
|
||||
{
|
||||
DestroyDynamicDatabase();
|
||||
@@ -59,7 +59,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression equal.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereEq()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -73,7 +73,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression equal with brackets.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereBracketsEq()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -88,7 +88,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression equal with brackets and or condition.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereBracketsOrEq()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -103,7 +103,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression equal with brackets.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereBracketsOrEq2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -120,7 +120,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression equal with brackets.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereBracketsOrEqForgotToEnd()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -139,7 +139,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression not equal.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereNotEq()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -153,7 +153,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression greater.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereGreater()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -167,7 +167,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression greater or equal.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereGreaterOrEqual()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -181,7 +181,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression less.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereLess()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -195,7 +195,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression less or equal.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereLessOrEqual()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -209,7 +209,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression like.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereLike()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -223,7 +223,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression not like.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereNotLike()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -237,7 +237,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression between.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereBetween()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -251,7 +251,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression in.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereIn()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -265,7 +265,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the where expression using anonymous types.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereAnon()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -279,7 +279,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the order by column.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestOrderByCol()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -293,7 +293,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the order by column number.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestOrderByNum()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -307,7 +307,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests the group by column.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestGroupByCol()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
|
||||
@@ -29,18 +29,18 @@
|
||||
using System.Linq;
|
||||
using DynamORM.Builders;
|
||||
using DynamORM.Builders.Implementation;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace DynamORM.Tests.Select
|
||||
{
|
||||
/// <summary>
|
||||
/// New parser tests.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
[TestClass]
|
||||
public class ParserTests : TestsBase
|
||||
{
|
||||
/// <summary>Setup test parameters.</summary>
|
||||
[TestFixtureSetUp]
|
||||
[TestInitialize]
|
||||
public virtual void SetUp()
|
||||
{
|
||||
CreateTestDatabase();
|
||||
@@ -51,7 +51,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Tear down test objects.</summary>
|
||||
[TestFixtureTearDown]
|
||||
[TestCleanup]
|
||||
public virtual void TearDown()
|
||||
{
|
||||
try
|
||||
@@ -65,7 +65,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromGet()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -77,7 +77,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method with multi tables.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromGetMultiKulti()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -89,7 +89,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method with as expression in text.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromGetAs1()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -101,7 +101,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method with as expression using lambda.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromGetAs2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -113,7 +113,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method using text.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromText()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -125,7 +125,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method using text with decorators.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromDecoratedText()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -137,7 +137,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method using text with as.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromTextAs1()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -149,7 +149,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method using invoke with as.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromTextAs2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -162,7 +162,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method using invoke with as.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromTextAs3()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -175,7 +175,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method using invoke with sub query.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromSubQuery1()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -188,7 +188,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method using invoke with sub query.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromSubQuery2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -201,7 +201,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method using invoke with sub query.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestFromSubQuery3()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -214,7 +214,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests where method with alias.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereAlias()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -228,7 +228,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests where method with alias.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestHavingAlias()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -242,7 +242,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests complex where method with alias.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereAliasComplex()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -258,7 +258,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests where method with alias using in.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereAliasIn()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -278,7 +278,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests where method with alias using between.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereAliasBetween1()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -298,7 +298,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests where method with alias using between.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereAliasBetween2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -318,7 +318,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests where method without alias.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereNoAlias()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -332,7 +332,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests where method with full column name.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestWhereNoAliasTableName()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -346,7 +346,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests simple join method.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestJoinClassic()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -360,7 +360,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests inner join method.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestInnerJoin()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -374,7 +374,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests inner join method with aliases mix.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestInnerJoin2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -389,7 +389,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method using invoke with sub query.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestInnerJoin3()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -404,7 +404,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests from method using invoke with sub query.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestInnerJoin4()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -419,7 +419,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests left outer join method.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestLeftOuterJoin()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -433,7 +433,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests left join method.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestLeftJoin()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -447,7 +447,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests right outer join method.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestRightOuterJoin()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -461,7 +461,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests right join method.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestRightJoin()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -475,7 +475,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests complex join with parameters.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestJoinClassicWithParamAndWhere()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -491,7 +491,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select all.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectAll1()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -505,7 +505,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select all.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectAll2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -519,7 +519,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select field.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectField1()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -533,7 +533,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select field.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectField2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -547,7 +547,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select field with alias.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectFieldAlias1()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -561,7 +561,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select field with alias.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectFieldAlias2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -575,7 +575,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select field with alias.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectFieldAlias3()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -589,7 +589,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select field with alias.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectFieldAlias4()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -603,7 +603,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select aggregate field with alias (Sum).
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectAggregateField1()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -617,7 +617,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select aggregate field with alias (Coalesce).
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectAggregateField2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -632,7 +632,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select aggregate field with alias (Sum).
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectAggregateField3()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -646,7 +646,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select aggregate field with alias (Sum).
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectAggregateField4()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -660,7 +660,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select aggregate field with alias (Sum).
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectAggregateField5()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -674,7 +674,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select from anonymous type.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectAnon()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -692,7 +692,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select escaped case.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectCaseEscaped1()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -707,7 +707,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select escaped case.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectCaseEscaped2()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -722,7 +722,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select escaped case.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestCoalesceEscaped()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -737,7 +737,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select escaped case.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestCoalesce()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -752,7 +752,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select escaped case.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestCoalesceCalculatedArgs()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -771,7 +771,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select escaped case.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestCoalesceInWhere()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -787,7 +787,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests select escaped case with sub query.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSelectCaseEscapedAndSub()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -805,7 +805,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests group by.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestGroupBy()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -819,7 +819,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests order by.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestOrderBy()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -833,7 +833,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests order by using string with number.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestOrderByNumberedColumnStr()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -847,7 +847,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests order by using member with number.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestOrderByNumberedColFn()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -861,7 +861,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests order by using member with field.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestOrderByAlt()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -875,7 +875,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests sub query select.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSubQuerySelect()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -892,7 +892,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests sub query where.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSubQueryWhere()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -909,7 +909,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests sub query in.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSubQueryWhereIn()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
@@ -926,7 +926,7 @@ namespace DynamORM.Tests.Select
|
||||
/// <summary>
|
||||
/// Tests sub query join.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestSubQueryJoin()
|
||||
{
|
||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||
|
||||
@@ -31,28 +31,25 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DynamORM.Builders;
|
||||
using DynamORM.Tests.Helpers;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace DynamORM.Tests.Select
|
||||
{
|
||||
/// <summary>Test typed ORM.</summary>
|
||||
/// <typeparam name="T">Type to test.</typeparam>
|
||||
[TestFixture(typeof(users))]
|
||||
[TestClass]
|
||||
public class TypedAccessTests<T> : TestsBase where T : class
|
||||
{
|
||||
/// <summary>Setup test parameters.</summary>
|
||||
[TestFixtureSetUp]
|
||||
[TestInitialize]
|
||||
public virtual void SetUp()
|
||||
{
|
||||
CreateTestDatabase();
|
||||
CreateDynamicDatabase();
|
||||
|
||||
// Cache table (profiler freaks out)
|
||||
GetTestTable();
|
||||
}
|
||||
|
||||
/// <summary>Tear down test objects.</summary>
|
||||
[TestFixtureTearDown]
|
||||
[TestCleanup]
|
||||
public virtual void TearDown()
|
||||
{
|
||||
DestroyDynamicDatabase();
|
||||
@@ -76,7 +73,7 @@ namespace DynamORM.Tests.Select
|
||||
#region Select typed
|
||||
|
||||
/// <summary>Test load all rows into mapped list alternate way.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedGetAll()
|
||||
{
|
||||
var list = (GetTestTable().Query(type: typeof(T)) as IEnumerable<object>).Cast<T>().ToList();
|
||||
@@ -85,7 +82,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test load all rows into mapped list alternate way.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedGetAll2()
|
||||
{
|
||||
var list = GetTestBuilder()
|
||||
@@ -98,7 +95,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test load all rows into mapped list alternate way.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedGetAll3()
|
||||
{
|
||||
var list = GetTestBuilder()
|
||||
@@ -110,21 +107,21 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test unknown op.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedUnknownOperation()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => GetTestTable().MakeMeASandwitch(type: typeof(T), with: "cheese"));
|
||||
Assert.ThrowsException<InvalidOperationException>(() => GetTestTable().MakeMeASandwitch(type: typeof(T), with: "cheese"));
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Count</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedCount()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Count(type: typeof(T), columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Count</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedCount2()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestBuilder()
|
||||
@@ -134,7 +131,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedSelectInEnumerableCount()
|
||||
{
|
||||
Assert.AreEqual(4, GetTestTable().Count(type: typeof(T), last: new DynamicColumn
|
||||
@@ -145,7 +142,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedSelectInEnumerableCount2()
|
||||
{
|
||||
Assert.AreEqual(4, GetTestBuilder()
|
||||
@@ -156,7 +153,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedSelectInArrayCount()
|
||||
{
|
||||
Assert.AreEqual(4, GetTestTable().Count(type: typeof(T), last: new DynamicColumn
|
||||
@@ -167,7 +164,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedSelectInArrayCount2()
|
||||
{
|
||||
Assert.AreEqual(4, GetTestBuilder()
|
||||
@@ -178,14 +175,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>First</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedFirst()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().First(type: typeof(T), columns: "id").id);
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>First</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedFirst2()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestBuilder()
|
||||
@@ -196,14 +193,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Last</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedLast()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Last(type: typeof(T), columns: "id").id);
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Last</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedLast2()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestBuilder()
|
||||
@@ -214,21 +211,21 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Count</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedCountSpecificRecord()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().Count(type: typeof(T), first: "Ori"));
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedMin()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().Min(type: typeof(T), columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedMin2()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestBuilder()
|
||||
@@ -238,14 +235,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedMax()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Max(type: typeof(T), columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedMax2()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestBuilder()
|
||||
@@ -255,14 +252,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedtAvg()
|
||||
{
|
||||
Assert.AreEqual(100.5, GetTestTable().Avg(type: typeof(T), columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedtAvg2()
|
||||
{
|
||||
Assert.AreEqual(100.5, GetTestBuilder()
|
||||
@@ -272,14 +269,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Sum</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedSum()
|
||||
{
|
||||
Assert.AreEqual(20100, GetTestTable().Sum(type: typeof(T), columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Sum</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedSum2()
|
||||
{
|
||||
Assert.AreEqual(20100, GetTestBuilder()
|
||||
@@ -289,21 +286,21 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Scalar</c> method for invalid operation exception.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedScalarException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => GetTestTable().Scalar(type: typeof(T), id: 19));
|
||||
Assert.ThrowsException<InvalidOperationException>(() => GetTestTable().Scalar(type: typeof(T), id: 19));
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Scalar</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedScalar()
|
||||
{
|
||||
Assert.AreEqual("Ori", GetTestTable().Scalar(type: typeof(T), columns: "first", id: 19));
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Scalar</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public void TestTypedScalar2()
|
||||
{
|
||||
Assert.AreEqual("Ori", GetTestBuilder()
|
||||
@@ -314,7 +311,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Scalar</c> method with SQLite specific aggregate.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedScalarGroupConcat()
|
||||
{
|
||||
// This test should produce something like this:
|
||||
@@ -324,7 +321,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Scalar</c> method with SQLite specific aggregate.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedScalarGroupConcat2()
|
||||
{
|
||||
// This test should produce something like this:
|
||||
@@ -338,7 +335,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Scalar</c> method with SQLite specific aggregate not using aggregate field.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedScalarGroupConcatNoAggregateField()
|
||||
{
|
||||
// This test should produce something like this:
|
||||
@@ -348,7 +345,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Scalar</c> method with SQLite specific aggregate not using aggregate field.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedScalarGroupConcatNoAggregateField2()
|
||||
{
|
||||
// This test should produce something like this:
|
||||
@@ -362,7 +359,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedFancyAggregateQuery()
|
||||
{
|
||||
var v = (GetTestTable().Query(type: typeof(T), columns: "first,first:aggregatefield:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
|
||||
@@ -377,7 +374,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedFancyAggregateQuery2()
|
||||
{
|
||||
var v = GetTestBuilder()
|
||||
@@ -398,14 +395,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("login")) len from "users";</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedAggregateInAggregate()
|
||||
{
|
||||
Assert.AreEqual(12.77, GetTestTable().Scalar(type: typeof(T), columns: @"length(""login""):len:avg"));
|
||||
}
|
||||
|
||||
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("login")) len from "users";</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedAggregateInAggregate2()
|
||||
{
|
||||
Assert.AreEqual(12.77, GetTestBuilder()
|
||||
@@ -415,14 +412,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("email")) len from "users";</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedAggregateInAggregateMark2()
|
||||
{
|
||||
Assert.AreEqual(27.7, GetTestTable().Avg(type: typeof(T), columns: @"length(""email""):len"));
|
||||
}
|
||||
|
||||
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("email")) len from "users";</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedAggregateInAggregateMark3()
|
||||
{
|
||||
Assert.AreEqual(27.7, GetTestBuilder()
|
||||
@@ -456,7 +453,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Single</c> multi.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedSingleObject()
|
||||
{
|
||||
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
||||
@@ -468,7 +465,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Single</c> multi.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedSingleObject2()
|
||||
{
|
||||
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
||||
@@ -489,14 +486,14 @@ namespace DynamORM.Tests.Select
|
||||
#region Where typed
|
||||
|
||||
/// <summary>Test typed where expression equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereEq()
|
||||
{
|
||||
Assert.AreEqual("hoyt.tran", GetTestTable().Single(type: typeof(T), where: new DynamicColumn("id").Eq(100)).login);
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereEq2()
|
||||
{
|
||||
Assert.AreEqual("hoyt.tran", GetTestBuilder()
|
||||
@@ -505,14 +502,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression not equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereNot()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").Not(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression not equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereNot2()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestBuilder()
|
||||
@@ -523,14 +520,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereLike()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Single(type: typeof(T), where: new DynamicColumn("login").Like("Hoyt.%")).id);
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereLike2()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestBuilder()
|
||||
@@ -539,14 +536,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression not like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereNotLike()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("login").NotLike("Hoyt.%")));
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression not like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereNotLike2()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestBuilder()
|
||||
@@ -557,7 +554,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression not like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereNotLike3()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestBuilder()
|
||||
@@ -568,14 +565,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression greater.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereGt()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").Greater(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression greater.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereGt2()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestBuilder()
|
||||
@@ -586,14 +583,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression greater or equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereGte()
|
||||
{
|
||||
Assert.AreEqual(101, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").GreaterOrEqual(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression greater or equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereGte2()
|
||||
{
|
||||
Assert.AreEqual(101, GetTestBuilder()
|
||||
@@ -604,14 +601,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression less.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereLt()
|
||||
{
|
||||
Assert.AreEqual(99, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").Less(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression less.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereLt2()
|
||||
{
|
||||
Assert.AreEqual(99, GetTestBuilder()
|
||||
@@ -622,14 +619,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression less or equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereLte()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").LessOrEqual(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression less or equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereLte2()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestBuilder()
|
||||
@@ -640,14 +637,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression between.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereBetween()
|
||||
{
|
||||
Assert.AreEqual(26, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").Between(75, 100)));
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression between.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereBetween2()
|
||||
{
|
||||
Assert.AreEqual(26, GetTestBuilder()
|
||||
@@ -658,21 +655,21 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression in parameters.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereIn1()
|
||||
{
|
||||
Assert.AreEqual(3, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").In(75, 99, 100)));
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression in array.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereIn2()
|
||||
{
|
||||
Assert.AreEqual(3, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").In(new[] { 75, 99, 100 })));
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression in parameters.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereIn3()
|
||||
{
|
||||
Assert.AreEqual(3, GetTestBuilder()
|
||||
@@ -683,7 +680,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression in array.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestTypedWhereIn4()
|
||||
{
|
||||
Assert.AreEqual(3, GetTestBuilder()
|
||||
@@ -698,7 +695,7 @@ namespace DynamORM.Tests.Select
|
||||
#region Select generic
|
||||
|
||||
/// <summary>Test load all rows into mapped list alternate way.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericGetAll()
|
||||
{
|
||||
var list = (GetTestTable().Query<T>() as IEnumerable<object>).Cast<T>().ToList();
|
||||
@@ -707,21 +704,21 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test unknown op.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericUnknownOperation()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => GetTestTable().MakeMeASandwitch<T>(with: "cheese"));
|
||||
Assert.ThrowsException<InvalidOperationException>(() => GetTestTable().MakeMeASandwitch<T>(with: "cheese"));
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Count</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericCount()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Count<T>(columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericSelectInEnumerableCount()
|
||||
{
|
||||
Assert.AreEqual(4, GetTestTable().Count<T>(last: new DynamicColumn
|
||||
@@ -732,7 +729,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericSelectInArrayCount()
|
||||
{
|
||||
Assert.AreEqual(4, GetTestTable().Count<T>(last: new DynamicColumn
|
||||
@@ -743,70 +740,70 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>First</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericFirst()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().First<T>(columns: "id").id);
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Last</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericLast()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Last<T>(columns: "id").id);
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Count</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericCountSpecificRecord()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().Count<T>(first: "Ori"));
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericMin()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().Min<T>(columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericMax()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Max<T>(columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Min</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenerictAvg()
|
||||
{
|
||||
Assert.AreEqual(100.5, GetTestTable().Avg<T>(columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Sum</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericSum()
|
||||
{
|
||||
Assert.AreEqual(20100, GetTestTable().Sum<T>(columns: "id"));
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Scalar</c> method for invalid operation exception.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericScalarException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => GetTestTable().Scalar<T>(id: 19));
|
||||
Assert.ThrowsException<InvalidOperationException>(() => GetTestTable().Scalar<T>(id: 19));
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Scalar</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericScalar()
|
||||
{
|
||||
Assert.AreEqual("Ori", GetTestTable().Scalar<T>(columns: "first", id: 19));
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Scalar</c> method with SQLite specific aggregate.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericScalarGroupConcat()
|
||||
{
|
||||
// This test should produce something like this:
|
||||
@@ -816,7 +813,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Scalar</c> method with SQLite specific aggregate not using aggregate field.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericScalarGroupConcatNoAggregateField()
|
||||
{
|
||||
// This test should produce something like this:
|
||||
@@ -826,7 +823,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericFancyAggregateQuery()
|
||||
{
|
||||
var v = (GetTestTable().Query<T>(columns: "first,first:aggregatefield:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
|
||||
@@ -841,14 +838,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("login")) len from "users";</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericAggregateInAggregate()
|
||||
{
|
||||
Assert.AreEqual(12.77, GetTestTable().Scalar<T>(columns: @"length(""login""):len:avg"));
|
||||
}
|
||||
|
||||
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("email")) len from "users";</code>.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericAggregateInAggregateMark2()
|
||||
{
|
||||
Assert.AreEqual(27.7, GetTestTable().Avg<T>(columns: @"length(""email""):len"));
|
||||
@@ -869,7 +866,7 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Single</c> multi.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericSingleObject()
|
||||
{
|
||||
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
||||
@@ -885,77 +882,77 @@ namespace DynamORM.Tests.Select
|
||||
#region Where generic
|
||||
|
||||
/// <summary>Test generic where expression equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereEq()
|
||||
{
|
||||
Assert.AreEqual("hoyt.tran", GetTestTable().Single<T>(where: new DynamicColumn("id").Eq(100)).login);
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression not equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereNot()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestTable().Count<T>(where: new DynamicColumn("id").Not(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereLike()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Single<T>(where: new DynamicColumn("login").Like("Hoyt.%")).id);
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression not like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereNotLike()
|
||||
{
|
||||
Assert.AreEqual(199, GetTestTable().Count<T>(where: new DynamicColumn("login").NotLike("Hoyt.%")));
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression greater.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereGt()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Count<T>(where: new DynamicColumn("id").Greater(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression greater or equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereGte()
|
||||
{
|
||||
Assert.AreEqual(101, GetTestTable().Count<T>(where: new DynamicColumn("id").GreaterOrEqual(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression less.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereLt()
|
||||
{
|
||||
Assert.AreEqual(99, GetTestTable().Count<T>(where: new DynamicColumn("id").Less(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression less or equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereLte()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Count<T>(where: new DynamicColumn("id").LessOrEqual(100)));
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression between.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereBetween()
|
||||
{
|
||||
Assert.AreEqual(26, GetTestTable().Count<T>(where: new DynamicColumn("id").Between(75, 100)));
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression in parameters.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereIn1()
|
||||
{
|
||||
Assert.AreEqual(3, GetTestTable().Count<T>(where: new DynamicColumn("id").In(75, 99, 100)));
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression in array.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public virtual void TestGenericWhereIn2()
|
||||
{
|
||||
Assert.AreEqual(3, GetTestTable().Count<T>(where: new DynamicColumn("id").In(new[] { 75, 99, 100 })));
|
||||
|
||||
Reference in New Issue
Block a user