Skip to content

Commit

Permalink
Fix some non-deterministic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Aug 1, 2020
1 parent 9c8f116 commit 6804d1b
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using System;
using System.Linq;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.TestModels.InheritanceModel;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;
Expand Down Expand Up @@ -62,6 +64,9 @@ join keylessanimal in queryTypeQuery on animal.Name equals keylessanimal.Name
Assert.Single(result);
}

protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
=> facade.UseTransaction(transaction.GetDbTransaction());

private string NormalizeDelimitersInRawString(string sql)
=> ((RelationalTestStore)Fixture.TestStore).NormalizeDelimitersInRawString(sql);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

// ReSharper disable InconsistentNaming
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.TestModels.InheritanceModel;
using Xunit;

Expand Down Expand Up @@ -48,5 +49,8 @@ public virtual void Using_from_sql_throws()

Assert.Equal(RelationalStrings.NonTPHOnFromSqlNotSupported("FromSqlInterpolated", typeof(Bird).Name), message);
}

protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
=> facade.UseTransaction(transaction.GetDbTransaction());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7753,7 +7753,7 @@ public virtual Task SelectMany_predicate_with_non_equality_comparison_with_Take_
return AssertQuery(
async,
ss => from g in ss.Set<Gear>()
from w in ss.Set<Weapon>().Where(x => x.OwnerFullName != g.FullName).Take(3)
from w in ss.Set<Weapon>().Where(x => x.OwnerFullName != g.FullName).OrderBy(x => x.Id).Take(3)
orderby g.Nickname, w.Id
select new { g, w },
assertOrder: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ public virtual Task Left_join_with_skip_navigation(bool async)
join s in ss.Set<EntityCompositeKey>()
on t.TwoSkipShared.OrderBy(e => e.Id).FirstOrDefault().Id equals s.ThreeSkipFull.OrderBy(e => e.Id).FirstOrDefault().Id into grouping
from s in grouping.DefaultIfEmpty()
orderby t.Key1, s.Key1
orderby t.Key1, s.Key1, t.Key2, s.Key2
select new { t, s },
ss => from t in ss.Set<EntityCompositeKey>()
join s in ss.Set<EntityCompositeKey>()
on t.TwoSkipShared.OrderBy(e => e.Id).FirstOrDefault().MaybeScalar(e => e.Id) equals s.ThreeSkipFull.OrderBy(e => e.Id).FirstOrDefault().MaybeScalar(e => e.Id) into grouping
from s in grouping.DefaultIfEmpty()
orderby t.MaybeScalar(e => e.Key1), s.MaybeScalar(e => e.Key1)
orderby t.Key1, s.MaybeScalar(e => e.Key1), t.Key2, s.Key2
select new { t, s },
assertOrder: true,
elementAsserter: (e, a) =>
Expand Down Expand Up @@ -417,7 +417,7 @@ public virtual Task Select_skip_navigation_first_or_default(bool async)
async,
ss => from r in ss.Set<EntityThree>()
orderby r.Id
select r.CompositeKeySkipFull.OrderBy(e => e.Key1).FirstOrDefault(),
select r.CompositeKeySkipFull.OrderBy(e => e.Key1).ThenBy(e => e.Key2).FirstOrDefault(),
assertOrder: true,
entryCount: 12);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7145,6 +7145,7 @@ CROSS APPLY (
SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId]
FROM [Weapons] AS [w]
WHERE ([w].[OwnerFullName] <> [g].[FullName]) OR [w].[OwnerFullName] IS NULL
ORDER BY [w].[Id]
) AS [t]
ORDER BY [g].[Nickname], [t].[Id]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,6 @@ WHERE [a0].[Discriminator] IN (N'Eagle', N'Kiwi') AND ([a0].[Name] = N'Great spo
ORDER BY [a].[Species]");
}

protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
=> facade.UseTransaction(transaction.GetDbTransaction());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,6 @@ FROM [Animals] AS [a0]
ORDER BY [a].[Species]");
}

protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
=> facade.UseTransaction(transaction.GetDbTransaction());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ FROM [JoinThreeToCompositeKeyFull] AS [j0]
INNER JOIN [EntityThrees] AS [e2] ON [j0].[ThreeId] = [e2].[Id]
WHERE (([e0].[Key1] = [j0].[CompositeId1]) AND ([e0].[Key2] = [j0].[CompositeId2])) AND ([e0].[Key3] = [j0].[CompositeId3])
ORDER BY [e2].[Id])
ORDER BY [e].[Key1], [e0].[Key1]");
ORDER BY [e].[Key1], [e0].[Key1], [e].[Key2], [e0].[Key2]");
}

public override async Task Select_many_over_skip_navigation(bool async)
Expand Down Expand Up @@ -554,7 +554,7 @@ FROM [EntityThrees] AS [e]
LEFT JOIN (
SELECT [t].[Key1], [t].[Key2], [t].[Key3], [t].[Name], [t].[ThreeId], [t].[CompositeId1], [t].[CompositeId2], [t].[CompositeId3]
FROM (
SELECT [e0].[Key1], [e0].[Key2], [e0].[Key3], [e0].[Name], [j].[ThreeId], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Key1]) AS [row]
SELECT [e0].[Key1], [e0].[Key2], [e0].[Key3], [e0].[Name], [j].[ThreeId], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Key1], [e0].[Key2]) AS [row]
FROM [JoinThreeToCompositeKeyFull] AS [j]
INNER JOIN [EntityCompositeKeys] AS [e0] ON (([j].[CompositeId1] = [e0].[Key1]) AND ([j].[CompositeId2] = [e0].[Key2])) AND ([j].[CompositeId3] = [e0].[Key3])
) AS [t]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ FROM [JoinThreeToCompositeKeyFull] AS [j0]
INNER JOIN [EntityThrees] AS [e2] ON [j0].[ThreeId] = [e2].[Id]
WHERE (([e0].[Key1] = [j0].[CompositeId1]) AND ([e0].[Key2] = [j0].[CompositeId2])) AND ([e0].[Key3] = [j0].[CompositeId3])
ORDER BY [e2].[Id])
ORDER BY [e].[Key1], [e0].[Key1]");
ORDER BY [e].[Key1], [e0].[Key1], [e].[Key2], [e0].[Key2]");
}

public override async Task Select_many_over_skip_navigation(bool async)
Expand Down Expand Up @@ -554,7 +554,7 @@ FROM [EntityThrees] AS [e]
LEFT JOIN (
SELECT [t].[Key1], [t].[Key2], [t].[Key3], [t].[Name], [t].[ThreeId], [t].[CompositeId1], [t].[CompositeId2], [t].[CompositeId3]
FROM (
SELECT [e0].[Key1], [e0].[Key2], [e0].[Key3], [e0].[Name], [j].[ThreeId], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Key1]) AS [row]
SELECT [e0].[Key1], [e0].[Key2], [e0].[Key3], [e0].[Name], [j].[ThreeId], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Key1], [e0].[Key2]) AS [row]
FROM [JoinThreeToCompositeKeyFull] AS [j]
INNER JOIN [EntityCompositeKeys] AS [e0] ON (([j].[CompositeId1] = [e0].[Key1]) AND ([j].[CompositeId2] = [e0].[Key2])) AND ([j].[CompositeId3] = [e0].[Key3])
) AS [t]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,6 @@ FROM [Animals] AS [a0]
ORDER BY [a].[Species]");
}

protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
=> facade.UseTransaction(transaction.GetDbTransaction());

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ FROM [JoinThreeToCompositeKeyFull] AS [j0]
INNER JOIN [EntityThrees] AS [e2] ON [j0].[ThreeId] = [e2].[Id]
WHERE (([e0].[Key1] = [j0].[CompositeId1]) AND ([e0].[Key2] = [j0].[CompositeId2])) AND ([e0].[Key3] = [j0].[CompositeId3])
ORDER BY [e2].[Id])
ORDER BY [e].[Key1], [e0].[Key1]");
ORDER BY [e].[Key1], [e0].[Key1], [e].[Key2], [e0].[Key2]");
}

public override async Task Select_many_over_skip_navigation(bool async)
Expand Down Expand Up @@ -590,7 +590,7 @@ FROM [EntityThrees] AS [e]
LEFT JOIN (
SELECT [t].[Key1], [t].[Key2], [t].[Key3], [t].[Name], [t].[ThreeId], [t].[CompositeId1], [t].[CompositeId2], [t].[CompositeId3]
FROM (
SELECT [e0].[Key1], [e0].[Key2], [e0].[Key3], [e0].[Name], [j].[ThreeId], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Key1]) AS [row]
SELECT [e0].[Key1], [e0].[Key2], [e0].[Key3], [e0].[Name], [j].[ThreeId], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Key1], [e0].[Key2]) AS [row]
FROM [JoinThreeToCompositeKeyFull] AS [j]
INNER JOIN [EntityCompositeKeys] AS [e0] ON (([j].[CompositeId1] = [e0].[Key1]) AND ([j].[CompositeId2] = [e0].[Key2])) AND ([j].[CompositeId3] = [e0].[Key3])
) AS [t]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ FROM [JoinThreeToCompositeKeyFull] AS [j0]
INNER JOIN [EntityThrees] AS [e2] ON [j0].[ThreeId] = [e2].[Id]
WHERE (([e0].[Key1] = [j0].[CompositeId1]) AND ([e0].[Key2] = [j0].[CompositeId2])) AND ([e0].[Key3] = [j0].[CompositeId3])
ORDER BY [e2].[Id])
ORDER BY [e].[Key1], [e0].[Key1]");
ORDER BY [e].[Key1], [e0].[Key1], [e].[Key2], [e0].[Key2]");
}

public override async Task Select_many_over_skip_navigation(bool async)
Expand Down Expand Up @@ -590,7 +590,7 @@ FROM [EntityThrees] AS [e]
LEFT JOIN (
SELECT [t].[Key1], [t].[Key2], [t].[Key3], [t].[Name], [t].[ThreeId], [t].[CompositeId1], [t].[CompositeId2], [t].[CompositeId3]
FROM (
SELECT [e0].[Key1], [e0].[Key2], [e0].[Key3], [e0].[Name], [j].[ThreeId], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Key1]) AS [row]
SELECT [e0].[Key1], [e0].[Key2], [e0].[Key3], [e0].[Name], [j].[ThreeId], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Key1], [e0].[Key2]) AS [row]
FROM [JoinThreeToCompositeKeyFull] AS [j]
INNER JOIN [EntityCompositeKeys] AS [e0] ON (([j].[CompositeId1] = [e0].[Key1]) AND ([j].[CompositeId2] = [e0].[Key2])) AND ([j].[CompositeId3] = [e0].[Key3])
) AS [t]
Expand Down

0 comments on commit 6804d1b

Please sign in to comment.