-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
NorthwindDbFunctionsQuerySqliteTest.cs
96 lines (81 loc) · 2.48 KB
/
NorthwindDbFunctionsQuerySqliteTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.EntityFrameworkCore.TestModels.Northwind;
namespace Microsoft.EntityFrameworkCore.Query;
#nullable disable
public class NorthwindDbFunctionsQuerySqliteTest : NorthwindDbFunctionsQueryRelationalTestBase<
NorthwindQuerySqliteFixture<NoopModelCustomizer>>
{
public NorthwindDbFunctionsQuerySqliteTest(
NorthwindQuerySqliteFixture<NoopModelCustomizer> fixture,
ITestOutputHelper testOutputHelper)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.Clear();
}
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual async Task Glob(bool async)
{
await AssertCount(
async,
ss => ss.Set<Customer>(),
ss => ss.Set<Customer>(),
c => EF.Functions.Glob(c.ContactName, "*M*"),
c => c.ContactName.Contains("M"));
AssertSql(
"""
SELECT COUNT(*)
FROM "Customers" AS "c"
WHERE "c"."ContactName" GLOB '*M*'
""");
}
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual async Task Glob_negated(bool async)
{
await AssertCount(
async,
ss => ss.Set<Customer>(),
ss => ss.Set<Customer>(),
c => !EF.Functions.Glob(c.CustomerID, "T*"),
c => !c.CustomerID.StartsWith("T"));
AssertSql(
"""
SELECT COUNT(*)
FROM "Customers" AS "c"
WHERE "c"."CustomerID" NOT GLOB 'T*'
""");
}
protected override string CaseInsensitiveCollation
=> "NOCASE";
protected override string CaseSensitiveCollation
=> "BINARY";
public override async Task Random_return_less_than_1(bool async)
{
await AssertCount(
async,
ss => ss.Set<Order>(),
ss => ss.Set<Order>(),
ss => EF.Functions.Random() <= 1,
c => true);
AssertSql(
"""
SELECT COUNT(*)
FROM "Orders" AS "o"
WHERE abs(random() / 9.2233720368547799E+18) <= 1.0
""");
}
public override async Task Random_return_greater_than_0(bool async)
{
await base.Random_return_greater_than_0(async);
AssertSql(
"""
SELECT COUNT(*)
FROM "Orders" AS "o"
WHERE abs(random() / 9.2233720368547799E+18) >= 0.0
""");
}
private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}