You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
EntityFrameworkCore.Jet/test/EFCore.Jet.FunctionalTests/ManyToManyTrackingJetTestBa...

73 lines
3.1 KiB
C#

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using EntityFrameworkCore.Jet.FunctionalTests.TestUtilities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.TestModels.ManyToManyModel;
using Microsoft.EntityFrameworkCore.TestUtilities;
namespace EntityFrameworkCore.Jet.FunctionalTests;
public abstract class ManyToManyTrackingJetTestBase<TFixture>(TFixture fixture)
: ManyToManyTrackingRelationalTestBase<TFixture>(fixture)
where TFixture : ManyToManyTrackingJetTestBase<TFixture>.ManyToManyTrackingJetFixtureBase
{
protected override Dictionary<string, DeleteBehavior> CustomDeleteBehaviors { get; } = new()
{
{ "EntityBranch.RootSkipShared", DeleteBehavior.ClientCascade },
{ "EntityBranch2.Leaf2SkipShared", DeleteBehavior.ClientCascade },
{ "EntityBranch2.SelfSkipSharedLeft", DeleteBehavior.ClientCascade },
{ "EntityOne.SelfSkipPayloadLeft", DeleteBehavior.ClientCascade },
{ "EntityTableSharing1.TableSharing2Shared", DeleteBehavior.ClientCascade },
{ "EntityTwo.SelfSkipSharedLeft", DeleteBehavior.ClientCascade },
{ "UnidirectionalEntityBranch.UnidirectionalEntityRoot", DeleteBehavior.ClientCascade },
{ "UnidirectionalEntityOne.SelfSkipPayloadLeft", DeleteBehavior.ClientCascade },
{ "UnidirectionalEntityTwo.SelfSkipSharedRight", DeleteBehavior.ClientCascade },
};
public class ManyToManyTrackingJetFixtureBase : ManyToManyTrackingRelationalFixture, ITestSqlLoggerFactory
{
public TestSqlLoggerFactory TestSqlLoggerFactory
=> (TestSqlLoggerFactory)ListLoggerFactory;
protected override ITestStoreFactory TestStoreFactory
=> JetTestStoreFactory.Instance;
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
{
base.OnModelCreating(modelBuilder, context);
modelBuilder
.Entity<JoinOneSelfPayload>()
.Property(e => e.Payload)
.HasDefaultValueSql("DATE()");
modelBuilder
.SharedTypeEntity<Dictionary<string, object>>("JoinOneToThreePayloadFullShared")
.IndexerProperty<string>("Payload")
.HasDefaultValue("Generated");
modelBuilder
.Entity<JoinOneToThreePayloadFull>()
.Property(e => e.Payload)
.HasDefaultValue("Generated");
modelBuilder
.Entity<UnidirectionalJoinOneSelfPayload>()
.Property(e => e.Payload)
.HasDefaultValueSql("DATE()");
modelBuilder
.SharedTypeEntity<Dictionary<string, object>>("UnidirectionalJoinOneToThreePayloadFullShared")
.IndexerProperty<string>("Payload")
.HasDefaultValue("Generated");
modelBuilder
.Entity<UnidirectionalJoinOneToThreePayloadFull>()
.Property(e => e.Payload)
.HasDefaultValue("Generated");
}
}
}