• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Tests.FailPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MongoDB.Driver.Tests.FailPoint的典型用法代码示例。如果您正苦于以下问题:C# FailPoint类的具体用法?C# FailPoint怎么用?C# FailPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FailPoint类属于MongoDB.Driver.Tests命名空间,在下文中一共展示了FailPoint类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestFindAndModifyWithMaxTime

 public void TestFindAndModifyWithMaxTime()
 {
     if (_primary.Supports(FeatureId.MaxTime))
     {
         using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
         {
             if (failpoint.IsSupported())
             {
                 failpoint.SetAlwaysOn();
                 var args = new FindAndModifyArgs
                 {
                     Update = Update.Set("x", 1),
                     MaxTime = TimeSpan.FromMilliseconds(1)
                 };
                 Assert.Throws<MongoExecutionTimeoutException>(() => _collection.FindAndModify(args));
             }
         }
     }
 }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:19,代码来源:MongoCollectionTests.cs


示例2: TestCountWithMaxTimeFromFind

 public void TestCountWithMaxTimeFromFind()
 {
     if (_primary.Supports(FeatureId.MaxTime))
     {
         using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
         {
             if (failpoint.IsSupported())
             {
                 failpoint.SetAlwaysOn();
                 Assert.Throws<MongoExecutionTimeoutException>(() => _collection.Find(Query.EQ("x", 1)).SetMaxTime(TimeSpan.FromMilliseconds(1)).Count());
             }
         }
     }
 }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:14,代码来源:MongoCollectionTests.cs


示例3: 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<MongoExecutionTimeoutException>(() => _collection.Distinct<BsonValue>(args));
                    }
                }
            }
        }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:22,代码来源: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<MongoExecutionTimeoutException>(() => _collection.MapReduce(args));
                    }
                }
            }
        }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:23,代码来源:MongoCollectionTests.cs


示例5: TestValidateWithMaxTime

        public void TestValidateWithMaxTime()
        {
            if (_primary.Supports(FeatureId.MaxTime) && _primary.InstanceType != MongoServerInstanceType.ShardRouter)
            {
                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 ValidateCollectionArgs
                        {
                            MaxTime = TimeSpan.FromMilliseconds(1)
                        };
                        Assert.Throws<MongoExecutionTimeoutException>(() => _collection.Validate(args));
                    }
                }
            }
        }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:21,代码来源: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.CreateIndex(IndexKeys.GeoSpatial("loc"));

                        failpoint.SetAlwaysOn();
                        var args = new GeoNearArgs
                        {
                            Near = new XYPoint(0, 0),
                            MaxTime = TimeSpan.FromMilliseconds(1)
                        };
                        Assert.Throws<MongoExecutionTimeoutException>(() => _collection.GeoNearAs<BsonDocument>(args));
                    }
                }
            }
        }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:23,代码来源:MongoCollectionTests.cs


示例7: 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<MongoExecutionTimeoutException>(() => _collection.Group(args));
                    }
                }
            }
        }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:24,代码来源: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.CreateIndex(IndexKeys.GeoSpatialHaystack("Location", "Type"), IndexOptions.SetBucketSize(1));

                            failpoint.SetAlwaysOn();
                            var args = new GeoHaystackSearchArgs
                            {
                                Near = new XYPoint(33, 33),
                                AdditionalFieldName = "Type",
                                AdditionalFieldValue = "restaurant",
                                Limit = 30,
                                MaxDistance = 6,
                                MaxTime = TimeSpan.FromMilliseconds(1)
                            };
                            Assert.Throws<MongoExecutionTimeoutException>(() => _collection.GeoHaystackSearchAs<Place>(args));
                        }
                    }
                }
            }
        }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:32,代码来源:MongoCollectionTests.cs


示例9: 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 query = _collection.Aggregate(new AggregateArgs
                        {
                            Pipeline = new BsonDocument[]
                            {
                                new BsonDocument("$match", Query.Exists("_id").ToBsonDocument())
                            },
                            MaxTime = TimeSpan.FromMilliseconds(1)
                        });
                        Assert.Throws<MongoExecutionTimeoutException>(() => query.ToList());
                    }
                }
            }
        }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:26,代码来源:MongoCollectionTests.cs


示例10: 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<MongoExecutionTimeoutException>(() => _collection.FindAll().SetMaxTime(maxTime).ToList());
                    }
                }
            }
        }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:18,代码来源:MongoCollectionTests.cs


示例11: 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<MongoExecutionTimeoutException>(() => _collection.FindOneAs(typeof(TestClass), args));
                    }
                }
            }
        }
开发者ID:p3p3pp3,项目名称:mongo-csharp-driver-for-tokumx,代码行数:18,代码来源:MongoCollectionTests.cs


示例12: TestCountWithMaxTime

 public void TestCountWithMaxTime()
 {
     if (_primary.Supports(FeatureId.MaxTime))
     {
         using (var failpoint = new FailPoint(FailPointName.MaxTimeAlwaysTimeout, _server, _primary))
         {
             if (failpoint.IsSupported())
             {
                 failpoint.SetAlwaysOn();
                 var args = new CountArgs { MaxTime = TimeSpan.FromMilliseconds(1) };
                 Assert.Throws<ExecutionTimeoutException>(() => _collection.Count(args));
             }
         }
     }
 }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:15,代码来源:MongoCollectionTests.cs


示例13: TestEvalWithMaxTime

 public void TestEvalWithMaxTime()
 {
     if (!DriverTestConfiguration.Client.Settings.Credentials.Any())
     {
         if (_primary.Supports(FeatureId.MaxTime))
         {
             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<MongoExecutionTimeoutException>(() => _adminDatabase.Eval(args));
                 }
             }
         }
     }
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:22,代码来源:MongoDatabaseTests.cs


示例14: TestEvalWithMaxTime

 public void TestEvalWithMaxTime()
 {
     if (_primary.Supports(FeatureId.MaxTime))
     {
         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:GGsus,项目名称:mongo-csharp-driver,代码行数:19,代码来源:MongoDatabaseTests.cs



注:本文中的MongoDB.Driver.Tests.FailPoint类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DriverUnitTests.FailPoint类代码示例发布时间:2022-05-26
下一篇:
C# GridFS.MongoGridFSSettings类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap