diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index 218a2ab..e9139eb 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -6,28 +6,168 @@ on:
pull_request:
branches: [ main ]
+env:
+ DOT_NET_VERSION: "7.0.x"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
-jobs:
- build-and-test:
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: ${{ env.DOT_NET_VERSION }}
+
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: build
+ run: dotnet build
+
+ in-memory:
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: ${{ env.DOT_NET_VERSION }}
+
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: build
+ run: dotnet build -p:DefineConstants=IN_MEMORY
+ - name: Test
+ run: dotnet test --no-build
+
+ lite-db:
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: ${{ env.DOT_NET_VERSION }}
+
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: build
+ run: dotnet build -p:DefineConstants=LITE_DB
+ - name: Test
+ run: dotnet test --no-build
+
+ sqlite:
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: ${{ env.DOT_NET_VERSION }}
+
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: build
+ run: dotnet build -p:DefineConstants=SQLITE
+ - name: Test
+ run: dotnet test --no-build
+
+ zone-tree:
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: ${{ env.DOT_NET_VERSION }}
+
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: build
+ run: dotnet build -p:DefineConstants=ZONE_TREE
+ - name: Test
+ run: dotnet test --no-build
+
+
+ cosmos-db:
+ needs: build
+ runs-on: windows-latest
+ steps:
+ - uses: janpio/cosmos-emulator-github-action@main
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: ${{ env.DOT_NET_VERSION }}
+
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: build
+ run: dotnet build -p:DefineConstants=COSMOS_DB
+ - name: Test
+ run: dotnet test --no-build
+
+ azure-tables:
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: ${{ env.DOT_NET_VERSION }}
+
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: build
+ run: dotnet build -p:DefineConstants=AZURE_TABLES
+ - name: Test
+ run: dotnet test --no-build
+
+ mongo-db:
+ needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
- dotnet-version: 7.0.x
+ dotnet-version: ${{ env.DOT_NET_VERSION }}
+
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: build
+ run: dotnet build -p:DefineConstants=MONGO_DB
+ - name: Test
+ run: dotnet test --no-build
- # run build and test
+ dynamo-db:
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: ${{ env.DOT_NET_VERSION }}
+
- name: Restore dependencies
run: dotnet restore
- - name: Build
- run: dotnet build --no-restore
+ - name: build
+ run: dotnet build -p:DefineConstants=DYNAMO_DB
- name: Test
- run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=ManagedCode.Repository.Tests/lcov.info
+ run: dotnet test --no-build
+
+
+
#- name: coverlet
# uses: b3b00/coverlet-action@1.1.9
diff --git a/ManagedCode.Database.AzureTables/ManagedCode.Database.AzureTables.csproj b/ManagedCode.Database.AzureTables/ManagedCode.Database.AzureTables.csproj
index 838a60f..b7a4749 100644
--- a/ManagedCode.Database.AzureTables/ManagedCode.Database.AzureTables.csproj
+++ b/ManagedCode.Database.AzureTables/ManagedCode.Database.AzureTables.csproj
@@ -25,7 +25,7 @@
-
+
diff --git a/ManagedCode.Database.Cosmos/ManagedCode.Database.Cosmos.csproj b/ManagedCode.Database.Cosmos/ManagedCode.Database.Cosmos.csproj
index 51541f0..3647c1c 100644
--- a/ManagedCode.Database.Cosmos/ManagedCode.Database.Cosmos.csproj
+++ b/ManagedCode.Database.Cosmos/ManagedCode.Database.Cosmos.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/ManagedCode.Database.DynamoDB/ManagedCode.Database.DynamoDB.csproj b/ManagedCode.Database.DynamoDB/ManagedCode.Database.DynamoDB.csproj
index 0966c21..2d9b87f 100644
--- a/ManagedCode.Database.DynamoDB/ManagedCode.Database.DynamoDB.csproj
+++ b/ManagedCode.Database.DynamoDB/ManagedCode.Database.DynamoDB.csproj
@@ -23,9 +23,9 @@
-
+
-
+
diff --git a/ManagedCode.Database.LiteDB/ManagedCode.Database.LiteDB.csproj b/ManagedCode.Database.LiteDB/ManagedCode.Database.LiteDB.csproj
index ee854c7..a65dfff 100644
--- a/ManagedCode.Database.LiteDB/ManagedCode.Database.LiteDB.csproj
+++ b/ManagedCode.Database.LiteDB/ManagedCode.Database.LiteDB.csproj
@@ -23,8 +23,8 @@
-
-
+
+
diff --git a/ManagedCode.Database.MongoDB/ManagedCode.Database.MongoDB.csproj b/ManagedCode.Database.MongoDB/ManagedCode.Database.MongoDB.csproj
index a04ae76..3defa95 100644
--- a/ManagedCode.Database.MongoDB/ManagedCode.Database.MongoDB.csproj
+++ b/ManagedCode.Database.MongoDB/ManagedCode.Database.MongoDB.csproj
@@ -25,8 +25,8 @@
-
-
+
+
diff --git a/ManagedCode.Database.SQLite/ManagedCode.Database.SQLite.csproj b/ManagedCode.Database.SQLite/ManagedCode.Database.SQLite.csproj
index 9e5dd2e..0f230de 100644
--- a/ManagedCode.Database.SQLite/ManagedCode.Database.SQLite.csproj
+++ b/ManagedCode.Database.SQLite/ManagedCode.Database.SQLite.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/ManagedCode.Database.Tests.Benchmark/ManagedCode.Database.Tests.Benchmark.csproj b/ManagedCode.Database.Tests.Benchmark/ManagedCode.Database.Tests.Benchmark.csproj
index 58ee124..d1833fa 100644
--- a/ManagedCode.Database.Tests.Benchmark/ManagedCode.Database.Tests.Benchmark.csproj
+++ b/ManagedCode.Database.Tests.Benchmark/ManagedCode.Database.Tests.Benchmark.csproj
@@ -11,11 +11,11 @@
-
-
-
+
+
+
-
+
diff --git a/ManagedCode.Database.Tests/AzureTablesTests/AzureTablesCollectionTests.cs b/ManagedCode.Database.Tests/AzureTablesTests/AzureTablesCollectionTests.cs
index e18e3c5..a215349 100644
--- a/ManagedCode.Database.Tests/AzureTablesTests/AzureTablesCollectionTests.cs
+++ b/ManagedCode.Database.Tests/AzureTablesTests/AzureTablesCollectionTests.cs
@@ -13,6 +13,7 @@
namespace ManagedCode.Database.Tests.AzureTablesTests;
+#if AZURE_TABLES || DEBUG
[Collection(nameof(AzureTablesTestContainer))]
public class AzureTablesCollectionTests : BaseCollectionTests
{
@@ -86,4 +87,5 @@ public override async Task DeleteAll()
deletedItems.Should().BeTrue();
await countAction.Should().ThrowExactlyAsync();
}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/AzureTablesTests/AzureTablesQueryableTests.cs b/ManagedCode.Database.Tests/AzureTablesTests/AzureTablesQueryableTests.cs
index fcd15d3..3fcdb42 100644
--- a/ManagedCode.Database.Tests/AzureTablesTests/AzureTablesQueryableTests.cs
+++ b/ManagedCode.Database.Tests/AzureTablesTests/AzureTablesQueryableTests.cs
@@ -10,6 +10,7 @@
namespace ManagedCode.Database.Tests.AzureTablesTests;
+#if AZURE_TABLES || DEBUG
[Collection(nameof(AzureTablesTestContainer))]
public class AzureTablesQueryableTests : BaseQueryableTests
{
@@ -37,3 +38,4 @@ await itemsResult
.ThrowAsync();
}
}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/BaseTests/BaseCollectionTests.cs b/ManagedCode.Database.Tests/BaseTests/BaseCollectionTests.cs
index ea0afe5..4ed99c6 100644
--- a/ManagedCode.Database.Tests/BaseTests/BaseCollectionTests.cs
+++ b/ManagedCode.Database.Tests/BaseTests/BaseCollectionTests.cs
@@ -7,11 +7,13 @@
using System.Threading.Tasks;
using ManagedCode.Database.Tests.TestContainers;
using Xunit;
+using Xunit.Abstractions;
namespace ManagedCode.Database.Tests.BaseTests;
public abstract class BaseCollectionTests : BaseTests where TItem : IBaseItem, new()
{
+
protected BaseCollectionTests(ITestContainer testContainer) : base(testContainer)
{
}
diff --git a/ManagedCode.Database.Tests/CosmosTests/CosmosCollectionTests.cs b/ManagedCode.Database.Tests/CosmosTests/CosmosCollectionTests.cs
index fc9a564..b6210c9 100644
--- a/ManagedCode.Database.Tests/CosmosTests/CosmosCollectionTests.cs
+++ b/ManagedCode.Database.Tests/CosmosTests/CosmosCollectionTests.cs
@@ -10,51 +10,53 @@
namespace ManagedCode.Database.Tests.CosmosTests;
+#if COSMOS_DB || DEBUG
[Collection(nameof(CosmosTestContainer))]
public class CosmosCollectionTests : BaseCollectionTests
{
- public CosmosCollectionTests(CosmosTestContainer container) : base(container)
+ public CosmosCollectionTests(ITestOutputHelper testOutputHelper, CosmosTestContainer container) : base(container)
{
}
- public override async Task DeleteItemById_WhenItemDoesntExists()
- {
- var baseMethod = () => base.DeleteItemById_WhenItemDoesntExists();
-
- await baseMethod.Should().ThrowExactlyAsync();
- }
+ public override async Task DeleteItemById_WhenItemDoesntExists()
+ {
+ var baseMethod = () => base.DeleteItemById_WhenItemDoesntExists();
- public override async Task DeleteListOfItemsById_WhenItemsDontExist()
- {
- var baseMethod = () => base.DeleteListOfItemsById_WhenItemsDontExist();
+ await baseMethod.Should().ThrowExactlyAsync();
+ }
- await baseMethod.Should().ThrowExactlyAsync();
- }
+ public override async Task DeleteListOfItemsById_WhenItemsDontExist()
+ {
+ var baseMethod = () => base.DeleteListOfItemsById_WhenItemsDontExist();
- public override async Task DeleteListOfItems_WhenItemsDontExist()
- {
- var baseMethod = () => base.DeleteListOfItems_WhenItemsDontExist();
+ await baseMethod.Should().ThrowExactlyAsync();
+ }
- await baseMethod.Should().ThrowExactlyAsync();
- }
+ public override async Task DeleteListOfItems_WhenItemsDontExist()
+ {
+ var baseMethod = () => base.DeleteListOfItems_WhenItemsDontExist();
- [Fact]
- public override async Task DeleteCollectionAsync()
- {
- // Arrange
- int itemsCount = 5;
- List list = new();
+ await baseMethod.Should().ThrowExactlyAsync();
+ }
- for (var i = 0; i < itemsCount; i++)
+ [Fact]
+ public override async Task DeleteCollectionAsync()
{
- list.Add(CreateNewItem());
- }
+ // Arrange
+ int itemsCount = 5;
+ List list = new();
- await Collection.InsertAsync(list);
- // Act
- var isDeleted = await Collection.DeleteCollectionAsync();
+ for (var i = 0; i < itemsCount; i++)
+ {
+ list.Add(CreateNewItem());
+ }
- // Assert
- isDeleted.Should().BeTrue();
- }
-}
\ No newline at end of file
+ await Collection.InsertAsync(list);
+ // Act
+ var isDeleted = await Collection.DeleteCollectionAsync();
+
+ // Assert
+ isDeleted.Should().BeTrue();
+ }
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/CosmosTests/CosmosQueryableTests.cs b/ManagedCode.Database.Tests/CosmosTests/CosmosQueryableTests.cs
index bfb009c..9a18a48 100644
--- a/ManagedCode.Database.Tests/CosmosTests/CosmosQueryableTests.cs
+++ b/ManagedCode.Database.Tests/CosmosTests/CosmosQueryableTests.cs
@@ -9,6 +9,7 @@
namespace ManagedCode.Database.Tests.CosmosTests;
+#if COSMOS_DB || DEBUG
[Collection(nameof(CosmosTestContainer))]
public class CosmosQueryableTests : BaseQueryableTests
{
@@ -108,4 +109,5 @@ public override async Task Take_NegativeNumber_ReturnZero()
await baseMethod.Should().ThrowExactlyAsync();
}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/DynamoDbTests/DynamoDBQueryableTests.cs b/ManagedCode.Database.Tests/DynamoDbTests/DynamoDBQueryableTests.cs
index 487171a..00a3e56 100644
--- a/ManagedCode.Database.Tests/DynamoDbTests/DynamoDBQueryableTests.cs
+++ b/ManagedCode.Database.Tests/DynamoDbTests/DynamoDBQueryableTests.cs
@@ -9,6 +9,7 @@
namespace ManagedCode.Database.Tests.DynamoDbTests;
+#if DYNAMO_DB || DEBUG
[Collection(nameof(DynamoDBTestContainer))]
public class DynamoDBQueryableTests : BaseQueryableTests
{
@@ -55,4 +56,5 @@ await itemsResult
.Should()
.ThrowAsync();
}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/DynamoDbTests/DynamoDbCollectionTests.cs b/ManagedCode.Database.Tests/DynamoDbTests/DynamoDbCollectionTests.cs
index c2af7c3..d19b35c 100644
--- a/ManagedCode.Database.Tests/DynamoDbTests/DynamoDbCollectionTests.cs
+++ b/ManagedCode.Database.Tests/DynamoDbTests/DynamoDbCollectionTests.cs
@@ -10,6 +10,7 @@
namespace ManagedCode.Database.Tests.DynamoDbTests;
+#if DYNAMO_DB || DEBUG
[Collection(nameof(DynamoDBTestContainer))]
public class DynamoDbCollectionTests : BaseCollectionTests
{
@@ -102,4 +103,5 @@ public override async Task UpdateItem_WhenItemDoesntExists()
// Assert
updateItem.Should().BeNull();
}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/InMemoryTests/InMemoryCollectionTests.cs b/ManagedCode.Database.Tests/InMemoryTests/InMemoryCollectionTests.cs
index ed84978..36b20ea 100644
--- a/ManagedCode.Database.Tests/InMemoryTests/InMemoryCollectionTests.cs
+++ b/ManagedCode.Database.Tests/InMemoryTests/InMemoryCollectionTests.cs
@@ -4,9 +4,11 @@
namespace ManagedCode.Database.Tests.InMemoryTests;
+#if IN_MEMORY || DEBUG
public class InMemoryCollectionTests : BaseCollectionTests
{
public InMemoryCollectionTests() : base(new InMemoryTestContainer())
{
}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/InMemoryTests/InMemoryQueryableTests.cs b/ManagedCode.Database.Tests/InMemoryTests/InMemoryQueryableTests.cs
index 87ac3e7..019c925 100644
--- a/ManagedCode.Database.Tests/InMemoryTests/InMemoryQueryableTests.cs
+++ b/ManagedCode.Database.Tests/InMemoryTests/InMemoryQueryableTests.cs
@@ -4,9 +4,11 @@
namespace ManagedCode.Database.Tests.InMemoryTests;
+#if IN_MEMORY || DEBUG
public class InMemoryQueryableTests : BaseQueryableTests
{
public InMemoryQueryableTests() : base(new InMemoryTestContainer())
{
}
-}
\ No newline at end of file
+}
+#endif
diff --git a/ManagedCode.Database.Tests/LiteDBTests/LiteDBCollectionTests.cs b/ManagedCode.Database.Tests/LiteDBTests/LiteDBCollectionTests.cs
index 8bc9537..9304d39 100644
--- a/ManagedCode.Database.Tests/LiteDBTests/LiteDBCollectionTests.cs
+++ b/ManagedCode.Database.Tests/LiteDBTests/LiteDBCollectionTests.cs
@@ -1,46 +1,48 @@
-// using System;
-// using System.Collections.Generic;
-// using System.Threading.Tasks;
-// using FluentAssertions;
-// using ManagedCode.Database.Tests.BaseTests;
-// using ManagedCode.Database.Tests.Common;
-// using ManagedCode.Database.Tests.TestContainers;
-//
-// namespace ManagedCode.Database.Tests.LiteDBTests;
-//
-// public class LiteDBCollectionTests : BaseCollectionTests
-// {
-// public LiteDBCollectionTests() : base(new LiteDBTestContainer())
-// {
-//
-// }
-//
-// public override async Task InsertOrUpdateListOfItems()
-// {
-//
-// // Arrange
-// int itemsCount = 5;
-// int updatedItemsCount = 0;
-// List list = new();
-//
-// for (var i = 0; i < itemsCount; i++)
-// {
-// list.Add(CreateNewItem());
-// }
-//
-// var itemsInsert = await Collection.InsertOrUpdateAsync(list);
-//
-// foreach (var item in list)
-// {
-// item.DateTimeData = DateTime.Now.AddDays(-1);
-// }
-//
-// // Act
-// var itemsUpdate = await Collection.InsertOrUpdateAsync(list);
-//
-// // Assert
-// itemsUpdate.Should().Be(updatedItemsCount);
-// itemsInsert.Should().Be(itemsCount);
-// list.Count.Should().Be(itemsCount);
-// }
-// }
\ No newline at end of file
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using FluentAssertions;
+using ManagedCode.Database.Tests.BaseTests;
+using ManagedCode.Database.Tests.Common;
+using ManagedCode.Database.Tests.TestContainers;
+
+namespace ManagedCode.Database.Tests.LiteDBTests;
+
+#if LITE_DB || DEBUG
+public class LiteDBCollectionTests : BaseCollectionTests
+{
+ public LiteDBCollectionTests() : base(new LiteDBTestContainer())
+ {
+
+ }
+
+ public override async Task InsertOrUpdateListOfItems()
+ {
+
+ // Arrange
+ int itemsCount = 5;
+ int updatedItemsCount = 0;
+ List list = new();
+
+ for (var i = 0; i < itemsCount; i++)
+ {
+ list.Add(CreateNewItem());
+ }
+
+ var itemsInsert = await Collection.InsertOrUpdateAsync(list);
+
+ foreach (var item in list)
+ {
+ item.DateTimeData = DateTime.Now.AddDays(-1);
+ }
+
+ // Act
+ var itemsUpdate = await Collection.InsertOrUpdateAsync(list);
+
+ // Assert
+ itemsUpdate.Should().Be(updatedItemsCount);
+ itemsInsert.Should().Be(itemsCount);
+ list.Count.Should().Be(itemsCount);
+ }
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/LiteDBTests/LiteDBQueryableTests.cs b/ManagedCode.Database.Tests/LiteDBTests/LiteDBQueryableTests.cs
index e081dc0..a162540 100644
--- a/ManagedCode.Database.Tests/LiteDBTests/LiteDBQueryableTests.cs
+++ b/ManagedCode.Database.Tests/LiteDBTests/LiteDBQueryableTests.cs
@@ -1,705 +1,707 @@
-// using System;
-// using System.Linq;
-// using System.Threading.Tasks;
-// using FluentAssertions;
-// using ManagedCode.Database.Tests.BaseTests;
-// using ManagedCode.Database.Tests.Common;
-// using ManagedCode.Database.Tests.TestContainers;
-//
-// namespace ManagedCode.Database.Tests.LiteDBTests;
-//
-// public class LiteDBQueryableTests : BaseQueryableTests
-// {
-// public LiteDBQueryableTests() : base(new LiteDBTestContainer())
-// {
-// }
-//
-// public override async Task OrderByDescendingTakeSkip_ReturnOk()
-// {
-//
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .OrderByDescending(o => o.IntData)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-//
-// itemsResult.First().IntData.Should().Be(itemsCountToInsert - itemsCountToSkip - 1);
-// }
-//
-// public override async Task OrderByTakeSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .OrderBy(o => o.IntData)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderByDescendingSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderByDescending(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderByDescendingSkipWhere_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderByDescending(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .Where(w => w.StringData == guid)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderByDescendingWhereSkip_ReturnOk()
-// {
-//
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderByDescending(o => o.IntData)
-// .Where(w => w.StringData == guid)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderBySkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderBy(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderBySkipWhere_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderBy(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .Where(w => w.StringData == guid)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderByWhereSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderBy(o => o.IntData)
-// .Where(w => w.StringData == guid)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// for (var i = 0; i < itemsCountToInsert; i++)
-// {
-// await Collection.InsertAsync(CreateNewItem());
-// }
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult.Count.Should().Be(itemsCountToTake);
-// }
-//
-// public override async Task TakeSkipOrderBy_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderBy(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeSkipOrderByDescending_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderByDescending(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeSkipOrderByDescendingWhere_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderByDescending(o => o.IntData)
-// .Where(w => w.StringData == guid)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeSkipOrderByWhere_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderBy(o => o.IntData)
-// .Where(w => w.StringData == guid)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeSkipWhereOrderBy_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .Where(w => w.StringData == guid)
-// .OrderBy(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeSkipWhereOrderByDescending_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .Where(w => w.StringData == guid)
-// .OrderByDescending(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeWhereOrderByDescendingSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Where(w => w.StringData == guid)
-// .OrderByDescending(o => o.IntData)
-// .Skip(itemsCountToSkip).ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeWhereSkipOrderBy_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Where(w => w.StringData == guid)
-// .Skip(itemsCountToSkip)
-// .OrderBy(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeWhereSkipOrderByDescending_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Where(w => w.StringData == guid)
-// .Skip(itemsCountToSkip)
-// .OrderByDescending(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeWhereOrderBySkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Where(w => w.StringData == guid)
-// .OrderBy(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task ThenBy_AfterOrderBy_ReturnOk()
-// {
-// var baseMethod = () => base.ThenBy_AfterOrderBy_ReturnOk();
-//
-// await baseMethod.Should().ThrowExactlyAsync("ORDER BY already defined in this query builder");
-// }
-//
-// public override async Task ThenBy_AfterOrderByDescending_ReturnOk()
-// {
-// var baseMethod = () => base.ThenBy_AfterOrderBy_ReturnOk();
-//
-// await baseMethod.Should().ThrowExactlyAsync("ORDER BY already defined in this query builder");
-// }
-//
-// public override async Task ThenByDescending_AfterOrderBy_ReturnOk()
-// {
-// var baseMethod = () => base.ThenBy_AfterOrderBy_ReturnOk();
-//
-// await baseMethod.Should().ThrowExactlyAsync("ORDER BY already defined in this query builder");
-//
-// }
-//
-// public override async Task WhereOrderByDescendingTakeSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .OrderByDescending(o => o.IntData)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-//
-// itemsResult.First().IntData.Should().Be(itemsCountToInsert - itemsCountToSkip - 1);
-// }
-//
-// public override async Task WhereOrderByTakeSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .OrderBy(o => o.IntData)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-//
-// itemsResult.First().IntData.Should().Be(itemsCountToSkip);
-// }
-//
-// public override async Task WhereTakeOrderByDescendingSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .Take(itemsCountToTake)
-// .OrderByDescending(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task WhereTakeOrderBySkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .Take(itemsCountToTake)
-// .OrderBy(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task WhereTakeSkipOrderBy_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderBy(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task WhereTakeSkipOrderByDescendingSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderByDescending(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task ThenByDescending_AfterOrderByDescending_ReturnOk()
-// {
-// string expectedErrorMessage = "ORDER BY already defined in this query builder";
-//
-// var baseMethod = async () => await base.ThenByDescending_AfterOrderByDescending_ReturnOk();
-// await baseMethod.Should().ThrowExactlyAsync(expectedErrorMessage);
-// }
-// }
\ No newline at end of file
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using FluentAssertions;
+using ManagedCode.Database.Tests.BaseTests;
+using ManagedCode.Database.Tests.Common;
+using ManagedCode.Database.Tests.TestContainers;
+
+namespace ManagedCode.Database.Tests.LiteDBTests;
+
+#if LITE_DB || DEBUG
+public class LiteDBQueryableTests : BaseQueryableTests
+{
+ public LiteDBQueryableTests() : base(new LiteDBTestContainer())
+ {
+ }
+
+ public override async Task OrderByDescendingTakeSkip_ReturnOk()
+ {
+
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .OrderByDescending(o => o.IntData)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+
+ itemsResult.First().IntData.Should().Be(itemsCountToInsert - itemsCountToSkip - 1);
+ }
+
+ public override async Task OrderByTakeSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .OrderBy(o => o.IntData)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderByDescendingSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderByDescending(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderByDescendingSkipWhere_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderByDescending(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .Where(w => w.StringData == guid)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderByDescendingWhereSkip_ReturnOk()
+ {
+
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderByDescending(o => o.IntData)
+ .Where(w => w.StringData == guid)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderBySkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderBy(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderBySkipWhere_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderBy(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .Where(w => w.StringData == guid)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderByWhereSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderBy(o => o.IntData)
+ .Where(w => w.StringData == guid)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ for (var i = 0; i < itemsCountToInsert; i++)
+ {
+ await Collection.InsertAsync(CreateNewItem());
+ }
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult.Count.Should().Be(itemsCountToTake);
+ }
+
+ public override async Task TakeSkipOrderBy_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderBy(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeSkipOrderByDescending_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderByDescending(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeSkipOrderByDescendingWhere_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderByDescending(o => o.IntData)
+ .Where(w => w.StringData == guid)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeSkipOrderByWhere_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderBy(o => o.IntData)
+ .Where(w => w.StringData == guid)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeSkipWhereOrderBy_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .Where(w => w.StringData == guid)
+ .OrderBy(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeSkipWhereOrderByDescending_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .Where(w => w.StringData == guid)
+ .OrderByDescending(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeWhereOrderByDescendingSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Where(w => w.StringData == guid)
+ .OrderByDescending(o => o.IntData)
+ .Skip(itemsCountToSkip).ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeWhereSkipOrderBy_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Where(w => w.StringData == guid)
+ .Skip(itemsCountToSkip)
+ .OrderBy(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeWhereSkipOrderByDescending_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Where(w => w.StringData == guid)
+ .Skip(itemsCountToSkip)
+ .OrderByDescending(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeWhereOrderBySkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Where(w => w.StringData == guid)
+ .OrderBy(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task ThenBy_AfterOrderBy_ReturnOk()
+ {
+ var baseMethod = () => base.ThenBy_AfterOrderBy_ReturnOk();
+
+ await baseMethod.Should().ThrowExactlyAsync("ORDER BY already defined in this query builder");
+ }
+
+ public override async Task ThenBy_AfterOrderByDescending_ReturnOk()
+ {
+ var baseMethod = () => base.ThenBy_AfterOrderBy_ReturnOk();
+
+ await baseMethod.Should().ThrowExactlyAsync("ORDER BY already defined in this query builder");
+ }
+
+ public override async Task ThenByDescending_AfterOrderBy_ReturnOk()
+ {
+ var baseMethod = () => base.ThenBy_AfterOrderBy_ReturnOk();
+
+ await baseMethod.Should().ThrowExactlyAsync("ORDER BY already defined in this query builder");
+
+ }
+
+ public override async Task WhereOrderByDescendingTakeSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .OrderByDescending(o => o.IntData)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+
+ itemsResult.First().IntData.Should().Be(itemsCountToInsert - itemsCountToSkip - 1);
+ }
+
+ public override async Task WhereOrderByTakeSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .OrderBy(o => o.IntData)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+
+ itemsResult.First().IntData.Should().Be(itemsCountToSkip);
+ }
+
+ public override async Task WhereTakeOrderByDescendingSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .Take(itemsCountToTake)
+ .OrderByDescending(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task WhereTakeOrderBySkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .Take(itemsCountToTake)
+ .OrderBy(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task WhereTakeSkipOrderBy_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderBy(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task WhereTakeSkipOrderByDescendingSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderByDescending(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task ThenByDescending_AfterOrderByDescending_ReturnOk()
+ {
+ string expectedErrorMessage = "ORDER BY already defined in this query builder";
+
+ var baseMethod = async () => await base.ThenByDescending_AfterOrderByDescending_ReturnOk();
+ await baseMethod.Should().ThrowExactlyAsync(expectedErrorMessage);
+ }
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/ManagedCode.Database.Tests.csproj b/ManagedCode.Database.Tests/ManagedCode.Database.Tests.csproj
index 213071c..ec521de 100644
--- a/ManagedCode.Database.Tests/ManagedCode.Database.Tests.csproj
+++ b/ManagedCode.Database.Tests/ManagedCode.Database.Tests.csproj
@@ -22,13 +22,13 @@
-
-
-
-
+
+
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/ManagedCode.Database.Tests/MongoDBTests/MongoDBCollectionTests.cs b/ManagedCode.Database.Tests/MongoDBTests/MongoDBCollectionTests.cs
index 586439f..a6b1b04 100644
--- a/ManagedCode.Database.Tests/MongoDBTests/MongoDBCollectionTests.cs
+++ b/ManagedCode.Database.Tests/MongoDBTests/MongoDBCollectionTests.cs
@@ -9,10 +9,12 @@
namespace ManagedCode.Database.Tests.MongoDBTests;
+#if MONGO_DB || DEBUG
[Collection(nameof(MongoDBTestContainer))]
public class MongoDBCollectionTests : BaseCollectionTests
{
public MongoDBCollectionTests(MongoDBTestContainer container) : base(container)
{
}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/MongoDBTests/MongoDBQueryableTests.cs b/ManagedCode.Database.Tests/MongoDBTests/MongoDBQueryableTests.cs
index 1acc6f5..2d6650b 100644
--- a/ManagedCode.Database.Tests/MongoDBTests/MongoDBQueryableTests.cs
+++ b/ManagedCode.Database.Tests/MongoDBTests/MongoDBQueryableTests.cs
@@ -11,6 +11,7 @@
namespace ManagedCode.Database.Tests.MongoDBTests;
+#if MONGO_DB || DEBUG
[Collection(nameof(MongoDBTestContainer))]
public class MongoDBQueryableTests : BaseQueryableTests
{
@@ -130,4 +131,5 @@ public override async Task Take_NegativeNumber_ReturnZero()
await baseMethod.Should().ThrowExactlyAsync();
}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/SQLiteTests/SQLiteCollectionTests.cs b/ManagedCode.Database.Tests/SQLiteTests/SQLiteCollectionTests.cs
index 2d4369c..de0d59f 100644
--- a/ManagedCode.Database.Tests/SQLiteTests/SQLiteCollectionTests.cs
+++ b/ManagedCode.Database.Tests/SQLiteTests/SQLiteCollectionTests.cs
@@ -1,12 +1,14 @@
-// using ManagedCode.Database.Tests.BaseTests;
-// using ManagedCode.Database.Tests.Common;
-// using ManagedCode.Database.Tests.TestContainers;
-//
-// namespace ManagedCode.Database.Tests.SQLiteTests;
-//
-// public class SQLiteCollectionTests : BaseCollectionTests
-// {
-// public SQLiteCollectionTests() : base(new SQLiteTestContainer())
-// {
-// }
-// }
\ No newline at end of file
+using ManagedCode.Database.Tests.BaseTests;
+using ManagedCode.Database.Tests.Common;
+using ManagedCode.Database.Tests.TestContainers;
+
+namespace ManagedCode.Database.Tests.SQLiteTests;
+
+#if SQLITE || DEBUG
+public class SQLiteCollectionTests : BaseCollectionTests
+{
+ public SQLiteCollectionTests() : base(new SQLiteTestContainer())
+ {
+ }
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/SQLiteTests/SQLiteQueryableTests.cs b/ManagedCode.Database.Tests/SQLiteTests/SQLiteQueryableTests.cs
index f048240..5676a64 100644
--- a/ManagedCode.Database.Tests/SQLiteTests/SQLiteQueryableTests.cs
+++ b/ManagedCode.Database.Tests/SQLiteTests/SQLiteQueryableTests.cs
@@ -1,694 +1,696 @@
-// using FluentAssertions;
-// using ManagedCode.Database.Tests.BaseTests;
-// using ManagedCode.Database.Tests.Common;
-// using ManagedCode.Database.Tests.TestContainers;
-// using System.Threading.Tasks;
-// using System;
-// using System.Linq;
-//
-// namespace ManagedCode.Database.Tests.SQLiteTests;
-//
-// public class SQLiteRepositoryTests : BaseQueryableTests
-// {
-// public SQLiteRepositoryTests() : base(new SQLiteTestContainer())
-// {
-// }
-//
-// public override async Task OrderByDescendingTakeSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .OrderByDescending(o => o.IntData)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-//
-// itemsResult.First().IntData.Should().Be(itemsCountToInsert - itemsCountToSkip - 1);
-// }
-//
-// public override async Task OrderByTakeSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .OrderBy(o => o.IntData)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task Take_NegativeNumber_ReturnZero()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = -3;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToInsert);
-// }
-//
-// public override async Task TakeOrderByDescendingSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderByDescending(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderByDescendingSkipWhere_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderByDescending(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .Where(w => w.StringData == guid)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderByDescendingWhereSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderByDescending(o => o.IntData)
-// .Where(w => w.StringData == guid)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderBySkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderBy(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderBySkipWhere_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderBy(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .Where(w => w.StringData == guid)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeOrderByWhereSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .OrderBy(o => o.IntData)
-// .Where(w => w.StringData == guid)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// for (var i = 0; i < itemsCountToInsert; i++)
-// {
-// await Collection.InsertAsync(CreateNewItem());
-// }
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult.Count.Should().Be(itemsCountToTake);
-// }
-//
-// public override async Task TakeSkipOrderBy_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderBy(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeSkipOrderByDescending_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderByDescending(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeSkipOrderByDescendingWhere_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderByDescending(o => o.IntData)
-// .Where(w => w.StringData == guid)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-//
-// public override async Task TakeSkipWhereOrderBy_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .Where(w => w.StringData == guid)
-// .OrderBy(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-//
-// public override async Task TakeSkipWhereOrderByDescending_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .Where(w => w.StringData == guid)
-// .OrderByDescending(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeSkipOrderByWhere_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderBy(o => o.IntData)
-// .Where(w => w.StringData == guid)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeWhereOrderByDescendingSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Where(w => w.StringData == guid)
-// .OrderByDescending(o => o.IntData)
-// .Skip(itemsCountToSkip).ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeWhereSkipOrderBy_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Where(w => w.StringData == guid)
-// .Skip(itemsCountToSkip)
-// .OrderBy(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeWhereSkipOrderByDescending_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Where(w => w.StringData == guid)
-// .Skip(itemsCountToSkip)
-// .OrderByDescending(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task TakeWhereOrderBySkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Take(itemsCountToTake)
-// .Where(w => w.StringData == guid)
-// .OrderBy(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task WhereOrderByDescendingTakeSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .OrderByDescending(o => o.IntData)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-//
-// itemsResult.First().IntData.Should().Be(itemsCountToInsert - itemsCountToSkip - 1);
-// }
-//
-// public override async Task WhereOrderByTakeSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .OrderBy(o => o.IntData)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-//
-// itemsResult.First().IntData.Should().Be(itemsCountToSkip);
-// }
-//
-// public override async Task WhereTakeOrderByDescendingSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .Take(itemsCountToTake)
-// .OrderByDescending(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task WhereTakeSkipOrderBy_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderBy(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-//
-// public override async Task WhereTakeSkipOrderByDescendingSkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .Take(itemsCountToTake)
-// .Skip(itemsCountToSkip)
-// .OrderByDescending(o => o.IntData)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInDescendingOrder(o => o.IntData);
-// }
-//
-// public override async Task WhereTakeOrderBySkip_ReturnOk()
-// {
-// // Arrange
-// int itemsCountToInsert = 5;
-// int itemsCountToTake = 3;
-// int itemsCountToSkip = 2;
-//
-// var guid = Guid.NewGuid().ToString();
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
-//
-// // Act
-// var itemsResult = await Collection.Query
-// .Where(w => w.StringData == guid)
-// .Take(itemsCountToTake)
-// .OrderBy(o => o.IntData)
-// .Skip(itemsCountToSkip)
-// .ToListAsync();
-//
-// // Assert
-// itemsResult
-// .Should()
-// .HaveCount(itemsCountToTake)
-// .And
-// .BeInAscendingOrder(o => o.IntData);
-// }
-// }
\ No newline at end of file
+using FluentAssertions;
+using ManagedCode.Database.Tests.BaseTests;
+using ManagedCode.Database.Tests.Common;
+using ManagedCode.Database.Tests.TestContainers;
+using System.Threading.Tasks;
+using System;
+using System.Linq;
+
+namespace ManagedCode.Database.Tests.SQLiteTests;
+
+#if SQLITE || DEBUG
+public class SQLiteRepositoryTests : BaseQueryableTests
+{
+ public SQLiteRepositoryTests() : base(new SQLiteTestContainer())
+ {
+ }
+
+ public override async Task OrderByDescendingTakeSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .OrderByDescending(o => o.IntData)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+
+ itemsResult.First().IntData.Should().Be(itemsCountToInsert - itemsCountToSkip - 1);
+ }
+
+ public override async Task OrderByTakeSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .OrderBy(o => o.IntData)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task Take_NegativeNumber_ReturnZero()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = -3;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToInsert);
+ }
+
+ public override async Task TakeOrderByDescendingSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderByDescending(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderByDescendingSkipWhere_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderByDescending(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .Where(w => w.StringData == guid)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderByDescendingWhereSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderByDescending(o => o.IntData)
+ .Where(w => w.StringData == guid)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderBySkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderBy(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderBySkipWhere_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderBy(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .Where(w => w.StringData == guid)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeOrderByWhereSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .OrderBy(o => o.IntData)
+ .Where(w => w.StringData == guid)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ for (var i = 0; i < itemsCountToInsert; i++)
+ {
+ await Collection.InsertAsync(CreateNewItem());
+ }
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult.Count.Should().Be(itemsCountToTake);
+ }
+
+ public override async Task TakeSkipOrderBy_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderBy(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeSkipOrderByDescending_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderByDescending(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeSkipOrderByDescendingWhere_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderByDescending(o => o.IntData)
+ .Where(w => w.StringData == guid)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+
+ public override async Task TakeSkipWhereOrderBy_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .Where(w => w.StringData == guid)
+ .OrderBy(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+
+ public override async Task TakeSkipWhereOrderByDescending_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .Where(w => w.StringData == guid)
+ .OrderByDescending(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeSkipOrderByWhere_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderBy(o => o.IntData)
+ .Where(w => w.StringData == guid)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeWhereOrderByDescendingSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Where(w => w.StringData == guid)
+ .OrderByDescending(o => o.IntData)
+ .Skip(itemsCountToSkip).ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeWhereSkipOrderBy_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Where(w => w.StringData == guid)
+ .Skip(itemsCountToSkip)
+ .OrderBy(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeWhereSkipOrderByDescending_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Where(w => w.StringData == guid)
+ .Skip(itemsCountToSkip)
+ .OrderByDescending(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task TakeWhereOrderBySkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Take(itemsCountToTake)
+ .Where(w => w.StringData == guid)
+ .OrderBy(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task WhereOrderByDescendingTakeSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .OrderByDescending(o => o.IntData)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+
+ itemsResult.First().IntData.Should().Be(itemsCountToInsert - itemsCountToSkip - 1);
+ }
+
+ public override async Task WhereOrderByTakeSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .OrderBy(o => o.IntData)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+
+ itemsResult.First().IntData.Should().Be(itemsCountToSkip);
+ }
+
+ public override async Task WhereTakeOrderByDescendingSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .Take(itemsCountToTake)
+ .OrderByDescending(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task WhereTakeSkipOrderBy_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderBy(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+
+ public override async Task WhereTakeSkipOrderByDescendingSkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .Take(itemsCountToTake)
+ .Skip(itemsCountToSkip)
+ .OrderByDescending(o => o.IntData)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInDescendingOrder(o => o.IntData);
+ }
+
+ public override async Task WhereTakeOrderBySkip_ReturnOk()
+ {
+ // Arrange
+ int itemsCountToInsert = 5;
+ int itemsCountToTake = 3;
+ int itemsCountToSkip = 2;
+
+ var guid = Guid.NewGuid().ToString();
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert, guid);
+
+ // Act
+ var itemsResult = await Collection.Query
+ .Where(w => w.StringData == guid)
+ .Take(itemsCountToTake)
+ .OrderBy(o => o.IntData)
+ .Skip(itemsCountToSkip)
+ .ToListAsync();
+
+ // Assert
+ itemsResult
+ .Should()
+ .HaveCount(itemsCountToTake)
+ .And
+ .BeInAscendingOrder(o => o.IntData);
+ }
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/TestContainers/CosmosTestContainer.cs b/ManagedCode.Database.Tests/TestContainers/CosmosTestContainer.cs
index a317de0..9340e8e 100644
--- a/ManagedCode.Database.Tests/TestContainers/CosmosTestContainer.cs
+++ b/ManagedCode.Database.Tests/TestContainers/CosmosTestContainer.cs
@@ -18,7 +18,7 @@ namespace ManagedCode.Database.Tests.TestContainers;
public class CosmosTestContainer : ITestContainer,
ICollectionFixture, IDisposable
{
- private readonly TestcontainersContainer _cosmosTestContainer;
+ private readonly IContainer _cosmosTestContainer;
private CosmosDatabase _database;
private DockerClient _dockerClient;
private const string containerName = "cosmosContainer";
@@ -28,26 +28,25 @@ public class CosmosTestContainer : ITestContainer,
public CosmosTestContainer()
{
- _cosmosTestContainer = new TestcontainersBuilder()
- .WithImage("mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator")
- .WithName(containerName)
- .WithExposedPort(8081)
- .WithPortBinding(8081, 8081)
- .WithPortBinding(10250, 10250)
- .WithPortBinding(10251, 10251)
- .WithPortBinding(10252, 10252)
- .WithPortBinding(10253, 10253)
- .WithPortBinding(10254, 10254)
- .WithPortBinding(10255, 10255)
- .WithEnvironment("AZURE_COSMOS_EMULATOR_PARTITION_COUNT", "2")
- .WithEnvironment("AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE", "127.0.0.1")
- .WithEnvironment("AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE", "true")
- .WithCleanUp(false)
- .WithWaitStrategy(Wait.ForUnixContainer()
- .UntilPortIsAvailable(8081))
- .Build();
-
- _dockerClient = new DockerClientConfiguration().CreateClient();
+// _cosmosTestContainer = new ContainerBuilder()
+// .WithImage("mcr.microsoft.com/cosmosdb/windows/azure-cosmos-emulator")
+// // .WithName(containerName)
+// .WithExposedPort(8081)
+// .WithExposedPort(10251)
+// .WithExposedPort(10252)
+// .WithExposedPort(10253)
+// .WithExposedPort(10254)
+// .WithExposedPort(10255)
+// .WithPortBinding(8081, 8081)
+// .WithEnvironment("ACCEPT_EULA", "Y")
+// .WithEnvironment("AZURE_COSMOS_EMULATOR_PARTITION_COUNT", "1")
+// .WithEnvironment("AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE", "127.0.0.1")
+// .WithEnvironment("AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE", "false")
+// .WithWaitStrategy(Wait.ForWindowsContainer()
+// .UntilPortIsAvailable(8081))
+// .Build();
+//
+// _dockerClient = new DockerClientConfiguration().CreateClient();
}
public IDatabaseCollection Collection =>
@@ -60,43 +59,42 @@ public string GenerateId()
public async Task InitializeAsync()
{
- ushort publicPort = 0;
-
- try
- {
- await _cosmosTestContainer.StartAsync();
-
- containerExsist = false;
- }
- catch (Exception ex) //TODO catch name already using exception
- {
- containerExsist = true;
- }
-
- if (!containerExsist)
- {
- publicPort = _cosmosTestContainer.GetMappedPublicPort(privatePort);
- containerId = _cosmosTestContainer.Id;
- }
- else
- {
- var listContainers = await _dockerClient.Containers.ListContainersAsync(new ContainersListParameters());
-
- ContainerListResponse containerListResponse = listContainers.FirstOrDefault(container => container.Names.Contains($"/{containerName}"));
-
- if (containerListResponse != null)
- {
- publicPort = containerListResponse.Ports.Single(port => port.PrivatePort == privatePort).PublicPort;
-
- containerId = containerListResponse.ID;
- }
- }
-
-
+ ushort publicPort = privatePort;
+
+ // try
+ // {
+ // await _cosmosTestContainer.StartAsync();
+ //
+ // containerExsist = false;
+ // }
+ // catch (Exception ex) //TODO catch name already using exception
+ // {
+ // containerExsist = true;
+ // }
+
+ // if (!containerExsist)
+ // {
+ // publicPort = _cosmosTestContainer.GetMappedPublicPort(privatePort);
+ // containerId = _cosmosTestContainer.Id;
+ // }
+ // else
+ // {
+ // var listContainers = await _dockerClient.Containers.ListContainersAsync(new ContainersListParameters());
+ //
+ // ContainerListResponse containerListResponse = listContainers.FirstOrDefault(container => container.Names.Contains($"/{containerName}"));
+ //
+ // if (containerListResponse != null)
+ // {
+ // publicPort = containerListResponse.Ports.Single(port => port.PrivatePort == privatePort).PublicPort;
+ //
+ // containerId = containerListResponse.ID;
+ // }
+ // }
+
_database = new CosmosDatabase(new CosmosOptions
{
ConnectionString =
- $"AccountEndpoint=https://localhost:{publicPort}/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
+ $"AccountEndpoint=https://localhost:8081;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
DatabaseName = "database",
CollectionName = $"testContainer",
AllowTableCreation = true,
@@ -106,12 +104,13 @@ public async Task InitializeAsync()
{
HttpMessageHandler httpMessageHandler = new HttpClientHandler()
{
- ServerCertificateCustomValidationCallback = (_, _, _, _) => true
+ ServerCertificateCustomValidationCallback =
+ HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
};
return new HttpClient(httpMessageHandler);
},
- ConnectionMode = ConnectionMode.Gateway
+ ConnectionMode = ConnectionMode.Gateway,
},
});
@@ -121,8 +120,8 @@ public async Task InitializeAsync()
public async Task DisposeAsync()
{
- // await _database.DeleteAsync();
- await _database.DisposeAsync();
+ await _database.DeleteAsync();
+ //await _database.DisposeAsync();
/* _testOutputHelper.WriteLine($"Cosmos container State:{_cosmosContainer.State}");
_testOutputHelper.WriteLine("=STOP=");*/
@@ -131,10 +130,11 @@ public async Task DisposeAsync()
public async void Dispose()
{
- await _dockerClient.Containers.RemoveContainerAsync(containerId,
- new ContainerRemoveParameters
- {
- Force = true
- });
+ await _database.DeleteAsync();
+ // await _dockerClient.Containers.RemoveContainerAsync(containerId,
+ // new ContainerRemoveParameters
+ // {
+ // Force = true
+ // });
}
}
diff --git a/ManagedCode.Database.Tests/TestContainers/LiteDBTestContainer.cs b/ManagedCode.Database.Tests/TestContainers/LiteDBTestContainer.cs
index bbd2ae7..dd5c56b 100644
--- a/ManagedCode.Database.Tests/TestContainers/LiteDBTestContainer.cs
+++ b/ManagedCode.Database.Tests/TestContainers/LiteDBTestContainer.cs
@@ -14,7 +14,7 @@ public class LiteDBTestContainer : ITestContainer
public LiteDBTestContainer()
{
- _databasePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid():N}.db");
+ _databasePath = Path.Combine(Environment.CurrentDirectory, $"{Guid.NewGuid():N}.db");
_database = new LiteDBDatabase(new LiteDBOptions
{
diff --git a/ManagedCode.Database.Tests/TestContainers/ZoneTreeTestContainer.cs b/ManagedCode.Database.Tests/TestContainers/ZoneTreeTestContainer.cs
index d21b5b7..e571be6 100644
--- a/ManagedCode.Database.Tests/TestContainers/ZoneTreeTestContainer.cs
+++ b/ManagedCode.Database.Tests/TestContainers/ZoneTreeTestContainer.cs
@@ -13,7 +13,7 @@ public class ZoneTreeTestContainer : ITestContainer
public ZoneTreeTestContainer()
{
- var databasePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid():N}");
+ var databasePath = Path.Combine(Environment.CurrentDirectory, $"zone{Guid.NewGuid():N}");
_database = new ZoneTreeDatabase(new ZoneTreeOptions()
{
diff --git a/ManagedCode.Database.Tests/ZoneTreeTests/ZoneTreeCollectionTests.cs b/ManagedCode.Database.Tests/ZoneTreeTests/ZoneTreeCollectionTests.cs
index df92283..b885163 100644
--- a/ManagedCode.Database.Tests/ZoneTreeTests/ZoneTreeCollectionTests.cs
+++ b/ManagedCode.Database.Tests/ZoneTreeTests/ZoneTreeCollectionTests.cs
@@ -1,45 +1,47 @@
-// using System;
-// using System.Collections.Generic;
-// using System.Threading.Tasks;
-// using FluentAssertions;
-// using ManagedCode.Database.Tests.BaseTests;
-// using ManagedCode.Database.Tests.Common;
-// using ManagedCode.Database.Tests.TestContainers;
-//
-// namespace ManagedCode.Database.Tests.ZoneTreeTests;
-//
-// public class ZoneTreeCollectionTests : BaseCollectionTests
-// {
-// public ZoneTreeCollectionTests() : base(new ZoneTreeTestContainer())
-// {
-// }
-//
-// public override async Task InsertOrUpdateListOfItems()
-// {
-// // Arrange
-// int itemsCount = 5;
-// int updatedItemsCount = 0;
-// List list = new();
-//
-// for (var i = 0; i < itemsCount; i++)
-// {
-// list.Add(CreateNewItem());
-// }
-//
-// var itemsInsert = await Collection.InsertOrUpdateAsync(list);
-//
-// foreach (var item in list)
-// {
-// item.DateTimeData = DateTime.Now.AddDays(-1);
-// }
-//
-// // Act
-// var itemsUpdate = await Collection.InsertOrUpdateAsync(list);
-// //TODO: LiteDB must be 100, but result 0
-//
-// // Assert
-// itemsUpdate.Should().Be(updatedItemsCount);
-// itemsInsert.Should().Be(itemsCount);
-// list.Count.Should().Be(itemsCount);
-// }
-// }
\ No newline at end of file
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using FluentAssertions;
+using ManagedCode.Database.Tests.BaseTests;
+using ManagedCode.Database.Tests.Common;
+using ManagedCode.Database.Tests.TestContainers;
+
+namespace ManagedCode.Database.Tests.ZoneTreeTests;
+
+#if ZONE_TREE || DEBUG
+public class ZoneTreeCollectionTests : BaseCollectionTests
+{
+ public ZoneTreeCollectionTests() : base(new ZoneTreeTestContainer())
+ {
+ }
+
+ public override async Task InsertOrUpdateListOfItems()
+ {
+ // Arrange
+ int itemsCount = 5;
+ int updatedItemsCount = 0;
+ List list = new();
+
+ for (var i = 0; i < itemsCount; i++)
+ {
+ list.Add(CreateNewItem());
+ }
+
+ var itemsInsert = await Collection.InsertOrUpdateAsync(list);
+
+ foreach (var item in list)
+ {
+ item.DateTimeData = DateTime.Now.AddDays(-1);
+ }
+
+ // Act
+ var itemsUpdate = await Collection.InsertOrUpdateAsync(list);
+ //TODO: LiteDB must be 100, but result 0
+
+ // Assert
+ itemsUpdate.Should().Be(updatedItemsCount);
+ itemsInsert.Should().Be(itemsCount);
+ list.Count.Should().Be(itemsCount);
+ }
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.Tests/ZoneTreeTests/ZoneTreeQueryableTests.cs b/ManagedCode.Database.Tests/ZoneTreeTests/ZoneTreeQueryableTests.cs
index f9560a0..fecf53b 100644
--- a/ManagedCode.Database.Tests/ZoneTreeTests/ZoneTreeQueryableTests.cs
+++ b/ManagedCode.Database.Tests/ZoneTreeTests/ZoneTreeQueryableTests.cs
@@ -1,53 +1,55 @@
-// using System;
-// using System.Threading.Tasks;
-// using FluentAssertions;
-// using ManagedCode.Database.Tests.BaseTests;
-// using ManagedCode.Database.Tests.Common;
-// using ManagedCode.Database.Tests.TestContainers;
-//
-// namespace ManagedCode.Database.Tests.ZoneTreeTests;
-//
-// public class ZoneTreeQueryableTests : BaseQueryableTests
-// {
-// public ZoneTreeQueryableTests() : base(new ZoneTreeTestContainer())
-// {
-// }
-//
-// public override async Task ThenByDescending_TakeNull_ReturnException()
-// {
-// // Arrange
-// int itemsCountToInsert = 1;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = () => Collection.Query
-// .OrderBy(o => o.StringData)
-// .ThenByDescending(null)
-// .ToListAsync();
-//
-// // Assert
-// await itemsResult
-// .Should()
-// .ThrowAsync();
-// }
-//
-// public override async Task ThenBy_TakeNull_ReturnException()
-// {
-// // Arrange
-// int itemsCountToInsert = 1;
-//
-// await CreateAndInsertItemsAsync(itemsCountToInsert);
-//
-// // Act
-// var itemsResult = () => Collection.Query
-// .OrderBy(o => o.StringData)
-// .ThenBy(null)
-// .ToListAsync();
-//
-// // Assert
-// await itemsResult
-// .Should()
-// .ThrowAsync();
-// }
-// }
\ No newline at end of file
+using System;
+using System.Threading.Tasks;
+using FluentAssertions;
+using ManagedCode.Database.Tests.BaseTests;
+using ManagedCode.Database.Tests.Common;
+using ManagedCode.Database.Tests.TestContainers;
+
+namespace ManagedCode.Database.Tests.ZoneTreeTests;
+
+#if ZONE_TREE || DEBUG
+public class ZoneTreeQueryableTests : BaseQueryableTests
+{
+ public ZoneTreeQueryableTests() : base(new ZoneTreeTestContainer())
+ {
+ }
+
+ public override async Task ThenByDescending_TakeNull_ReturnException()
+ {
+ // Arrange
+ int itemsCountToInsert = 1;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = () => Collection.Query
+ .OrderBy(o => o.StringData)
+ .ThenByDescending(null)
+ .ToListAsync();
+
+ // Assert
+ await itemsResult
+ .Should()
+ .ThrowAsync();
+ }
+
+ public override async Task ThenBy_TakeNull_ReturnException()
+ {
+ // Arrange
+ int itemsCountToInsert = 1;
+
+ await CreateAndInsertItemsAsync(itemsCountToInsert);
+
+ // Act
+ var itemsResult = () => Collection.Query
+ .OrderBy(o => o.StringData)
+ .ThenBy(null)
+ .ToListAsync();
+
+ // Assert
+ await itemsResult
+ .Should()
+ .ThrowAsync();
+ }
+}
+#endif
\ No newline at end of file
diff --git a/ManagedCode.Database.ZoneTree/ManagedCode.Database.ZoneTree.csproj b/ManagedCode.Database.ZoneTree/ManagedCode.Database.ZoneTree.csproj
index 5579350..9d80a05 100644
--- a/ManagedCode.Database.ZoneTree/ManagedCode.Database.ZoneTree.csproj
+++ b/ManagedCode.Database.ZoneTree/ManagedCode.Database.ZoneTree.csproj
@@ -21,7 +21,7 @@
-
+
diff --git a/ManagedCode.Database.ZoneTree/ZoneTreeWrapper.cs b/ManagedCode.Database.ZoneTree/ZoneTreeWrapper.cs
index 5ae0c8f..46f2c1b 100644
--- a/ManagedCode.Database.ZoneTree/ZoneTreeWrapper.cs
+++ b/ManagedCode.Database.ZoneTree/ZoneTreeWrapper.cs
@@ -102,7 +102,9 @@ public bool Delete(TKey key)
public void DeleteAll()
{
- _zoneTree.Maintenance.DestroyTree();
+ using var iterator = _zoneTree.CreateIterator();
+ while (iterator.Next())
+ _zoneTree.TryDelete(iterator.CurrentKey);
}
public long Count()
@@ -114,7 +116,8 @@ public long Count()
public IEnumerable Enumerate()
{
using var iterator = _zoneTree.CreateIterator();
- while (iterator.Next()) yield return iterator.CurrentValue;
+ while (iterator.Next())
+ yield return iterator.CurrentValue;
}
public IEnumerable EnumerateReverse()
diff --git a/ManagedCode.Database.sln b/ManagedCode.Database.sln
index 31ad67c..fa4ae21 100644
--- a/ManagedCode.Database.sln
+++ b/ManagedCode.Database.sln
@@ -27,6 +27,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManagedCode.Database.ZoneTr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagedCode.Database.DynamoDB", "ManagedCode.Database.DynamoDB\ManagedCode.Database.DynamoDB.csproj", "{ED12ED3C-F0FB-4BC1-A283-BF6E74BA99A2}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Orleans", "Orleans", "{6408F3FF-28A1-4377-84A6-FCE0548AC306}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagedCode.Database.Orleans.Persistence", "Orleans\ManagedCode.Database.Orleans.Persistence\ManagedCode.Database.Orleans.Persistence.csproj", "{0558E9C2-D608-49F0-A094-9AEA0BAB800E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -73,6 +77,10 @@ Global
{ED12ED3C-F0FB-4BC1-A283-BF6E74BA99A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED12ED3C-F0FB-4BC1-A283-BF6E74BA99A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED12ED3C-F0FB-4BC1-A283-BF6E74BA99A2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0558E9C2-D608-49F0-A094-9AEA0BAB800E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0558E9C2-D608-49F0-A094-9AEA0BAB800E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0558E9C2-D608-49F0-A094-9AEA0BAB800E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0558E9C2-D608-49F0-A094-9AEA0BAB800E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -87,6 +95,7 @@ Global
{46AD78EF-B94E-44C2-8CFE-13E8851610F8} = {B34993FC-20CB-4E46-86D7-8B8A30B3FABE}
{8F382CD4-7E0A-41E1-BB91-96E58F3F166C} = {9D86DFE5-1381-4621-8AC4-DC502CE5F43B}
{ED12ED3C-F0FB-4BC1-A283-BF6E74BA99A2} = {9D86DFE5-1381-4621-8AC4-DC502CE5F43B}
+ {0558E9C2-D608-49F0-A094-9AEA0BAB800E} = {6408F3FF-28A1-4377-84A6-FCE0548AC306}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {481455E7-0A98-4AB2-9F00-F32D40AB884D}
diff --git a/Orleans/ManagedCode.Database.Orleans.Persistence/Class1.cs b/Orleans/ManagedCode.Database.Orleans.Persistence/Class1.cs
new file mode 100644
index 0000000..f10d540
--- /dev/null
+++ b/Orleans/ManagedCode.Database.Orleans.Persistence/Class1.cs
@@ -0,0 +1,61 @@
+using System.Net;
+using ManagedCode.Database.Core;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Orleans.Configuration;
+using Orleans.Runtime;
+using Orleans.Storage;
+
+namespace ManagedCode.Database.Orleans.Persistence;
+
+public class DatabaseGrainStorage : IGrainStorage, IRestExceptionDecoder, ILifecycleParticipant where TItem : IItem
+{
+ private readonly IDatabase _database;
+ private readonly IDatabaseCollection _collection;
+
+ public DatabaseGrainStorage(
+ string name,
+ // AzureTableStorageOptions options,
+ IOptions clusterOptions,
+ IServiceProvider services,
+ // ILogger logger,
+ IDatabase database,
+ IDatabaseCollection collection
+
+ )
+ {
+ _database = database;
+ _collection = collection;
+ // this.options = options;
+ // this.clusterOptions = clusterOptions.Value;
+ // this.name = name;
+ // this.storageSerializer = options.GrainStorageSerializer;
+ // this.logger = logger;
+ }
+
+ public Task ReadStateAsync(string stateName, GrainId grainId, IGrainState grainState)
+ {
+ //_collection.GetAsync()
+ return Task.CompletedTask;
+ }
+
+ public Task WriteStateAsync(string stateName, GrainId grainId, IGrainState grainState)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task ClearStateAsync(string stateName, GrainId grainId, IGrainState grainState)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool DecodeException(Exception exception, out HttpStatusCode httpStatusCode, out string restStatus, bool getExtendedErrors = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Participate(ISiloLifecycle observer)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/Orleans/ManagedCode.Database.Orleans.Persistence/ManagedCode.Database.Orleans.Persistence.csproj b/Orleans/ManagedCode.Database.Orleans.Persistence/ManagedCode.Database.Orleans.Persistence.csproj
new file mode 100644
index 0000000..2ab9727
--- /dev/null
+++ b/Orleans/ManagedCode.Database.Orleans.Persistence/ManagedCode.Database.Orleans.Persistence.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net7.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+