Skip to content

Commit 02d2cc5

Browse files
committed
Fix SQL Server tests
1 parent 052d3c0 commit 02d2cc5

48 files changed

Lines changed: 964 additions & 197 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/cosmos-provider/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Non-relational provider with its own parallel query pipeline. Uses JSON for docu
1919
## Azure Cosmos DB Emulator for Tests
2020

2121
- `TestEnvironment.InitializeAsync()` auto-starts a `Testcontainers.CosmosDb` container when `Test__Cosmos__DefaultConnection` is not set. Set the env var to use an existing emulator instead.
22-
- Skip tests requiring unsupported features on the Linux emulator with `[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)]`.
22+
- Skip tests requiring unsupported features on the Linux emulator with ` [ConditionalFact(typeof(CosmosTestEnvironment), nameof(CosmosTestEnvironment.IsNotLinuxEmulator))]`.

eng/Versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<OpenTelemetryExporterInMemoryVersion>1.15.1</OpenTelemetryExporterInMemoryVersion>
5353
<SQLitePCLRawVersion>3.0.3</SQLitePCLRawVersion>
5454
<SQLite3MCPCLRawBundleVersion>2.3.2</SQLite3MCPCLRawBundleVersion>
55+
<XUnitV3Version>4.0.0-pre.81</XUnitV3Version>
5556
<MicrosoftDotNetXUnitV3ExtensionsVersion>11.0.0-beta.26263.112</MicrosoftDotNetXUnitV3ExtensionsVersion>
5657
<MicrosoftTestingPlatformVersion>2.2.2</MicrosoftTestingPlatformVersion>
5758
</PropertyGroup>

src/EFCore/Metadata/Internal/ForeignKey.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ public virtual IDependentKeyValueFactory DependentKeyValueFactory
951951
if (field == null)
952952
{
953953
EnsureReadOnly();
954+
((IKey)PrincipalKey).GetPrincipalKeyValueFactory();
954955
}
955956

956957
return field!;

src/EFCore/Metadata/RuntimeForeignKey.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,18 +259,25 @@ IEnumerable<IReadOnlySkipNavigation> IReadOnlyForeignKey.GetReferencingSkipNavig
259259
/// <inheritdoc />
260260
[DebuggerStepThrough]
261261
IDependentKeyValueFactory<TKey> IForeignKey.GetDependentKeyValueFactory<TKey>()
262-
=> (IDependentKeyValueFactory<TKey>)_dependentKeyValueFactory!;
262+
=> (IDependentKeyValueFactory<TKey>)((IRuntimeForeignKey)this).DependentKeyValueFactory;
263263

264264
/// <inheritdoc />
265265
[DebuggerStepThrough]
266266
IDependentKeyValueFactory IForeignKey.GetDependentKeyValueFactory()
267-
=> _dependentKeyValueFactory!;
267+
=> ((IRuntimeForeignKey)this).DependentKeyValueFactory;
268268

269269
/// <inheritdoc />
270270
IDependentKeyValueFactory IRuntimeForeignKey.DependentKeyValueFactory
271271
{
272272
[DebuggerStepThrough]
273-
get => _dependentKeyValueFactory!;
273+
get
274+
{
275+
if (_dependentKeyValueFactory == null)
276+
{
277+
((IKey)PrincipalKey).GetPrincipalKeyValueFactory();
278+
}
279+
return _dependentKeyValueFactory!;
280+
}
274281

275282
[DebuggerStepThrough]
276283
set => _dependentKeyValueFactory = value;

test/Directory.Build.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
<NuGetAudit>false</NuGetAudit>
99
</PropertyGroup>
1010

11-
<PropertyGroup Condition="'$(IsUnitTestProject)' == 'true'">
12-
<TestRunnerName>XUnitV3</TestRunnerName>
11+
<PropertyGroup Condition="'$(IsTestProject)' != 'false'">
12+
<OutputType>Exe</OutputType>
13+
<TestRunnerName>XUnitV3</TestRunnerName>
1314
</PropertyGroup>
1415

1516
</Project>

test/EFCore.AspNet.Specification.Tests/EFCore.AspNet.Specification.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<Nullable>disable</Nullable>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010
<IsPackable>true</IsPackable>
11+
<!-- This project contains base tests to be used by providers, but is not itself a test project with
12+
tests to be executed. Disable test discovery. -->
13+
<IsTestProject>false</IsTestProject>
1114
<IncludeSymbols>true</IncludeSymbols>
1215
<ImplicitUsings>true</ImplicitUsings>
1316
<NoWarn>$(NoWarn);8981</NoWarn>

test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Microsoft.EntityFrameworkCore.Query.Translations;
88

9-
[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)]
9+
[ConditionalClass(typeof(CosmosTestEnvironment), nameof(CosmosTestEnvironment.IsNotLinuxEmulator))]
1010
public class VectorSearchTranslationsCosmosTest : IClassFixture<VectorSearchTranslationsCosmosTest.VectorSearchFixture>
1111
{
1212
public VectorSearchTranslationsCosmosTest(VectorSearchFixture fixture, ITestOutputHelper testOutputHelper)

test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ WHERE DATEDIFF(millisecond, [m].[TimeSpanAsTime], @timeSpan) = 0
814814
public virtual void Can_query_using_DateDiffMicrosecond_using_TimeSpan()
815815
{
816816
using var context = CreateContext();
817-
var timeSpan = new TimeSpan(2, 1, 0);
817+
var timeSpan = new TimeSpan(11, 15, 13);
818818

819819
var results
820820
= context.Set<MappedNullableDataTypes>()
@@ -825,7 +825,7 @@ var results
825825
Assert.Empty(results);
826826
AssertSql(
827827
"""
828-
@timeSpan='02:01:00' (Nullable = true)
828+
@timeSpan='11:15:13' (Nullable = true)
829829
830830
SELECT [m].[Int]
831831
FROM [MappedNullableDataTypes] AS [m]
@@ -837,7 +837,7 @@ WHERE DATEDIFF(microsecond, [m].[TimeSpanAsTime], @timeSpan) = 0
837837
public virtual void Can_query_using_DateDiffNanosecond_using_TimeSpan()
838838
{
839839
using var context = CreateContext();
840-
var timeSpan = new TimeSpan(2, 1, 0);
840+
var timeSpan = new TimeSpan(11, 15, 13);
841841

842842
var results
843843
= context.Set<MappedNullableDataTypes>()
@@ -848,7 +848,7 @@ var results
848848
Assert.Empty(results);
849849
AssertSql(
850850
"""
851-
@timeSpan='02:01:00' (Nullable = true)
851+
@timeSpan='11:15:13' (Nullable = true)
852852
853853
SELECT [m].[Int]
854854
FROM [MappedNullableDataTypes] AS [m]

test/EFCore.SqlServer.FunctionalTests/Query/AdHocPrecompiledQuerySqlServerTest.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using Xunit.Sdk;
5+
46
namespace Microsoft.EntityFrameworkCore.Query;
57

68
public class AdHocPrecompiledQuerySqlServerTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper)
@@ -9,9 +11,17 @@ public class AdHocPrecompiledQuerySqlServerTest(NonSharedFixture fixture, ITestO
911
protected override bool AlwaysPrintGeneratedSources
1012
=> false;
1113

12-
[ConditionalFact(typeof(SqlServerTestEnvironment), nameof(SqlServerTestEnvironment.SupportsJsonPathExpressions))]
13-
public override async Task Index_no_evaluatability()
14+
public override async Task Index_no_evaluatability()
1415
{
16+
17+
if (!SqlServerTestEnvironment.SupportsJsonPathExpressions)
18+
19+
{
20+
21+
throw SkipException.ForSkip("Requires SupportsJsonPathExpressions");
22+
23+
}
24+
1525
await base.Index_no_evaluatability();
1626

1727
AssertSql(
@@ -22,9 +32,17 @@ WHERE CAST(JSON_VALUE([j].[IntList], '$[' + CAST([j].[Id] AS nvarchar(max)) + ']
2232
""");
2333
}
2434

25-
[ConditionalFact(typeof(SqlServerTestEnvironment), nameof(SqlServerTestEnvironment.SupportsJsonPathExpressions))]
26-
public override async Task Index_with_captured_variable()
35+
public override async Task Index_with_captured_variable()
2736
{
37+
38+
if (!SqlServerTestEnvironment.SupportsJsonPathExpressions)
39+
40+
{
41+
42+
throw SkipException.ForSkip("Requires SupportsJsonPathExpressions");
43+
44+
}
45+
2846
await base.Index_with_captured_variable();
2947

3048
AssertSql(

0 commit comments

Comments
 (0)