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
1 change: 0 additions & 1 deletion src/Liquid.Repository.Mongo/Exceptions/MongoException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace Liquid.Repository.Mongo.Exceptions
/// Occurs when an exception has occurred in Mongo Db.
/// </summary>
/// <seealso cref="LiquidException" />
[Serializable]
[ExcludeFromCodeCoverage]
public class MongoException : LiquidException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Liquid.Repository.Mongo/MongoClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class MongoClientFactory : IMongoClientFactory
public MongoClientFactory(IOptions<MongoDbSettings> settings)
{
_mongoClients = new Dictionary<string, IMongoClient>();
_settings = settings;
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
}

///<inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public IServiceCollectionExtensionsTests()
var options = new MongoRunnerOptions
{
UseSingleNodeReplicaSet = false,
AdditionalArguments = "--quiet"
AdditionalArguments = "--quiet",
};

_runner = MongoRunner.Run(options);
Expand All @@ -43,7 +43,7 @@ public IServiceCollectionExtensionsTests()
{
{"MyMongoEntityOptions:Settings:1:DatabaseName", _databaseName},
{"MyMongoEntityOptions:Settings:1:ConnectionString", _runner.ConnectionString},
{"MyMongoEntityOptions:Settings:1:CollectionName", "TestEntity"},
{"MyMongoEntityOptions:Settings:1:CollectionName", "ATestEntity"},
{"MyMongoEntityOptions:Settings:1:ShardKey", "id"},
{"MyMongoEntityOptions:Settings:2:DatabaseName", _databaseName},
{"MyMongoEntityOptions:Settings:2:ConnectionString", _runner.ConnectionString},
Expand All @@ -60,7 +60,7 @@ public IServiceCollectionExtensionsTests()
[Fact]
public void AddLiquidMongoRepository_WhenAdded_ServicesIsFilledForTestEntity()
{
_services.AddLiquidMongoRepository<TestEntity, int>("MyMongoEntityOptions","TestEntity");
_services.AddLiquidMongoRepository<TestEntity, int>("MyMongoEntityOptions","ATestEntity");
_services.AddLiquidMongoRepository<AnotherTestEntity, int>("MyMongoEntityOptions", "AnotherTestEntity");
_serviceProvider = _services.BuildServiceProvider();
Assert.NotNull(_serviceProvider.GetService<IMongoDataContext<TestEntity>>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="EphemeralMongo.Core" Version="2.0.0" />
<PackageReference Include="EphemeralMongo6.runtime.linux-x64" Version="1.1.0" Condition="$([MSBuild]::IsOSPlatform('Linux'))" />
<PackageReference Include="EphemeralMongo6.runtime.osx-x64" Version="1.1.0" Condition="$([MSBuild]::IsOSPlatform('OSX'))" />
<PackageReference Include="EphemeralMongo6.runtime.win-x64" Version="2.0.0" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
<PackageReference Include="EphemeralMongo8.runtime.linux-x64" Version="2.0.0" Condition="$([MSBuild]::IsOSPlatform('Linux'))" />
<PackageReference Include="EphemeralMongo8.runtime.osx-x64" Version="2.0.0" Condition="$([MSBuild]::IsOSPlatform('OSX'))" />
<PackageReference Include="EphemeralMongo8.runtime.win-x64" Version="2.0.0" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.4" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
Expand Down
10 changes: 8 additions & 2 deletions test/Liquid.Repository.Mongo.Tests/MongoClientFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public MongoClientFactoryTests()
var options = new MongoRunnerOptions
{
UseSingleNodeReplicaSet = false,
AdditionalArguments = "--quiet"
AdditionalArguments = "--quiet",
};

_runner = MongoRunner.Run(options);
Expand All @@ -44,7 +44,7 @@ public MongoClientFactoryTests()
{
CollectionName = "TestEntities2",
ShardKey = "id",
ConnectionString = "incorrect connection string",
ConnectionString = "",
DatabaseName = $"{_databaseName}-2"
}
}
Expand Down Expand Up @@ -78,5 +78,11 @@ public void GetClient_WhenDatabaseSettingsIsWrong_ThrowException()
MongoEntitySettings settings = null;
Assert.Throws<MongoDB.Driver.MongoConfigurationException>(() => _sut.GetClient("TestEntities2", out settings));
}

[Fact]
public void Constructor_WhenSettingsIsNull_ThrowException()
{
Assert.Throws<ArgumentNullException>(() => new MongoClientFactory(null));
}
}
}
Loading