Skip to content

Commit 77f31ca

Browse files
committed
Reenable some tests on Linux Cosmos emulator
1 parent f5e4d85 commit 77f31ca

7 files changed

Lines changed: 55 additions & 19 deletions

File tree

src/EFCore/Metadata/Internal/ForeignKey.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,8 @@ public virtual IDependentKeyValueFactory DependentKeyValueFactory
951951
if (field == null)
952952
{
953953
EnsureReadOnly();
954-
((IKey)PrincipalKey).GetPrincipalKeyValueFactory();
954+
// The principal key value factory creates the dependent key value factory
955+
_ = ((IKey)PrincipalKey).GetPrincipalKeyValueFactory();
955956
}
956957

957958
return field!;

src/EFCore/Metadata/RuntimeForeignKey.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ IDependentKeyValueFactory IRuntimeForeignKey.DependentKeyValueFactory
274274
{
275275
if (_dependentKeyValueFactory == null)
276276
{
277-
((IKey)PrincipalKey).GetPrincipalKeyValueFactory();
277+
// The principal key value factory creates the dependent key value factory
278+
_ = ((IKey)PrincipalKey).GetPrincipalKeyValueFactory();
278279
}
279280
return _dependentKeyValueFactory!;
280281
}

test/Directory.Build.props

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
Exclude tests tagged with the "failing" category. Microsoft.DotNet.XUnitV3Extensions
1818
attributes such as [ConditionalClass]/[ConditionalAssembly] add `category=failing` to tests
1919
whose condition evaluates to false; this filter is what actually skips them at the runner.
20-
Plumbed through both Arcade's RunTests target (used by test.cmd / test.sh /
21-
eng/common/build.* with the test switch) and the Microsoft.Testing.Platform MSBuild target
22-
(used by `dotnet test` and VS Test Explorer).
20+
Microsoft.Testing.Platform's targets forward TestingPlatformCommandLineArguments into
21+
RunArguments before ComputeRunArguments, so this single property covers both `dotnet test`
22+
(InvokeTestingPlatform) and Arcade's RunTests target (test.cmd / test.sh /
23+
eng/common/build.* -test). Setting TestRunnerAdditionalArguments in addition produces
24+
duplicate args and breaks MTP's ignore-exit-code option (it accepts at most one value).
2325
-->
24-
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --filter-not-trait category=failing --ignore-exit-code 8</TestRunnerAdditionalArguments>
2526
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --filter-not-trait category=failing --ignore-exit-code 8</TestingPlatformCommandLineArguments>
2627
</PropertyGroup>
2728

test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,26 @@ public override void Infer_type_mapping_from_in_subquery_to_item()
131131
=> Assert.Throws<InvalidOperationException>(() => base.Infer_type_mapping_from_in_subquery_to_item());
132132

133133
public override Task Can_query_custom_type_not_mapped_by_default_equality(bool async)
134-
=> CosmosTestHelpers.Instance.NoSyncTest(async, a => base.Can_query_custom_type_not_mapped_by_default_equality(a));
134+
=> CosmosTestHelpers.Instance.NoSyncTest(async, RunCustomTypeNotMappedByDefaultEqualityAsync);
135+
136+
// The base test seeds a SimpleCounter and only cleans up after a successful query. When the
137+
// sync variant runs, .Single() throws SyncNotSupported before cleanup, leaving the seeded
138+
// entity behind and causing the next iteration to fail with a 409 conflict. Delete any
139+
// leftover rows before seeding to keep the test independent of execution order.
140+
private async Task RunCustomTypeNotMappedByDefaultEqualityAsync(bool async)
141+
{
142+
await using (var context = CreateContext())
143+
{
144+
var existing = await context.Set<SimpleCounter>().ToListAsync();
145+
if (existing.Count > 0)
146+
{
147+
context.RemoveRange(existing);
148+
await context.SaveChangesAsync();
149+
}
150+
}
151+
152+
await base.Can_query_custom_type_not_mapped_by_default_equality(async);
153+
}
135154

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

test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ private class SharedChangeContext<TEntity>(Action<EntityTypeBuilder<TEntity>> en
320320

321321
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
322322
=> optionsBuilder
323+
.EnableServiceProviderCaching(false)
323324
.UseChangeTrackingProxies()
324325
.UseInMemoryDatabase(GetType().ShortDisplayName());
325326

test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceQuerySqlServerFixtureBase.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,16 @@ public abstract class TPCInheritanceQuerySqlServerFixtureBase : TPCInheritanceQu
99
{
1010
protected override ITestStoreFactory TestStoreFactory
1111
=> SqlServerTestStoreFactory.Instance;
12+
13+
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
14+
{
15+
base.OnModelCreating(modelBuilder, context);
16+
17+
// Start TPC sequences past the explicit seed key range to avoid PK collisions on insert.
18+
if (!UseGeneratedKeys)
19+
{
20+
modelBuilder.HasSequence("AnimalSequence").StartsAt(10);
21+
modelBuilder.HasSequence("DrinkSequence").StartsAt(10);
22+
}
23+
}
1224
}

test/EFCore.VisualBasic.FunctionalTests/NorthwindQueryVisualBasicTest.vb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
Imports Microsoft.EntityFrameworkCore.Query
55
Imports Microsoft.EntityFrameworkCore.TestModels.Northwind
6+
Imports System.Threading.Tasks
67
Imports Microsoft.EntityFrameworkCore.TestUtilities
78
Imports Xunit
89

@@ -18,7 +19,7 @@ Partial Public Class NorthwindQueryVisualBasicTest
1819

1920
<Theory>
2021
<MemberData(NameOf(IsAsyncData))>
21-
Public Async Sub CompareString_Equals_Binary(async As Boolean)
22+
Public Async Function CompareString_Equals_Binary(async As Boolean) As Task
2223
Await AssertQuery(
2324
async,
2425
Function(ss) ss.Set(Of Customer).Where(Function(c) c.CustomerID = "ALFKI"))
@@ -27,11 +28,11 @@ Partial Public Class NorthwindQueryVisualBasicTest
2728
"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]
2829
FROM [Customers] AS [c]
2930
WHERE [c].[CustomerID] = N'ALFKI'")
30-
End Sub
31+
End Function
3132

3233
<Theory>
3334
<MemberData(NameOf(IsAsyncData))>
34-
Public Async Sub CompareString_LessThanOrEqual_Binary(async As Boolean)
35+
Public Async Function CompareString_LessThanOrEqual_Binary(async As Boolean) As Task
3536
Await AssertQuery(
3637
async,
3738
Function(ss) ss.Set(Of Customer).Where(Function(c) c.CustomerID <= "ALFKI"))
@@ -40,11 +41,11 @@ WHERE [c].[CustomerID] = N'ALFKI'")
4041
"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]
4142
FROM [Customers] AS [c]
4243
WHERE [c].[CustomerID] <= N'ALFKI'")
43-
End Sub
44+
End Function
4445

4546
<Theory>
4647
<MemberData(NameOf(IsAsyncData))>
47-
Public Async Sub AddChecked(async As Boolean)
48+
Public Async Function AddChecked(async As Boolean) As Task
4849
Await AssertQuery(
4950
async,
5051
Function(ss) ss.Set(Of Product).Where(Function(p) p.UnitsInStock + 1 = 102))
@@ -53,11 +54,11 @@ WHERE [c].[CustomerID] <= N'ALFKI'")
5354
"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock]
5455
FROM [Products] AS [p]
5556
WHERE [p].[UnitsInStock] + CAST(1 AS smallint) = CAST(102 AS smallint)")
56-
End Sub
57+
End Function
5758

5859
<Theory>
5960
<MemberData(NameOf(IsAsyncData))>
60-
Public Async Sub SubtractChecked(async As Boolean)
61+
Public Async Function SubtractChecked(async As Boolean) As Task
6162
Await AssertQuery(
6263
async,
6364
Function(ss) ss.Set(Of Product).Where(Function(p) p.UnitsInStock - 1 = 100))
@@ -66,11 +67,11 @@ WHERE [p].[UnitsInStock] + CAST(1 AS smallint) = CAST(102 AS smallint)")
6667
"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock]
6768
FROM [Products] AS [p]
6869
WHERE [p].[UnitsInStock] - CAST(1 AS smallint) = CAST(100 AS smallint)")
69-
End Sub
70+
End Function
7071

7172
<Theory>
7273
<MemberData(NameOf(IsAsyncData))>
73-
Public Async Sub MultiplyChecked(async As Boolean)
74+
Public Async Function MultiplyChecked(async As Boolean) As Task
7475
Await AssertQuery(
7576
async,
7677
Function(ss) ss.Set(Of Product).Where(Function(p) p.UnitsInStock * 1 = 101))
@@ -79,11 +80,11 @@ WHERE [p].[UnitsInStock] - CAST(1 AS smallint) = CAST(100 AS smallint)")
7980
"SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock]
8081
FROM [Products] AS [p]
8182
WHERE [p].[UnitsInStock] * CAST(1 AS smallint) = CAST(101 AS smallint)")
82-
End Sub
83+
End Function
8384

8485
<Theory>
8586
<MemberData(NameOf(IsAsyncData))>
86-
Public Async Sub Parameter_name_gets_sanitized(async As Boolean)
87+
Public Async Function Parameter_name_gets_sanitized(async As Boolean) As Task
8788
Dim units = 101
8889
Await AssertQuery(
8990
async,
@@ -95,7 +96,7 @@ WHERE [p].[UnitsInStock] * CAST(1 AS smallint) = CAST(101 AS smallint)")
9596
SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock]
9697
FROM [Products] AS [p]
9798
WHERE [p].[UnitsInStock] = @units")
98-
End Sub
99+
End Function
99100

100101
Private Sub AssertSql(ParamArray expected As String())
101102
Fixture.TestSqlLoggerFactory.AssertBaseline(expected)

0 commit comments

Comments
 (0)