Skip to content

Commit

Permalink
Expression bodies for query test base classes (dotnet#26761)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers authored Nov 20, 2021
1 parent f1227ab commit 04f5cbe
Show file tree
Hide file tree
Showing 42 changed files with 3,610 additions and 8,124 deletions.
8 changes: 4 additions & 4 deletions All.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestVarOrType_005FSimpleTypes/@EntryIndexedValue">WARNING</s:String>
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/ReadSettingsFromFileLevel/@EntryValue">True</s:Boolean>

<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=EntityFramework/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="EntityFramework"&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;CAN_CHANGE_TO_IMPLICIT&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;ALWAYS_IMPLICIT&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;ALWAYS_IMPLICIT&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;XMLReformatCode&gt;True&lt;/XMLReformatCode&gt;&lt;CSUpdateFileHeader&gt;True&lt;/CSUpdateFileHeader&gt;&lt;CSharpFormatDocComments&gt;True&lt;/CSharpFormatDocComments&gt;&lt;RemoveCodeRedundancies&gt;True&lt;/RemoveCodeRedundancies&gt;&lt;CSMakeAutoPropertyGetOnly&gt;True&lt;/CSMakeAutoPropertyGetOnly&gt;&lt;CSArrangeQualifiers&gt;True&lt;/CSArrangeQualifiers&gt;&lt;CSEnforceVarKeywordUsageSettings&gt;True&lt;/CSEnforceVarKeywordUsageSettings&gt;&lt;CSFixBuiltinTypeReferences&gt;True&lt;/CSFixBuiltinTypeReferences&gt;&lt;CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="False" AddMissingParentheses="False" ArrangeBraces="False" ArrangeAttributes="True" ArrangeArgumentsStyle="False" /&gt;&lt;IDEA_SETTINGS&gt;&amp;lt;profile version="1.0"&amp;gt;&#xD;
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=EntityFramework/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="EntityFramework"&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;CAN_CHANGE_TO_IMPLICIT&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;ALWAYS_IMPLICIT&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;ALWAYS_IMPLICIT&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;XMLReformatCode&gt;True&lt;/XMLReformatCode&gt;&lt;CSUpdateFileHeader&gt;True&lt;/CSUpdateFileHeader&gt;&lt;CSharpFormatDocComments&gt;True&lt;/CSharpFormatDocComments&gt;&lt;RemoveCodeRedundancies&gt;True&lt;/RemoveCodeRedundancies&gt;&lt;CSMakeAutoPropertyGetOnly&gt;True&lt;/CSMakeAutoPropertyGetOnly&gt;&lt;CSArrangeQualifiers&gt;True&lt;/CSArrangeQualifiers&gt;&lt;CSEnforceVarKeywordUsageSettings&gt;True&lt;/CSEnforceVarKeywordUsageSettings&gt;&lt;CSFixBuiltinTypeReferences&gt;True&lt;/CSFixBuiltinTypeReferences&gt;&lt;CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" ArrangeAttributes="True" ArrangeVarStyle="True" ArrangeBraces="True" ArrangeCodeBodyStyle="True" ArrangeObjectCreation="True" /&gt;&lt;IDEA_SETTINGS&gt;&amp;lt;profile version="1.0"&amp;gt;&#xD;
&amp;lt;option name="myName" value="EntityFramework" /&amp;gt;&#xD;
&amp;lt;inspection_tool class="ES6ShorthandObjectProperty" enabled="false" level="WARNING" enabled_by_default="false" /&amp;gt;&#xD;
&amp;lt;inspection_tool class="JSArrowFunctionBracesCanBeRemoved" enabled="false" level="WARNING" enabled_by_default="false" /&amp;gt;&#xD;
Expand All @@ -55,8 +55,8 @@
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="HTML"&amp;gt;&#xD;
&amp;lt;OptimizeImports&amp;gt;false&amp;lt;/OptimizeImports&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;OptimizeImports&amp;gt;false&amp;lt;/OptimizeImports&amp;gt;&#xD;
&amp;lt;Rearrange&amp;gt;false&amp;lt;/Rearrange&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="HTTP Request"&amp;gt;&#xD;
Expand All @@ -75,8 +75,8 @@
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="JavaScript"&amp;gt;&#xD;
&amp;lt;OptimizeImports&amp;gt;false&amp;lt;/OptimizeImports&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;OptimizeImports&amp;gt;false&amp;lt;/OptimizeImports&amp;gt;&#xD;
&amp;lt;Rearrange&amp;gt;false&amp;lt;/Rearrange&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="Markdown"&amp;gt;&#xD;
Expand All @@ -92,8 +92,8 @@
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="XML"&amp;gt;&#xD;
&amp;lt;OptimizeImports&amp;gt;false&amp;lt;/OptimizeImports&amp;gt;&#xD;
&amp;lt;Reformat&amp;gt;false&amp;lt;/Reformat&amp;gt;&#xD;
&amp;lt;OptimizeImports&amp;gt;false&amp;lt;/OptimizeImports&amp;gt;&#xD;
&amp;lt;Rearrange&amp;gt;false&amp;lt;/Rearrange&amp;gt;&#xD;
&amp;lt;/Language&amp;gt;&#xD;
&amp;lt;Language id="yaml"&amp;gt;&#xD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public virtual ISetSource GetExpectedData()
(typeof(CompositeOne), "OneToMany_Optional_Self_Inverse1Id2"),
e => l1s.SingleOrDefault(l => l.Id2 == ((CompositeOne)e)?.Id2)?.OneToMany_Optional_Self_Inverse1?.Id2
},

{
(typeof(CompositeTwo), "OneToOne_Optional_PK_Inverse2Id1"),
e => l2s.SingleOrDefault(l => l.Id1 == ((CompositeTwo)e)?.Id1)?.OneToOne_Optional_PK_Inverse2?.Id1
Expand Down Expand Up @@ -112,7 +111,6 @@ public virtual ISetSource GetExpectedData()
(typeof(CompositeTwo), "OneToMany_Optional_Self_Inverse2Id2"),
e => l2s.SingleOrDefault(l => l.Id2 == ((CompositeTwo)e)?.Id2)?.OneToMany_Optional_Self_Inverse2?.Id2
},

{
(typeof(CompositeThree), "OneToOne_Optional_PK_Inverse3Id1"),
e => l3s.SingleOrDefault(l => l.Id1 == ((CompositeThree)e)?.Id1)?.OneToOne_Optional_PK_Inverse3?.Id1
Expand Down Expand Up @@ -161,7 +159,6 @@ public virtual ISetSource GetExpectedData()
(typeof(CompositeThree), "OneToMany_Optional_Self_Inverse3Id2"),
e => l3s.SingleOrDefault(l => l.Id2 == ((CompositeThree)e)?.Id2)?.OneToMany_Optional_Self_Inverse3?.Id2
},

{
(typeof(CompositeFour), "OneToOne_Optional_PK_Inverse4Id1"),
e => l4s.SingleOrDefault(l => l.Id1 == ((CompositeFour)e)?.Id1)?.OneToOne_Optional_PK_Inverse4?.Id1
Expand Down Expand Up @@ -212,13 +209,14 @@ public virtual ISetSource GetExpectedData()
},
};
}

public IReadOnlyDictionary<Type, object> GetEntitySorters()
=> new Dictionary<Type, Func<object, object>>
{
{ typeof(CompositeOne), e => (((CompositeOne)e)?.Id1 ,((CompositeOne)e)?.Id2) },
{ typeof(CompositeTwo), e => (((CompositeTwo)e)?.Id1 ,((CompositeTwo)e)?.Id2) },
{ typeof(CompositeThree), e => (((CompositeThree)e)?.Id1 ,((CompositeThree)e)?.Id2) },
{ typeof(CompositeFour), e => (((CompositeFour)e)?.Id1 ,((CompositeFour)e)?.Id2) },
{ typeof(CompositeOne), e => (((CompositeOne)e)?.Id1, ((CompositeOne)e)?.Id2) },
{ typeof(CompositeTwo), e => (((CompositeTwo)e)?.Id1, ((CompositeTwo)e)?.Id2) },
{ typeof(CompositeThree), e => (((CompositeThree)e)?.Id1, ((CompositeThree)e)?.Id2) },
{ typeof(CompositeFour), e => (((CompositeFour)e)?.Id1, ((CompositeFour)e)?.Id2) },
}.ToDictionary(e => e.Key, e => (object)e.Value);

public IReadOnlyDictionary<Type, object> GetEntityAsserters()
Expand Down Expand Up @@ -313,50 +311,60 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con

modelBuilder.Entity<CompositeOne>().HasOne(e => e.OneToOne_Optional_Self1).WithOne();
modelBuilder.Entity<CompositeOne>().HasOne(e => e.OneToOne_Required_PK1).WithOne(e => e.OneToOne_Required_PK_Inverse2)
.HasPrincipalKey<CompositeOne>(e => new { e.Id1, e.Id2 }).HasForeignKey<CompositeTwo>(e => new { e.Id1, e.Id2 }).IsRequired().OnDelete(DeleteBehavior.Restrict);
.HasPrincipalKey<CompositeOne>(e => new { e.Id1, e.Id2 }).HasForeignKey<CompositeTwo>(e => new { e.Id1, e.Id2 })
.IsRequired().OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeOne>().HasOne(e => e.OneToOne_Optional_PK1).WithOne(e => e.OneToOne_Optional_PK_Inverse2)
.HasPrincipalKey<CompositeOne>(e => new { e.Id1, e.Id2 }).IsRequired(false);
modelBuilder.Entity<CompositeOne>().HasOne(e => e.OneToOne_Required_FK1).WithOne(e => e.OneToOne_Required_FK_Inverse2)
.HasForeignKey<CompositeTwo>(e => new { e.Level1_Required_Id1, e.Level1_Required_Id2 }).IsRequired().OnDelete(DeleteBehavior.Restrict);
.HasForeignKey<CompositeTwo>(e => new { e.Level1_Required_Id1, e.Level1_Required_Id2 }).IsRequired()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeOne>().HasOne(e => e.OneToOne_Optional_FK1).WithOne(e => e.OneToOne_Optional_FK_Inverse2)
.HasForeignKey<CompositeTwo>(e => new { e.Level1_Optional_Id1, e.Level1_Optional_Id2 } ).IsRequired(false);
.HasForeignKey<CompositeTwo>(e => new { e.Level1_Optional_Id1, e.Level1_Optional_Id2 }).IsRequired(false);
modelBuilder.Entity<CompositeOne>().HasMany(e => e.OneToMany_Required1).WithOne(e => e.OneToMany_Required_Inverse2).IsRequired()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeOne>().HasMany(e => e.OneToMany_Optional1).WithOne(e => e.OneToMany_Optional_Inverse2).IsRequired(false);
modelBuilder.Entity<CompositeOne>().HasMany(e => e.OneToMany_Optional1).WithOne(e => e.OneToMany_Optional_Inverse2)
.IsRequired(false);
modelBuilder.Entity<CompositeOne>().HasMany(e => e.OneToMany_Required_Self1).WithOne(e => e.OneToMany_Required_Self_Inverse1)
.IsRequired().OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeOne>().HasMany(e => e.OneToMany_Optional_Self1).WithOne(e => e.OneToMany_Optional_Self_Inverse1)
.IsRequired(false);

modelBuilder.Entity<CompositeTwo>().HasOne(e => e.OneToOne_Optional_Self2).WithOne();
modelBuilder.Entity<CompositeTwo>().HasOne(e => e.OneToOne_Required_PK2).WithOne(e => e.OneToOne_Required_PK_Inverse3)
.HasPrincipalKey<CompositeTwo>(e => new { e.Id1, e.Id2 }).HasForeignKey<CompositeThree>(e => new { e.Id1, e.Id2 }).IsRequired().OnDelete(DeleteBehavior.Restrict);
.HasPrincipalKey<CompositeTwo>(e => new { e.Id1, e.Id2 }).HasForeignKey<CompositeThree>(e => new { e.Id1, e.Id2 })
.IsRequired().OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeTwo>().HasOne(e => e.OneToOne_Optional_PK2).WithOne(e => e.OneToOne_Optional_PK_Inverse3)
.HasPrincipalKey<CompositeTwo>(e => new { e.Id1, e.Id2 }).IsRequired(false);
modelBuilder.Entity<CompositeTwo>().HasOne(e => e.OneToOne_Required_FK2).WithOne(e => e.OneToOne_Required_FK_Inverse3)
.HasForeignKey<CompositeThree>(e => new { e.Level2_Required_Id1, e.Level2_Required_Id2 }).IsRequired().OnDelete(DeleteBehavior.Restrict);
.HasForeignKey<CompositeThree>(e => new { e.Level2_Required_Id1, e.Level2_Required_Id2 }).IsRequired()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeTwo>().HasOne(e => e.OneToOne_Optional_FK2).WithOne(e => e.OneToOne_Optional_FK_Inverse3)
.HasForeignKey<CompositeThree>(e => new { e.Level2_Optional_Id1, e.Level2_Optional_Id2 }).IsRequired(false);
modelBuilder.Entity<CompositeTwo>().HasMany(e => e.OneToMany_Required2).WithOne(e => e.OneToMany_Required_Inverse3).IsRequired()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeTwo>().HasMany(e => e.OneToMany_Optional2).WithOne(e => e.OneToMany_Optional_Inverse3).IsRequired(false);
modelBuilder.Entity<CompositeTwo>().HasMany(e => e.OneToMany_Optional2).WithOne(e => e.OneToMany_Optional_Inverse3)
.IsRequired(false);
modelBuilder.Entity<CompositeTwo>().HasMany(e => e.OneToMany_Required_Self2).WithOne(e => e.OneToMany_Required_Self_Inverse2)
.IsRequired().OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeTwo>().HasMany(e => e.OneToMany_Optional_Self2).WithOne(e => e.OneToMany_Optional_Self_Inverse2)
.IsRequired(false);

modelBuilder.Entity<CompositeThree>().HasOne(e => e.OneToOne_Optional_Self3).WithOne();
modelBuilder.Entity<CompositeThree>().HasOne(e => e.OneToOne_Required_PK3).WithOne(e => e.OneToOne_Required_PK_Inverse4)
.HasPrincipalKey<CompositeThree>(e => new { e.Id1, e.Id2 }).HasForeignKey<CompositeFour>(e => new { e.Id1, e.Id2 }).IsRequired().OnDelete(DeleteBehavior.Restrict);
.HasPrincipalKey<CompositeThree>(e => new { e.Id1, e.Id2 }).HasForeignKey<CompositeFour>(e => new { e.Id1, e.Id2 })
.IsRequired().OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeThree>().HasOne(e => e.OneToOne_Optional_PK3).WithOne(e => e.OneToOne_Optional_PK_Inverse4)
.HasPrincipalKey<CompositeThree>(e => new { e.Id1, e.Id2 }).IsRequired(false);
modelBuilder.Entity<CompositeThree>().HasOne(e => e.OneToOne_Required_FK3).WithOne(e => e.OneToOne_Required_FK_Inverse4)
.HasForeignKey<CompositeFour>(e => new { e.Level3_Required_Id1, e.Level3_Required_Id2 }).IsRequired().OnDelete(DeleteBehavior.Restrict);
.HasForeignKey<CompositeFour>(e => new { e.Level3_Required_Id1, e.Level3_Required_Id2 }).IsRequired()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeThree>().HasOne(e => e.OneToOne_Optional_FK3).WithOne(e => e.OneToOne_Optional_FK_Inverse4)
.HasForeignKey<CompositeFour>(e => new { e.Level3_Optional_Id1, e.Level3_Optional_Id2 }).IsRequired(false);
modelBuilder.Entity<CompositeThree>().HasMany(e => e.OneToMany_Required3).WithOne(e => e.OneToMany_Required_Inverse4).IsRequired()
modelBuilder.Entity<CompositeThree>().HasMany(e => e.OneToMany_Required3).WithOne(e => e.OneToMany_Required_Inverse4)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeThree>().HasMany(e => e.OneToMany_Optional3).WithOne(e => e.OneToMany_Optional_Inverse4).IsRequired(false);
modelBuilder.Entity<CompositeThree>().HasMany(e => e.OneToMany_Optional3).WithOne(e => e.OneToMany_Optional_Inverse4)
.IsRequired(false);
modelBuilder.Entity<CompositeThree>().HasMany(e => e.OneToMany_Required_Self3).WithOne(e => e.OneToMany_Required_Self_Inverse3)
.IsRequired().OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<CompositeThree>().HasMany(e => e.OneToMany_Optional_Self3).WithOne(e => e.OneToMany_Optional_Self_Inverse3)
Expand Down Expand Up @@ -413,5 +421,4 @@ public override IQueryable<TEntity> Set<TEntity>()
}
}
}

}
Loading

0 comments on commit 04f5cbe

Please sign in to comment.