Skip to content

Commit c1c1e70

Browse files
committed
feat(litedb): Add shared tests (failing)
accomplished by copying boilerplate
1 parent 1850cf5 commit c1c1e70

13 files changed

+90
-19
lines changed

IntBasis.DocumentOriented.LiteDB.Tests/IntBasis.DocumentOriented.LiteDB.Tests.csproj

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
@@ -7,6 +7,10 @@
77
<IsPackable>false</IsPackable>
88
</PropertyGroup>
99

10+
<PropertyGroup>
11+
<DefineConstants>LITE_DB</DefineConstants>
12+
</PropertyGroup>
13+
1014
<ItemGroup>
1115
<PackageReference Include="FluentAssertions" Version="6.7.0" />
1216
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
@@ -23,6 +27,8 @@
2327

2428
<ItemGroup>
2529
<ProjectReference Include="..\IntBasis.DocumentOriented.LiteDB\IntBasis.DocumentOriented.LiteDB.csproj" />
30+
<ProjectReference Include="..\IntBasis.DocumentOriented.Testing\IntBasis.DocumentOriented.Testing.csproj" />
2631
</ItemGroup>
32+
<Import Project="..\IntBasis.DocumentOriented.SharedTests\IntBasis.DocumentOriented.SharedTests.projitems" Label="Shared" />
2733

2834
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using IntBasis.DocumentOriented.Testing;
2+
using Microsoft.Extensions.DependencyInjection;
3+
4+
namespace IntBasis.DocumentOriented.LiteDB.Tests;
5+
6+
public class IntegrationAttribute : BaseServiceProviderDataAttribute
7+
{
8+
LiteDbConfiguration TestConfig => new(fileName: ":temp:");
9+
10+
protected override void ConfigureServices(IServiceCollection services)
11+
{
12+
services.AddDocumentOrientedLiteDb(TestConfig);
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
global using Xunit;
1+
global using Xunit;
2+
global using FluentAssertions;

IntBasis.DocumentOriented.LiteDB/Class1.cs

-8
This file was deleted.

IntBasis.DocumentOriented.LiteDB/IntBasis.DocumentOriented.LiteDB.csproj

+12
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,16 @@
1212
<PackageProjectUrl>https://github.com/IntBasis/IntBasis.DocumentOriented</PackageProjectUrl>
1313
</PropertyGroup>
1414

15+
<ItemGroup>
16+
<ProjectReference Include="..\IntBasis.DocumentOriented\IntBasis.DocumentOriented.csproj" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<InternalsVisibleTo Include="$(AssemblyName).Tests" />
25+
</ItemGroup>
26+
1527
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace IntBasis.DocumentOriented.LiteDB;
2+
3+
public class LiteDbConfiguration
4+
{
5+
public string FileName { get; set; }
6+
7+
public LiteDbConfiguration(string fileName)
8+
{
9+
FileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using IntBasis.DocumentOriented;
2+
using IntBasis.DocumentOriented.LiteDB;
3+
4+
// .NET Practice is to place ServiceCollectionExtensions in the following namespace
5+
// to improve discoverability of the extension method during service configuration
6+
namespace Microsoft.Extensions.DependencyInjection;
7+
8+
public static class ServiceCollectionExtensions
9+
{
10+
/// <summary>
11+
/// Adds LiteDB implementation of Document Oriented Database services.
12+
/// <para/>
13+
/// External:
14+
/// <list type="bullet">
15+
/// <item> <see cref="IDocumentChanges"/> </item>
16+
/// <item> <see cref="IDocumentStorage"/> </item>
17+
/// <item> <see cref="IDocumentQuery"/> </item>
18+
/// </list>
19+
/// </summary>
20+
public static IServiceCollection AddDocumentOrientedLiteDb(this IServiceCollection services,
21+
LiteDbConfiguration configuration)
22+
{
23+
services.AddSingleton(configuration);
24+
//services.AddTransient<IDocumentChanges, LiteDbDocumentChanges>();
25+
//services.AddTransient<IDocumentStorage, LiteDbDocumentStorage>();
26+
//services.AddTransient<IDocumentQuery, LiteDbDocumentQuery>();
27+
return services;
28+
}
29+
}

IntBasis.DocumentOriented.MongoDB.Tests/IntBasis.DocumentOriented.MongoDB.Tests.csproj

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@
44
<TargetFramework>net6.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
87
<IsPackable>false</IsPackable>
98
</PropertyGroup>
109

11-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
12-
<DefineConstants>MONGO_DB</DefineConstants>
13-
</PropertyGroup>
14-
15-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
10+
<PropertyGroup>
1611
<DefineConstants>MONGO_DB</DefineConstants>
1712
</PropertyGroup>
1813

IntBasis.DocumentOriented.RavenDB.Tests/IntBasis.DocumentOriented.RavenDB.Tests.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
<IsPackable>false</IsPackable>
88
</PropertyGroup>
99

10+
<PropertyGroup>
11+
<DefineConstants>RAVEN_DB</DefineConstants>
12+
</PropertyGroup>
13+
1014
<ItemGroup>
1115
<PackageReference Include="FluentAssertions" Version="6.7.0" />
1216
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />

IntBasis.DocumentOriented.SharedTests/DocumentChangesTest.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#if MONGO_DB
22
namespace IntBasis.DocumentOriented.MongoDB.Tests;
3-
#else
3+
#elif RAVEN_DB
44
namespace IntBasis.DocumentOriented.RavenDB.Tests;
5+
#elif LITE_DB
6+
namespace IntBasis.DocumentOriented.LiteDB.Tests;
57
#endif
68

79
public class DocumentChangesTest

IntBasis.DocumentOriented.SharedTests/DocumentQueryTest.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#if MONGO_DB
22
namespace IntBasis.DocumentOriented.MongoDB.Tests;
3-
#else
3+
#elif RAVEN_DB
44
namespace IntBasis.DocumentOriented.RavenDB.Tests;
5+
#elif LITE_DB
6+
namespace IntBasis.DocumentOriented.LiteDB.Tests;
57
#endif
68

79
public class DocumentQueryTest

IntBasis.DocumentOriented.SharedTests/DocumentStorageTest.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
#if MONGO_DB
44
namespace IntBasis.DocumentOriented.MongoDB.Tests;
5-
#else
5+
#elif RAVEN_DB
66
namespace IntBasis.DocumentOriented.RavenDB.Tests;
7+
#elif LITE_DB
8+
namespace IntBasis.DocumentOriented.LiteDB.Tests;
79
#endif
810

911
public class Category : IDocumentEntity

IntBasis.DocumentOriented.sln

+1
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,6 @@ Global
8282
IntBasis.DocumentOriented.SharedTests\IntBasis.DocumentOriented.SharedTests.projitems*{18336c34-5471-4b45-bc54-66157365ef6c}*SharedItemsImports = 5
8383
IntBasis.DocumentOriented.SharedTests\IntBasis.DocumentOriented.SharedTests.projitems*{23468ff7-afff-495f-8f82-49101e129b48}*SharedItemsImports = 5
8484
IntBasis.DocumentOriented.SharedTests\IntBasis.DocumentOriented.SharedTests.projitems*{35d8e8ab-07e0-430d-8a7a-54c2a93c2fd7}*SharedItemsImports = 13
85+
IntBasis.DocumentOriented.SharedTests\IntBasis.DocumentOriented.SharedTests.projitems*{eb2a1c8c-4ad8-44c2-8350-ea5c2b69a9f5}*SharedItemsImports = 5
8586
EndGlobalSection
8687
EndGlobal

0 commit comments

Comments
 (0)