From 1ea32ee00f074b817e93145905ec4b61061d1d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCsters?= Date: Wed, 28 May 2025 09:10:25 +0200 Subject: [PATCH 1/7] chore: added sync-fork workflow --- .github/workflows/sync-fork.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/sync-fork.yaml diff --git a/.github/workflows/sync-fork.yaml b/.github/workflows/sync-fork.yaml new file mode 100644 index 0000000..b20ff06 --- /dev/null +++ b/.github/workflows/sync-fork.yaml @@ -0,0 +1,17 @@ +name: Sync Fork + +on: + schedule: + - cron: '*/30 * * * *' # every 30 minutes + workflow_dispatch: # on button click + +jobs: + sync: + + runs-on: ubuntu-latest + + steps: + - uses: tgymnich/fork-sync@v2.0 + with: + base: main + head: main From 1375b0a18ef28056642f4d0dd0825cd97810a2ed Mon Sep 17 00:00:00 2001 From: Kane Vo Date: Thu, 31 Jul 2025 13:39:30 +0700 Subject: [PATCH 2/7] feat: add upsert operation --- .../RepositoryTestBase.UpsertAsync.cs | 104 ++++++++++++++++++ .../Abstractions/IDatabaseClient`1.cs | 4 + .../IDatabaseRepository`1.Upsert.cs | 26 +++++ .../MultiTenantDatabaseRepository`1.Upsert.cs | 30 +++++ .../DatabaseRepository`1.Upsert.cs | 35 ++++++ ...Wemogy.Infrastructure.Database.Core.csproj | 15 +++ .../Client/CosmosDatabaseClient`1.cs | 27 +++++ .../Client/InMemoryDatabaseClient`1.cs | 50 +++++++++ .../Client/MongoDatabaseClient`1.cs | 10 ++ 9 files changed, 301 insertions(+) create mode 100644 src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs create mode 100644 src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseRepository`1.Upsert.cs create mode 100644 src/core/Wemogy.Infrastructure.Database.Core/Plugins/MultiTenantDatabase/Repositories/MultiTenantDatabaseRepository`1.Upsert.cs create mode 100644 src/core/Wemogy.Infrastructure.Database.Core/Repositories/DatabaseRepository`1.Upsert.cs diff --git a/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs b/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs new file mode 100644 index 0000000..622222e --- /dev/null +++ b/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs @@ -0,0 +1,104 @@ +using System; +using System.Threading.Tasks; +using FluentAssertions; +using Wemogy.Infrastructure.Database.Core.UnitTests.Fakes.Entities; +using Xunit; + +namespace Wemogy.Infrastructure.Database.Core.UnitTests.Repositories; + +public partial class RepositoryTestBase +{ + [Fact] + public async Task UpsertAsync_ShouldCreateIfNotExist() + { + // Arrange + await ResetAsync(); + var user = User.Faker.Generate(); + + // Act & Assert + if (MicrosoftUserRepository.GetType().Name.Contains("Mongo")) + { + await Assert.ThrowsAsync(async () => + await MicrosoftUserRepository.UpsertAsync(user, user.TenantId)); + } + else + { + var updatedUser = await MicrosoftUserRepository.UpsertAsync( + user, + user.TenantId); + updatedUser.Id.Should().Be(user.Id); + updatedUser.TenantId.Should().Be(user.TenantId); + } + } + + [Fact] + public async Task UpsertAsync_ShouldReplaceIfExist() + { + // Arrange + await ResetAsync(); + var user = User.Faker.Generate(); + await MicrosoftUserRepository.CreateAsync(user); + user.Firstname = "Updated"; + + // Act & Assert + if (MicrosoftUserRepository.GetType().Name.Contains("Mongo")) + { + await Assert.ThrowsAsync(async () => + await MicrosoftUserRepository.UpsertAsync(user, user.TenantId)); + } + else + { + var updatedUser = await MicrosoftUserRepository.UpsertAsync( + user, + user.TenantId); + updatedUser.Firstname.Should().Be("Updated"); + updatedUser.Id.Should().Be(user.Id); + updatedUser.TenantId.Should().Be(user.TenantId); + } + } + + [Fact] + public async Task UpsertAsyncWithoutPartitionKey_ShouldCreateIfNotExist() + { + // Arrange + await ResetAsync(); + var user = User.Faker.Generate(); + + // Act & Assert + if (MicrosoftUserRepository.GetType().Name.Contains("Mongo")) + { + await Assert.ThrowsAsync(async () => + await MicrosoftUserRepository.UpsertAsync(user)); + } + else + { + var updatedUser = await MicrosoftUserRepository.UpsertAsync(user); + updatedUser.Id.Should().Be(user.Id); + updatedUser.TenantId.Should().Be(user.TenantId); + } + } + + [Fact] + public async Task UpsertAsyncWithoutPartitionKey_ShouldReplaceIfExist() + { + // Arrange + await ResetAsync(); + var user = User.Faker.Generate(); + await MicrosoftUserRepository.CreateAsync(user); + user.Firstname = "Updated"; + + // Act & Assert + if (MicrosoftUserRepository.GetType().Name.Contains("Mongo")) + { + await Assert.ThrowsAsync(async () => + await MicrosoftUserRepository.UpsertAsync(user)); + } + else + { + var updatedUser = await MicrosoftUserRepository.UpsertAsync(user); + updatedUser.Firstname.Should().Be("Updated"); + updatedUser.Id.Should().Be(user.Id); + updatedUser.TenantId.Should().Be(user.TenantId); + } + } +} diff --git a/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseClient`1.cs b/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseClient`1.cs index 849db88..ee7e5ff 100644 --- a/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseClient`1.cs +++ b/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseClient`1.cs @@ -47,4 +47,8 @@ Task CountAsync( Task DeleteAsync(string id, string partitionKey); Task DeleteAsync(Expression> predicate); + + Task UpsertAsync(TEntity entity); + + Task UpsertAsync(TEntity entity, string partitionKey); } diff --git a/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseRepository`1.Upsert.cs b/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseRepository`1.Upsert.cs new file mode 100644 index 0000000..255cfde --- /dev/null +++ b/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseRepository`1.Upsert.cs @@ -0,0 +1,26 @@ +using System; +using System.Threading.Tasks; + +namespace Wemogy.Infrastructure.Database.Core.Abstractions; + +/// +/// Defines methods for upserting entities in a database repository. +/// +/// The type of the entity managed by the repository. +public partial interface IDatabaseRepository +{ + /// + /// Upsert an entity in the database. + /// + /// The entity to upsert + /// The upserted entity as persisted + Task UpsertAsync(TEntity entity); + + /// + /// Upsert an entity in the database, using the specified partition key. + /// + /// The entity to upsert. + /// The partition key to use for the upsert operation. + /// The upserted entity as persisted + Task UpsertAsync(TEntity entity, string partitionKey); +} diff --git a/src/core/Wemogy.Infrastructure.Database.Core/Plugins/MultiTenantDatabase/Repositories/MultiTenantDatabaseRepository`1.Upsert.cs b/src/core/Wemogy.Infrastructure.Database.Core/Plugins/MultiTenantDatabase/Repositories/MultiTenantDatabaseRepository`1.Upsert.cs new file mode 100644 index 0000000..13d4922 --- /dev/null +++ b/src/core/Wemogy.Infrastructure.Database.Core/Plugins/MultiTenantDatabase/Repositories/MultiTenantDatabaseRepository`1.Upsert.cs @@ -0,0 +1,30 @@ +using System.Threading.Tasks; + +namespace Wemogy.Infrastructure.Database.Core.Plugins.MultiTenantDatabase.Repositories; + +/// +/// Repository for handling multi-tenant database operations for . +/// +public partial class MultiTenantDatabaseRepository +{ + /// + /// Inserts or updates the specified entity in the database. + /// + /// The entity to upsert. + /// The upserted entity. + public Task UpsertAsync(TEntity entity) + { + return _databaseRepository.UpsertAsync(entity); + } + + /// + /// Inserts or updates the specified entity in the database using the provided partition key. + /// + /// The entity to upsert. + /// The partition key to use for the operation. + /// The upserted entity. + public Task UpsertAsync(TEntity entity, string partitionKey) + { + return _databaseRepository.UpsertAsync(entity, partitionKey); + } +} diff --git a/src/core/Wemogy.Infrastructure.Database.Core/Repositories/DatabaseRepository`1.Upsert.cs b/src/core/Wemogy.Infrastructure.Database.Core/Repositories/DatabaseRepository`1.Upsert.cs new file mode 100644 index 0000000..cecd0c4 --- /dev/null +++ b/src/core/Wemogy.Infrastructure.Database.Core/Repositories/DatabaseRepository`1.Upsert.cs @@ -0,0 +1,35 @@ +using System.Threading.Tasks; +using Wemogy.Infrastructure.Database.Core.Abstractions; + +namespace Wemogy.Infrastructure.Database.Core.Repositories; + +/// +/// Represents a repository for performing database operations on entities of type . +/// +/// The type of the entity. +public partial class DatabaseRepository + where TEntity : class, IEntityBase +{ + /// + /// Inserts or updates the specified entity in the database using the provided partition key. + /// + /// The entity to upsert. + /// The partition key for the entity. + /// A task that represents the asynchronous operation. The task result contains the upserted entity. + public Task UpsertAsync(TEntity entity, string partitionKey) + { + return _database.UpsertAsync( + entity, + partitionKey); + } + + /// + /// Inserts or updates the specified entity in the database. + /// + /// The entity to upsert. + /// A task that represents the asynchronous operation. The task result contains the upserted entity. + public Task UpsertAsync(TEntity entity) + { + return _database.UpsertAsync(entity); + } +} diff --git a/src/core/Wemogy.Infrastructure.Database.Core/Wemogy.Infrastructure.Database.Core.csproj b/src/core/Wemogy.Infrastructure.Database.Core/Wemogy.Infrastructure.Database.Core.csproj index 8d5a583..92dbe34 100644 --- a/src/core/Wemogy.Infrastructure.Database.Core/Wemogy.Infrastructure.Database.Core.csproj +++ b/src/core/Wemogy.Infrastructure.Database.Core/Wemogy.Infrastructure.Database.Core.csproj @@ -175,5 +175,20 @@ content Compile + + cs + content + Compile + + + cs + content + Compile + + + cs + content + Compile + diff --git a/src/cosmos/Wemogy.Infrastructure.Database.Cosmos/Client/CosmosDatabaseClient`1.cs b/src/cosmos/Wemogy.Infrastructure.Database.Cosmos/Client/CosmosDatabaseClient`1.cs index f62048a..ca02510 100644 --- a/src/cosmos/Wemogy.Infrastructure.Database.Cosmos/Client/CosmosDatabaseClient`1.cs +++ b/src/cosmos/Wemogy.Infrastructure.Database.Cosmos/Client/CosmosDatabaseClient`1.cs @@ -167,6 +167,33 @@ public async Task ReplaceAsync(TEntity entity) } } + public async Task UpsertAsync(TEntity entity) + { + var partitionKey = ResolvePartitionKey(entity); + var upsertResponse = await _container.UpsertItemAsync( + entity, + partitionKey.CosmosPartitionKey, + new ItemRequestOptions + { + EnableContentResponseOnWrite = true + }); + + return upsertResponse.Resource; + } + + public async Task UpsertAsync(TEntity entity, string partitionKey) + { + var upsertResponse = await _container.UpsertItemAsync( + entity, + new PartitionKey(partitionKey).CosmosPartitionKey, + new ItemRequestOptions + { + EnableContentResponseOnWrite = true + }); + + return upsertResponse.Resource; + } + public Task DeleteAsync(string id, string partitionKey) { return DeleteAsync( diff --git a/src/in-memory/Wemogy.Infrastructure.Database.InMemory/Client/InMemoryDatabaseClient`1.cs b/src/in-memory/Wemogy.Infrastructure.Database.InMemory/Client/InMemoryDatabaseClient`1.cs index b694617..e7fddeb 100644 --- a/src/in-memory/Wemogy.Infrastructure.Database.InMemory/Client/InMemoryDatabaseClient`1.cs +++ b/src/in-memory/Wemogy.Infrastructure.Database.InMemory/Client/InMemoryDatabaseClient`1.cs @@ -197,6 +197,56 @@ public Task ReplaceAsync(TEntity entity) return Task.FromResult(entity.Clone()); } + public Task UpsertAsync(TEntity entity) + { + var id = ResolveIdValue(entity); + var partitionKeyValue = ResolvePartitionKeyValue(entity); + + if (!EntityPartitions.TryGetValue( + partitionKeyValue, + out var entities)) + { + entities = new List(); + EntityPartitions.Add( + partitionKeyValue, + entities); + } + + var existingEntity = entities.AsQueryable().FirstOrDefault("e => e.Id.Equals(@0)", id); + + if (existingEntity != null) + { + entities.Remove(existingEntity); + } + + entities.Add(entity.Clone()); + return Task.FromResult(entity.Clone()); + } + + public Task UpsertAsync(TEntity entity, string partitionKey) + { + if (!EntityPartitions.TryGetValue( + partitionKey, + out var entities)) + { + entities = new List(); + EntityPartitions.Add( + partitionKey, + entities); + } + + var id = ResolveIdValue(entity); + var existingEntity = entities.AsQueryable().FirstOrDefault("e => e.Id.Equals(@0)", id); + + if (existingEntity != null) + { + entities.Remove(existingEntity); + } + + entities.Add(entity.Clone()); + return Task.FromResult(entity.Clone()); + } + public Task DeleteAsync(string id, string partitionKey) { if (!EntityPartitions.TryGetValue( diff --git a/src/mongo/Wemogy.Infrastructure.Database.Mongo/Client/MongoDatabaseClient`1.cs b/src/mongo/Wemogy.Infrastructure.Database.Mongo/Client/MongoDatabaseClient`1.cs index ab4bcd8..ca085dd 100644 --- a/src/mongo/Wemogy.Infrastructure.Database.Mongo/Client/MongoDatabaseClient`1.cs +++ b/src/mongo/Wemogy.Infrastructure.Database.Mongo/Client/MongoDatabaseClient`1.cs @@ -185,6 +185,16 @@ public async Task ReplaceAsync(TEntity entity) return entity; } + public Task UpsertAsync(TEntity entity) + { + throw new NotSupportedException(); + } + + public Task UpsertAsync(TEntity entity, string partitionKey) + { + throw new NotSupportedException(); + } + public async Task DeleteAsync(string id, string partitionKey) { var filter = GetEntityFilterDefinition( From 7d06c271e565a6a5fb4f1552f71aeac8ef01b5e7 Mon Sep 17 00:00:00 2001 From: Kane Vo Date: Tue, 12 Aug 2025 11:24:45 +0700 Subject: [PATCH 3/7] chore: remove sync folk --- .github/workflows/sync-fork.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/sync-fork.yaml b/.github/workflows/sync-fork.yaml index b20ff06..3a2abed 100644 --- a/.github/workflows/sync-fork.yaml +++ b/.github/workflows/sync-fork.yaml @@ -1,5 +1,3 @@ -name: Sync Fork - on: schedule: - cron: '*/30 * * * *' # every 30 minutes From ce648bab97c4da71f6ff972bbfa1600125c19aac Mon Sep 17 00:00:00 2001 From: Kane Vo Date: Tue, 12 Aug 2025 11:41:40 +0700 Subject: [PATCH 4/7] chore: remove sync folk --- .github/workflows/sync-fork.yaml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .github/workflows/sync-fork.yaml diff --git a/.github/workflows/sync-fork.yaml b/.github/workflows/sync-fork.yaml deleted file mode 100644 index 3a2abed..0000000 --- a/.github/workflows/sync-fork.yaml +++ /dev/null @@ -1,15 +0,0 @@ -on: - schedule: - - cron: '*/30 * * * *' # every 30 minutes - workflow_dispatch: # on button click - -jobs: - sync: - - runs-on: ubuntu-latest - - steps: - - uses: tgymnich/fork-sync@v2.0 - with: - base: main - head: main From 501eb8ec1dc035dc2ed026547fb0387b891ef709 Mon Sep 17 00:00:00 2001 From: Kane Vo Date: Tue, 12 Aug 2025 11:42:01 +0700 Subject: [PATCH 5/7] fix: change tests separate from mongo --- .../RepositoryTestBase.UpsertAsync.cs | 120 ++++++++++++------ 1 file changed, 82 insertions(+), 38 deletions(-) diff --git a/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs b/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs index 622222e..203e023 100644 --- a/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs +++ b/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs @@ -15,20 +15,31 @@ public async Task UpsertAsync_ShouldCreateIfNotExist() await ResetAsync(); var user = User.Faker.Generate(); - // Act & Assert - if (MicrosoftUserRepository.GetType().Name.Contains("Mongo")) - { - await Assert.ThrowsAsync(async () => - await MicrosoftUserRepository.UpsertAsync(user, user.TenantId)); - } - else + // Act + Exception? exception = null; + User? updatedUser = null; + + try { - var updatedUser = await MicrosoftUserRepository.UpsertAsync( + updatedUser = await MicrosoftUserRepository.UpsertAsync( user, user.TenantId); - updatedUser.Id.Should().Be(user.Id); - updatedUser.TenantId.Should().Be(user.TenantId); } + catch (Exception ex) + { + exception = ex; + } + + // Assert + if (exception is NotSupportedException) + { + // Expected outcome in certain implementations + return; + } + + exception.Should().BeNull(); + updatedUser.Id.Should().Be(user.Id); + updatedUser.TenantId.Should().Be(user.TenantId); } [Fact] @@ -40,21 +51,32 @@ public async Task UpsertAsync_ShouldReplaceIfExist() await MicrosoftUserRepository.CreateAsync(user); user.Firstname = "Updated"; - // Act & Assert - if (MicrosoftUserRepository.GetType().Name.Contains("Mongo")) - { - await Assert.ThrowsAsync(async () => - await MicrosoftUserRepository.UpsertAsync(user, user.TenantId)); - } - else + // Act + Exception? exception = null; + User? updatedUser = null; + + try { - var updatedUser = await MicrosoftUserRepository.UpsertAsync( + updatedUser = await MicrosoftUserRepository.UpsertAsync( user, user.TenantId); - updatedUser.Firstname.Should().Be("Updated"); - updatedUser.Id.Should().Be(user.Id); - updatedUser.TenantId.Should().Be(user.TenantId); } + catch (Exception ex) + { + exception = ex; + } + + // Assert + if (exception is NotSupportedException) + { + // Expected outcome in certain implementations + return; + } + + exception.Should().BeNull(); + updatedUser.Firstname.Should().Be("Updated"); + updatedUser.Id.Should().Be(user.Id); + updatedUser.TenantId.Should().Be(user.TenantId); } [Fact] @@ -64,18 +86,30 @@ public async Task UpsertAsyncWithoutPartitionKey_ShouldCreateIfNotExist() await ResetAsync(); var user = User.Faker.Generate(); - // Act & Assert - if (MicrosoftUserRepository.GetType().Name.Contains("Mongo")) + // Act + Exception? exception = null; + User? updatedUser = null; + + try + { + updatedUser = await MicrosoftUserRepository.UpsertAsync(user); + } + catch (Exception ex) { - await Assert.ThrowsAsync(async () => - await MicrosoftUserRepository.UpsertAsync(user)); + exception = ex; } - else + + // Assert + if (exception is NotSupportedException) { - var updatedUser = await MicrosoftUserRepository.UpsertAsync(user); - updatedUser.Id.Should().Be(user.Id); - updatedUser.TenantId.Should().Be(user.TenantId); + // Expected outcome in certain implementations + return; } + + exception.Should().BeNull(); + updatedUser.Should().NotBeNull(); + updatedUser.Id.Should().Be(user.Id); + updatedUser.TenantId.Should().Be(user.TenantId); } [Fact] @@ -87,18 +121,28 @@ public async Task UpsertAsyncWithoutPartitionKey_ShouldReplaceIfExist() await MicrosoftUserRepository.CreateAsync(user); user.Firstname = "Updated"; - // Act & Assert - if (MicrosoftUserRepository.GetType().Name.Contains("Mongo")) + // Act + Exception? exception = null; + User? updatedUser = null; + + try { - await Assert.ThrowsAsync(async () => - await MicrosoftUserRepository.UpsertAsync(user)); + updatedUser = await MicrosoftUserRepository.UpsertAsync(user); } - else + catch (Exception ex) { - var updatedUser = await MicrosoftUserRepository.UpsertAsync(user); - updatedUser.Firstname.Should().Be("Updated"); - updatedUser.Id.Should().Be(user.Id); - updatedUser.TenantId.Should().Be(user.TenantId); + exception = ex; } + + // Assert + if (exception is NotSupportedException) + { + // Expected outcome in certain implementations + return; + } + + updatedUser.Firstname.Should().Be("Updated"); + updatedUser.Id.Should().Be(user.Id); + updatedUser.TenantId.Should().Be(user.TenantId); } } From 5421fb2259da48782a40aae97fe6e6d25e671fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCsters?= Date: Tue, 12 Aug 2025 06:49:20 +0200 Subject: [PATCH 6/7] fix: removed duplicated typeparam docs --- .../Abstractions/IDatabaseRepository`1.Upsert.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseRepository`1.Upsert.cs b/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseRepository`1.Upsert.cs index 255cfde..f1956c5 100644 --- a/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseRepository`1.Upsert.cs +++ b/src/core/Wemogy.Infrastructure.Database.Core/Abstractions/IDatabaseRepository`1.Upsert.cs @@ -1,4 +1,3 @@ -using System; using System.Threading.Tasks; namespace Wemogy.Infrastructure.Database.Core.Abstractions; @@ -6,7 +5,6 @@ namespace Wemogy.Infrastructure.Database.Core.Abstractions; /// /// Defines methods for upserting entities in a database repository. /// -/// The type of the entity managed by the repository. public partial interface IDatabaseRepository { /// From e3f289686e8a9a7af37c1b525d0137a12aafaae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCsters?= Date: Tue, 12 Aug 2025 06:51:28 +0200 Subject: [PATCH 7/7] fix: adjusted tests to assert all values --- .../Repositories/RepositoryTestBase.UpsertAsync.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs b/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs index 203e023..eaa2d71 100644 --- a/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs +++ b/src/core/Wemogy.Infrastructure.Database.Core.UnitTests/Repositories/RepositoryTestBase.UpsertAsync.cs @@ -38,6 +38,7 @@ public async Task UpsertAsync_ShouldCreateIfNotExist() } exception.Should().BeNull(); + updatedUser.Should().NotBeNull(); updatedUser.Id.Should().Be(user.Id); updatedUser.TenantId.Should().Be(user.TenantId); } @@ -74,6 +75,7 @@ public async Task UpsertAsync_ShouldReplaceIfExist() } exception.Should().BeNull(); + updatedUser.Should().NotBeNull(); updatedUser.Firstname.Should().Be("Updated"); updatedUser.Id.Should().Be(user.Id); updatedUser.TenantId.Should().Be(user.TenantId); @@ -141,6 +143,8 @@ public async Task UpsertAsyncWithoutPartitionKey_ShouldReplaceIfExist() return; } + exception.Should().BeNull(); + updatedUser.Should().NotBeNull(); updatedUser.Firstname.Should().Be("Updated"); updatedUser.Id.Should().Be(user.Id); updatedUser.TenantId.Should().Be(user.TenantId);