-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactored the test infrastructure and all tests. * Remove DatabaseFixture.
- Loading branch information
Showing
198 changed files
with
4,997 additions
and
3,039 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
...lis.Specification.EntityFramework6.IntegrationTests/Fixture/Collections/ReadCollection.cs
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...is.Specification.EntityFramework6.IntegrationTests/Fixture/Collections/WriteCollection.cs
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
.../tests/Ardalis.Specification.EntityFramework6.IntegrationTests/Fixture/DatabaseFixture.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
.../tests/Ardalis.Specification.EntityFramework6.Tests/Fixture/Collections/ReadCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Tests.Fixture; | ||
|
||
[CollectionDefinition("ReadCollection")] | ||
public class ReadCollection : ICollectionFixture<TestFactory> | ||
{ | ||
public ReadCollection() | ||
{ | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...tests/Ardalis.Specification.EntityFramework6.Tests/Fixture/Collections/WriteCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Tests.Fixture; | ||
|
||
[CollectionDefinition("WriteCollection")] | ||
public class WriteCollection : ICollectionFixture<TestFactory> | ||
{ | ||
public WriteCollection() | ||
{ | ||
|
||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ion.UnitTests/Fixture/Entities/Address.cs → ...mework6.Tests/Fixture/Entities/Address.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Ardalis.Specification.UnitTests.Fixture.Entities; | ||
namespace Tests.Fixture; | ||
|
||
public class Address | ||
{ | ||
|
4 changes: 1 addition & 3 deletions
4
...ion.UnitTests/Fixture/Entities/Company.cs → ...mework6.Tests/Fixture/Entities/Company.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...ion.UnitTests/Fixture/Entities/Country.cs → ...mework6.Tests/Fixture/Entities/Country.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ion.UnitTests/Fixture/Entities/Product.cs → ...mework6.Tests/Fixture/Entities/Product.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Ardalis.Specification.UnitTests.Fixture.Entities; | ||
namespace Tests.Fixture; | ||
|
||
public class Product | ||
{ | ||
|
4 changes: 1 addition & 3 deletions
4
...sts/Fixture/Entities/Seeds/AddressSeed.cs → ...sts/Fixture/Entities/Seeds/AddressSeed.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...sts/Fixture/Entities/Seeds/CompanySeed.cs → ...sts/Fixture/Entities/Seeds/CompanySeed.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...sts/Fixture/Entities/Seeds/CountrySeed.cs → ...sts/Fixture/Entities/Seeds/CountrySeed.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...sts/Fixture/Entities/Seeds/ProductSeed.cs → ...sts/Fixture/Entities/Seeds/ProductSeed.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...Tests/Fixture/Entities/Seeds/StoreSeed.cs → ...Tests/Fixture/Entities/Seeds/StoreSeed.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...ation.UnitTests/Fixture/Entities/Store.cs → ...ramework6.Tests/Fixture/Entities/Store.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...IntegrationTests/Fixture/RepositoryOfT.cs → ...Framework6.Tests/Fixture/RepositoryOfT.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15
...IntegrationTests/Fixture/TestDbContext.cs → ...Framework6.Tests/Fixture/TestDbContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...ntityFramework6/tests/Ardalis.Specification.EntityFramework6.Tests/Fixture/TestFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using MartinCostello.SqlLocalDb; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Testcontainers.MsSql; | ||
|
||
namespace Tests.Fixture; | ||
|
||
public class TestFactory : IAsyncLifetime | ||
{ | ||
// Flag to force using Docker SQL Server. Update it manually if you want to avoid localDb locally. | ||
private const bool _forceDocker = false; | ||
private MsSqlContainer? _dbContainer = null; | ||
|
||
public string ConnectionString { get; private set; } = null!; | ||
|
||
public async Task InitializeAsync() | ||
{ | ||
using (var localDB = new SqlLocalDbApi()) | ||
{ | ||
if (_forceDocker || !localDB.IsLocalDBInstalled()) | ||
{ | ||
_dbContainer = CreateContainer(); | ||
await _dbContainer.StartAsync(); | ||
ConnectionString = _dbContainer.GetConnectionString(); | ||
} | ||
else | ||
{ | ||
var databaseName = $"SpecificationEF6TestsDB_{Guid.NewGuid().ToString().Replace('-', '_')}"; | ||
ConnectionString = $"Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog={databaseName};Integrated Security=SSPI;TrustServerCertificate=True;"; | ||
} | ||
} | ||
|
||
using var dbContext = new TestDbContext(ConnectionString); | ||
|
||
dbContext.Database.CreateIfNotExists(); | ||
|
||
dbContext.Countries.AddRange(CountrySeed.Get()); | ||
dbContext.Companies.AddRange(CompanySeed.Get()); | ||
dbContext.Stores.AddRange(StoreSeed.Get()); | ||
dbContext.Addresses.AddRange(AddressSeed.Get()); | ||
dbContext.Products.AddRange(ProductSeed.Get()); | ||
|
||
dbContext.SaveChanges(); | ||
} | ||
|
||
public async Task DisposeAsync() | ||
{ | ||
if (_dbContainer is not null) | ||
{ | ||
await _dbContainer.StopAsync(); | ||
} | ||
else | ||
{ | ||
using var dbContext = new TestDbContext(ConnectionString); | ||
dbContext.Database.Delete(); | ||
} | ||
} | ||
|
||
private static MsSqlContainer CreateContainer() => new MsSqlBuilder() | ||
.WithImage("mcr.microsoft.com/mssql/server:2022-latest") | ||
//.WithName("SpecificationEFCoreTestsDB") | ||
.WithPassword("P@ssW0rd!") | ||
.Build(); | ||
} |
7 changes: 7 additions & 0 deletions
7
...ation.EntityFramework6/tests/Ardalis.Specification.EntityFramework6.Tests/GlobalUsings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
global using Ardalis.Specification; | ||
global using Ardalis.Specification.EntityFramework6; | ||
global using FluentAssertions; | ||
global using System.Collections.Generic; | ||
global using System.Linq; | ||
global using Tests.Fixture; | ||
global using Xunit; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.