Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public virtual Task Include_trunk_optional(bool async)
=> AssertQuery(
async,
ss => ss.Set<RelationshipsRootEntity>().Include(x => x.OptionalReferenceTrunk),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude<RelationshipsRootEntity>(x => x.OptionalReferenceTrunk!)));

[ConditionalTheory]
Expand All @@ -34,7 +33,6 @@ public virtual Task Include_trunk_collection(bool async)
=> AssertQuery(
async,
ss => ss.Set<RelationshipsRootEntity>().Include(x => x.CollectionTrunk),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude<RelationshipsRootEntity>(x => x.CollectionTrunk)));

[ConditionalTheory]
Expand All @@ -60,7 +58,6 @@ public virtual Task Include_branch_required_required(bool async)
=> AssertQuery(
async,
ss => ss.Set<RelationshipsRootEntity>().Include(x => x.RequiredReferenceTrunk.RequiredReferenceBranch),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(
e,
a,
Expand All @@ -73,7 +70,6 @@ public virtual Task Include_branch_required_collection(bool async)
=> AssertQuery(
async,
ss => ss.Set<RelationshipsRootEntity>().Include(x => x.RequiredReferenceTrunk.CollectionBranch),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(
e,
a,
Expand All @@ -86,7 +82,6 @@ public virtual Task Include_branch_optional_optional(bool async)
=> AssertQuery(
async,
ss => ss.Set<RelationshipsRootEntity>().Include(x => x.OptionalReferenceTrunk!.OptionalReferenceBranch),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(
e,
a,
Expand All @@ -99,7 +94,6 @@ public virtual Task Include_branch_optional_collection(bool async)
=> AssertQuery(
async,
ss => ss.Set<RelationshipsRootEntity>().Include(x => x.OptionalReferenceTrunk!.CollectionBranch),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(
e,
a,
Expand All @@ -112,7 +106,6 @@ public virtual Task Include_branch_collection_collection(bool async)
=> AssertQuery(
async,
ss => ss.Set<RelationshipsRootEntity>().Include(x => x.CollectionTrunk).ThenInclude(x => x.CollectionBranch),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(
e,
a,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,11 @@ public static void AssertOwnedTrunk(RelationshipsTrunkEntity expected, Relations
}

Assert.Equal(expected.CollectionBranch.Count, actual.CollectionBranch?.Count ?? 0);
var expectedCollection = expected.CollectionBranch.OrderBy(e => e.Name).ToList();
var actualCollection = actual.CollectionBranch is null ? [] : actual.CollectionBranch.OrderBy(e => e.Name).ToList();
for (var i = 0; i < expected.CollectionBranch.Count; i++)
{
AssertOwnedBranch(expected.CollectionBranch[i], actual.CollectionBranch![i]);
AssertOwnedBranch(expectedCollection[i], actualCollection![i]);
}
}

Expand All @@ -526,9 +528,11 @@ public static void AssertOwnedBranch(RelationshipsBranchEntity expected, Relatio
}

Assert.Equal(expected.CollectionLeaf.Count, actual.CollectionLeaf?.Count ?? 0);
var expectedCollection = expected.CollectionLeaf.OrderBy(e => e.Name).ToList();
var actualCollection = actual.CollectionLeaf is null ? [] : actual.CollectionLeaf.OrderBy(e => e.Name).ToList();
for (var i = 0; i < expected.CollectionLeaf.Count; i++)
{
AssertOwnedLeaf(expected.CollectionLeaf[i], actual.CollectionLeaf![i]);
AssertOwnedLeaf(expectedCollection[i], actualCollection![i]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public virtual Task Select_multiple_branch_leaf(bool async)
Assert.Equal(e.Id, a.Id);
AssertEqual(e.RequiredReferenceBranch, a.RequiredReferenceBranch);
AssertEqual(e.OptionalReferenceLeaf, a.OptionalReferenceLeaf);
AssertCollection(e.CollectionLeaf, a.CollectionLeaf, ordered: true);
AssertCollection(e.CollectionBranch, a.CollectionBranch, ordered: true);
AssertCollection(e.CollectionLeaf, a.CollectionLeaf, ordered: false);
AssertCollection(e.CollectionBranch, a.CollectionBranch, ordered: false);
Assert.Equal(e.Name, a.Name);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ public NavigationIncludeSqlServerTest(NavigationRelationshipsSqlServerFixture fi
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}

public override async Task Include_trunk_required(bool async)
{
await base.Include_trunk_required(async);

AssertSql(
"""
SELECT [r].[Id], [r].[Name], [r].[OptionalReferenceTrunkId], [r].[RequiredReferenceTrunkId], [t].[Id], [t].[CollectionRootId], [t].[Name], [t].[OptionalReferenceBranchId], [t].[RequiredReferenceBranchId]
FROM [RootEntities] AS [r]
INNER JOIN [TrunkEntities] AS [t] ON [r].[RequiredReferenceTrunkId] = [t].[Id]
""");
}

public override async Task Include_trunk_optional(bool async)
{
await base.Include_trunk_optional(async);
Expand All @@ -25,6 +37,109 @@ FROM [RootEntities] AS [r]
""");
}

public override async Task Include_trunk_collection(bool async)
{
await base.Include_trunk_collection(async);

AssertSql(
"""
SELECT [r].[Id], [r].[Name], [r].[OptionalReferenceTrunkId], [r].[RequiredReferenceTrunkId], [t].[Id], [t].[CollectionRootId], [t].[Name], [t].[OptionalReferenceBranchId], [t].[RequiredReferenceBranchId]
FROM [RootEntities] AS [r]
LEFT JOIN [TrunkEntities] AS [t] ON [r].[Id] = [t].[CollectionRootId]
ORDER BY [r].[Id]
""");
}

public override async Task Include_trunk_required_optional_and_collection(bool async)
{
await base.Include_trunk_required_optional_and_collection(async);

AssertSql(
"""
SELECT [r].[Id], [r].[Name], [r].[OptionalReferenceTrunkId], [r].[RequiredReferenceTrunkId], [t].[Id], [t].[CollectionRootId], [t].[Name], [t].[OptionalReferenceBranchId], [t].[RequiredReferenceBranchId], [t0].[Id], [t0].[CollectionRootId], [t0].[Name], [t0].[OptionalReferenceBranchId], [t0].[RequiredReferenceBranchId], [t1].[Id], [t1].[CollectionRootId], [t1].[Name], [t1].[OptionalReferenceBranchId], [t1].[RequiredReferenceBranchId]
FROM [RootEntities] AS [r]
INNER JOIN [TrunkEntities] AS [t] ON [r].[RequiredReferenceTrunkId] = [t].[Id]
LEFT JOIN [TrunkEntities] AS [t0] ON [r].[OptionalReferenceTrunkId] = [t0].[Id]
LEFT JOIN [TrunkEntities] AS [t1] ON [r].[Id] = [t1].[CollectionRootId]
ORDER BY [r].[Id], [t].[Id], [t0].[Id]
""");
}

public override async Task Include_branch_required_required(bool async)
{
await base.Include_branch_required_required(async);

AssertSql(
"""
SELECT [r].[Id], [r].[Name], [r].[OptionalReferenceTrunkId], [r].[RequiredReferenceTrunkId], [t].[Id], [t].[CollectionRootId], [t].[Name], [t].[OptionalReferenceBranchId], [t].[RequiredReferenceBranchId], [b].[Id], [b].[CollectionTrunkId], [b].[Name], [b].[OptionalReferenceLeafId], [b].[RequiredReferenceLeafId]
FROM [RootEntities] AS [r]
INNER JOIN [TrunkEntities] AS [t] ON [r].[RequiredReferenceTrunkId] = [t].[Id]
INNER JOIN [BranchEntities] AS [b] ON [t].[RequiredReferenceBranchId] = [b].[Id]
""");
}

public override async Task Include_branch_required_collection(bool async)
{
await base.Include_branch_required_collection(async);

AssertSql(
"""
SELECT [r].[Id], [r].[Name], [r].[OptionalReferenceTrunkId], [r].[RequiredReferenceTrunkId], [t].[Id], [t].[CollectionRootId], [t].[Name], [t].[OptionalReferenceBranchId], [t].[RequiredReferenceBranchId], [b].[Id], [b].[CollectionTrunkId], [b].[Name], [b].[OptionalReferenceLeafId], [b].[RequiredReferenceLeafId]
FROM [RootEntities] AS [r]
INNER JOIN [TrunkEntities] AS [t] ON [r].[RequiredReferenceTrunkId] = [t].[Id]
LEFT JOIN [BranchEntities] AS [b] ON [t].[Id] = [b].[CollectionTrunkId]
ORDER BY [r].[Id], [t].[Id]
""");
}

public override async Task Include_branch_optional_optional(bool async)
{
await base.Include_branch_optional_optional(async);

AssertSql(
"""
SELECT [r].[Id], [r].[Name], [r].[OptionalReferenceTrunkId], [r].[RequiredReferenceTrunkId], [t].[Id], [t].[CollectionRootId], [t].[Name], [t].[OptionalReferenceBranchId], [t].[RequiredReferenceBranchId], [b].[Id], [b].[CollectionTrunkId], [b].[Name], [b].[OptionalReferenceLeafId], [b].[RequiredReferenceLeafId]
FROM [RootEntities] AS [r]
LEFT JOIN [TrunkEntities] AS [t] ON [r].[OptionalReferenceTrunkId] = [t].[Id]
LEFT JOIN [BranchEntities] AS [b] ON [t].[OptionalReferenceBranchId] = [b].[Id]
""");
}

public override async Task Include_branch_optional_collection(bool async)
{
await base.Include_branch_optional_collection(async);

AssertSql(
"""
SELECT [r].[Id], [r].[Name], [r].[OptionalReferenceTrunkId], [r].[RequiredReferenceTrunkId], [t].[Id], [t].[CollectionRootId], [t].[Name], [t].[OptionalReferenceBranchId], [t].[RequiredReferenceBranchId], [b].[Id], [b].[CollectionTrunkId], [b].[Name], [b].[OptionalReferenceLeafId], [b].[RequiredReferenceLeafId]
FROM [RootEntities] AS [r]
LEFT JOIN [TrunkEntities] AS [t] ON [r].[OptionalReferenceTrunkId] = [t].[Id]
LEFT JOIN [BranchEntities] AS [b] ON [t].[Id] = [b].[CollectionTrunkId]
ORDER BY [r].[Id], [t].[Id]
""");
}

public override async Task Include_branch_collection_collection(bool async)
{
await base.Include_branch_collection_collection(async);

AssertSql(
"""
SELECT [r].[Id], [r].[Name], [r].[OptionalReferenceTrunkId], [r].[RequiredReferenceTrunkId], [s].[Id], [s].[CollectionRootId], [s].[Name], [s].[OptionalReferenceBranchId], [s].[RequiredReferenceBranchId], [s].[Id0], [s].[CollectionTrunkId], [s].[Name0], [s].[OptionalReferenceLeafId], [s].[RequiredReferenceLeafId]
FROM [RootEntities] AS [r]
LEFT JOIN (
SELECT [t].[Id], [t].[CollectionRootId], [t].[Name], [t].[OptionalReferenceBranchId], [t].[RequiredReferenceBranchId], [b].[Id] AS [Id0], [b].[CollectionTrunkId], [b].[Name] AS [Name0], [b].[OptionalReferenceLeafId], [b].[RequiredReferenceLeafId]
FROM [TrunkEntities] AS [t]
LEFT JOIN [BranchEntities] AS [b] ON [t].[Id] = [b].[CollectionTrunkId]
) AS [s] ON [r].[Id] = [s].[CollectionRootId]
ORDER BY [r].[Id], [s].[Id]
""");
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public override async Task Select_subquery_root_set_optional_trunk_FirstOrDefaul
AssertSql();
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public override async Task Select_subquery_root_set_optional_trunk_FirstOrDefaul
AssertSql();
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ FROM [RootEntities] AS [r]
""");
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ FROM [RootEntities] AS [r]
""");
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ ORDER BY [r].[Id]
""");
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ ORDER BY [r].[Id]
""");
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ [RequiredReferenceLeaf] nvarchar(max) '$.RequiredReferenceLeaf' AS JSON
""");
}

public override async Task Project_branch_collection_element_using_indexer_constant(bool async)
{
await base.Project_branch_collection_element_using_indexer_constant(async);

AssertSql(
"""
SELECT JSON_QUERY([r].[RequiredReferenceTrunk], '$.CollectionBranch'), [r].[Id]
FROM [RootEntities] AS [r]
ORDER BY [r].[Id]
""");
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ private async Task AssertCantTrackJson(Func<Task> test)
AssertSql();
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ ORDER BY [r].[Id]
""");
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ private async Task AssertCantTrackJson(Func<Task> test)
AssertSql();
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ public OwnedJsonTypeNoTrackingProjectionSqlServerTest(OwnedJsonTypeRelationships
Fixture.TestSqlLoggerFactory.Clear();
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ public OwnedJsonTypeReferenceNoTrackingProjectionSqlServerTest(OwnedJsonTypeRela
Fixture.TestSqlLoggerFactory.Clear();
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ WHEN [r].[OptionalReferenceTrunk_Name] IS NOT NULL THEN [r].[Id]
""");
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ private async Task AssertCantTrackOwned(Func<Task> test)
AssertSql();
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ WHEN [r2].[OptionalReferenceTrunk_OptionalReferenceBranch_Name] IS NOT NULL THEN
""");
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

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