public async Task IdenticalItemsMatchIgnoringItemsFilteredOutAsync() { var now = DateTime.Now; await AddItemToCollection1Async(0, "Item1", 1, now, new BsonDocument("Foo", "1").AddRange(new BsonDocument("Bar", 0))); await AddItemToCollection1Async(0, "Item2", 21, now.AddDays(1), new BsonDocument("FooBar", "2").AddRange(new BsonDocument("BarFoo", 1))); await AddItemToCollection2Async(0, "Item1", 1, now, new BsonDocument("Foo", "1").AddRange(new BsonDocument("Bar", 0))); await AddItemToCollection2Async(0, "Item2", 21, now.AddDays(1), new BsonDocument("FooBar", "2").AddRange(new BsonDocument("BarFoo", 1))); var item = new Item(0, "Item3", 22, now, null) { Ignore = true }; await _collection1.InsertOneAsync(item); var comparer = new MongoDbComparer <Item>(ConnectionString1, Database1, Collection1, ConnectionString2, Database2, Collection2, filter: i => !i.Ignore); var results = await comparer.CompareAsync(i => i.Name); results.Match.Should().BeTrue(); results.OnlyInCollection1.Should().BeEmpty(); results.OnlyInCollection2.Should().BeEmpty(); results.Different.Should().BeEmpty(); }
public void SetUp() { _collection1 = new MongoClient(ConnectionString1).GetDatabase(Database1).GetCollection <Item>(Collection1); _collection2 = new MongoClient(ConnectionString2).GetDatabase(Database2).GetCollection <Item>(Collection2); _comparer = new MongoDbComparer <Item>(ConnectionString1, Database1, Collection1, ConnectionString2, Database2, Collection2); // ReSharper disable UnusedVariable var r1 = _collection1.DeleteManyAsync(i => true).Result; var r2 = _collection2.DeleteManyAsync(i => true).Result; // ReSharper restore UnusedVariable }
public async Task NonIdenticalItemsMatchIfTheNonMatchingFieldIsIgnoredAsync() { var now = DateTime.Now; await AddItemToCollection1Async(0, "Item1", 1, now, new BsonDocument("Foo", "1").AddRange(new BsonDocument("Bar", 0))); await AddItemToCollection1Async(0, "Item2", 1, now.AddDays(1), new BsonDocument("FooBar", "2").AddRange(new BsonDocument("BarFoo", 1))); await AddItemToCollection2Async(0, "Item1", 2, now, new BsonDocument("Foo", "1").AddRange(new BsonDocument("Bar", 0))); await AddItemToCollection2Async(0, "Item2", 2, now.AddDays(1), new BsonDocument("FooBar", "2").AddRange(new BsonDocument("BarFoo", 1))); var comparer = new MongoDbComparer <Item>(ConnectionString1, Database1, Collection1, ConnectionString2, Database2, Collection2, new[] { "Number" }); var results = await comparer.CompareAsync(i => i.Name); results.Match.Should().BeTrue(); results.OnlyInCollection1.Should().BeEmpty(); results.OnlyInCollection2.Should().BeEmpty(); results.Different.Should().BeEmpty(); }