Skip to content

Commit

Permalink
switch mongodb back to linqv2
Browse files Browse the repository at this point in the history
  • Loading branch information
glucaci committed Apr 22, 2024
1 parent beee3be commit 2c2d94d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Server/src/Store.Mongo/IdOpsDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Serializers;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using MongoDB.Extensions.Context;
using Environment = IdOps.Model.Environment;

Expand All @@ -25,6 +26,7 @@ protected override void OnConfiguring(IMongoDatabaseBuilder builder)
{
builder
.RegisterSerializer(new DateTimeOffsetSerializer(BsonType.String))
.ConfigureConnection(con => con.LinqProvider = LinqProvider.V2)
.ConfigureConnection(con => con.ReadConcern = ReadConcern.Majority)
.ConfigureConnection(con => con.WriteConcern = WriteConcern.WMajority)
.ConfigureConnection(con => con.ReadPreference = ReadPreference.Primary)
Expand Down
14 changes: 8 additions & 6 deletions src/Server/test/Store.Mongo.Tests/IdentityResourceStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ public async Task GetAllTest_AssertResult()
{
// Arrange
IIdOpsDbContext context = CreateDbContext();

await context.IdentityResources.InsertManyAsync(TestData.GetIdentityResources());

var store = new IdentityResourceStore(context);
var id = Guid.Parse("00000000-0001-0000-0000-000000000000");
var tenant = "bar";

// Act
IReadOnlyList<IdentityResource> result = await store.GetAllAsync(default, default, default);
IReadOnlyList<IdentityResource> result = await store.GetAllAsync(
new[] { id },
new[] { tenant },
default);

// Assert
result.Count.Should().Be(2);
result[0].Id.Should().Be(Guid.Parse("00000000-0001-0000-0000-000000000000"));
result[1].Id.Should().Be(Guid.Parse("00000000-0002-0000-0000-000000000000"));
result.Count.Should().Be(1);
result[0].Id.Should().Be(id);
}

private IIdOpsDbContext CreateDbContext()
Expand Down

0 comments on commit 2c2d94d

Please sign in to comment.