public async Task CanCustomizeCollectionName() { var randomCollectionName = Guid.NewGuid().ToString("N"); var randomLockCollectionName = Guid.NewGuid().ToString("N"); var options = new Options(collectionName: randomCollectionName, lockCollectionName: randomLockCollectionName); var migrator = new Migrator(_database, new[] { new DummyStep() }, options); await migrator.ExecuteAsync(); var collectionNames = await GetCollectionNames(_database); Console.WriteLine($@"Found the following collections in the current database: {string.Join(Environment.NewLine, collectionNames.Select(name => name.PadLeft(4)))}"); Assert.That(collectionNames.OrderBy(name => name), Is.EqualTo(new[] { randomCollectionName, randomLockCollectionName }.OrderBy(name => name))); }
public async Task TryThis(int parallelism) { await Task.WhenAll(Enumerable.Range(0, parallelism) .Select(async n => { Console.WriteLine($"Starting migration {n}..."); await _migrator.ExecuteAsync(); Console.WriteLine($"Migration {n} is done!"); })); var collection = _database.GetCollection <Execution>("executions"); var executions = await collection.Find(e => true).ToListAsync(); Assert.That(executions.Count, Is.EqualTo(20)); var actualExecutions = executions.OrderBy(e => e.Sequence).Select(e => new { e.Number, e.BranchSpec }).ToArray(); var expectedExecutions = new[] { new{ Number = 1, BranchSpec = "master" }, new{ Number = 2, BranchSpec = "master" }, new{ Number = 3, BranchSpec = "master" }, new{ Number = 4, BranchSpec = "master" }, new{ Number = 5, BranchSpec = "master" }, new{ Number = 6, BranchSpec = "master" }, new{ Number = 7, BranchSpec = "master" }, new{ Number = 8, BranchSpec = "master" }, new{ Number = 9, BranchSpec = "master" }, new{ Number = 10, BranchSpec = "master" }, new{ Number = 11, BranchSpec = "master" }, new{ Number = 12, BranchSpec = "master" }, new{ Number = 13, BranchSpec = "master" }, new{ Number = 14, BranchSpec = "master" }, new{ Number = 15, BranchSpec = "master" }, new{ Number = 16, BranchSpec = "master" }, new{ Number = 17, BranchSpec = "master" }, new{ Number = 18, BranchSpec = "master" }, new{ Number = 19, BranchSpec = "master" }, new{ Number = 20, BranchSpec = "master" }, }; Assert.That(actualExecutions, Is.EqualTo(expectedExecutions)); }