diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs index 9559f950d0b..0481da61533 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs @@ -52,34 +52,6 @@ public override async Task Like_identity(bool async) AssertSql(); } - public override Task Random_return_less_than_1(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Random_return_less_than_1(async); - - AssertSql( - """ -SELECT VALUE COUNT(1) -FROM root c -WHERE ((c["$type"] = "Order") AND (RAND() < 1.0)) -"""); - }); - - public override Task Random_return_greater_than_0(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Random_return_greater_than_0(async); - - AssertSql( - """ -SELECT VALUE COUNT(1) -FROM root c -WHERE ((c["$type"] = "Order") AND (RAND() >= 0.0)) -"""); - }); - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs index c1027628534..e3d3a5ed169 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs @@ -1915,122 +1915,6 @@ ORDER BY ((c["Region"] != null) ? c["Region"] : "ZZ") } } - public override Task DateTime_parse_is_inlined(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.DateTime_parse_is_inlined(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (c["OrderDate"] > "1998-01-01T12:00:00")) -"""); - }); - - public override Task DateTime_parse_is_parameterized_when_from_closure(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.DateTime_parse_is_parameterized_when_from_closure(a); - - AssertSql( - """ -@Parse='1998-01-01T12:00:00' - -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (c["OrderDate"] > @Parse)) -"""); - }); - - public override Task New_DateTime_is_inlined(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.New_DateTime_is_inlined(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (c["OrderDate"] > "1998-01-01T12:00:00")) -"""); - }); - - public override Task New_DateTime_is_parameterized_when_from_closure(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.New_DateTime_is_parameterized_when_from_closure(a); - - AssertSql( - """ -@p='1998-01-01T12:00:00' - -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (c["OrderDate"] > @p)) -""", - // - """ -@p='1998-01-01T11:00:00' - -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (c["OrderDate"] > @p)) -"""); - }); - - public override async Task Random_next_is_not_funcletized_1(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Random_next_is_not_funcletized_1(async)); - - AssertSql(); - } - - public override async Task Random_next_is_not_funcletized_2(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Random_next_is_not_funcletized_2(async)); - - AssertSql(); - } - - public override async Task Random_next_is_not_funcletized_3(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Random_next_is_not_funcletized_3(async)); - - AssertSql(); - } - - public override async Task Random_next_is_not_funcletized_4(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Random_next_is_not_funcletized_4(async)); - - AssertSql(); - } - - public override async Task Random_next_is_not_funcletized_5(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Random_next_is_not_funcletized_5(async)); - - AssertSql(); - } - - public override async Task Random_next_is_not_funcletized_6(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Random_next_is_not_funcletized_6(async)); - - AssertSql(); - } - public override Task Environment_newline_is_funcletized(bool async) => Fixture.NoSyncTest( async, async a => @@ -2066,242 +1950,6 @@ public override async Task String_concat_with_navigation2(bool async) AssertSql(); } - public override async Task Select_bitwise_or(bool async) - { - // Always throws for sync. - if (async) - { - // Bitwise operators on booleans. Issue #13168. - await Assert.ThrowsAsync(() => base.Select_bitwise_or(async)); - AssertSql( - """ -SELECT VALUE -{ - "CustomerID" : c["id"], - "Value" : ((c["id"] = "ALFKI") | (c["id"] = "ANATR")) -} -FROM root c -ORDER BY c["id"] -"""); - } - } - - public override async Task Select_bitwise_or_multiple(bool async) - { - // Always throws for sync. - if (async) - { - // Bitwise operators on booleans. Issue #13168. - await Assert.ThrowsAsync(() => base.Select_bitwise_or_multiple(async)); - AssertSql( - """ -SELECT VALUE -{ - "CustomerID" : c["id"], - "Value" : (((c["id"] = "ALFKI") | (c["id"] = "ANATR")) | (c["id"] = "ANTON")) -} -FROM root c -ORDER BY c["id"] -"""); - } - } - - public override async Task Select_bitwise_and(bool async) - { - // Always throws for sync. - if (async) - { - // Bitwise operators on booleans. Issue #13168. - await Assert.ThrowsAsync(() => base.Select_bitwise_and(async)); - AssertSql( - """ -SELECT VALUE -{ - "CustomerID" : c["id"], - "Value" : ((c["id"] = "ALFKI") & (c["id"] = "ANATR")) -} -FROM root c -ORDER BY c["id"] -"""); - } - } - - public override async Task Select_bitwise_and_or(bool async) - { - // Always throws for sync. - if (async) - { - // Bitwise operators on booleans. Issue #13168. - await Assert.ThrowsAsync(() => base.Select_bitwise_and_or(async)); - AssertSql( - """ -SELECT VALUE -{ - "CustomerID" : c["id"], - "Value" : (((c["id"] = "ALFKI") & (c["id"] = "ANATR")) | (c["id"] = "ANTON")) -} -FROM root c -ORDER BY c["id"] -"""); - } - } - - public override async Task Where_bitwise_or_with_logical_or(bool async) - { - // Always throws for sync. - if (async) - { - // Bitwise operators on booleans. Issue #13168. - await Assert.ThrowsAsync(() => base.Where_bitwise_or_with_logical_or(async)); - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["id"] = "ALFKI") | (c["id"] = "ANATR")) OR (c["id"] = "ANTON")) -"""); - } - } - - public override Task Where_bitwise_and_with_logical_and(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_bitwise_and_with_logical_and(a); - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["id"] = "ALFKI") & (c["id"] = "ANATR")) AND (c["id"] = "ANTON")) -"""); - }); - - public override async Task Where_bitwise_or_with_logical_and(bool async) - { - // Always throws for sync. - if (async) - { - // Bitwise operators on booleans. Issue #13168. - await Assert.ThrowsAsync(() => base.Where_bitwise_or_with_logical_and(async)); - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["id"] = "ALFKI") | (c["id"] = "ANATR")) AND (c["Country"] = "Germany")) -"""); - } - } - - public override Task Where_bitwise_and_with_logical_or(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_bitwise_and_with_logical_or(a); - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["id"] = "ALFKI") & (c["id"] = "ANATR")) OR (c["id"] = "ANTON")) -"""); - }); - - public override Task Where_bitwise_binary_not(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_bitwise_binary_not(a); - - AssertSql( - """ -@negatedId='-10249' - -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (~(c["OrderID"]) = @negatedId)) -"""); - }); - - public override Task Where_bitwise_binary_and(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_bitwise_binary_and(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND ((c["OrderID"] & 10248) = 10248)) -"""); - }); - - public override Task Where_bitwise_binary_or(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_bitwise_binary_or(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND ((c["OrderID"] | 10248) = 10248)) -"""); - }); - - public override Task Where_bitwise_binary_xor(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_bitwise_binary_xor(async); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND ((c["OrderID"] ^ 1) = 10249)) -"""); - }); - - public override async Task Select_bitwise_or_with_logical_or(bool async) - { - // Always throws for sync. - if (async) - { - // Bitwise operators on booleans. Issue #13168. - await Assert.ThrowsAsync(() => base.Select_bitwise_or_with_logical_or(async)); - AssertSql( - """ -SELECT VALUE -{ - "CustomerID" : c["id"], - "Value" : (((c["id"] = "ALFKI") | (c["id"] = "ANATR")) OR (c["id"] = "ANTON")) -} -FROM root c -ORDER BY c["id"] -"""); - } - } - - public override async Task Select_bitwise_and_with_logical_and(bool async) - { - // Always throws for sync. - if (async) - { - // Bitwise operators on booleans. Issue #13168. - await Assert.ThrowsAsync(() => base.Select_bitwise_and_with_logical_and(async)); - AssertSql( - """ -SELECT VALUE -{ - "CustomerID" : c["id"], - "Value" : (((c["id"] = "ALFKI") & (c["id"] = "ANATR")) AND (c["id"] = "ANTON")) -} -FROM root c -ORDER BY c["id"] -"""); - } - } - public override async Task Handle_materialization_properly_when_more_than_two_query_sources_are_involved(bool async) { // Cosmos client evaluation. Issue #17246. diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/MiscellaneousTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/MiscellaneousTranslationsCosmosTest.cs index 5efbf266cda..06b22f7c3ab 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/MiscellaneousTranslationsCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/MiscellaneousTranslationsCosmosTest.cs @@ -79,6 +79,66 @@ public override Task Byte_array_First(bool async) #endregion Byte array + #region Random + + public override Task Random_on_EF_Functions(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Random_on_EF_Functions(a); + + AssertSql( + """ +SELECT VALUE COUNT(1) +FROM root c +WHERE ((RAND() >= 0.0) AND (RAND() < 1.0)) +"""); + }); + + public override async Task Random_Shared_Next_with_no_args(bool async) + { + await AssertTranslationFailed(() => base.Random_Shared_Next_with_no_args(async)); + + AssertSql(); + } + + public override async Task Random_Shared_Next_with_one_arg(bool async) + { + await AssertTranslationFailed(() => base.Random_Shared_Next_with_one_arg(async)); + + AssertSql(); + } + + public override async Task Random_Shared_Next_with_two_args(bool async) + { + await AssertTranslationFailed(() => base.Random_Shared_Next_with_two_args(async)); + + AssertSql(); + } + + public override async Task Random_new_Next_with_no_args(bool async) + { + await AssertTranslationFailed(() => base.Random_new_Next_with_no_args(async)); + + AssertSql(); + } + + public override async Task Random_new_Next_with_one_arg(bool async) + { + await AssertTranslationFailed(() => base.Random_new_Next_with_one_arg(async)); + + AssertSql(); + } + + public override async Task Random_new_Next_with_two_args(bool async) + { + await AssertTranslationFailed(() => base.Random_new_Next_with_two_args(async)); + + AssertSql(); + } + + #endregion Random + #region Convert public override async Task Convert_ToBoolean(bool async) diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/OperatorTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/OperatorTranslationsCosmosTest.cs new file mode 100644 index 00000000000..ab39e7c5b37 --- /dev/null +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/OperatorTranslationsCosmosTest.cs @@ -0,0 +1,243 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Xunit.Sdk; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class OperatorTranslationsCosmosTest : OperatorTranslationsTestBase +{ + public OperatorTranslationsCosmosTest(BasicTypesQueryCosmosFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Bitwise + + public override Task Bitwise_or(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Bitwise_xor(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Int"] ^ c["Short"]) = 1) +""", + // + """ +SELECT VALUE (c["Int"] ^ c["Short"]) +FROM root c +"""); + }); + + public override async Task Bitwise_or_over_boolean(bool async) + { + // Always throws for sync. + if (async) + { + // Bitwise operators on booleans. Issue #13168. + await Assert.ThrowsAsync(() => base.Bitwise_or_over_boolean(async)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Int"] = 12) | (c["String"] = "Seattle")) +"""); + } + } + + public override async Task Bitwise_or_multiple(bool async) + { + // Always throws for sync. + if (async) + { + // Bitwise operators on booleans. Issue #13168. + await Assert.ThrowsAsync(() => base.Bitwise_or_multiple(async)); + + AssertSql(); + } + } + + public override Task Bitwise_and(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Bitwise_xor(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Int"] ^ c["Short"]) = 1) +""", + // + """ +SELECT VALUE (c["Int"] ^ c["Short"]) +FROM root c +"""); + }); + + public override async Task Bitwise_and_over_boolean(bool async) + { + // Always throws for sync. + if (async) + { + // Bitwise operators on booleans. Issue #13168. + await Assert.ThrowsAsync(() => base.Bitwise_and_over_boolean(async)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Int"] = 8) & (c["String"] = "Seattle")) +"""); + } + } + + public override Task Bitwise_xor(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Bitwise_xor(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Int"] ^ c["Short"]) = 1) +""", + // + """ +SELECT VALUE (c["Int"] ^ c["Short"]) +FROM root c +"""); + }); + + public override Task Bitwise_xor_over_boolean(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Bitwise_xor_over_boolean(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Int"] = c["Short"]) != (c["String"] = "Seattle")) +"""); + }); + + public override Task Bitwise_complement(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Bitwise_complement(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (~(c["Int"]) = -9) +"""); + }); + + public override async Task Bitwise_and_or_over_boolean(bool async) + { + // Always throws for sync. + if (async) + { + // Bitwise operators on booleans. Issue #13168. + await Assert.ThrowsAsync(() => base.Bitwise_and_or_over_boolean(async)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (((c["Int"] = 12) & (c["Short"] = 12)) | (c["String"] = "Seattle")) +"""); + } + } + + public override async Task Bitwise_or_with_logical_or(bool async) + { + // Always throws for sync. + if (async) + { + // Bitwise operators on booleans. Issue #13168. + await Assert.ThrowsAsync(() => base.Bitwise_or_with_logical_or(async)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (((c["Int"] = 12) | (c["Short"] = 12)) OR (c["String"] = "Seattle")) +"""); + } + } + + public override async Task Bitwise_and_with_logical_and(bool async) + { + // Always throws for sync. + if (async) + { + // Bitwise operators on booleans. Issue #13168. + await Assert.ThrowsAsync(() => base.Bitwise_and_with_logical_and(async)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (((c["Int"] = 8) & (c["Short"] = 8)) AND (c["String"] = "Seattle")) +"""); + } + } + + public override async Task Bitwise_or_with_logical_and(bool async) + { + // Always throws for sync. + if (async) + { + // Bitwise operators on booleans. Issue #13168. + await Assert.ThrowsAsync(() => base.Bitwise_or_with_logical_and(async)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (((c["Int"] = 8) | (c["Short"] = 9)) AND (c["String"] = "Seattle")) +"""); + } + } + + public override async Task Bitwise_and_with_logical_or(bool async) + { + // Always throws for sync. + if (async) + { + // Bitwise operators on booleans. Issue #13168. + await Assert.ThrowsAsync(() => base.Bitwise_and_with_logical_or(async)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (((c["Int"] = 12) & (c["Short"] = 12)) OR (c["String"] = "Seattle")) +"""); + } + } + + #endregion Bitwise + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/TemporalTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/TemporalTranslationsCosmosTest.cs index 0fc11bd3edd..721a5c2a43b 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/TemporalTranslationsCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/TemporalTranslationsCosmosTest.cs @@ -191,6 +191,66 @@ public override async Task DateTime_subtract_and_TotalDays(bool async) AssertSql(); } + public override Task DateTime_Parse_with_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_Parse_with_constant(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["DateTime"] = "1998-05-04T15:30:10") +"""); + }); + + public override Task DateTime_Parse_with_parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_Parse_with_parameter(a); + + AssertSql( + """ +@Parse=? + +SELECT VALUE c +FROM root c +WHERE (c["DateTime"] = @Parse) +"""); + }); + + public override Task DateTime_new_with_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_new_with_constant(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["DateTime"] = "1998-05-04T15:30:10") +"""); + }); + + public override Task DateTime_new_with_parameters(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_new_with_parameters(a); + + AssertSql( + """ +@p=? + +SELECT VALUE c +FROM root c +WHERE (c["DateTime"] = @p) +"""); + }); + #endregion DateTime #region DateOnly diff --git a/test/EFCore.InMemory.FunctionalTests/Query/Translations/OperatorTranslationsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/Translations/OperatorTranslationsInMemoryTest.cs new file mode 100644 index 00000000000..7db964fc412 --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/Translations/OperatorTranslationsInMemoryTest.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class OperatorTranslationsInMemoryTest(BasicTypesQueryInMemoryFixture fixture) + : OperatorTranslationsTestBase(fixture); diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs index 6d8b35db5de..49f3c613548 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs @@ -44,24 +44,6 @@ public override Task Using_string_Equals_with_StringComparison_throws_informativ () => base.Using_string_Equals_with_StringComparison_throws_informative_error(async), CoreStrings.QueryUnableToTranslateStringEqualsWithStringComparison); - public override Task Random_next_is_not_funcletized_1(bool async) - => AssertTranslationFailed(() => base.Random_next_is_not_funcletized_1(async)); - - public override Task Random_next_is_not_funcletized_2(bool async) - => AssertTranslationFailed(() => base.Random_next_is_not_funcletized_2(async)); - - public override Task Random_next_is_not_funcletized_3(bool async) - => AssertTranslationFailed(() => base.Random_next_is_not_funcletized_3(async)); - - public override Task Random_next_is_not_funcletized_4(bool async) - => AssertTranslationFailed(() => base.Random_next_is_not_funcletized_4(async)); - - public override Task Random_next_is_not_funcletized_5(bool async) - => AssertTranslationFailed(() => base.Random_next_is_not_funcletized_5(async)); - - public override Task Random_next_is_not_funcletized_6(bool async) - => AssertTranslationFailed(() => base.Random_next_is_not_funcletized_6(async)); - protected override QueryAsserter CreateQueryAsserter(TFixture fixture) => new RelationalQueryAsserter( fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression); diff --git a/test/EFCore.Relational.Specification.Tests/Query/Translations/MiscellaneousTranslationsRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/Translations/MiscellaneousTranslationsRelationalTestBase.cs new file mode 100644 index 00000000000..cda5ff03a2f --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/Translations/MiscellaneousTranslationsRelationalTestBase.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public abstract class MiscellaneousTranslationsRelationalTestBase(TFixture fixture) : MiscellaneousTranslationsTestBase(fixture) + where TFixture : BasicTypesQueryFixtureBase, new() +{ + public override Task Random_Shared_Next_with_no_args(bool async) + => AssertTranslationFailed(() => base.Random_Shared_Next_with_no_args(async)); + + public override Task Random_Shared_Next_with_one_arg(bool async) + => AssertTranslationFailed(() => base.Random_Shared_Next_with_one_arg(async)); + + public override Task Random_Shared_Next_with_two_args(bool async) + => AssertTranslationFailed(() => base.Random_Shared_Next_with_two_args(async)); + + public override Task Random_new_Next_with_no_args(bool async) + => AssertTranslationFailed(() => base.Random_new_Next_with_no_args(async)); + + public override Task Random_new_Next_with_one_arg(bool async) + => AssertTranslationFailed(() => base.Random_new_Next_with_one_arg(async)); + + public override Task Random_new_Next_with_two_args(bool async) + => AssertTranslationFailed(() => base.Random_new_Next_with_two_args(async)); +} diff --git a/test/EFCore.Specification.Tests/DataBindingTestBase.cs b/test/EFCore.Specification.Tests/DataBindingTestBase.cs index 118c6b500af..f8732999347 100644 --- a/test/EFCore.Specification.Tests/DataBindingTestBase.cs +++ b/test/EFCore.Specification.Tests/DataBindingTestBase.cs @@ -281,20 +281,20 @@ public virtual void Remove_detached_entity_from_LocalView(bool toObservableColle Assert.Equal(2, local.ToList().Count); Assert.True(local.Contains(driver1)); - Assert.True(localView.Contains(driver1)); + Assert.Contains(driver1, localView); Assert.True(local.Contains(driver2)); - Assert.True(localView.Contains(driver2)); + Assert.Contains(driver2, localView); Assert.False(local.Contains(driver3)); - Assert.False(localView.Contains(driver3)); + Assert.DoesNotContain(driver3, localView); context.Entry(driver3); Assert.True(local.Contains(driver1)); - Assert.True(localView.Contains(driver1)); + Assert.Contains(driver1, localView); Assert.True(local.Contains(driver2)); - Assert.True(localView.Contains(driver2)); + Assert.Contains(driver2, localView); Assert.False(local.Contains(driver3)); - Assert.False(localView.Contains(driver3)); + Assert.DoesNotContain(driver3, localView); local.Remove(driver3); @@ -302,11 +302,11 @@ public virtual void Remove_detached_entity_from_LocalView(bool toObservableColle Assert.Equal(2, local.ToList().Count); Assert.True(local.Contains(driver1)); - Assert.True(localView.Contains(driver1)); + Assert.Contains(driver1, localView); Assert.True(local.Contains(driver2)); - Assert.True(localView.Contains(driver2)); + Assert.Contains(driver2, localView); Assert.False(local.Contains(driver3)); - Assert.False(localView.Contains(driver3)); + Assert.DoesNotContain(driver3, localView); } [ConditionalTheory] diff --git a/test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.cs index 39519691f3d..7e56fe46177 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.cs @@ -59,26 +59,6 @@ public virtual Task Like_all_literals_with_escape(bool async) c => EF.Functions.Like("%", "!%", "!"), c => "%".Contains("%")); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Random_return_less_than_1(bool async) - => AssertCount( - async, - ss => ss.Set(), - ss => ss.Set(), - ss => EF.Functions.Random() < 1, - c => true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Random_return_greater_than_0(bool async) - => AssertCount( - async, - ss => ss.Set(), - ss => ss.Set(), - ss => EF.Functions.Random() >= 0, - c => true); - protected NorthwindContext CreateContext() => Fixture.CreateContext(); } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs index 5c553f21d37..a9fb1c35e31 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs @@ -3077,95 +3077,6 @@ private static Customer Process(Customer c, ManualResetEventSlim e, SemaphoreSli return c; } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTime_parse_is_inlined(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate > DateTime.Parse("1/1/1998 12:00:00 PM"))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTime_parse_is_parameterized_when_from_closure(bool async) - { - var date = "1/1/1998 12:00:00 PM"; - - return AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate > DateTime.Parse(date))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task New_DateTime_is_inlined(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate > new DateTime(1998, 1, 1, 12, 0, 0))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task New_DateTime_is_parameterized_when_from_closure(bool async) - { - var year = 1998; - var month = 1; - var date = 1; - var hour = 12; - - await AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate > new DateTime(year, month, date, hour, 0, 0))); - - hour = 11; - - await AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate > new DateTime(year, month, date, hour, 0, 0))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Random_next_is_not_funcletized_1(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderID < (Random.Shared.Next() - 2147483647)), - assertEmpty: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Random_next_is_not_funcletized_2(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderID > Random.Shared.Next(5))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Random_next_is_not_funcletized_3(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderID > Random.Shared.Next(0, 10))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Random_next_is_not_funcletized_4(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderID - 20000 > new Random(15).Next()), - assertEmpty: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Random_next_is_not_funcletized_5(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderID > new Random(15).Next(5))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Random_next_is_not_funcletized_6(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderID > new Random(15).Next(0, 10))); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Environment_newline_is_funcletized(bool async) @@ -3219,117 +3130,6 @@ public virtual Task String_concat_with_navigation2(bool async) async, ss => ss.Set().Select(o => o.Customer.City + " " + o.Customer.City)); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_bitwise_or(bool async) - => AssertQuery( - async, - ss => ss.Set().OrderBy(c => c.CustomerID).Select( - c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" })); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_bitwise_or_multiple(bool async) - => AssertQuery( - async, - ss => ss.Set().OrderBy(c => c.CustomerID) - .Select( - c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" | c.CustomerID == "ANTON" })); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_bitwise_and(bool async) - => AssertQuery( - async, - ss => ss.Set().OrderBy(c => c.CustomerID).Select( - c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" })); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_bitwise_and_or(bool async) - => AssertQuery( - async, - ss => ss.Set().OrderBy(c => c.CustomerID) - .Select( - c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" | c.CustomerID == "ANTON" })); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_or_with_logical_or(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" || c.CustomerID == "ANTON")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_and_with_logical_and(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" && c.CustomerID == "ANTON"), - assertEmpty: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_or_with_logical_and(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" && c.Country == "Germany")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_and_with_logical_or(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" || c.CustomerID == "ANTON")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_binary_not(bool async) - { - var negatedId = ~10248; - - return AssertQuery( - async, - ss => ss.Set().Where(o => ~o.OrderID == negatedId)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_binary_and(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => (o.OrderID & 10248) == 10248)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_binary_or(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => (o.OrderID | 10248) == 10248)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_binary_xor(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => (o.OrderID ^ 1) == 10249)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_bitwise_or_with_logical_or(bool async) - => AssertQuery( - async, - ss => ss.Set().OrderBy(c => c.CustomerID).Select( - c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" || c.CustomerID == "ANTON" })); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_bitwise_and_with_logical_and(bool async) - => AssertQuery( - async, - ss => ss.Set().OrderBy(c => c.CustomerID).Select( - c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" && c.CustomerID == "ANTON" })); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Handle_materialization_properly_when_more_than_two_query_sources_are_involved(bool async) diff --git a/test/EFCore.Specification.Tests/Query/Translations/MiscellaneousTranslationsTestBase.cs b/test/EFCore.Specification.Tests/Query/Translations/MiscellaneousTranslationsTestBase.cs index d3b98d701f3..7c09cd8de42 100644 --- a/test/EFCore.Specification.Tests/Query/Translations/MiscellaneousTranslationsTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/Translations/MiscellaneousTranslationsTestBase.cs @@ -71,6 +71,63 @@ public virtual Task Byte_array_First(bool async) #endregion Byte array + #region Random + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Random_on_EF_Functions(bool async) + => AssertCount( + async, + ss => ss.Set(), + ss => ss.Set(), + ss => EF.Functions.Random() >= 0 && EF.Functions.Random() < 1, + c => true); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Random_Shared_Next_with_no_args(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.Int < (Random.Shared.Next() - 2147483647)), + assertEmpty: true); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Random_Shared_Next_with_one_arg(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.Int > Random.Shared.Next(5) - 2147483647)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Random_Shared_Next_with_two_args(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.Int > Random.Shared.Next(0, 10) - 2147483647)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Random_new_Next_with_no_args(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.Int > new Random(15).Next() - 2147483647)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Random_new_Next_with_one_arg(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.Int > new Random(15).Next(5) - 2147483647)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Random_new_Next_with_two_args(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.Int > new Random(15).Next(0, 10) - 2147483647)); + + #endregion Random + #region Convert [ConditionalTheory] diff --git a/test/EFCore.Specification.Tests/Query/Translations/OperatorTranslationsTestBase.cs b/test/EFCore.Specification.Tests/Query/Translations/OperatorTranslationsTestBase.cs new file mode 100644 index 00000000000..a1f58662859 --- /dev/null +++ b/test/EFCore.Specification.Tests/Query/Translations/OperatorTranslationsTestBase.cs @@ -0,0 +1,137 @@ +// 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.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public abstract class OperatorTranslationsTestBase(TFixture fixture) : QueryTestBase(fixture) + where TFixture : BasicTypesQueryFixtureBase, new() +{ + #region Bitwise +#pragma warning disable CS0675 // Bitwise-or operator used on a sign-extended operand + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Bitwise_or(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => (b.Int | b.Long) == 7)); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.Int | b.Long)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Bitwise_or_over_boolean(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => b.Int == 12 | b.String == "Seattle")); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.Int == 12 | b.String == "Seattle")); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_or_multiple(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => (b.Int | b.Short | b.Long) == 7)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Bitwise_and(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => (b.Int & b.Short) == 2)); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.Int & b.Short)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Bitwise_and_over_boolean(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => b.Int == 8 & b.String == "Seattle")); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.Int == 8 & b.String == "Seattle")); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Bitwise_xor(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => (b.Int ^ b.Short) == 1)); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.Int ^ b.Short)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_xor_over_boolean(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => (b.Int == b.Short) ^ (b.String == "Seattle"))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_complement(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => ~b.Int == -9)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_and_or_over_boolean(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Int == 12 & b.Short == 12 | b.String == "Seattle")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_or_with_logical_or(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Int == 12 | b.Short == 12 || b.String == "Seattle")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_and_with_logical_and(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Int == 8 & b.Short == 8 && b.String == "Seattle")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_or_with_logical_and(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Int == 8 | b.Short == 9 && b.String == "Seattle")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_and_with_logical_or(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Int == 12 & b.Short == 12 || b.String == "Seattle")); + +#pragma warning restore CS0675 // Bitwise-or operator used on a sign-extended operand + #endregion Bitwise +} diff --git a/test/EFCore.Specification.Tests/Query/Translations/StringTranslationsTestBase.cs b/test/EFCore.Specification.Tests/Query/Translations/StringTranslationsTestBase.cs index 60c6cbe37e1..3a729c7c9fe 100644 --- a/test/EFCore.Specification.Tests/Query/Translations/StringTranslationsTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/Translations/StringTranslationsTestBase.cs @@ -664,7 +664,7 @@ public virtual async Task Compare_with_parameter(bool async) BasicTypesEntity? basicTypeEntity; await using (var context = CreateContext()) { - basicTypeEntity = await context.BasicTypesEntities.SingleAsync(c => c.String == "Seattle"); + basicTypeEntity = await context.BasicTypesEntities.SingleAsync(c => c.Id == 1); } ClearLog(); @@ -818,7 +818,7 @@ public virtual async Task CompareTo_with_parameter(bool async) BasicTypesEntity? basicTypesEntity; using (var context = CreateContext()) { - basicTypesEntity = await context.BasicTypesEntities.SingleAsync(x => x.String == "Seattle"); + basicTypesEntity = await context.BasicTypesEntities.SingleAsync(x => x.Id == 1); } ClearLog(); diff --git a/test/EFCore.Specification.Tests/Query/Translations/TemporalTranslationsTestBase.cs b/test/EFCore.Specification.Tests/Query/Translations/TemporalTranslationsTestBase.cs index 02a3df62e07..68cfedb82e5 100644 --- a/test/EFCore.Specification.Tests/Query/Translations/TemporalTranslationsTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/Translations/TemporalTranslationsTestBase.cs @@ -132,6 +132,45 @@ public virtual Task DateTime_subtract_and_TotalDays(bool async) ss => ss.Set().Where(o => (o.DateTime - date).TotalDays > 365)); } + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Parse_with_constant(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime == DateTime.Parse("5/4/1998 15:30:10 PM"))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Parse_with_parameter(bool async) + { + var date = "5/4/1998 15:30:10 PM"; + + return AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime == DateTime.Parse(date))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_new_with_constant(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime == new DateTime(1998, 5, 4, 15, 30, 10))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task DateTime_new_with_parameters(bool async) + { + var year = 1998; + var month = 5; + var date = 4; + var hour = 15; + + await AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime == new DateTime(year, month, date, hour, 30, 10))); + } + #endregion DateTime #region DateOnly diff --git a/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesData.cs b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesData.cs index 87b16dd7f8c..88dfc71c308 100644 --- a/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesData.cs +++ b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesData.cs @@ -183,7 +183,34 @@ public static IReadOnlyList CreateBasicTypesEntities() Double = 12, Decimal = 12, - String = "", + String = "Berlin", + + // DateTime = DateTime.MinValue, + // DateOnly = DateOnly.MinValue, + // TimeOnly = TimeOnly.MinValue, + // DateTimeOffset = DateTimeOffset.MinValue, + // TimeSpan = TimeSpan.MinValue, + + Bool = false, + // Guid = new Guid("088ca6e6-c756-42f8-a298-8c28e63fdba6"), + ByteArray = [], + + // Enum = BasicEnum.One, + }, + + new() + { + Id = 6, + + Byte = 1, + Short = 2, + Int = 3, + Long = 4, + Float = 5.6f, + Double = 6.7f, + Decimal = 8.8m, + + String = "Seattle", // DateTime = DateTime.MinValue, // DateOnly = DateOnly.MinValue, diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServer160Test.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServer160Test.cs index 8c3b1ed3cc2..e07a410ed2c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServer160Test.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServer160Test.cs @@ -1437,30 +1437,6 @@ WHERE CAST(DATALENGTH(N'foo') AS int) = 3 } } - public override async Task Random_return_less_than_1(bool async) - { - await base.Random_return_less_than_1(async); - - AssertSql( - """ -SELECT COUNT(*) -FROM [Orders] AS [o] -WHERE RAND() < 1.0E0 -"""); - } - - 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 RAND() >= 0.0E0 -"""); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs index 6e3fb9dc042..17098b8f986 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs @@ -1404,30 +1404,6 @@ WHERE CAST(DATALENGTH(N'foo') AS int) = 3 } } - public override async Task Random_return_less_than_1(bool async) - { - await base.Random_return_less_than_1(async); - - AssertSql( - """ -SELECT COUNT(*) -FROM [Orders] AS [o] -WHERE RAND() < 1.0E0 -"""); - } - - 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 RAND() >= 0.0E0 -"""); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs index 9ca8f2be28c..3b69024591a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs @@ -3023,66 +3023,6 @@ ORDER BY COALESCE([c].[Region], N'ZZ') """); } - public override async Task DateTime_parse_is_inlined(bool async) - { - await base.DateTime_parse_is_inlined(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > '1998-01-01T12:00:00.000' -"""); - } - - public override async Task DateTime_parse_is_parameterized_when_from_closure(bool async) - { - await base.DateTime_parse_is_parameterized_when_from_closure(async); - - AssertSql( - """ -@Parse='1998-01-01T12:00:00.0000000' (Nullable = true) (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @Parse -"""); - } - - public override async Task New_DateTime_is_inlined(bool async) - { - await base.New_DateTime_is_inlined(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > '1998-01-01T12:00:00.000' -"""); - } - - public override async Task New_DateTime_is_parameterized_when_from_closure(bool async) - { - await base.New_DateTime_is_parameterized_when_from_closure(async); - - AssertSql( - """ -@p='1998-01-01T12:00:00.0000000' (Nullable = true) (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @p -""", - // - """ -@p='1998-01-01T11:00:00.0000000' (Nullable = true) (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @p -"""); - } - public override async Task Environment_newline_is_funcletized(bool async) { await base.Environment_newline_is_funcletized(async); @@ -3168,188 +3108,6 @@ FROM [Orders] AS [o] """); } - public override async Task Select_bitwise_or(bool async) - { - await base.Select_bitwise_or(async); - - AssertSql( - """ -SELECT [c].[CustomerID], CASE - WHEN [c].[CustomerID] IN (N'ALFKI', N'ANATR') THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -ORDER BY [c].[CustomerID] -"""); - } - - public override async Task Select_bitwise_or_multiple(bool async) - { - await base.Select_bitwise_or_multiple(async); - - AssertSql( - """ -SELECT [c].[CustomerID], CASE - WHEN [c].[CustomerID] IN (N'ALFKI', N'ANATR', N'ANTON') THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -ORDER BY [c].[CustomerID] -"""); - } - - public override async Task Select_bitwise_and(bool async) - { - await base.Select_bitwise_and(async); - - AssertSql( - """ -SELECT [c].[CustomerID], CAST(0 AS bit) AS [Value] -FROM [Customers] AS [c] -ORDER BY [c].[CustomerID] -"""); - } - - public override async Task Select_bitwise_and_or(bool async) - { - await base.Select_bitwise_and_or(async); - - AssertSql( - """ -SELECT [c].[CustomerID], CASE - WHEN [c].[CustomerID] = N'ANTON' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -ORDER BY [c].[CustomerID] -"""); - } - - public override async Task Where_bitwise_or_with_logical_or(bool async) - { - await base.Where_bitwise_or_with_logical_or(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] IN (N'ALFKI', N'ANATR', N'ANTON') -"""); - } - - public override async Task Where_bitwise_and_with_logical_and(bool async) - { - await base.Where_bitwise_and_with_logical_and(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE 0 = 1 -"""); - } - - public override async Task Where_bitwise_or_with_logical_and(bool async) - { - await base.Where_bitwise_or_with_logical_and(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] IN (N'ALFKI', N'ANATR') AND [c].[Country] = N'Germany' -"""); - } - - public override async Task Where_bitwise_and_with_logical_or(bool async) - { - await base.Where_bitwise_and_with_logical_or(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ANTON' -"""); - } - - public override async Task Where_bitwise_binary_not(bool async) - { - await base.Where_bitwise_binary_not(async); - - AssertSql( - """ -@negatedId='-10249' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE ~[o].[OrderID] = @negatedId -"""); - } - - public override async Task Where_bitwise_binary_and(bool async) - { - await base.Where_bitwise_binary_and(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] & 10248 = 10248 -"""); - } - - public override async Task Where_bitwise_binary_or(bool async) - { - await base.Where_bitwise_binary_or(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] | 10248 = 10248 -"""); - } - - public override async Task Where_bitwise_binary_xor(bool async) - { - await base.Where_bitwise_binary_xor(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] ^ 1 = 10249 -"""); - } - - public override async Task Select_bitwise_or_with_logical_or(bool async) - { - await base.Select_bitwise_or_with_logical_or(async); - - AssertSql( - """ -SELECT [c].[CustomerID], CASE - WHEN [c].[CustomerID] IN (N'ALFKI', N'ANATR', N'ANTON') THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -ORDER BY [c].[CustomerID] -"""); - } - - public override async Task Select_bitwise_and_with_logical_and(bool async) - { - await base.Select_bitwise_and_with_logical_and(async); - - AssertSql( - """ -SELECT [c].[CustomerID], CAST(0 AS bit) AS [Value] -FROM [Customers] AS [c] -ORDER BY [c].[CustomerID] -"""); - } - public override async Task Handle_materialization_properly_when_more_than_two_query_sources_are_involved(bool async) { await base.Handle_materialization_properly_when_more_than_two_query_sources_are_involved(async); @@ -6864,48 +6622,6 @@ public override async Task Using_string_Equals_with_StringComparison_throws_info AssertSql(); } - public override async Task Random_next_is_not_funcletized_1(bool async) - { - await base.Random_next_is_not_funcletized_1(async); - - AssertSql(); - } - - public override async Task Random_next_is_not_funcletized_2(bool async) - { - await base.Random_next_is_not_funcletized_2(async); - - AssertSql(); - } - - public override async Task Random_next_is_not_funcletized_3(bool async) - { - await base.Random_next_is_not_funcletized_3(async); - - AssertSql(); - } - - public override async Task Random_next_is_not_funcletized_4(bool async) - { - await base.Random_next_is_not_funcletized_4(async); - - AssertSql(); - } - - public override async Task Random_next_is_not_funcletized_5(bool async) - { - await base.Random_next_is_not_funcletized_5(async); - - AssertSql(); - } - - public override async Task Random_next_is_not_funcletized_6(bool async) - { - await base.Random_next_is_not_funcletized_6(async); - - AssertSql(); - } - public override async Task SelectMany_after_client_method(bool async) { await base.SelectMany_after_client_method(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqlServerTest.cs index aff4ff2712d..e59e75669f2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqlServerTest.cs @@ -3,7 +3,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Translations; -public class MiscellaneousTranslationsSqlServerTest : MiscellaneousTranslationsTestBase +public class MiscellaneousTranslationsSqlServerTest : MiscellaneousTranslationsRelationalTestBase { public MiscellaneousTranslationsSqlServerTest(BasicTypesQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -105,6 +105,64 @@ WHERE CAST(DATALENGTH([b].[ByteArray]) AS int) >= 1 AND CAST(SUBSTRING([b].[Byte #endregion Byte array + #region Random + + public override async Task Random_on_EF_Functions(bool async) + { + await base.Random_on_EF_Functions(async); + + AssertSql( + """ +SELECT COUNT(*) +FROM [BasicTypesEntities] AS [b] +WHERE RAND() >= 0.0E0 AND RAND() < 1.0E0 +"""); + } + + public override async Task Random_Shared_Next_with_no_args(bool async) + { + await base.Random_Shared_Next_with_no_args(async); + + AssertSql(); + } + + public override async Task Random_Shared_Next_with_one_arg(bool async) + { + await base.Random_Shared_Next_with_one_arg(async); + + AssertSql(); + } + + public override async Task Random_Shared_Next_with_two_args(bool async) + { + await base.Random_Shared_Next_with_two_args(async); + + AssertSql(); + } + + public override async Task Random_new_Next_with_no_args(bool async) + { + await base.Random_new_Next_with_no_args(async); + + AssertSql(); + } + + public override async Task Random_new_Next_with_one_arg(bool async) + { + await base.Random_new_Next_with_one_arg(async); + + AssertSql(); + } + + public override async Task Random_new_Next_with_two_args(bool async) + { + await base.Random_new_Next_with_two_args(async); + + AssertSql(); + } + + #endregion Random + #region Convert public override async Task Convert_ToBoolean(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/OperatorTranslationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/OperatorTranslationsSqlServerTest.cs new file mode 100644 index 00000000000..8c28b93ed39 --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/OperatorTranslationsSqlServerTest.cs @@ -0,0 +1,215 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class OperatorTranslationsSqlServerTest : OperatorTranslationsTestBase +{ + public OperatorTranslationsSqlServerTest(BasicTypesQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Bitwise + + public override async Task Bitwise_or(bool async) + { + await base.Bitwise_or(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[Int] AS bigint) | [b].[Long] = CAST(7 AS bigint) +""", + // + """ +SELECT CAST([b].[Int] AS bigint) | [b].[Long] +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Bitwise_or_over_boolean(bool async) + { + await base.Bitwise_or_over_boolean(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] = 12 OR [b].[String] = N'Seattle' +""", + // + """ +SELECT CASE + WHEN [b].[Int] = 12 OR [b].[String] = N'Seattle' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Bitwise_or_multiple(bool async) + { + await base.Bitwise_or_multiple(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[Int] | [b].[Short] AS bigint) | [b].[Long] = CAST(7 AS bigint) +"""); + } + + public override async Task Bitwise_and(bool async) + { + await base.Bitwise_and(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] & [b].[Short] = 2 +""", + // + """ +SELECT [b].[Int] & [b].[Short] +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Bitwise_and_over_boolean(bool async) + { + await base.Bitwise_and_over_boolean(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] = 8 AND [b].[String] = N'Seattle' +""", + // + """ +SELECT CASE + WHEN [b].[Int] = 8 AND [b].[String] = N'Seattle' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Bitwise_xor(bool async) + { + await base.Bitwise_xor(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] ^ [b].[Short] = 1 +""", + // + """ +SELECT [b].[Int] ^ [b].[Short] +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Bitwise_xor_over_boolean(bool async) + { + await base.Bitwise_xor_over_boolean(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE ~CAST([b].[Int] ^ [b].[Short] AS bit) ^ CASE + WHEN [b].[String] = N'Seattle' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) +"""); + } + + public override async Task Bitwise_complement(bool async) + { + await base.Bitwise_complement(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE ~[b].[Int] = -9 +"""); + } + + public override async Task Bitwise_and_or_over_boolean(bool async) + { + await base.Bitwise_and_or_over_boolean(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE ([b].[Int] = 12 AND [b].[Short] = CAST(12 AS smallint)) OR [b].[String] = N'Seattle' +"""); + } + + public override async Task Bitwise_or_with_logical_or(bool async) + { + await base.Bitwise_or_with_logical_or(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] = 12 OR [b].[Short] = CAST(12 AS smallint) OR [b].[String] = N'Seattle' +"""); + } + + public override async Task Bitwise_and_with_logical_and(bool async) + { + await base.Bitwise_and_with_logical_and(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] = 8 AND [b].[Short] = CAST(8 AS smallint) AND [b].[String] = N'Seattle' +"""); + } + + public override async Task Bitwise_or_with_logical_and(bool async) + { + await base.Bitwise_or_with_logical_and(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE ([b].[Int] = 8 OR [b].[Short] = CAST(9 AS smallint)) AND [b].[String] = N'Seattle' +"""); + } + + public override async Task Bitwise_and_with_logical_or(bool async) + { + await base.Bitwise_and_with_logical_or(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE ([b].[Int] = 12 AND [b].[Short] = CAST(12 AS smallint)) OR [b].[String] = N'Seattle' +"""); + } + + #endregion Bitwise + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/TemporalTranslationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/TemporalTranslationsSqlServerTest.cs index aa7e326911f..4748c20c60a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/TemporalTranslationsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/TemporalTranslationsSqlServerTest.cs @@ -191,6 +191,58 @@ WHERE CONVERT(time, [b].[DateTime]) = '00:00:00' public override Task DateTime_subtract_and_TotalDays(bool async) => AssertTranslationFailed(() => base.DateTime_subtract_and_TotalDays(async)); + public override async Task DateTime_Parse_with_constant(bool async) + { + await base.DateTime_Parse_with_constant(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] = '1998-05-04T15:30:10.0000000' +"""); + } + + public override async Task DateTime_Parse_with_parameter(bool async) + { + await base.DateTime_Parse_with_parameter(async); + + AssertSql( + """ +@Parse='1998-05-04T15:30:10.0000000' + +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] = @Parse +"""); + } + + public override async Task DateTime_new_with_constant(bool async) + { + await base.DateTime_new_with_constant(async); + + AssertSql( + """ +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] = '1998-05-04T15:30:10.0000000' +"""); + } + + public override async Task DateTime_new_with_parameters(bool async) + { + await base.DateTime_new_with_parameters(async); + + AssertSql( + """ +@p='1998-05-04T15:30:10.0000000' + +SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] = @p +"""); + } + #endregion DateTime #region DateOnly diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs index aa552d1c51b..353529405aa 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs @@ -72,35 +72,6 @@ protected override string CaseInsensitiveCollation protected override string CaseSensitiveCollation => "BINARY"; - public override async Task Random_return_less_than_1(bool async) - { - await AssertCount( - async, - ss => ss.Set(), - ss => ss.Set(), - 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); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs index 4d9b89fc8ea..ac6ad120588 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs @@ -317,11 +317,6 @@ LIMIT @p """); } - [ConditionalTheory(Skip = "Issue #16645 bitwise xor support")] - [MemberData(nameof(IsAsyncData))] - public override Task Where_bitwise_binary_xor(bool async) - => AssertTranslationFailed(() => base.Where_bitwise_binary_xor(async)); - public override Task Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(bool async) => null; diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqliteTest.cs index 87b01cf25e1..26683357025 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqliteTest.cs @@ -3,7 +3,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Translations; -public class MiscellaneousTranslationsSqliteTest : MiscellaneousTranslationsTestBase +public class MiscellaneousTranslationsSqliteTest : MiscellaneousTranslationsRelationalTestBase { public MiscellaneousTranslationsSqliteTest(BasicTypesQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -80,6 +80,64 @@ public override Task Byte_array_First(bool async) #endregion Byte array + #region Random + + public override async Task Random_on_EF_Functions(bool async) + { + await base.Random_on_EF_Functions(async); + + AssertSql( + """ +SELECT COUNT(*) +FROM "BasicTypesEntities" AS "b" +WHERE abs(random() / 9.2233720368547799E+18) >= 0.0 AND abs(random() / 9.2233720368547799E+18) < 1.0 +"""); + } + + public override async Task Random_Shared_Next_with_no_args(bool async) + { + await base.Random_Shared_Next_with_no_args(async); + + AssertSql(); + } + + public override async Task Random_Shared_Next_with_one_arg(bool async) + { + await base.Random_Shared_Next_with_one_arg(async); + + AssertSql(); + } + + public override async Task Random_Shared_Next_with_two_args(bool async) + { + await base.Random_Shared_Next_with_two_args(async); + + AssertSql(); + } + + public override async Task Random_new_Next_with_no_args(bool async) + { + await base.Random_new_Next_with_no_args(async); + + AssertSql(); + } + + public override async Task Random_new_Next_with_one_arg(bool async) + { + await base.Random_new_Next_with_one_arg(async); + + AssertSql(); + } + + public override async Task Random_new_Next_with_two_args(bool async) + { + await base.Random_new_Next_with_two_args(async); + + AssertSql(); + } + + #endregion Random + #region Convert public override Task Convert_ToBoolean(bool async) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/OperatorTranslationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/OperatorTranslationsSqliteTest.cs new file mode 100644 index 00000000000..cbedc68377b --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/OperatorTranslationsSqliteTest.cs @@ -0,0 +1,187 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class OperatorTranslationsSqliteTest : OperatorTranslationsTestBase +{ + public OperatorTranslationsSqliteTest(BasicTypesQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Bitwise + + public override async Task Bitwise_or(bool async) + { + await base.Bitwise_or(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE CAST("b"."Int" AS INTEGER) | "b"."Long" = 7 +""", + // + """ +SELECT CAST("b"."Int" AS INTEGER) | "b"."Long" +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task Bitwise_or_over_boolean(bool async) + { + await base.Bitwise_or_over_boolean(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" = 12 OR "b"."String" = 'Seattle' +""", + // + """ +SELECT "b"."Int" = 12 OR "b"."String" = 'Seattle' +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task Bitwise_or_multiple(bool async) + { + await base.Bitwise_or_multiple(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE CAST("b"."Int" | "b"."Short" AS INTEGER) | "b"."Long" = 7 +"""); + } + + public override async Task Bitwise_and(bool async) + { + await base.Bitwise_and(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" & "b"."Short" = 2 +""", + // + """ +SELECT "b"."Int" & "b"."Short" +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task Bitwise_and_over_boolean(bool async) + { + await base.Bitwise_and_over_boolean(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" = 8 AND "b"."String" = 'Seattle' +""", + // + """ +SELECT "b"."Int" = 8 AND "b"."String" = 'Seattle' +FROM "BasicTypesEntities" AS "b" +"""); + } + + [ConditionalTheory(Skip = "Issue #16645 bitwise xor support")] + [MemberData(nameof(IsAsyncData))] + public override Task Bitwise_xor(bool async) + => AssertTranslationFailed(() => base.Bitwise_xor(async)); + + [ConditionalTheory(Skip = "Issue #16645 bitwise xor support")] + [MemberData(nameof(IsAsyncData))] + public override Task Bitwise_xor_over_boolean(bool async) + => AssertTranslationFailed(() => base.Bitwise_xor_over_boolean(async)); + + public override async Task Bitwise_complement(bool async) + { + await base.Bitwise_complement(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE ~"b"."Int" = -9 +"""); + } + + public override async Task Bitwise_and_or_over_boolean(bool async) + { + await base.Bitwise_and_or_over_boolean(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE ("b"."Int" = 12 AND "b"."Short" = 12) OR "b"."String" = 'Seattle' +"""); + } + + public override async Task Bitwise_or_with_logical_or(bool async) + { + await base.Bitwise_or_with_logical_or(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" = 12 OR "b"."Short" = 12 OR "b"."String" = 'Seattle' +"""); + } + + public override async Task Bitwise_and_with_logical_and(bool async) + { + await base.Bitwise_and_with_logical_and(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" = 8 AND "b"."Short" = 8 AND "b"."String" = 'Seattle' +"""); + } + + public override async Task Bitwise_or_with_logical_and(bool async) + { + await base.Bitwise_or_with_logical_and(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE ("b"."Int" = 8 OR "b"."Short" = 9) AND "b"."String" = 'Seattle' +"""); + } + + public override async Task Bitwise_and_with_logical_or(bool async) + { + await base.Bitwise_and_with_logical_or(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE ("b"."Int" = 12 AND "b"."Short" = 12) OR "b"."String" = 'Seattle' +"""); + } + + #endregion Bitwise + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/StringTranslationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/StringTranslationsSqliteTest.cs index 48a318ac958..855254dd6d0 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/StringTranslationsSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/StringTranslationsSqliteTest.cs @@ -808,7 +808,7 @@ public override async Task Compare_with_parameter(bool async) """ SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" FROM "BasicTypesEntities" AS "b" -WHERE "b"."String" = 'Seattle' +WHERE "b"."Id" = 1 LIMIT 2 """, // @@ -1043,7 +1043,7 @@ public override async Task CompareTo_with_parameter(bool async) """ SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" FROM "BasicTypesEntities" AS "b" -WHERE "b"."String" = 'Seattle' +WHERE "b"."Id" = 1 LIMIT 2 """, // diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/TemporalTranslationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/TemporalTranslationsSqliteTest.cs index bfb251157d3..06a8c6cb035 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/TemporalTranslationsSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/TemporalTranslationsSqliteTest.cs @@ -193,6 +193,58 @@ WHERE rtrim(rtrim(strftime('%H:%M:%f', "b"."DateTime"), '0'), '.') = '00:00:00' public override Task DateTime_subtract_and_TotalDays(bool async) => AssertTranslationFailed(() => base.DateTime_subtract_and_TotalDays(async)); + public override async Task DateTime_Parse_with_constant(bool async) + { + await base.DateTime_Parse_with_constant(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" = '1998-05-04 15:30:10' +"""); + } + + public override async Task DateTime_Parse_with_parameter(bool async) + { + await base.DateTime_Parse_with_parameter(async); + + AssertSql( + """ +@Parse='1998-05-04T15:30:10.0000000' (DbType = DateTime) + +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" = @Parse +"""); + } + + public override async Task DateTime_new_with_constant(bool async) + { + await base.DateTime_new_with_constant(async); + + AssertSql( + """ +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" = '1998-05-04 15:30:10' +"""); + } + + public override async Task DateTime_new_with_parameters(bool async) + { + await base.DateTime_new_with_parameters(async); + + AssertSql( + """ +@p='1998-05-04T15:30:10.0000000' (DbType = DateTime) + +SELECT "b"."Id", "b"."Bool", "b"."Byte", "b"."ByteArray", "b"."DateOnly", "b"."DateTime", "b"."DateTimeOffset", "b"."Decimal", "b"."Double", "b"."Enum", "b"."FlagsEnum", "b"."Float", "b"."Guid", "b"."Int", "b"."Long", "b"."Short", "b"."String", "b"."TimeOnly", "b"."TimeSpan" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" = @p +"""); + } + #endregion DateTime #region DateOnly