Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cosmo #95

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 147 additions & 7 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Data.Tables" Version="12.7.1" />
<PackageReference Include="Azure.Data.Tables" Version="12.8.0" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.31.2" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.32.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.100.21" />
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.102.8" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="LiteDB" Version="5.0.13" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="LiteDB" Version="5.0.16" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="MongoDB.Driver" Version="2.19.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<ItemGroup>
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.3" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.4" />
</ItemGroup>

</Project>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@


<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.4.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Diagnostics.NETCore.Client" Version="0.2.351802" />
<PackageReference Include="Microsoft.Diagnostics.NETCore.Client" Version="0.2.410101" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace ManagedCode.Database.Tests.AzureTablesTests;

#if AZURE_TABLES || DEBUG
[Collection(nameof(AzureTablesTestContainer))]
public class AzureTablesCollectionTests : BaseCollectionTests<TableId, TestAzureTablesItem>
{
Expand Down Expand Up @@ -86,4 +87,5 @@ public override async Task DeleteAll()
deletedItems.Should().BeTrue();
await countAction.Should().ThrowExactlyAsync<DatabaseException>();
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace ManagedCode.Database.Tests.AzureTablesTests;

#if AZURE_TABLES || DEBUG
[Collection(nameof(AzureTablesTestContainer))]
public class AzureTablesQueryableTests : BaseQueryableTests<TableId, TestAzureTablesItem>
{
Expand Down Expand Up @@ -37,3 +38,4 @@ await itemsResult
.ThrowAsync<ArgumentNullException>();
}
}
#endif
2 changes: 2 additions & 0 deletions ManagedCode.Database.Tests/BaseTests/BaseCollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TId, TItem> : BaseTests<TId, TItem> where TItem : IBaseItem<TId>, new()
{

protected BaseCollectionTests(ITestContainer<TId, TItem> testContainer) : base(testContainer)
{
}
Expand Down
68 changes: 35 additions & 33 deletions ManagedCode.Database.Tests/CosmosTests/CosmosCollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,53 @@

namespace ManagedCode.Database.Tests.CosmosTests;

#if COSMOS_DB || DEBUG
[Collection(nameof(CosmosTestContainer))]
public class CosmosCollectionTests : BaseCollectionTests<string, TestCosmosItem>
{
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<DatabaseException>();
}
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<DatabaseException>();
}

await baseMethod.Should().ThrowExactlyAsync<DatabaseException>();
}
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<DatabaseException>();
}

await baseMethod.Should().ThrowExactlyAsync<DatabaseException>();
}
public override async Task DeleteListOfItems_WhenItemsDontExist()
{
var baseMethod = () => base.DeleteListOfItems_WhenItemsDontExist();

[Fact]
public override async Task DeleteCollectionAsync()
{
// Arrange
int itemsCount = 5;
List<TestCosmosItem> list = new();
await baseMethod.Should().ThrowExactlyAsync<DatabaseException>();
}

for (var i = 0; i < itemsCount; i++)
[Fact]
public override async Task DeleteCollectionAsync()
{
list.Add(CreateNewItem());
}
// Arrange
int itemsCount = 5;
List<TestCosmosItem> 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();
}
}
await Collection.InsertAsync(list);
// Act
var isDeleted = await Collection.DeleteCollectionAsync();

// Assert
isDeleted.Should().BeTrue();
}
}
#endif
Loading