Skip to content

Commit fbae0a6

Browse files
committed
test: fixing path for ways to run tests
1 parent 5fb93f7 commit fbae0a6

13 files changed

Lines changed: 27 additions & 81 deletions

SharpRepository.Tests.Integration/CompoundKeyRepositoryJoinTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using SharpRepository.InMemoryRepository;
88
using SharpRepository.EfCoreRepository;
99
using Microsoft.EntityFrameworkCore;
10-
using Microsoft.Data.Sqlite;
1110
using SharpRepository.Tests.Integration.Data;
1211
using SharpRepository.MongoDbRepository;
1312
using System;
@@ -28,11 +27,8 @@ public void Join_GetAll_Should_Return_All_Items_InMemory()
2827
[Test]
2928
public void Join_GetAll_Should_Return_All_Items_EfCore()
3029
{
31-
var connection = new SqliteConnection("DataSource=:memory:");
32-
connection.Open();
33-
3430
var options = new DbContextOptionsBuilder<TestObjectContextCore>()
35-
.UseSqlite(connection)
31+
.UseInMemoryDatabase("integration test")
3632
.Options;
3733

3834
// Create the schema in the database

SharpRepository.Tests.Integration/Data/CompoundKeyRepositoryTestCaseDataFactory.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Microsoft.Data.Sqlite;
21
using Microsoft.EntityFrameworkCore;
32
using Microsoft.Extensions.Caching.Memory;
43
using NUnit.Framework;
@@ -30,11 +29,8 @@ public static IEnumerable<TestCaseData> Build(RepositoryType[] includeType)
3029

3130
if (includeType.Contains(RepositoryType.EfCore))
3231
{
33-
var connection = new SqliteConnection("DataSource=:memory:");
34-
connection.Open();
35-
3632
var options = new DbContextOptionsBuilder<TestObjectContextCore>()
37-
.UseSqlite(connection)
33+
.UseInMemoryDatabase("integration test")
3834
.Options;
3935

4036
// Create the schema in the database

SharpRepository.Tests.Integration/Data/RepositoryTestCaseDataFactory.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using SharpRepository.MongoDbRepository;
88
using SharpRepository.InMemoryRepository;
99
using System;
10-
using Microsoft.Data.Sqlite;
1110
using Microsoft.EntityFrameworkCore;
1211

1312
namespace SharpRepository.Tests.Integration.Data
@@ -30,11 +29,8 @@ public static IEnumerable<TestCaseData> Build(RepositoryType[] includeType, stri
3029

3130
if (includeType.Contains(RepositoryType.EfCore))
3231
{
33-
var connection = new SqliteConnection("DataSource=:memory:");
34-
connection.Open();
35-
3632
var options = new DbContextOptionsBuilder<TestObjectContextCore>()
37-
.UseSqlite(connection)
33+
.UseInMemoryDatabase("integration test")
3834
.Options;
3935

4036
// Create the schema in the database

SharpRepository.Tests.Integration/SharpRepository.Tests.Integration.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.6" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.6" />
1212
<PackageReference Include="EntityFramework.SqlServerCompact" Version="6.4.4" />
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
1414
<PackageReference Include="Moq" Version="4.18.1" />

SharpRepository.Tests.Integration/Spikes/EfCoreAsNoTracking.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Collections.Generic;
77
using Shouldly;
88
using SharpRepository.Repository.FetchStrategies;
9-
using Microsoft.Data.Sqlite;
109
using Microsoft.EntityFrameworkCore;
1110

1211
namespace SharpRepository.Tests.Integration.Spikes
@@ -21,11 +20,8 @@ public void SetupRepository()
2120
{
2221
var dbPath = EfDataDirectoryFactory.Build();
2322

24-
var connection = new SqliteConnection("DataSource=:memory:");
25-
connection.Open();
26-
2723
var options = new DbContextOptionsBuilder<TestObjectContextCore>()
28-
.UseSqlite(connection)
24+
.UseInMemoryDatabase("integration test")
2925
.Options;
3026

3127
using (dbContext = new TestObjectContextCore(options))

SharpRepository.Tests.Integration/Spikes/EfCoreCompoundKeySpikes.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using SharpRepository.Tests.Integration.TestObjects;
88
using Shouldly;
99
using Microsoft.EntityFrameworkCore;
10-
using Microsoft.Data.Sqlite;
1110

1211
namespace SharpRepository.Tests.Integration.Spikes
1312
{
@@ -19,11 +18,8 @@ public class EfCoreCompoundKeySpikes
1918
[SetUp]
2019
public void Setup()
2120
{
22-
var connection = new SqliteConnection("DataSource=:memory:");
23-
connection.Open();
24-
2521
var options = new DbContextOptionsBuilder<TestObjectContextCore>()
26-
.UseSqlite(connection)
22+
.UseInMemoryDatabase("integration test")
2723
.Options;
2824

2925
// Run the test against one instance of the context

SharpRepository.Tests.Integration/Spikes/EfCoreLazyLoadSpike.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
using SharpRepository.Repository.Queries;
1414
using SharpRepository.Repository.Specifications;
1515
using Microsoft.EntityFrameworkCore;
16-
using Microsoft.Data.Sqlite;
1716
using Microsoft.Extensions.Logging;
1817
using System;
1918

@@ -29,13 +28,8 @@ public class EfCoreLazyLoadSpike
2928
[SetUp]
3029
public void SetupRepository()
3130
{
32-
var dbPath = EfDataDirectoryFactory.Build();
33-
34-
var connection = new SqliteConnection("DataSource=:memory:");
35-
connection.Open();
36-
3731
var options = new DbContextOptionsBuilder<TestObjectContextCore>()
38-
.UseSqlite(connection)
32+
.UseInMemoryDatabase("integration test")
3933
.Options;
4034

4135
// Create the schema in the database

SharpRepository.Tests.Integration/Spikes/EfCoreSelectorSpike.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-

2-
using Microsoft.Data.Sqlite;
3-
using Microsoft.EntityFrameworkCore;
1+
using Microsoft.EntityFrameworkCore;
42
using NUnit.Framework;
53
using SharpRepository.EfCoreRepository;
64
using SharpRepository.Tests.Integration.Data;
@@ -23,13 +21,8 @@ public class EfCoreSelectorSpike
2321
[SetUp]
2422
public void SetupRepository()
2523
{
26-
var dbPath = EfDataDirectoryFactory.Build();
27-
28-
var connection = new SqliteConnection("DataSource=:memory:");
29-
connection.Open();
30-
3124
var options = new DbContextOptionsBuilder<TestObjectContextCore>()
32-
.UseSqlite(connection)
25+
.UseInMemoryDatabase("integration test")
3326
.Options;
3427

3528
// Create the schema in the database

SharpRepository.Tests.Integration/Spikes/RepositoryDependencySpikes.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-

2-
using Microsoft.Data.Sqlite;
3-
using Microsoft.EntityFrameworkCore;
1+
using Microsoft.EntityFrameworkCore;
42
using Microsoft.Extensions.Caching.Memory;
53
using Microsoft.Extensions.Configuration;
64
using NUnit.Framework;
@@ -23,11 +21,8 @@ public class RepositoryDependencySpikes
2321
[SetUp]
2422
public void Setup()
2523
{
26-
var connection = new SqliteConnection("DataSource=:memory:");
27-
connection.Open();
28-
2924
var options = new DbContextOptionsBuilder<TestObjectContextCore>()
30-
.UseSqlite(connection)
25+
.UseInMemoryDatabase("integration test")
3126
.Options;
3227

3328
var config = new ConfigurationBuilder()

SharpRepository.Tests.Integration/Spikes/StandardCachingSpikes.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Shouldly;
88
using Microsoft.Extensions.Caching.Memory;
99
using SharpRepository.EfCoreRepository;
10-
using Microsoft.Data.Sqlite;
1110
using Microsoft.EntityFrameworkCore;
1211

1312
namespace SharpRepository.Tests.Integration.Spikes
@@ -128,11 +127,8 @@ public void Delete_With_Cache_And_Ef()
128127
{
129128
var cachingStrategy = new StandardCachingStrategy<Contact, string>(cacheProvider);
130129

131-
var connection = new SqliteConnection("DataSource=:memory:");
132-
connection.Open();
133-
134130
var options = new DbContextOptionsBuilder<TestObjectContextCore>()
135-
.UseSqlite(connection)
131+
.UseInMemoryDatabase("integration test")
136132
.Options;
137133

138134
var context = new TestObjectContextCore(options);
@@ -151,11 +147,9 @@ public void Delete_With_Cache_And_Ef()
151147
public void Delete_Loop_With_Cache_And_Ef()
152148
{
153149
var cachingStrategy = new StandardCachingStrategy<Contact, string>(cacheProvider);
154-
var connection = new SqliteConnection("DataSource=:memory:");
155-
connection.Open();
156-
150+
157151
var options = new DbContextOptionsBuilder<TestObjectContextCore>()
158-
.UseSqlite(connection)
152+
.UseInMemoryDatabase("integration test")
159153
.Options;
160154

161155
var context = new TestObjectContextCore(options);

0 commit comments

Comments
 (0)