Skip to content

Commit

Permalink
v9.1.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
vova3211 committed Dec 23, 2024
1 parent 92c8bce commit 1d9d84e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
52 changes: 26 additions & 26 deletions Tests/MigrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ public class MigrationTests
[OneTimeSetUp]
public void OneTimeSetup()
{
var runner = Mongo2Go.MongoDbRunner.Start();
_client = new MongoClient(runner.ConnectionString);
_db = _client.GetDatabase("migration-tests");
_runner = runner;
}
var runner = Mongo2Go.MongoDbRunner.Start();
_client = new MongoClient(runner.ConnectionString);
_db = _client.GetDatabase("migration-tests");
_runner = runner;
}

[OneTimeTearDown]
public void OneTimeTearDown()
{
_runner.Dispose();
}
_runner.Dispose();
}

[Test, Category("unit")]
public void Apply_Schema4_AllMigrationsApplied()
{
// ARRANGE
var history = _db.GetCollection<MigrationHistory>("migrations");
var users = _db.GetCollection<MigrationMongoUser>("users");
var roles = _db.GetCollection<MongoRole<ObjectId>>("roles");
var initialVersion = 4;
var existingHistory = new List<MigrationHistory>
// ARRANGE
var history = _db.GetCollection<MigrationHistory>("migrations");
var users = _db.GetCollection<MigrationMongoUser>("users");
var roles = _db.GetCollection<MongoRole<ObjectId>>("roles");
var initialVersion = 4;
var existingHistory = new List<MigrationHistory>
{
new MigrationHistory
{
Expand All @@ -54,21 +54,21 @@ public void Apply_Schema4_AllMigrationsApplied()
InstalledOn = DateTime.UtcNow.AddDays(-1)
}
};
history.InsertMany(existingHistory);
history.InsertMany(existingHistory);


// ACT
Migrator.Apply<MigrationMongoUser, MongoRole<ObjectId>, ObjectId>(history, users, roles);
// ACT
Migrator.Apply<MigrationMongoUser, MongoRole<ObjectId>, ObjectId>(history, users, roles);

// ASSERT
var historyAfter = history
.Find("{}")
.SortBy(h => h.DatabaseVersion)
.ToList();
// ASSERT
var historyAfter = history
.Find("{}")
.SortBy(h => h.DatabaseVersion)
.ToList();

var expectedHistoryObjectsAfter = Migrator.CurrentVersion - initialVersion + existingHistory.Count;
Assert.That(historyAfter.Count, Is.EqualTo(expectedHistoryObjectsAfter),
() => "Expected all migrations to run");
Assert.That(historyAfter.Last().DatabaseVersion, Is.EqualTo(Migrator.CurrentVersion));
}
var expectedHistoryObjectsAfter = Migrator.CurrentVersion - initialVersion + existingHistory.Count;
Assert.That(historyAfter.Count, Is.EqualTo(expectedHistoryObjectsAfter),
() => "Expected all migrations to run");
Assert.That(historyAfter.Last().DatabaseVersion, Is.EqualTo(Migrator.CurrentVersion));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<Authors>Matteo Fabbri</Authors>
<Company />
<Product>AspNetCore.Identity.Mongo</Product>
<Version>9.1.1</Version>
<AssemblyVersion>9.1.1.0</AssemblyVersion>
<FileVersion>9.1.1.0</FileVersion>
<Version>9.1.2</Version>
<AssemblyVersion>9.1.2.0</AssemblyVersion>
<FileVersion>9.1.2.0</FileVersion>
<PackageProjectUrl>https://github.com/matteofabbri/AspNetCore.Identity.Mongo</PackageProjectUrl>
<NeutralLanguage />
<PackageReleaseNotes>Removed obsolete properties.</PackageReleaseNotes>
Expand Down
5 changes: 4 additions & 1 deletion src/AspNetCore.Identity.Mongo/MongoIdentityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public static IdentityBuilder AddIdentityMongoDbProvider<TUser, TRole, TKey>(thi

// apply migrations before identity services resolved
if (!dbOptions.DisableAutoMigrations)
Migrator.Apply<MigrationMongoUser<TKey>, TRole, TKey>(migrationCollection, migrationUserCollection, roleCollection);
{
Migrator.Apply<MigrationMongoUser<TKey>, TRole, TKey>(
migrationCollection, migrationUserCollection, roleCollection);
}

var builder = services.AddIdentity<TUser, TRole>(setupIdentityAction ?? (x => { }));

Expand Down

0 comments on commit 1d9d84e

Please # to comment.