當前位置: 首頁>>代碼示例>>C#>>正文


C# DriverUnitTests.FailPoint類代碼示例

本文整理匯總了C#中MongoDB.DriverUnitTests.FailPoint的典型用法代碼示例。如果您正苦於以下問題:C# FailPoint類的具體用法?C# FailPoint怎麽用?C# FailPoint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FailPoint類屬於MongoDB.DriverUnitTests命名空間,在下文中一共展示了FailPoint類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestEvalWithMaxTime

 public void TestEvalWithMaxTime()
 {
     if (_primary.Supports(FeatureId.MaxTime) && _primary.InstanceType != MongoServerInstanceType.ShardRouter)
     {
         using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
         {
             if (failpoint.IsSupported())
             {
                 failpoint.SetAlwaysOn();
                 var args = new EvalArgs
                 {
                     Code = "return 0;",
                     MaxTime = TimeSpan.FromMilliseconds(1)
                 };
                 Assert.Throws<ExecutionTimeoutException>(() => _database.Eval(args));
             }
         }
     }
 }
開發者ID:KeithLee208,項目名稱:mongo-csharp-driver,代碼行數:19,代碼來源:MongoDatabaseTests.cs

示例2: TestFindOneAsWithMaxTime

        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));
                    }
                }
            }
        }
開發者ID:rjvranjan80,項目名稱:mongo-csharp-driver,代碼行數:18,代碼來源:MongoCollectionTests.cs

示例3: TestFindWithMaxTime

        public void TestFindWithMaxTime()
        {
            if (_primary.Supports(FeatureId.MaxTime))
            {
                using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
                {
                    if (failpoint.IsSupported())
                    {
                        if (_collection.Exists()) { _collection.Drop(); }
                        _collection.Insert(new BsonDocument("x", 1));

                        failpoint.SetAlwaysOn();
                        var maxTime = TimeSpan.FromMilliseconds(1);
                        Assert.Throws<ExecutionTimeoutException>(() => _collection.FindAll().SetMaxTime(maxTime).ToList());
                    }
                }
            }
        }
開發者ID:rjvranjan80,項目名稱:mongo-csharp-driver,代碼行數:18,代碼來源:MongoCollectionTests.cs

示例4: TestMapReduceInlineWithMaxTime

        public void TestMapReduceInlineWithMaxTime()
        {
            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)); // make sure collection has at least one document so map gets called

                        failpoint.SetAlwaysOn();
                        var args = new MapReduceArgs
                        {
                            MapFunction = "function() { }",
                            ReduceFunction = "function(key, value) { return 0; }",
                            MaxTime = TimeSpan.FromMilliseconds(1)
                        };
                        Assert.Throws<ExecutionTimeoutException>(() => _collection.MapReduce(args));
                    }
                }
            }
        }
開發者ID:rjvranjan80,項目名稱:mongo-csharp-driver,代碼行數:23,代碼來源:MongoCollectionTests.cs

示例5: TestFindAndRemoveWithMaxTime

 public void TestFindAndRemoveWithMaxTime()
 {
     if (_primary.Supports(FeatureId.MaxTime))
     {
         using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
         {
             if (failpoint.IsSupported())
             {
                 failpoint.SetAlwaysOn();
                 var args = new FindAndRemoveArgs { MaxTime = TimeSpan.FromMilliseconds(1) };
                 Assert.Throws<ExecutionTimeoutException>(() => _collection.FindAndRemove(args));
             }
         }
     }
 }
開發者ID:rjvranjan80,項目名稱:mongo-csharp-driver,代碼行數:15,代碼來源:MongoCollectionTests.cs

示例6: TestGeoNearWithMaxTime

        public void TestGeoNearWithMaxTime()
        {
            if (_primary.Supports(FeatureId.MaxTime))
            {
                using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
                {
                    if (failpoint.IsSupported())
                    {
                        if (_collection.Exists()) { _collection.Drop(); }
                        _collection.Insert(new BsonDocument("loc", new BsonArray { 0, 0 }));
                        _collection.EnsureIndex(IndexKeys.GeoSpatial("loc"));

                        failpoint.SetAlwaysOn();
                        var args = new GeoNearArgs
                        {
                            Near = GeoNearPoint.From(0, 0),
                            MaxTime = TimeSpan.FromMilliseconds(1)
                        };
                        Assert.Throws<ExecutionTimeoutException>(() => _collection.GeoNearAs<BsonDocument>(args));
                    }
                }
            }
        }
開發者ID:rjvranjan80,項目名稱:mongo-csharp-driver,代碼行數:23,代碼來源:MongoCollectionTests.cs

示例7: TestAggregateMaxTime

        public void TestAggregateMaxTime()
        {
            if (_primary.Supports(FeatureId.MaxTime))
            {
                using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
                {
                    if (failpoint.IsSupported())
                    {
                        _collection.RemoveAll();
                        _collection.DropAllIndexes();
                        _collection.Insert(new BsonDocument("x", 1));

                        failpoint.SetAlwaysOn();
                        var args = new AggregateArgs
                        {
                            Pipeline = new BsonDocument[]
                            {
                                new BsonDocument("$match", Query.Exists("_id").ToBsonDocument())
                            },
                            MaxTime = TimeSpan.FromMilliseconds(1)
                        };
                        var query = _collection.Aggregate(args);
                        Assert.Throws<ExecutionTimeoutException>(() => query.ToList());
                    }
                }
            }
        }
開發者ID:rjvranjan80,項目名稱:mongo-csharp-driver,代碼行數:27,代碼來源:MongoCollectionTests.cs

示例8: TestGeoHaystackSearchWithMaxTime

        public void TestGeoHaystackSearchWithMaxTime()
        {
            if (_primary.Supports(FeatureId.MaxTime))
            {
                if (_primary.InstanceType != MongoServerInstanceType.ShardRouter)
                {
                    using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
                    {
                        if (failpoint.IsSupported())
                        {
                            if (_collection.Exists()) { _collection.Drop(); }
                            _collection.Insert(new Place { Location = new[] { 34.2, 33.3 }, Type = "restaurant" });
                            _collection.Insert(new Place { Location = new[] { 34.2, 37.3 }, Type = "restaurant" });
                            _collection.Insert(new Place { Location = new[] { 59.1, 87.2 }, Type = "office" });
                            _collection.EnsureIndex(IndexKeys.GeoSpatialHaystack("Location", "Type"), IndexOptions.SetBucketSize(1));

                            failpoint.SetAlwaysOn();
                            var args = new GeoHaystackSearchArgs
                            {
                                Near = GeoNearPoint.From(33, 33),
                                AdditionalFieldName = "Type",
                                AdditionalFieldValue = "restaurant",
                                Limit = 30,
                                MaxDistance = 6,
                                MaxTime = TimeSpan.FromMilliseconds(1)
                            };
                            Assert.Throws<ExecutionTimeoutException>(() => _collection.GeoHaystackSearchAs<Place>(args));
                        }
                    }
                }
            }
        }
開發者ID:rjvranjan80,項目名稱:mongo-csharp-driver,代碼行數:32,代碼來源:MongoCollectionTests.cs

示例9: TestDistinctWithMaxTime

        public void TestDistinctWithMaxTime()
        {
            if (_primary.Supports(FeatureId.MaxTime))
            {
                using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
                {
                    if (failpoint.IsSupported())
                    {
                        _collection.Drop();
                        _collection.Insert(new BsonDocument("x", 1)); // ensure collection is not empty

                        failpoint.SetAlwaysOn();
                        var args = new DistinctArgs
                        {
                            Key = "x",
                            MaxTime = TimeSpan.FromMilliseconds(1)
                        };
                        Assert.Throws<ExecutionTimeoutException>(() => _collection.Distinct<BsonValue>(args));
                    }
                }
            }
        }
開發者ID:RepoCorp,項目名稱:mongo-csharp-driver,代碼行數:22,代碼來源:MongoCollectionTests.cs

示例10: TestValidateWithMaxTime

        public void TestValidateWithMaxTime()
        {
            if (_primary.Supports(FeatureId.MaxTime))
            {
                using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
                {
                    var instance = _server.RequestConnection.ServerInstance; // FailPoint did a RequestStart
                    if (instance.InstanceType != MongoServerInstanceType.ShardRouter)
                    {
                        if (failpoint.IsSupported())
                        {
                            _collection.Drop();
                            _collection.Insert(new BsonDocument("x", 1)); // ensure collection is not empty

                            failpoint.SetAlwaysOn();
                            var args = new ValidateCollectionArgs
                            {
                                MaxTime = TimeSpan.FromMilliseconds(1)
                            };
                            Assert.Throws<ExecutionTimeoutException>(() => _collection.Validate(args));
                        }
                    }
                }
            }
        }
開發者ID:RepoCorp,項目名稱:mongo-csharp-driver,代碼行數:25,代碼來源:MongoCollectionTests.cs

示例11: TestGroupWithMaxTime

        public void TestGroupWithMaxTime()
        {
            if (_primary.Supports(FeatureId.MaxTime))
            {
                using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
                {
                    if (failpoint.IsSupported())
                    {
                        _collection.Drop();
                        _collection.Insert(new BsonDocument("x", 1)); // ensure collection is not empty

                        failpoint.SetAlwaysOn();
                        var args = new GroupArgs
                        {
                            KeyFields = GroupBy.Keys("x"),
                            Initial = new BsonDocument("count", 0),
                            ReduceFunction = "function(doc, prev) { prev.count += 1 }",
                            MaxTime = TimeSpan.FromMilliseconds(1)
                        };
                        Assert.Throws<ExecutionTimeoutException>(() => _collection.Group(args));
                    }
                }
            }
        }
開發者ID:RepoCorp,項目名稱:mongo-csharp-driver,代碼行數:24,代碼來源:MongoCollectionTests.cs

示例12: TestFindAndModifyWithMaxTime

 public void TestFindAndModifyWithMaxTime()
 {
     if (_primary.Supports(FeatureId.MaxTime) && _primary.Supports(FeatureId.FailPoints))
     {
         using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
         {
             failpoint.SetAlwaysOn();
             var args = new FindAndModifyArgs
             {
                 Update = Update.Set("x", 1),
                 MaxTime = TimeSpan.FromMilliseconds(1)
             };
             Assert.Throws<ExecutionTimeoutException>(() => _collection.FindAndModify(args));
         }
     }
 }
開發者ID:JamesWiliamson,項目名稱:mongo-csharp-driver,代碼行數:16,代碼來源:MongoCollectionTests.cs


注:本文中的MongoDB.DriverUnitTests.FailPoint類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。