Skip to content

Commit d78256f

Browse files
committed
update tests
1 parent a2dc62d commit d78256f

10 files changed

+84
-70
lines changed

test/EFCore.Jet.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesJetTest.cs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -271,29 +271,26 @@ public override async Task Delete_Where_Skip_Take_Skip_Take_causing_subquery(boo
271271
await base.Delete_Where_Skip_Take_Skip_Take_causing_subquery(async);
272272

273273
AssertSql(
274-
"""
275-
@__p_0='100'
276-
@__p_1='20'
277-
@__p_2='5'
278-
279-
DELETE FROM [o]
280-
FROM [Order Details] AS [o]
281-
WHERE EXISTS (
282-
SELECT 1
283-
FROM (
284-
SELECT [t].[OrderID], [t].[ProductID], [t].[Discount], [t].[Quantity], [t].[UnitPrice]
274+
"""
275+
DELETE FROM `Order Details` AS `o`
276+
WHERE EXISTS (
277+
SELECT 1
285278
FROM (
286-
SELECT [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice]
287-
FROM [Order Details] AS [o0]
288-
WHERE [o0].[OrderID] < 10300
289-
ORDER BY (SELECT 1)
290-
OFFSET @__p_0 ROWS FETCH NEXT @__p_0 ROWS ONLY
291-
) AS [t]
292-
ORDER BY (SELECT 1)
293-
OFFSET @__p_1 ROWS FETCH NEXT @__p_2 ROWS ONLY
294-
) AS [t0]
295-
WHERE [t0].[OrderID] = [o].[OrderID] AND [t0].[ProductID] = [o].[ProductID])
296-
""");
279+
SELECT TOP 5 `t1`.`OrderID`, `t1`.`ProductID`, `t1`.`Discount`, `t1`.`Quantity`, `t1`.`UnitPrice`
280+
FROM (
281+
SELECT TOP 25 `t0`.`OrderID`, `t0`.`ProductID`, `t0`.`Discount`, `t0`.`Quantity`, `t0`.`UnitPrice`
282+
FROM (
283+
SELECT TOP 100 `t`.`OrderID`, `t`.`ProductID`, `t`.`Discount`, `t`.`Quantity`, `t`.`UnitPrice`
284+
FROM (
285+
SELECT TOP 200 `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice`
286+
FROM `Order Details` AS `o0`
287+
WHERE `o0`.`OrderID` < 10300
288+
) AS `t`
289+
) AS `t0`
290+
) AS `t1`
291+
) AS `t2`
292+
WHERE `t2`.`OrderID` = `o`.`OrderID` AND `t2`.`ProductID` = `o`.`ProductID`)
293+
""");
297294
}
298295

299296
public override async Task Delete_Where_Distinct(bool async)

test/EFCore.Jet.FunctionalTests/Query/FromSqlQueryJetTest.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
using Microsoft.EntityFrameworkCore.Query;
1111
using Xunit;
1212
using Xunit.Abstractions;
13+
using EntityFrameworkCore.Jet.FunctionalTests.TestUtilities;
14+
using System.Data.Odbc;
1315

1416
namespace EntityFrameworkCore.Jet.FunctionalTests.Query;
1517

@@ -991,7 +993,13 @@ public override async Task FromSqlRaw_composed_with_common_table_expression(bool
991993
}
992994

993995
protected override DbParameter CreateDbParameter(string name, object value)
994-
=> new OleDbParameter { ParameterName = name, Value = value };
996+
{
997+
if (((JetTestStore)Fixture.TestStore).IsOleDb())
998+
{
999+
return new OleDbParameter { ParameterName = name, Value = value };
1000+
}
1001+
return new OdbcParameter { ParameterName = name, Value = value };
1002+
}
9951003

9961004
private void AssertSql(params string[] expected)
9971005
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);

test/EFCore.Jet.FunctionalTests/Query/GearsOfWarQueryJetTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7233,7 +7233,7 @@ public override async Task Checked_context_with_cast_does_not_fail(bool isAsync)
72337233
"""
72347234
SELECT `l`.`Name`, `l`.`Discriminator`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, `l`.`DefeatedByNickname`, `l`.`DefeatedBySquadId`, `l`.`HighCommandId`
72357235
FROM `LocustLeaders` AS `l`
7236-
WHERE CBYTE(`l`.`ThreatLevel`) >= 5
7236+
WHERE CBYTE(`l`.`ThreatLevel`) >= CBYTE(5)
72377237
""");
72387238
}
72397239

test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,10 +1903,10 @@ public override async Task Indexof_with_one_constant_arg(bool async)
19031903
await base.Indexof_with_one_constant_arg(async);
19041904

19051905
AssertSql(
1906-
"""
1906+
"""
19071907
SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
19081908
FROM `Customers` AS `c`
1909-
WHERE (InStr(`c`.`ContactName`, 'a') - 1) = 1
1909+
WHERE (INSTR(1, `c`.`ContactName`, 'a', 1) - 1) = 1
19101910
""");
19111911
}
19121912

@@ -1915,13 +1915,13 @@ public override async Task Indexof_with_one_parameter_arg(bool async)
19151915
await base.Indexof_with_one_parameter_arg(async);
19161916

19171917
AssertSql(
1918-
"""
1919-
@__pattern_0='a' (Size = 255)
1920-
@__pattern_0='a' (Size = 255)
1918+
"""
1919+
@__pattern_0='a' (Size = 30)
1920+
@__pattern_0='a' (Size = 30)
19211921
19221922
SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
19231923
FROM `Customers` AS `c`
1924-
WHERE IIF(? = '', 0, InStr(`c`.`ContactName`, ?) - 1) = 1
1924+
WHERE IIF(@__pattern_0 = '', 0, INSTR(1, `c`.`ContactName`, @__pattern_0, 1) - 1) = 1
19251925
""");
19261926
}
19271927

@@ -1933,7 +1933,7 @@ public override async Task Indexof_with_constant_starting_position(bool async)
19331933
"""
19341934
SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
19351935
FROM `Customers` AS `c`
1936-
WHERE (InStr(3, `c`.`ContactName`, 'a', 1) - 1) = 4
1936+
WHERE (INSTR(3, `c`.`ContactName`, 'a', 1) - 1) = 4
19371937
""");
19381938
}
19391939

@@ -1947,7 +1947,7 @@ public override async Task Indexof_with_parameter_starting_position(bool async)
19471947
19481948
SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
19491949
FROM `Customers` AS `c`
1950-
WHERE (InStr({AssertSqlHelper.Parameter("@__start_0")} + 1, `c`.`ContactName`, 'a', 1) - 1) = 4
1950+
WHERE (INSTR({AssertSqlHelper.Parameter("@__start_0")} + 1, `c`.`ContactName`, 'a', 1) - 1) = 4
19511951
""");
19521952
}
19531953

@@ -2050,12 +2050,11 @@ public override async Task Substring_with_two_args_with_Index_of(bool async)
20502050
await base.Substring_with_two_args_with_Index_of(async);
20512051

20522052
AssertSql(
2053-
@"SELECT SUBSTRING(`c`.`ContactName`, CASE
2054-
WHEN 'a' = '' THEN 0
2055-
ELSE CAST(CHARINDEX('a', `c`.`ContactName`) AS int) - 1
2056-
END + 1, 3)
2057-
FROM `Customers` AS `c`
2058-
WHERE `c`.`CustomerID` = 'ALFKI'");
2053+
"""
2054+
SELECT MID(`c`.`ContactName`, (INSTR(1, `c`.`ContactName`, 'a', 1) - 1) + 1, 3)
2055+
FROM `Customers` AS `c`
2056+
WHERE `c`.`CustomerID` = 'ALFKI'
2057+
""");
20592058
}
20602059

20612060
public override async Task IsNullOrEmpty_in_predicate(bool isAsync)

test/EFCore.Jet.FunctionalTests/Query/NorthwindSelectQueryJetTest.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public NorthwindSelectQueryJetTest(
1717
: base(fixture)
1818
{
1919
ClearLog();
20-
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
20+
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
2121
}
2222

2323
protected override bool CanExecuteQueryString
@@ -922,8 +922,10 @@ public override async Task Select_byte_constant(bool isAsync)
922922
await base.Select_byte_constant(isAsync);
923923

924924
AssertSql(
925-
$@"SELECT IIF(`c`.`CustomerID` = 'ALFKI', 0x01, 0x02)
926-
FROM `Customers` AS `c`");
925+
"""
926+
SELECT IIF(`c`.`CustomerID` = 'ALFKI', CBYTE(1), CBYTE(2))
927+
FROM `Customers` AS `c`
928+
""");
927929
}
928930

929931
public override async Task Select_short_constant(bool isAsync)

test/EFCore.Jet.FunctionalTests/Query/NorthwindWhereQueryJetTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,11 @@ public override async Task Where_string_indexof(bool isAsync)
743743
await base.Where_string_indexof(isAsync);
744744

745745
AssertSql(
746-
$@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
746+
"""
747+
SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
747748
FROM `Customers` AS `c`
748-
WHERE (INSTR(`c`.`City`, 'Sea') - 1) <> -1 OR (`c`.`City` IS NULL)");
749+
WHERE (INSTR(1, `c`.`City`, 'Sea', 1) - 1) <> -1 OR `c`.`City` IS NULL
750+
""");
749751
}
750752

751753
public override async Task Where_string_replace(bool isAsync)

test/EFCore.Jet.FunctionalTests/Query/SimpleQueryJetTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public override async Task Comparing_byte_column_to_enum_in_vb_creating_double_c
7878
"""
7979
SELECT `f`.`Id`, `f`.`Taste`
8080
FROM `Food` AS `f`
81-
WHERE `f`.`Taste` = 0x01
81+
WHERE `f`.`Taste` = CBYTE(1)
8282
""");
8383
}
8484

test/EFCore.Jet.FunctionalTests/Query/SqlExecutorJetTest.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,13 @@ public override async Task Query_with_parameters_interpolated(bool async)
118118
}
119119

120120
protected override DbParameter CreateDbParameter(string name, object value)
121-
=> new OdbcParameter { ParameterName = name, Value = value };
121+
{
122+
if (((JetTestStore)Fixture.TestStore).IsOleDb())
123+
{
124+
return new OleDbParameter { ParameterName = name, Value = value };
125+
}
126+
return new OdbcParameter { ParameterName = name, Value = value };
127+
}
122128

123129
protected override string TenMostExpensiveProductsSproc => "`Ten Most Expensive Products`";
124130
protected override string CustomerOrderHistorySproc => "`CustOrderHist` @CustomerID";

test/EFCore.Jet.FunctionalTests/Query/TPTInheritanceQueryJetTest.cs

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public override async Task Byte_enum_value_constant_used_in_projection(bool asyn
2727
await base.Byte_enum_value_constant_used_in_projection(async);
2828

2929
AssertSql(
30-
"""
31-
SELECT IIF(`b`.`IsFlightless` = TRUE, 0x00, 0x01)
30+
"""
31+
SELECT IIF(`b`.`IsFlightless` = TRUE, CBYTE(0), CBYTE(1))
3232
FROM (`Animals` AS `a`
3333
INNER JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id`)
3434
INNER JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id`
@@ -265,13 +265,10 @@ public override async Task Can_use_is_kiwi_with_cast(bool async)
265265
await base.Can_use_is_kiwi_with_cast(async);
266266

267267
AssertSql(
268-
"""
269-
SELECT CASE
270-
WHEN [k].[Id] IS NOT NULL THEN [k].[FoundOn]
271-
ELSE CAST(0 AS tinyint)
272-
END AS [Value]
273-
FROM [Animals] AS [a]
274-
LEFT JOIN [Kiwi] AS [k] ON [a].[Id] = [k].[Id]
268+
"""
269+
SELECT IIF(`k`.`Id` IS NOT NULL, `k`.`FoundOn`, CBYTE(0)) AS `Value`
270+
FROM `Animals` AS `a`
271+
LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id`
275272
""");
276273
}
277274

@@ -399,14 +396,12 @@ public override async Task Can_use_of_type_kiwi_where_north_on_derived_property(
399396
await base.Can_use_of_type_kiwi_where_north_on_derived_property(async);
400397

401398
AssertSql(
402-
"""
403-
SELECT [a].[Id], [a].[CountryId], [a].[Name], [a].[Species], [b].[EagleId], [b].[IsFlightless], [k].[FoundOn], CASE
404-
WHEN [k].[Id] IS NOT NULL THEN N'Kiwi'
405-
END AS [Discriminator]
406-
FROM [Animals] AS [a]
407-
LEFT JOIN [Birds] AS [b] ON [a].[Id] = [b].[Id]
408-
LEFT JOIN [Kiwi] AS [k] ON [a].[Id] = [k].[Id]
409-
WHERE ([k].[Id] IS NOT NULL) AND [k].[FoundOn] = CAST(0 AS tinyint)
399+
"""
400+
SELECT `a`.`Id`, `a`.`CountryId`, `a`.`Name`, `a`.`Species`, `b`.`EagleId`, `b`.`IsFlightless`, `k`.`FoundOn`, IIF(`k`.`Id` IS NOT NULL, 'Kiwi', NULL) AS `Discriminator`
401+
FROM (`Animals` AS `a`
402+
LEFT JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id`)
403+
LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id`
404+
WHERE `k`.`Id` IS NOT NULL AND `k`.`FoundOn` = CBYTE(0)
410405
""");
411406
}
412407

@@ -415,14 +410,12 @@ public override async Task Can_use_of_type_kiwi_where_south_on_derived_property(
415410
await base.Can_use_of_type_kiwi_where_south_on_derived_property(async);
416411

417412
AssertSql(
418-
"""
419-
SELECT [a].[Id], [a].[CountryId], [a].[Name], [a].[Species], [b].[EagleId], [b].[IsFlightless], [k].[FoundOn], CASE
420-
WHEN [k].[Id] IS NOT NULL THEN N'Kiwi'
421-
END AS [Discriminator]
422-
FROM [Animals] AS [a]
423-
LEFT JOIN [Birds] AS [b] ON [a].[Id] = [b].[Id]
424-
LEFT JOIN [Kiwi] AS [k] ON [a].[Id] = [k].[Id]
425-
WHERE ([k].[Id] IS NOT NULL) AND [k].[FoundOn] = CAST(1 AS tinyint)
413+
"""
414+
SELECT `a`.`Id`, `a`.`CountryId`, `a`.`Name`, `a`.`Species`, `b`.`EagleId`, `b`.`IsFlightless`, `k`.`FoundOn`, IIF(`k`.`Id` IS NOT NULL, 'Kiwi', NULL) AS `Discriminator`
415+
FROM (`Animals` AS `a`
416+
LEFT JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id`)
417+
LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id`
418+
WHERE `k`.`Id` IS NOT NULL AND `k`.`FoundOn` = CBYTE(1)
426419
""");
427420
}
428421

test/EFCore.Jet.FunctionalTests/TestUtilities/JetTestStore.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
using System.Collections.Generic;
55
using System.Data;
66
using System.Data.Common;
7+
using System.Data.OleDb;
78
using System.IO;
89
using System.Linq;
910
using System.Reflection;
1011
using System.Text.RegularExpressions;
1112
using System.Threading.Tasks;
1213
using EntityFrameworkCore.Jet.Data;
14+
using Humanizer;
1315
using Microsoft.EntityFrameworkCore;
1416
using Microsoft.EntityFrameworkCore.TestUtilities;
1517

@@ -418,5 +420,10 @@ public static string CreateConnectionString(string name)
418420

419421
public override string NormalizeDelimitersInRawString(string sql)
420422
=> sql.Replace("[", "`").Replace("]", "`");
423+
424+
public bool IsOleDb()
425+
{
426+
return ((EntityFrameworkCore.Jet.Data.JetConnection)Connection).DataAccessProviderFactory is OleDbFactory;
427+
}
421428
}
422429
}

0 commit comments

Comments
 (0)