Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Shouldly;
using Wemogy.Infrastructure.Database.Core.Constants;
using Wemogy.Infrastructure.Database.Core.UnitTests.Fakes.Entities;
using Xunit;
Expand All @@ -9,7 +10,7 @@ public class PartitionKeyDefaultsTests
[Fact]
public static void GlobalPartition_DefaultValue()
{
Assert.Equal("global", PartitionKeyDefaults.GlobalPartition);
PartitionKeyDefaults.GlobalPartition.ShouldBe("global");
}

[Fact]
Expand All @@ -19,9 +20,9 @@ public static void CustomizeGlobalPartition_WhenCalled_ThenCustomizesGlobalParti
PartitionKeyDefaults.CustomizeGlobalPartition("custom");
var tenantB = new Tenant();

Assert.Equal("custom", PartitionKeyDefaults.GlobalPartition);
Assert.Equal("global", tenantA.PartitionKey);
Assert.Equal("custom", tenantB.PartitionKey);
PartitionKeyDefaults.GlobalPartition.ShouldBe("custom");
tenantA.PartitionKey.ShouldBe("global");
tenantB.PartitionKey.ShouldBe("custom");

// Clean up
PartitionKeyDefaults.CustomizeGlobalPartition("global");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wemogy.Infrastructure.Database.Core.Abstractions;
using Wemogy.Infrastructure.Database.Core.UnitTests.Fakes.Entities;

namespace Wemogy.Infrastructure.Database.Core.UnitTests.DatabaseRepositories
namespace Wemogy.Infrastructure.Database.Core.UnitTests.DatabaseRepositories;

public interface IDataCenterRepository : IDatabaseRepository<DataCenter>
{
public interface IDataCenterRepository : IDatabaseRepository<DataCenter>
{
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using FluentAssertions;
using Shouldly;
using Wemogy.Core.Errors.Exceptions;
using Wemogy.Infrastructure.Database.Core.Attributes;
using Wemogy.Infrastructure.Database.Core.Extensions;
Expand Down Expand Up @@ -27,12 +27,12 @@ public void ThrowIfNotSoftDeletableShouldWork(Type type, bool expectedToBeSoftDe
// Assert
if (expectedToBeSoftDeletable)
{
exception.Should().BeNull();
exception.ShouldBeNull();
}
else
{
exception.Should().NotBeNull();
exception.Should().BeOfType<UnexpectedErrorException>();
exception.ShouldNotBeNull();
exception.ShouldBeOfType<UnexpectedErrorException>();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Threading.Tasks;
using FluentAssertions;
using Shouldly;
using Wemogy.Infrastructure.Database.Core.UnitTests.Fakes.Entities;
using Xunit;

Expand All @@ -22,8 +22,8 @@ public async Task CountAsync_ShouldReturnTotalCountForeachDatabase()
var msUsersCount = await MicrosoftUserRepository.CountAsync(x => true);
var appleUsersCount = await AppleUserRepository.CountAsync(x => true);

msUsersCount.Should().Be(2);
appleUsersCount.Should().Be(1);
msUsersCount.ShouldBe(2);
appleUsersCount.ShouldBe(1);
}

[Fact]
Expand All @@ -41,8 +41,8 @@ public async Task CountAsync_ShouldSupportFilteringForeachDatabase()
var msUsersCount = await MicrosoftUserRepository.CountAsync(x => x.Id == user1.Id);
var appleUsersCount = await AppleUserRepository.CountAsync(x => x.Id == user1.Id);

msUsersCount.Should().Be(1);
appleUsersCount.Should().Be(1);
msUsersCount.ShouldBe(1);
appleUsersCount.ShouldBe(1);
}

[Fact]
Expand All @@ -60,7 +60,7 @@ public async Task CountAsync_ShouldReturnNullIfNoMatchesForeachDatabase()
var msUsersCount = await MicrosoftUserRepository.CountAsync(x => false);
var appleUsersCount = await AppleUserRepository.CountAsync(x => false);

msUsersCount.Should().Be(0);
appleUsersCount.Should().Be(0);
msUsersCount.ShouldBe(0);
appleUsersCount.ShouldBe(0);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Threading.Tasks;
using FluentAssertions;
using Shouldly;
using Wemogy.Infrastructure.Database.Core.UnitTests.Fakes.Entities;
using Xunit;

Expand All @@ -20,8 +20,8 @@ public async Task CreateAsync_ShouldReturnTwoDifferentCreatedEntities()
var appleEntity = await AppleUserRepository.CreateAsync(appleUser);

// Act & Assert
msEntity.Should().BeEquivalentTo(msUser);
appleEntity.Should().BeEquivalentTo(appleUser);
msEntity.ShouldBeEquivalentTo(msUser);
appleEntity.ShouldBeEquivalentTo(appleUser);
AssertPartitionKeyPrefixIsRemoved(msEntity);
AssertPartitionKeyPrefixIsRemoved(appleEntity);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Threading.Tasks;
using FluentAssertions;
using Shouldly;
using Wemogy.Core.Errors.Exceptions;
using Wemogy.Infrastructure.Database.Core.UnitTests.Fakes.Entities;
using Xunit;
Expand All @@ -24,8 +24,8 @@ public async Task DeleteByIdAsync_ShouldDeleteFromCorrectTenant()
var msEntities = await MicrosoftUserRepository.GetAllAsync();
var appleEntities = await AppleUserRepository.GetAllAsync();

msEntities.Count.Should().Be(2);
appleEntities.Count.Should().Be(2);
msEntities.Count.ShouldBe(2);
appleEntities.Count.ShouldBe(2);

// Act
await MicrosoftUserRepository.DeleteAsync(user1.Id);
Expand All @@ -35,10 +35,10 @@ public async Task DeleteByIdAsync_ShouldDeleteFromCorrectTenant()
msEntities = await MicrosoftUserRepository.GetAllAsync();
appleEntities = await AppleUserRepository.GetAllAsync();

msEntities.Count.Should().Be(1);
msEntities.Should().ContainSingle(u => u.Id == user2.Id);
appleEntities.Count.Should().Be(1);
appleEntities.Should().ContainSingle(u => u.Id == user1.Id);
msEntities.Count.ShouldBe(1);
msEntities.ShouldContain(u => u.Id == user2.Id, 1);
appleEntities.Count.ShouldBe(1);
appleEntities.ShouldContain(u => u.Id == user1.Id, 1);
}

[Fact]
Expand All @@ -57,8 +57,8 @@ public async Task DeleteByIdAndTenantIdAsync_ShouldDeleteFromCorrectTenant()
var msEntities = await MicrosoftUserRepository.GetAllAsync();
var appleEntities = await AppleUserRepository.GetAllAsync();

msEntities.Count.Should().Be(2);
appleEntities.Count.Should().Be(2);
msEntities.Count.ShouldBe(2);
appleEntities.Count.ShouldBe(2);

// Act
await MicrosoftUserRepository.DeleteAsync(
Expand All @@ -72,10 +72,10 @@ await AppleUserRepository.DeleteAsync(
msEntities = await MicrosoftUserRepository.GetAllAsync();
appleEntities = await AppleUserRepository.GetAllAsync();

msEntities.Count.Should().Be(1);
msEntities.Should().ContainSingle(u => u.Id == user2.Id);
appleEntities.Count.Should().Be(1);
appleEntities.Should().ContainSingle(u => u.Id == user1.Id);
msEntities.Count.ShouldBe(1);
msEntities.ShouldContain(u => u.Id == user2.Id, 1);
appleEntities.Count.ShouldBe(1);
appleEntities.ShouldContain(u => u.Id == user1.Id, 1);
}

[Fact]
Expand All @@ -94,8 +94,8 @@ public async Task DeleteByPredicateAsync_ShouldDeleteFromCorrectTenant()
var msEntities = await MicrosoftUserRepository.GetAllAsync();
var appleEntities = await AppleUserRepository.GetAllAsync();

msEntities.Count.Should().Be(2);
appleEntities.Count.Should().Be(2);
msEntities.Count.ShouldBe(2);
appleEntities.Count.ShouldBe(2);

// Act
await MicrosoftUserRepository.DeleteAsync(u => u.Firstname == user1.Firstname);
Expand All @@ -105,10 +105,10 @@ public async Task DeleteByPredicateAsync_ShouldDeleteFromCorrectTenant()
msEntities = await MicrosoftUserRepository.GetAllAsync();
appleEntities = await AppleUserRepository.GetAllAsync();

msEntities.Count.Should().Be(1);
msEntities.Should().ContainSingle(u => u.Id == user2.Id);
appleEntities.Count.Should().Be(1);
appleEntities.Should().ContainSingle(u => u.Id == user1.Id);
msEntities.Count.ShouldBe(1);
msEntities.ShouldContain(u => u.Id == user2.Id, 1);
appleEntities.Count.ShouldBe(1);
appleEntities.ShouldContain(u => u.Id == user1.Id, 1);
}

[Fact]
Expand All @@ -127,8 +127,8 @@ public async Task DeleteByPredicateForPartitionKeyAsync_ShouldDeleteFromCorrectT
// Assert
var msEntities = await MicrosoftUserRepository.GetAllAsync();

msEntities.Should().HaveCount(1);
msEntities.Should().ContainSingle(u => u.Id == user1.Id);
msEntities.ShouldHaveSingleItem();
msEntities.ShouldContain(u => u.Id == user1.Id, 1);
}

[Fact]
Expand All @@ -146,7 +146,7 @@ public async Task DeleteShouldThrowIfNotExists()
"tenantId"));

// Assert
exception1.Should().BeOfType<NotFoundErrorException>();
exception1.ShouldBeOfType<NotFoundErrorException>();
AssertExceptionMessageDoesNotContainPrefix(exception1);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Threading.Tasks;
using FluentAssertions;
using Shouldly;
using Wemogy.Infrastructure.Database.Core.UnitTests.Fakes.Entities;
using Xunit;

Expand All @@ -20,7 +20,7 @@ public async Task EnsureExistsByIdMultipleAsync_ShouldWorkIfItemWasFound()
AssertExceptionMessageDoesNotContainPrefix(exception);

// Assert
exception.Should().BeNull();
exception.ShouldBeNull();
}

[Fact]
Expand All @@ -38,7 +38,7 @@ await Record.ExceptionAsync(
AssertExceptionMessageDoesNotContainPrefix(exception);

// Assert
exception.Should().BeNull();
exception.ShouldBeNull();
}

[Fact]
Expand All @@ -58,7 +58,7 @@ await Record.ExceptionAsync(
AssertExceptionMessageDoesNotContainPrefix(exception);

// Assert
exception.Should().BeNull();
exception.ShouldBeNull();
}

[Fact]
Expand All @@ -76,6 +76,6 @@ await Record.ExceptionAsync(
AssertExceptionMessageDoesNotContainPrefix(exception);

// Assert
exception.Should().BeNull();
exception.ShouldBeNull();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Threading.Tasks;
using FluentAssertions;
using Shouldly;
using Wemogy.Infrastructure.Database.Core.UnitTests.Fakes.Entities;
using Xunit;

Expand All @@ -20,8 +20,8 @@ public async Task ExistsByIdMultipleAsync_ShouldWorkIfItemWasFound()
var appleExists = await AppleUserRepository.ExistsAsync(user.Id);

// Assert
msExists.Should().BeTrue();
appleExists.Should().BeFalse();
msExists.ShouldBeTrue();
appleExists.ShouldBeFalse();
}

[Fact]
Expand All @@ -37,7 +37,7 @@ public async Task ExistsByPredicate_ShouldWork()
var appleExists = await AppleUserRepository.ExistsAsync(x => x.Id == user.Id && x.TenantId == user.TenantId);

// Assert
msExists.Should().BeTrue();
appleExists.Should().BeFalse();
msExists.ShouldBeTrue();
appleExists.ShouldBeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using FluentAssertions;
using Shouldly;
using Wemogy.Infrastructure.Database.Core.UnitTests.Fakes.Entities;
using Xunit;

Expand Down Expand Up @@ -30,8 +30,8 @@ public async Task GetAllAsyncMultiple_ShouldOnlyGetFromCorrectPartition()
AssertPartitionKeyPrefixIsRemoved(appleUserFromDb);

// Assert
msUserFromDb.Should().BeEquivalentTo(new List<User> { msUser });
appleUserFromDb.Should().BeEquivalentTo(new List<User> { appleUser1, appleUser2, appleUser3 });
msUserFromDb.ShouldBeEquivalentTo(new List<User> { msUser });
appleUserFromDb.ShouldBeEquivalentTo(new List<User> { appleUser1, appleUser2, appleUser3 });
}

[Fact]
Expand All @@ -56,7 +56,7 @@ public async Task GetAllAsyncMultiple_ShouldOnlyGetFromCorrectPartitionEvenIfThe
AssertPartitionKeyPrefixIsRemoved(appleUserFromDb);

// Assert
msUserFromDb.Should().BeEquivalentTo(new List<User> { msUser });
appleUserFromDb.Should().BeEquivalentTo(new List<User> { appleUser1, appleUser2, appleUser3 });
msUserFromDb.ShouldBeEquivalentTo(new List<User> { msUser });
appleUserFromDb.ShouldBeEquivalentTo(new List<User> { appleUser1, appleUser2, appleUser3 });
}
}
Loading
Loading