You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
206 lines
5.9 KiB
C#
206 lines
5.9 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore.BulkUpdates;
|
|
using Microsoft.EntityFrameworkCore.TestUtilities;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace EntityFrameworkCore.Jet.FunctionalTests.BulkUpdates;
|
|
|
|
public class TPCInheritanceBulkUpdatesJetTest : TPCInheritanceBulkUpdatesTestBase<TPCInheritanceBulkUpdatesJetFixture>
|
|
{
|
|
public TPCInheritanceBulkUpdatesJetTest(
|
|
TPCInheritanceBulkUpdatesJetFixture fixture,
|
|
ITestOutputHelper testOutputHelper)
|
|
: base(fixture, testOutputHelper)
|
|
{
|
|
}
|
|
|
|
[ConditionalFact]
|
|
public virtual void Check_all_tests_overridden()
|
|
=> TestHelpers.AssertAllMethodsOverridden(GetType());
|
|
|
|
public override async Task Delete_where_hierarchy(bool async)
|
|
{
|
|
await base.Delete_where_hierarchy(async);
|
|
|
|
AssertSql();
|
|
}
|
|
|
|
public override async Task Delete_where_hierarchy_derived(bool async)
|
|
{
|
|
await base.Delete_where_hierarchy_derived(async);
|
|
|
|
AssertSql(
|
|
"""
|
|
DELETE FROM [k]
|
|
FROM [Kiwi] AS [k]
|
|
WHERE [k].[Name] = N'Great spotted kiwi'
|
|
""");
|
|
}
|
|
|
|
public override async Task Delete_where_using_hierarchy(bool async)
|
|
{
|
|
await base.Delete_where_using_hierarchy(async);
|
|
|
|
AssertSql(
|
|
"""
|
|
DELETE FROM [c]
|
|
FROM [Countries] AS [c]
|
|
WHERE (
|
|
SELECT COUNT(*)
|
|
FROM (
|
|
SELECT [e].[Id], [e].[CountryId], [e].[Name], [e].[Species], [e].[EagleId], [e].[IsFlightless], [e].[Group], NULL AS [FoundOn], N'Eagle' AS [Discriminator]
|
|
FROM [Eagle] AS [e]
|
|
UNION ALL
|
|
SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator]
|
|
FROM [Kiwi] AS [k]
|
|
) AS [t]
|
|
WHERE [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0
|
|
""");
|
|
}
|
|
|
|
public override async Task Delete_where_using_hierarchy_derived(bool async)
|
|
{
|
|
await base.Delete_where_using_hierarchy_derived(async);
|
|
|
|
AssertSql(
|
|
"""
|
|
DELETE FROM [c]
|
|
FROM [Countries] AS [c]
|
|
WHERE (
|
|
SELECT COUNT(*)
|
|
FROM (
|
|
SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator]
|
|
FROM [Kiwi] AS [k]
|
|
) AS [t]
|
|
WHERE [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0
|
|
""");
|
|
}
|
|
|
|
public override async Task Delete_where_keyless_entity_mapped_to_sql_query(bool async)
|
|
{
|
|
await base.Delete_where_keyless_entity_mapped_to_sql_query(async);
|
|
|
|
AssertSql();
|
|
}
|
|
|
|
public override async Task Delete_where_hierarchy_subquery(bool async)
|
|
{
|
|
await base.Delete_where_hierarchy_subquery(async);
|
|
|
|
AssertSql();
|
|
}
|
|
|
|
public override async Task Delete_GroupBy_Where_Select_First(bool async)
|
|
{
|
|
await base.Delete_GroupBy_Where_Select_First(async);
|
|
|
|
AssertSql();
|
|
}
|
|
|
|
public override async Task Delete_GroupBy_Where_Select_First_2(bool async)
|
|
{
|
|
await base.Delete_GroupBy_Where_Select_First_2(async);
|
|
|
|
AssertSql();
|
|
}
|
|
|
|
public override async Task Delete_GroupBy_Where_Select_First_3(bool async)
|
|
{
|
|
await base.Delete_GroupBy_Where_Select_First_3(async);
|
|
|
|
AssertSql();
|
|
}
|
|
|
|
public override async Task Update_where_hierarchy_subquery(bool async)
|
|
{
|
|
await base.Update_where_hierarchy_subquery(async);
|
|
|
|
AssertExecuteUpdateSql();
|
|
}
|
|
|
|
public override async Task Update_where_using_hierarchy(bool async)
|
|
{
|
|
await base.Update_where_using_hierarchy(async);
|
|
|
|
AssertExecuteUpdateSql(
|
|
"""
|
|
UPDATE [c]
|
|
SET [c].[Name] = N'Monovia'
|
|
FROM [Countries] AS [c]
|
|
WHERE (
|
|
SELECT COUNT(*)
|
|
FROM (
|
|
SELECT [e].[Id], [e].[CountryId], [e].[Name], [e].[Species], [e].[EagleId], [e].[IsFlightless], [e].[Group], NULL AS [FoundOn], N'Eagle' AS [Discriminator]
|
|
FROM [Eagle] AS [e]
|
|
UNION ALL
|
|
SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator]
|
|
FROM [Kiwi] AS [k]
|
|
) AS [t]
|
|
WHERE [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0
|
|
""");
|
|
}
|
|
|
|
public override async Task Update_where_using_hierarchy_derived(bool async)
|
|
{
|
|
await base.Update_where_using_hierarchy_derived(async);
|
|
|
|
AssertExecuteUpdateSql(
|
|
"""
|
|
UPDATE [c]
|
|
SET [c].[Name] = N'Monovia'
|
|
FROM [Countries] AS [c]
|
|
WHERE (
|
|
SELECT COUNT(*)
|
|
FROM (
|
|
SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator]
|
|
FROM [Kiwi] AS [k]
|
|
) AS [t]
|
|
WHERE [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0
|
|
""");
|
|
}
|
|
|
|
public override async Task Update_with_interface_in_property_expression(bool async)
|
|
{
|
|
await base.Update_with_interface_in_property_expression(async);
|
|
|
|
AssertExecuteUpdateSql(
|
|
"""
|
|
UPDATE [c]
|
|
SET [c].[SugarGrams] = 0
|
|
FROM [Coke] AS [c]
|
|
""");
|
|
}
|
|
|
|
public override async Task Update_with_interface_in_EF_Property_in_property_expression(bool async)
|
|
{
|
|
await base.Update_with_interface_in_EF_Property_in_property_expression(async);
|
|
|
|
AssertExecuteUpdateSql(
|
|
"""
|
|
UPDATE [c]
|
|
SET [c].[SugarGrams] = 0
|
|
FROM [Coke] AS [c]
|
|
""");
|
|
}
|
|
|
|
public override async Task Update_where_keyless_entity_mapped_to_sql_query(bool async)
|
|
{
|
|
await base.Update_where_keyless_entity_mapped_to_sql_query(async);
|
|
|
|
AssertExecuteUpdateSql();
|
|
}
|
|
|
|
protected override void ClearLog()
|
|
=> Fixture.TestSqlLoggerFactory.Clear();
|
|
|
|
private void AssertSql(params string[] expected)
|
|
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
|
|
|
|
private void AssertExecuteUpdateSql(params string[] expected)
|
|
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected, forUpdate: true);
|
|
}
|