Updated test project.
This commit is contained in:
@@ -29,16 +29,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DynamORM.Tests.Helpers;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace DynamORM.Tests.Select
|
||||
{
|
||||
/// <summary>Test typed ORM.</summary>
|
||||
[TestFixture]
|
||||
[TestClass]
|
||||
public class RenamedTypedAccessTests : TypedAccessTests<Users>
|
||||
{
|
||||
/// <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 override void TestTypedFancyAggregateQuery()
|
||||
{
|
||||
var v = (GetTestTable().Query(type: typeof(Users), columns: "first,first:AggregateField:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
|
||||
@@ -53,7 +53,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 override void TestGenericFancyAggregateQuery()
|
||||
{
|
||||
var v = (GetTestTable().Query<Users>(columns: "first,first:AggregateField:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
|
||||
@@ -68,21 +68,21 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>First</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public override void TestTypedFirst()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().First(type: typeof(Users), columns: "id").Id);
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Last</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public override void TestTypedLast()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Last(type: typeof(Users), columns: "id").Id);
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Single</c> multi.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public override void TestTypedSingleObject()
|
||||
{
|
||||
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
||||
@@ -94,35 +94,35 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public override void TestTypedWhereEq()
|
||||
{
|
||||
Assert.AreEqual("hoyt.tran", GetTestTable().Single(type: typeof(Users), where: new DynamicColumn("id").Eq(100)).Login);
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public override void TestTypedWhereLike()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Single(type: typeof(Users), where: new DynamicColumn("login").Like("Hoyt.%")).Id);
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>First</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public override void TestGenericFirst()
|
||||
{
|
||||
Assert.AreEqual(1, GetTestTable().First<Users>(columns: "id").Id);
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Last</c> method.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public override void TestGenericLast()
|
||||
{
|
||||
Assert.AreEqual(200, GetTestTable().Last<Users>(columns: "id").Id);
|
||||
}
|
||||
|
||||
/// <summary>Test generic <c>Single</c> multi.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public override void TestGenericSingleObject()
|
||||
{
|
||||
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
||||
@@ -134,14 +134,14 @@ namespace DynamORM.Tests.Select
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression equal.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public override void TestGenericWhereEq()
|
||||
{
|
||||
Assert.AreEqual("hoyt.tran", GetTestTable().Single<Users>(where: new DynamicColumn("id").Eq(100)).Login);
|
||||
}
|
||||
|
||||
/// <summary>Test generic where expression like.</summary>
|
||||
[Test]
|
||||
[TestMethod]
|
||||
public override void TestGenericWhereLike()
|
||||
{
|
||||
Assert.AreEqual(100, GetTestTable().Single<Users>(where: new DynamicColumn("login").Like("Hoyt.%")).Id);
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace DynamORM.Tests.Select
|
||||
Assert.AreEqual(200, GetTestBuilder()
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Select(x => x.Count(x.t.id))
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
@@ -149,7 +149,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.last.In(new object[] { "Hendricks", "Goodwin", "Freeman" }.Take(3)))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test count with in statement.</summary>
|
||||
@@ -171,7 +171,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.last.In(new object[] { "Hendricks", "Goodwin", "Freeman" }))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>First</c> method.</summary>
|
||||
@@ -231,7 +231,7 @@ namespace DynamORM.Tests.Select
|
||||
Assert.AreEqual(1, GetTestBuilder()
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Select(x => x.Min(x.t.id))
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Min</c> method.</summary>
|
||||
@@ -248,7 +248,7 @@ namespace DynamORM.Tests.Select
|
||||
Assert.AreEqual(200, GetTestBuilder()
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Select(x => x.Max(x.t.id))
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Min</c> method.</summary>
|
||||
@@ -282,7 +282,7 @@ namespace DynamORM.Tests.Select
|
||||
Assert.AreEqual(20100, GetTestBuilder()
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Select(x => x.Sum(x.t.id))
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed <c>Scalar</c> method for invalid operation exception.</summary>
|
||||
@@ -516,7 +516,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.t.id != 100)
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression like.</summary>
|
||||
@@ -550,7 +550,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.t.login.NotLike("Hoyt.%"))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression not like.</summary>
|
||||
@@ -561,7 +561,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => !x.t.login.Like("Hoyt.%"))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression greater.</summary>
|
||||
@@ -579,7 +579,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.t.id > 100)
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression greater or equal.</summary>
|
||||
@@ -597,7 +597,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.t.id >= 100)
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression less.</summary>
|
||||
@@ -615,7 +615,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.t.id < 100)
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression less or equal.</summary>
|
||||
@@ -633,7 +633,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.t.id <= 100)
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression between.</summary>
|
||||
@@ -651,7 +651,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.t.id.Between(75, 100))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression in parameters.</summary>
|
||||
@@ -676,7 +676,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.t.id.In(75, 99, 100))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
/// <summary>Test typed where expression in array.</summary>
|
||||
@@ -687,7 +687,7 @@ namespace DynamORM.Tests.Select
|
||||
.From(x => x(typeof(T)).As(x.t))
|
||||
.Where(x => x.t.id.In(new[] { 75, 99, 100 }))
|
||||
.Select(x => x.Count())
|
||||
.Scalar());
|
||||
.ScalarAs<int>());
|
||||
}
|
||||
|
||||
#endregion Where typed
|
||||
|
||||
Reference in New Issue
Block a user