Skip to content

Commit f72fd5f

Browse files
ChrisJollyAUgithub-actions
andauthored
Add more tests (#280)
* Add more tests * updates * updates * updates * [GitHub Actions] Update green tests. --------- Co-authored-by: github-actions <[email protected]>
1 parent 563008f commit f72fd5f

27 files changed

+22351
-295
lines changed

Dependencies.targets

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
3-
<DotNetVersion>[9.0.4,9.0.999]</DotNetVersion>
4-
<EFCoreVersion>[9.0.4,9.0.999]</EFCoreVersion>
5-
<MSLibVersion>[9.0.4,9.0.999]</MSLibVersion>
3+
<DotNetVersion>[9.0.6,9.0.999]</DotNetVersion>
4+
<EFCoreVersion>[9.0.6,9.0.999]</EFCoreVersion>
5+
<MSLibVersion>[9.0.6,9.0.999]</MSLibVersion>
66
</PropertyGroup>
77

88
<ItemGroup>
@@ -28,16 +28,16 @@
2828
<PackageReference Update="Microsoft.EntityFrameworkCore.Design" Version="$(EFCoreVersion)" />
2929
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="$(EFCoreVersion)" />
3030
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="$(MSLibVersion)" />
31-
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.13.0" />
32-
<PackageReference Update="MSTest.TestAdapter" Version="3.8.3" />
33-
<PackageReference Update="MSTest.TestFramework" Version="3.8.3" />
31+
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.14.1" />
32+
<PackageReference Update="MSTest.TestAdapter" Version="3.9.3" />
33+
<PackageReference Update="MSTest.TestFramework" Version="3.9.3" />
3434
<PackageReference Update="coverlet.collector" Version="6.0.4" />
3535
<PackageReference Update="Newtonsoft.Json" Version="13.0.3" />
3636

3737
<!-- EFCore.Jet.FunctionalTests -->
3838
<PackageReference Update="xunit.core" Version="2.9.3"/>
3939
<PackageReference Update="xunit.assert" Version="2.9.3" />
40-
<PackageReference Update="xunit.runner.visualstudio" Version="3.0.2" />
40+
<PackageReference Update="xunit.runner.visualstudio" Version="3.1.1" />
4141
<PackageReference Update="xunit.runner.console" Version="2.9.3" />
4242
<PackageReference Update="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MSLibVersion)" />
4343
<PackageReference Update="NetTopologySuite" Version="2.5.0" />

src/EFCore.Jet.Data/AdoxSchema.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ public override void RenameColumn(string tableName, string oldColumnName, string
648648
}
649649
}
650650

651-
protected static string GetDataTypeString(DataTypeEnum dataType, bool isIdentity = false)
651+
private static string GetDataTypeString(DataTypeEnum dataType, bool isIdentity = false)
652652
{
653653
switch (dataType)
654654
{

src/EFCore.Jet.Data/DaoSchema.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ public override void RenameColumn(string tableName, string oldColumnName, string
553553
}
554554
}
555555

556-
protected static string GetDataTypeString(DataTypeEnum dataType, bool isIdentity = false)
556+
private static string GetDataTypeString(DataTypeEnum dataType, bool isIdentity = false)
557557
=> dataType switch
558558
{
559559
DataTypeEnum.dbBoolean => "bit",

src/EFCore.Jet/Extensions/JetIndexExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public static void SetJetIncludeProperties(this IMutableIndex index, IReadOnlyLi
3434
/// <param name="index"> The index. </param>
3535
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
3636
/// <param name="properties"> The value to set. </param>
37-
public static void SetJetIncludeProperties(
37+
public static IReadOnlyList<string>? SetJetIncludeProperties(
3838
this IConventionIndex index, IReadOnlyList<string> properties, bool fromDataAnnotation = false)
39-
=> index.SetOrRemoveAnnotation(
39+
=> (IReadOnlyList<string>?)index.SetOrRemoveAnnotation(
4040
JetAnnotationNames.Include,
4141
properties,
42-
fromDataAnnotation);
42+
fromDataAnnotation)?.Value;
4343

4444
/// <summary>
4545
/// Returns the <see cref="ConfigurationSource" /> for the included property names.

src/EFCore.Jet/Extensions/JetModelExtensions.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public static void SetJetIdentitySeed(this IMutableModel model, int? seed)
3434
/// <param name="model"> The model. </param>
3535
/// <param name="seed"> The value to set. </param>
3636
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
37-
public static void SetJetIdentitySeed(this IConventionModel model, int? seed, bool fromDataAnnotation = false)
38-
=> model.SetOrRemoveAnnotation(
37+
public static int? SetJetIdentitySeed(this IConventionModel model, int? seed, bool fromDataAnnotation = false)
38+
=> (int?)model.SetOrRemoveAnnotation(
3939
JetAnnotationNames.IdentitySeed,
4040
seed,
41-
fromDataAnnotation);
41+
fromDataAnnotation)?.Value;
4242

4343
/// <summary>
4444
/// Returns the <see cref="ConfigurationSource" /> for the default schema.
@@ -72,12 +72,12 @@ public static void SetJetIdentityIncrement(this IMutableModel model, int? increm
7272
/// <param name="model"> The model. </param>
7373
/// <param name="increment"> The value to set. </param>
7474
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
75-
public static void SetJetIdentityIncrement(
75+
public static int? SetJetIdentityIncrement(
7676
this IConventionModel model, int? increment, bool fromDataAnnotation = false)
77-
=> model.SetOrRemoveAnnotation(
77+
=> (int?) model.SetOrRemoveAnnotation(
7878
JetAnnotationNames.IdentityIncrement,
7979
increment,
80-
fromDataAnnotation);
80+
fromDataAnnotation)?.Value;
8181

8282
/// <summary>
8383
/// Returns the <see cref="ConfigurationSource" /> for the default identity increment.
@@ -112,16 +112,16 @@ public static void SetValueGenerationStrategy(this IMutableModel model, JetValue
112112
/// <param name="model"> The model. </param>
113113
/// <param name="value"> The value to set. </param>
114114
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
115-
public static void SetValueGenerationStrategy(
115+
public static JetValueGenerationStrategy? SetValueGenerationStrategy(
116116
this IConventionModel model, JetValueGenerationStrategy? value, bool fromDataAnnotation = false)
117-
=> model.SetOrRemoveAnnotation(JetAnnotationNames.ValueGenerationStrategy, value, fromDataAnnotation);
117+
=> (JetValueGenerationStrategy?)model.SetOrRemoveAnnotation(JetAnnotationNames.ValueGenerationStrategy, value, fromDataAnnotation)?.Value;
118118

119119
/// <summary>
120120
/// Returns the <see cref="ConfigurationSource" /> for the default <see cref="JetValueGenerationStrategy" />.
121121
/// </summary>
122122
/// <param name="model"> The model. </param>
123123
/// <returns> The <see cref="ConfigurationSource" /> for the default <see cref="JetValueGenerationStrategy" />. </returns>
124-
public static ConfigurationSource? GetJetValueGenerationStrategyConfigurationSource(this IConventionModel model)
124+
public static ConfigurationSource? GetValueGenerationStrategyConfigurationSource(this IConventionModel model)
125125
=> model.FindAnnotation(JetAnnotationNames.ValueGenerationStrategy)?.GetConfigurationSource();
126126
}
127127
}

src/EFCore.Jet/Extensions/JetPropertyExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ public static void SetValueGenerationStrategy(
510510
/// </summary>
511511
/// <param name="property"> The property. </param>
512512
/// <returns> The <see cref="ConfigurationSource" /> for the <see cref="JetValueGenerationStrategy" />. </returns>
513-
public static ConfigurationSource? GetJetValueGenerationStrategyConfigurationSource(
513+
public static ConfigurationSource? GetValueGenerationStrategyConfigurationSource(
514514
this IConventionProperty property)
515515
=> property.FindAnnotation(JetAnnotationNames.ValueGenerationStrategy)?.GetConfigurationSource();
516516

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetDateTimeMemberTranslator.cs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ private static readonly Dictionary<string, string> DatePartMapping
8585
[false],
8686
returnType),
8787

88-
nameof(DateTime.Date) => DateTimeNullChecked(
88+
nameof(DateTime.Date) => _sqlExpressionFactory.DateTimeNullChecked(
8989
instance!,
9090
_sqlExpressionFactory.Function(
9191
"DATEVALUE",
9292
[instance!],
9393
false,
9494
[false],
9595
returnType)),
96-
nameof(DateTime.TimeOfDay) => TimeSpanNullChecked(
96+
nameof(DateTime.TimeOfDay) => _sqlExpressionFactory.TimeSpanNullChecked(
9797
instance!,
9898
_sqlExpressionFactory.Function(
9999
"TIMEVALUE",
@@ -109,31 +109,5 @@ private static readonly Dictionary<string, string> DatePartMapping
109109
}
110110
return null;
111111
}
112-
113-
public CaseExpression DateTimeNullChecked(
114-
SqlExpression checkSqlExpression,
115-
SqlExpression notNullSqlExpression)
116-
=> (CaseExpression)_sqlExpressionFactory.Case(
117-
[
118-
new CaseWhenClause(
119-
_sqlExpressionFactory.IsNull(checkSqlExpression),
120-
_sqlExpressionFactory.Constant(
121-
null,typeof(DateTime),
122-
notNullSqlExpression.TypeMapping))
123-
],
124-
notNullSqlExpression);
125-
126-
public CaseExpression TimeSpanNullChecked(
127-
SqlExpression checkSqlExpression,
128-
SqlExpression notNullSqlExpression)
129-
=> (CaseExpression)_sqlExpressionFactory.Case(
130-
[
131-
new CaseWhenClause(
132-
_sqlExpressionFactory.IsNull(checkSqlExpression),
133-
_sqlExpressionFactory.Constant(
134-
null,typeof(TimeSpan),
135-
notNullSqlExpression.TypeMapping))
136-
],
137-
notNullSqlExpression);
138112
}
139113
}

src/EFCore.Jet/Query/JetSqlExpressionFactory.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class JetSqlExpressionFactory(SqlExpressionFactoryDependencies dependenci
77

88
#region Expression factory methods
99

10-
public SqlBinaryExpression? NullChecked(
10+
public virtual SqlBinaryExpression? NullChecked(
1111
SqlExpression sqlExpression,
1212
RelationalTypeMapping? typeMapping = null)
1313
=> (SqlBinaryExpression?)MakeBinary(
@@ -18,7 +18,7 @@ public class JetSqlExpressionFactory(SqlExpressionFactoryDependencies dependenci
1818
RelationalTypeMapping.NullMapping),
1919
typeMapping);
2020

21-
public CaseExpression NullChecked(
21+
public virtual CaseExpression NullChecked(
2222
SqlExpression checkSqlExpression,
2323
SqlExpression notNullSqlExpression)
2424
=> (CaseExpression)Case(
@@ -31,6 +31,31 @@ public CaseExpression NullChecked(
3131
],
3232
notNullSqlExpression);
3333

34+
public virtual CaseExpression DateTimeNullChecked(
35+
SqlExpression checkSqlExpression,
36+
SqlExpression notNullSqlExpression)
37+
=> (CaseExpression)Case(
38+
[
39+
new CaseWhenClause(
40+
IsNull(checkSqlExpression),
41+
Constant(
42+
null,typeof(DateTime),
43+
notNullSqlExpression.TypeMapping))
44+
],
45+
notNullSqlExpression);
46+
47+
public virtual CaseExpression TimeSpanNullChecked(
48+
SqlExpression checkSqlExpression,
49+
SqlExpression notNullSqlExpression)
50+
=> (CaseExpression)Case(
51+
[
52+
new CaseWhenClause(
53+
IsNull(checkSqlExpression),
54+
Constant(
55+
null,typeof(TimeSpan),
56+
notNullSqlExpression.TypeMapping))
57+
],
58+
notNullSqlExpression);
3459
#endregion Expression factory methods
3560
}
3661
}

src/EFCore.Jet/Query/Sql/Internal/JetQuerySqlGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ protected override Expression VisitSqlUnary(SqlUnaryExpression sqlUnaryExpressio
608608
}
609609

610610

611-
protected Expression VisitJetConvertExpression(SqlUnaryExpression convertExpression)
611+
private Expression VisitJetConvertExpression(SqlUnaryExpression convertExpression)
612612
{
613613
var typeMapping = convertExpression.TypeMapping ?? throw new InvalidOperationException(
614614
RelationalStrings.UnsupportedType(convertExpression.Type.ShortDisplayName()));

src/EFCore.Jet/Scaffolding/Internal/JetDatabaseModelFactory.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -457,20 +457,7 @@ private void GetIndexes(DbConnection connection, IReadOnlyList<DatabaseTable> ta
457457
{
458458
var isUnique = indexType == "UNIQUE";
459459

460-
if (isUnique)
461-
{
462-
var uniqueConstraint = new DatabaseUniqueConstraint
463-
{
464-
Table = table,
465-
Name = indexName,
466-
};
467-
468-
_logger.UniqueConstraintFound(indexName!, tableName!);
469-
470-
table.UniqueConstraints.Add(uniqueConstraint);
471-
indexOrKey = uniqueConstraint;
472-
}
473-
else
460+
if (!isUnique || (indexName?.StartsWith("ix_", StringComparison.CurrentCultureIgnoreCase) ?? false))
474461
{
475462
// In contrast to SQL Standard, MS Access will implicitly create an index for every FK
476463
// constraint.
@@ -507,6 +494,19 @@ private void GetIndexes(DbConnection connection, IReadOnlyList<DatabaseTable> ta
507494
table.Indexes.Add(index);
508495
indexOrKey = index;
509496
}
497+
else
498+
{
499+
var uniqueConstraint = new DatabaseUniqueConstraint
500+
{
501+
Table = table,
502+
Name = indexName,
503+
};
504+
505+
_logger.UniqueConstraintFound(indexName!, tableName!);
506+
507+
table.UniqueConstraints.Add(uniqueConstraint);
508+
indexOrKey = uniqueConstraint;
509+
}
510510
}
511511

512512
foreach (var indexColumn in indexColumns)

0 commit comments

Comments
 (0)