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

Updated MongoDB Driver to 3.0.0 #144

Closed
wants to merge 4 commits into from
Closed
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: 1 addition & 0 deletions samples/MongoDb/UserRepository.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using Squadron.Samples.Shared;

namespace Squadron.Samples.Mongo
Expand Down
5 changes: 3 additions & 2 deletions samples/MongoDb/UserRepositoryTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using MongoDB.Driver;
Expand All @@ -10,7 +11,7 @@

namespace Squadron.Samples.Mongo
{
public class UserRepositoryTests : IClassFixture<MongoResource>
public class UserRepositoryTests : IClassFixture<MongoResource>
{
private readonly MongoResource _mongoResource;

Expand Down Expand Up @@ -49,7 +50,7 @@ public async Task GetAll_MatchSnapshot()
File = new FileInfo("users.json")
};

IMongoCollection<User> col = await _mongoResource
IMongoCollection<User> col = await _mongoResource
.CreateCollectionFromFileAsync<User>(db, options);

var repo = new UserRepository(db);
Expand Down
4 changes: 1 addition & 3 deletions samples/MongoDb/UserRepositoryWithTransaction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using Squadron.Samples.Shared;

namespace Squadron.Samples.Mongo
Expand Down Expand Up @@ -31,8 +32,5 @@ public async Task<IEnumerable<User>> GetAllAsync()
IMongoCollection<User> col = _mongoDatabase.GetCollection<User>("users");
return await col.AsQueryable().ToListAsync();
}



}
}
4 changes: 2 additions & 2 deletions src/AzureStorage/AzureStorage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.10.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.8.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.22.2" />
<PackageReference Include="Azure.Storage.Queues" Version="12.20.1" />
<PackageReference Include="System.Collections.Immutable" Version="1.6.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Polly" Version="7.2.4" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

</Project>
15 changes: 6 additions & 9 deletions src/Mongo.Tests/MongoReplicaSetResourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

namespace Squadron
{
public class MongoReplicaSetResourceTests
: IClassFixture<MongoReplicaSetResource>
public class MongoReplicaSetResourceTests : IClassFixture<MongoReplicaSetResource>
{
private readonly MongoReplicaSetResource _mongoRsResource;

Expand All @@ -25,13 +24,11 @@ public void CommitTransaction_NoError()
//Act
Action action = () =>
{
using (IClientSessionHandle session = _mongoRsResource.Client.StartSession())
{
IMongoCollection<BsonDocument> collection = _mongoRsResource.CreateCollection<BsonDocument>("bar");
session.StartTransaction();
collection.InsertOne(session, new BsonDocument("name", "test"));
session.CommitTransaction();
}
using IClientSessionHandle session = _mongoRsResource.Client.StartSession();
IMongoCollection<BsonDocument> collection = _mongoRsResource.CreateCollection<BsonDocument>("bar");
session.StartTransaction();
collection.InsertOne(session, new BsonDocument("name", "test"));
session.CommitTransaction();
};

//Assert
Expand Down
2 changes: 1 addition & 1 deletion src/Mongo/Mongo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.28.0" />
<PackageReference Include="MongoDB.Driver" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
21 changes: 11 additions & 10 deletions src/Mongo/MongoReplicaSetResource.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
using System;
using System;
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Driver;

namespace Squadron
{
/// <inheritdoc/>
/// <inheritdoc/>
public class MongoReplicaSetResource : MongoReplicaSetResource<MongoReplicaSetDefaultOptions> { }

/// <summary>
/// Represents a mongo database replica set resource that can be used by unit tests.
/// </summary>
/// <seealso cref="IDisposable"/>
public class MongoReplicaSetResource<TOptions> :
MongoResource<TOptions>
public class MongoReplicaSetResource<TOptions> : MongoResource<TOptions>
where TOptions : MongoReplicaSetDefaultOptions, new()
{
public override async Task InitializeAsync()
{
await base.InitializeAsync();

var client = new MongoClient(ConnectionString + "/?connect=direct");
BsonDocument rsConfig = CreateReplicaSetConfiguration();
var command = new BsonDocumentCommand<BsonDocument>(new BsonDocument
{
{"replSetInitiate", rsConfig}
});

var command = new BsonDocumentCommand<BsonDocument>(
new BsonDocument
{
{"replSetInitiate", rsConfig}
});

await client.GetDatabase("admin")
.RunCommandAsync(command);
await client.GetDatabase("admin").RunCommandAsync(command);

await Initializer.WaitAsync(new MongoReplicaSetStatus(ConnectionString));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mongo/MongoResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private MongoClient GetClient()
{
return new MongoClient(new MongoClientSettings
{
ConnectionMode = ConnectionMode.Direct,
DirectConnection = true,
ReadConcern = ReadConcern.Majority,
WriteConcern = WriteConcern.Acknowledged,
Server = new MongoServerAddress(Manager.Instance.Address, Manager.Instance.HostPort),
Expand Down
2 changes: 1 addition & 1 deletion src/Nats.Tests/Nats.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="AlterNats.Hosting" Version="1.0.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion src/PostgreSql/PostgreSql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AssemblyName>Squadron.PostgreSql</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql" Version="4.1.1" />
<PackageReference Include="Npgsql" Version="8.0.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" />
Expand Down
Loading