Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0.3/Tests only] Updates many-to-many change tracking tests to work with generated key values #23807

Merged
merged 1 commit into from
Jan 5, 2021
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
1,866 changes: 1,275 additions & 591 deletions test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,20 @@ public abstract class ManyToManyQueryFixtureBase : SharedStoreFixtureBase<ManyTo
public Func<DbContext> GetContextCreator()
=> () => CreateContext();

private ManyToManyData _data;

public ISetSource GetExpectedData()
=> new ManyToManyData();
{
if (_data == null)
{
using var context = CreateContext();
_data = new ManyToManyData(context, false);
context.ChangeTracker.DetectChanges();
context.ChangeTracker.Clear();
}

return _data;
}

public IReadOnlyDictionary<Type, object> GetEntitySorters()
=> new Dictionary<Type, Func<object, object>>
Expand Down Expand Up @@ -329,7 +341,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
});
}

public virtual bool UseGeneratedKeys
=> false;

protected override void Seed(ManyToManyContext context)
=> ManyToManyContext.Seed(context);
{
new ManyToManyData(context, UseGeneratedKeys);
context.SaveChanges();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ public ManyToManyContext(DbContextOptions options)
public DbSet<ImplicitManyToManyB> ImplicitManyToManyBs { get; set; }
public DbSet<GeneratedKeysLeft> GeneratedKeysLefts { get; set; }
public DbSet<GeneratedKeysRight> GeneratedKeysRights { get; set; }

public static void Seed(ManyToManyContext context)
=> ManyToManyData.Seed(context);
}

public static class ManyToManyContextExtensions
Expand Down
Loading