Skip to content

Commit cf9fde2

Browse files
committed
Migrate to .NET 10, update dependencies, and modernize test tooling
- Target net10.0 in the .NET Core console demo and the test project (the test project moves off net48). - Point the test project at the .NET Core demo project and register the EF6 SQLite provider through a code-based DbConfiguration, since modern .NET has no app.config provider discovery. Sign the demo so the signed test assembly can reference it. - Update dependencies: EntityFramework 6.5.2, System.Data.SQLite(.EF6) 1.0.119, Moq 4.20.72, MSTest 4.2.3. - Convert the solution from .sln to .slnx. - Run the unit tests on Microsoft.Testing.Platform (MSTest runner), opted in via global.json. - Adapt the tests to MSTest 4: replace [ExpectedException] with Assert.ThrowsExactly and fix Assert.AreEqual argument order. - Replace the package's deprecated licenseUrl with the SPDX expression Apache-2.0.
1 parent 78c556b commit cf9fde2

29 files changed

Lines changed: 111 additions & 161 deletions

SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<AssemblyOriginatorKeyFile>..\Shared\SQLite.CodeFirst.StrongNameKey.snk</AssemblyOriginatorKeyFile>
1111
</PropertyGroup>
1212
<ItemGroup>
13-
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
13+
<PackageReference Include="System.Data.SQLite" Version="1.0.119" />
1414
</ItemGroup>
1515
<ItemGroup>
1616
<Reference Include="System.ComponentModel.DataAnnotations" />

SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<SignAssembly>true</SignAssembly>
7+
<AssemblyOriginatorKeyFile>..\Shared\SQLite.CodeFirst.StrongNameKey.snk</AssemblyOriginatorKeyFile>
68
</PropertyGroup>
79

810
<ItemGroup>
9-
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
10-
<PackageReference Include="System.Data.SQLite.EF6" Version="1.0.118" />
11+
<PackageReference Include="System.Data.SQLite" Version="1.0.119" />
12+
<PackageReference Include="System.Data.SQLite.EF6" Version="1.0.119" />
1113
</ItemGroup>
1214

1315
<ItemGroup>

SQLite.CodeFirst.Test/IntegrationTests/InMemoryDbCreationTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using Microsoft.VisualStudio.TestTools.UnitTesting;
4-
using SQLite.CodeFirst.Console;
5-
using SQLite.CodeFirst.Console.Entity;
4+
using SQLite.CodeFirst.NetCore.Console;
5+
using SQLite.CodeFirst.NetCore.Console.Entity;
66

77
namespace SQLite.CodeFirst.Test.IntegrationTests
88
{

SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationDefaultCollationTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using System.Data.SQLite;
55
using System.Linq;
66
using Microsoft.VisualStudio.TestTools.UnitTesting;
7-
using SQLite.CodeFirst.Console;
8-
using SQLite.CodeFirst.Console.Entity;
7+
using SQLite.CodeFirst.NetCore.Console;
8+
using SQLite.CodeFirst.NetCore.Console.Entity;
99

1010
namespace SQLite.CodeFirst.Test.IntegrationTests
1111
{

SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using System.Data.SQLite;
55
using System.Linq;
66
using Microsoft.VisualStudio.TestTools.UnitTesting;
7-
using SQLite.CodeFirst.Console;
8-
using SQLite.CodeFirst.Console.Entity;
7+
using SQLite.CodeFirst.NetCore.Console;
8+
using SQLite.CodeFirst.NetCore.Console.Entity;
99

1010
namespace SQLite.CodeFirst.Test.IntegrationTests
1111
{
Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net48</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<AssemblyTitle>SQLite.CodeFirst.Test</AssemblyTitle>
55
<Description>Contains the Unit Tests for the SQLite.CodeFirst Library.</Description>
66
<Version>1.0.0.0</Version>
77
<SignAssembly>true</SignAssembly>
88
<AssemblyOriginatorKeyFile>..\Shared\SQLite.CodeFirst.StrongNameKey.snk</AssemblyOriginatorKeyFile>
9+
<!-- Run the tests on Microsoft.Testing.Platform via the MSTest runner instead of VSTest. -->
10+
<OutputType>Exe</OutputType>
11+
<EnableMSTestRunner>true</EnableMSTestRunner>
912
</PropertyGroup>
10-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
11-
<DebugType>full</DebugType>
12-
</PropertyGroup>
13-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
14-
<DebugType>pdbonly</DebugType>
15-
</PropertyGroup>
16-
<ItemGroup>
17-
<PackageReference Include="Moq" Version="4.20.70" />
18-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
19-
<PackageReference Include="MSTest.TestAdapter" Version="3.2.2" />
20-
<PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
21-
</ItemGroup>
2213
<ItemGroup>
23-
<Reference Include="System.ComponentModel.DataAnnotations" />
14+
<PackageReference Include="Moq" Version="4.20.72" />
15+
<PackageReference Include="MSTest.TestAdapter" Version="4.2.3" />
16+
<PackageReference Include="MSTest.TestFramework" Version="4.2.3" />
2417
</ItemGroup>
2518
<ItemGroup>
26-
<ProjectReference Include="..\SQLite.CodeFirst.Console\SQLite.CodeFirst.Console.csproj" />
19+
<ProjectReference Include="..\SQLite.CodeFirst.NetCore.Console\SQLite.CodeFirst.NetCore.Console.csproj" />
2720
<ProjectReference Include="..\SQLite.CodeFirst\SQLite.CodeFirst.csproj" />
2821
</ItemGroup>
29-
</Project>
22+
</Project>

SQLite.CodeFirst.Test/TestSetup.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Data.Entity;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using SQLite.CodeFirst.NetCore.Console;
4+
5+
namespace SQLite.CodeFirst.Test
6+
{
7+
/// <summary>
8+
/// Registers the SQLite Entity Framework 6 provider once for the whole test assembly.
9+
/// On .NET (Core) there is no app.config based provider discovery, so the code based
10+
/// <see cref="Configuration"/> from the demo project is applied before any test runs.
11+
/// Setting it explicitly (instead of relying on assembly scanning) makes the registration
12+
/// independent of which DbContext the test runner happens to touch first.
13+
/// </summary>
14+
[TestClass]
15+
public static class TestSetup
16+
{
17+
[AssemblyInitialize]
18+
public static void Initialize(TestContext context)
19+
{
20+
DbConfiguration.SetConfiguration(new Configuration());
21+
}
22+
}
23+
}

SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/CollateConstraintTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public void CreateStatement_StatementIsCorrect_NoConstraint()
1212
var collationConstraint = new CollateConstraint();
1313
collationConstraint.CollationFunction = CollationFunction.None;
1414
string output = collationConstraint.CreateStatement();
15-
Assert.AreEqual(output, "");
15+
Assert.AreEqual("", output);
1616
}
1717

1818
[TestMethod]
@@ -21,7 +21,7 @@ public void CreateStatement_StatementIsCorrect_NoCase()
2121
var collationConstraint = new CollateConstraint();
2222
collationConstraint.CollationFunction = CollationFunction.NoCase;
2323
string output = collationConstraint.CreateStatement();
24-
Assert.AreEqual(output, "COLLATE NOCASE");
24+
Assert.AreEqual("COLLATE NOCASE", output);
2525
}
2626
}
2727
}

SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/ColumnConstraintCollectionTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void CreateStatementOneColumnConstraintTest()
1818
columnConstraintMock.Object
1919
});
2020
string output = columnConstraintCollection.CreateStatement();
21-
Assert.AreEqual(output, "dummy1");
21+
Assert.AreEqual("dummy1", output);
2222
}
2323

2424
[TestMethod]
@@ -36,7 +36,7 @@ public void CreateStatementTwoColumnConstraintsTest()
3636
columnConstraintMock2.Object
3737
});
3838
string output = columnConstraintCollection.CreateStatement();
39-
Assert.AreEqual(output, "dummy1 dummy2");
39+
Assert.AreEqual("dummy1 dummy2", output);
4040
}
4141
}
4242
}

SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/DefaultValueConstraintTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public void CreateStatement_StatementIsCorrect_IntDefault()
1212
var defaultValueConstraint = new DefaultValueConstraint();
1313
defaultValueConstraint.DefaultValue = "0";
1414
string output = defaultValueConstraint.CreateStatement();
15-
Assert.AreEqual(output, "DEFAULT (0)");
15+
Assert.AreEqual("DEFAULT (0)", output);
1616
}
1717

1818
[TestMethod]
@@ -21,7 +21,7 @@ public void CreateStatement_StatementIsCorrect_StringDefault()
2121
var defaultValueConstraint = new DefaultValueConstraint();
2222
defaultValueConstraint.DefaultValue = @"'Something'";
2323
string output = defaultValueConstraint.CreateStatement();
24-
Assert.AreEqual(output, "DEFAULT ('Something')");
24+
Assert.AreEqual("DEFAULT ('Something')", output);
2525
}
2626

2727
[TestMethod]
@@ -30,7 +30,7 @@ public void CreateStatement_StatementIsCorrect_ExpressionDefault()
3030
var defaultValueConstraint = new DefaultValueConstraint();
3131
defaultValueConstraint.DefaultValue = @"datetime('now')";
3232
string output = defaultValueConstraint.CreateStatement();
33-
Assert.AreEqual(output, "DEFAULT (datetime('now'))");
33+
Assert.AreEqual("DEFAULT (datetime('now'))", output);
3434
}
3535
}
3636
}

0 commit comments

Comments
 (0)