public void TestFindOneAsWithSkipAndSortyBy() { _collection.RemoveAll(); _collection.Insert(new BsonDocument { { "X", 2 } }); _collection.Insert(new BsonDocument { { "X", 1 } }); var sortBy = SortBy.Ascending("X"); var args = new FindOneArgs { Skip = 1, SortBy = sortBy }; var document = (TestClass)_collection.FindOneAs(typeof(TestClass), args); Assert.AreEqual(2, document.X); }
public void TestFindOneAsWithMaxTime() { if (_primary.Supports(FeatureId.MaxTime)) { using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary)) { if (failpoint.IsSupported()) { _collection.RemoveAll(); _collection.Insert(new BsonDocument { { "X", 1 } }); failpoint.SetAlwaysOn(); var args = new FindOneArgs { MaxTime = TimeSpan.FromMilliseconds(1) }; Assert.Throws<ExecutionTimeoutException>(() => _collection.FindOneAs(typeof(TestClass), args)); } } } }