forked from FirebirdSQL/NETProvider
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSqlQueryFbTest.cs
More file actions
190 lines (157 loc) · 6.22 KB
/
SqlQueryFbTest.cs
File metadata and controls
190 lines (157 loc) · 6.22 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.
*
* Software distributed under the License is distributed on
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* All Rights Reserved.
*/
//$Authors = Jiri Cincura (jiri@cincura.net)
using System;
using System.Data.Common;
using System.Linq;
using System.Threading.Tasks;
using FirebirdSql.Data.FirebirdClient;
using FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;
namespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;
public class SqlQueryFbTest : SqlQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>
{
public SqlQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)
: base(fixture)
{ }
// Uses INTERSECT
[NotSupportedByProviderTheory]
[MemberData(nameof(IsAsyncData))]
public override Task Multiple_occurrences_of_SqlQuery_with_db_parameter_adds_two_parameters(bool async)
{
return base.Multiple_occurrences_of_SqlQuery_with_db_parameter_adds_two_parameters(async);
}
[Theory(Skip = "Provider does the casting.")]
[MemberData(nameof(IsAsyncData))]
public override Task Bad_data_error_handling_invalid_cast(bool async)
{
return base.Bad_data_error_handling_invalid_cast(async);
}
[Theory(Skip = "Provider does the casting.")]
[MemberData(nameof(IsAsyncData))]
public override Task Bad_data_error_handling_invalid_cast_key(bool async)
{
return base.Bad_data_error_handling_invalid_cast_key(async);
}
[Theory(Skip = "Provider does the casting.")]
[MemberData(nameof(IsAsyncData))]
public override Task Bad_data_error_handling_invalid_cast_no_tracking(bool async)
{
return base.Bad_data_error_handling_invalid_cast_no_tracking(async);
}
[Theory(Skip = "Provider does the casting.")]
[MemberData(nameof(IsAsyncData))]
public override Task Bad_data_error_handling_invalid_cast_projection(bool async)
{
return base.Bad_data_error_handling_invalid_cast_projection(async);
}
[Theory(Skip = "Provider does the casting.")]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_queryable_simple_projection_composed(bool async)
{
return base.SqlQueryRaw_queryable_simple_projection_composed(async);
}
[DoesNotHaveTheDataTheory]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_with_dbParameter_mixed_in_subquery(bool async)
{
return base.SqlQueryRaw_with_dbParameter_mixed_in_subquery(async);
}
[DoesNotHaveTheDataTheory]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_queryable_multiple_composed_with_parameters_and_closure_parameters(bool async)
{
return base.SqlQueryRaw_queryable_multiple_composed_with_parameters_and_closure_parameters(async);
}
[DoesNotHaveTheDataTheory]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_queryable_multiple_composed_with_closure_parameters(bool async)
{
return base.SqlQueryRaw_queryable_multiple_composed_with_closure_parameters(async);
}
[DoesNotHaveTheDataTheory]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_queryable_multiple_composed(bool async)
{
return base.SqlQueryRaw_queryable_multiple_composed(async);
}
[DoesNotHaveTheDataTheory]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_in_subquery_with_positional_dbParameter_without_name(bool async)
{
return base.SqlQueryRaw_in_subquery_with_positional_dbParameter_without_name(async);
}
[DoesNotHaveTheDataTheory]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_in_subquery_with_positional_dbParameter_with_name(bool async)
{
return base.SqlQueryRaw_in_subquery_with_positional_dbParameter_with_name(async);
}
[DoesNotHaveTheDataTheory]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_in_subquery_with_dbParameter(bool async)
{
return base.SqlQueryRaw_in_subquery_with_dbParameter(async);
}
[DoesNotHaveTheDataTheory]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_does_not_parameterize_interpolated_string(bool async)
{
return base.SqlQueryRaw_does_not_parameterize_interpolated_string(async);
}
[DoesNotHaveTheDataTheory]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_queryable_with_null_parameter(bool async)
{
return base.SqlQueryRaw_queryable_with_null_parameter(async);
}
[DoesNotHaveTheDataTheory]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQuery_queryable_multiple_composed_with_parameters_and_closure_parameters_interpolated(bool async)
{
return base.SqlQuery_queryable_multiple_composed_with_parameters_and_closure_parameters_interpolated(async);
}
[Theory(Skip = "Firebird matches the casing exactly. Frankly the test is weird.")]
[MemberData(nameof(IsAsyncData))]
public override Task SqlQueryRaw_queryable_simple_different_cased_columns_and_not_enough_columns_throws(bool async)
{
return base.SqlQueryRaw_queryable_simple_different_cased_columns_and_not_enough_columns_throws(async);
}
[Fact]
public async Task Where_datetime_between_translated_correctly()
{
using var context = CreateContext();
var inicio = new DateTime(2026, 1, 1);
var fim = new DateTime(2026, 1, 31);
var query = context.Orders.Where(o => o.OrderDate >= inicio && o.OrderDate <= fim);
var sql = query.ToQueryString();
Assert.Contains("BETWEEN", sql);
Assert.Contains("AND", sql);
}
[Fact]
public async Task Where_OrderDate_and_Id_not_translated_to_between()
{
using var context = CreateContext();
var inicio = new DateTime(1997, 1, 1);
var query = context.Orders.Where(o => o.OrderDate >= inicio && o.OrderID <= 10);
var sql = query.ToQueryString();
Assert.DoesNotContain("BETWEEN", sql);
}
protected override DbParameter CreateDbParameter(string name, object value)
=> new FbParameter { ParameterName = name, Value = value };
}