-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d8580e
commit ff5f075
Showing
3 changed files
with
91 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...l.Tests/Cassandra/Configuration/MultitenantConfigurator/Scenarios/Configuring_cosmosdb.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
| ||
using Cassandra; | ||
using FluentAssertions; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using StreamStore.NoSql.Cassandra.Configuration; | ||
using StreamStore.NoSql.Cassandra.Multitenancy; | ||
using StreamStore.Testing; | ||
|
||
namespace StreamStore.NoSql.Tests.Cassandra.Configuration.MultitenantConfigurator; | ||
|
||
public class Configuring_cosmosdb: Scenario | ||
{ | ||
|
||
[Fact] | ||
public void When_connection_string_is_not_set() | ||
{ | ||
// Arrange | ||
var configuration = new ConfigurationBuilder().Build(); | ||
var configurator = new CassandraMultitenantConfigurator(); | ||
|
||
// Act | ||
var act = () => configurator.UseCosmosDb(configuration); | ||
|
||
//Assert | ||
act.Should().Throw<ArgumentException>(); | ||
} | ||
|
||
|
||
[Fact] | ||
public void When_connection_string_is_defined() | ||
{ | ||
// Arrange | ||
var configurator = new CassandraMultitenantConfigurator(); | ||
var services = new ServiceCollection(); | ||
var connectionString = "HostName=azure.com;Username=streamstore;Password=xxxxxxxxxxx;Port=10350"; | ||
|
||
var inMemoryConfig = new Dictionary<string, string?>() | ||
{ | ||
{ "ConnectionStrings:StreamStore", connectionString }, | ||
}; | ||
var configuration = new ConfigurationBuilder().AddInMemoryCollection(inMemoryConfig).Build(); | ||
|
||
// Act | ||
configurator | ||
.UseCosmosDb(configuration) | ||
.WithKeyspaceProvider<FakeKeyspaceProvider>(); | ||
configurator.Configure(services); | ||
var provider = services.BuildServiceProvider(); | ||
|
||
// Assert | ||
var clusterConfigurator = provider.GetRequiredService<IClusterConfigurator>(); | ||
var builder = Cluster.Builder(); | ||
clusterConfigurator.Configure(builder); | ||
var cluster = builder.Build(); | ||
cluster.Should().NotBeNull(); | ||
|
||
// Arrange | ||
configurator = new CassandraMultitenantConfigurator(); | ||
services = new ServiceCollection(); | ||
|
||
// Act | ||
configurator | ||
.UseCosmosDb(connectionString) | ||
.WithKeyspaceProvider<FakeKeyspaceProvider>(); | ||
configurator.Configure(services); | ||
provider = services.BuildServiceProvider(); | ||
|
||
// Assert | ||
clusterConfigurator = provider.GetRequiredService<IClusterConfigurator>(); | ||
builder = Cluster.Builder(); | ||
clusterConfigurator.Configure(builder); | ||
cluster = builder.Build(); | ||
cluster.Should().NotBeNull(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters