当前位置: 首页>>代码示例>>C#>>正文


C# MongoServerSettings.ToClusterKey方法代码示例

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


在下文中一共展示了MongoServerSettings.ToClusterKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToClusterKey_should_copy_relevant_values

        public void ToClusterKey_should_copy_relevant_values()
        {
            var credentials = new[] { MongoCredential.CreateMongoCRCredential("source", "username", "password") };
            var servers = new[] { new MongoServerAddress("localhost") };
            var sslSettings = new SslSettings
            {
                CheckCertificateRevocation = true,
                EnabledSslProtocols = SslProtocols.Ssl3
            };

            var subject = new MongoServerSettings
            {
                ConnectionMode = ConnectionMode.Direct,
                ConnectTimeout = TimeSpan.FromSeconds(1),
                Credentials = credentials,
                GuidRepresentation = GuidRepresentation.Standard,
                IPv6 = true,
                MaxConnectionIdleTime = TimeSpan.FromSeconds(2),
                MaxConnectionLifeTime = TimeSpan.FromSeconds(3),
                MaxConnectionPoolSize = 10,
                MinConnectionPoolSize = 5,
                ReplicaSetName = "rs",
                LocalThreshold = TimeSpan.FromMilliseconds(20),
                Servers = servers,
                ServerSelectionTimeout = TimeSpan.FromSeconds(6),
                SocketTimeout = TimeSpan.FromSeconds(4),
                SslSettings = sslSettings,
                UseSsl = true,
                VerifySslCertificate = true,
                WaitQueueSize = 20,
                WaitQueueTimeout = TimeSpan.FromSeconds(5)
            };

            var result = subject.ToClusterKey();

            result.ConnectionMode.Should().Be(subject.ConnectionMode);
            result.ConnectTimeout.Should().Be(subject.ConnectTimeout);
            result.Credentials.Should().Equal(subject.Credentials);
            result.IPv6.Should().Be(subject.IPv6);
            result.MaxConnectionIdleTime.Should().Be(subject.MaxConnectionIdleTime);
            result.MaxConnectionLifeTime.Should().Be(subject.MaxConnectionLifeTime);
            result.MaxConnectionPoolSize.Should().Be(subject.MaxConnectionPoolSize);
            result.MinConnectionPoolSize.Should().Be(subject.MinConnectionPoolSize);
            result.ReplicaSetName.Should().Be(subject.ReplicaSetName);
            result.LocalThreshold.Should().Be(subject.LocalThreshold);
            result.Servers.Should().Equal(subject.Servers);
            result.ServerSelectionTimeout.Should().Be(subject.ServerSelectionTimeout);
            result.SocketTimeout.Should().Be(subject.SocketTimeout);
            result.SslSettings.Should().Be(subject.SslSettings);
            result.UseSsl.Should().Be(subject.UseSsl);
            result.VerifySslCertificate.Should().Be(subject.VerifySslCertificate);
            result.WaitQueueSize.Should().Be(subject.WaitQueueSize);
            result.WaitQueueTimeout.Should().Be(subject.WaitQueueTimeout);
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:54,代码来源:MongoServerSettingsTests.cs


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