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


C# MongoServerSettings.Clone方法代码示例

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


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

示例1: TestAll

        public void TestAll()
        {
            var settings = new MongoServerSettings();
            settings.ConnectionMode = ConnectionMode.ReplicaSet;
            settings.ConnectTimeout = TimeSpan.FromSeconds(1);
            settings.DefaultCredentials = MongoCredentials.Create("username", "password");
            settings.MaxConnectionIdleTime = TimeSpan.FromSeconds(2);
            settings.MaxConnectionLifeTime = TimeSpan.FromSeconds(3);
            settings.MaxConnectionPoolSize = 99;
            settings.MinConnectionPoolSize = 11;
            settings.ReplicaSetName = "replicaname";
            settings.SafeMode = SafeMode.Create(5, TimeSpan.FromSeconds(4));
            settings.Server = new MongoServerAddress("server");
            settings.SlaveOk = true;
            settings.SocketTimeout = TimeSpan.FromSeconds(5);
            settings.WaitQueueSize = 55;
            settings.WaitQueueTimeout = TimeSpan.FromSeconds(6);

            Assert.AreEqual(ConnectionMode.ReplicaSet, settings.ConnectionMode);
            Assert.AreEqual(TimeSpan.FromSeconds(1), settings.ConnectTimeout);
            Assert.AreEqual(MongoCredentials.Create("username", "password"), settings.DefaultCredentials);
            Assert.AreEqual(TimeSpan.FromSeconds(2), settings.MaxConnectionIdleTime);
            Assert.AreEqual(TimeSpan.FromSeconds(3), settings.MaxConnectionLifeTime);
            Assert.AreEqual(99, settings.MaxConnectionPoolSize);
            Assert.AreEqual(11, settings.MinConnectionPoolSize);
            Assert.AreEqual("replicaname", settings.ReplicaSetName);
            Assert.AreEqual(SafeMode.Create(5, TimeSpan.FromSeconds(4)), settings.SafeMode);
            Assert.AreEqual(new MongoServerAddress("server"), settings.Server);
            Assert.IsTrue((new[] { new MongoServerAddress("server") }).SequenceEqual(settings.Servers));
            Assert.AreEqual(TimeSpan.FromSeconds(5), settings.SocketTimeout);
            Assert.AreEqual(55, settings.WaitQueueSize);
            Assert.AreEqual(TimeSpan.FromSeconds(6), settings.WaitQueueTimeout);

            Assert.IsFalse(settings.IsFrozen);
            var hashCode = settings.GetHashCode();
            var stringRepresentation = settings.ToString();
            Assert.AreEqual(settings, settings);

            settings.Freeze();
            Assert.IsTrue(settings.IsFrozen);
            Assert.AreEqual(hashCode, settings.GetHashCode());
            Assert.AreEqual(stringRepresentation, settings.ToString());

            var clone = settings.Clone();
            Assert.IsFalse(clone.IsFrozen);
            Assert.AreEqual(settings, clone);
        }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:47,代码来源:MongoServerSettingsTests.cs

示例2: TestEquals

        public void TestEquals()
        {
            var settings = new MongoServerSettings();
            var clone = settings.Clone();
            Assert.IsTrue(clone.Equals(settings));

            clone = settings.Clone();
            clone.ConnectionMode = ConnectionMode.Direct;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.ConnectTimeout = new TimeSpan(1, 2, 3);
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.Credentials = new[] { MongoCredential.CreateMongoCRCredential("db2", "user2", "password2") };
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.Credentials = new[] { MongoCredential.CreateMongoCRCredential("db1", "user2", "password2") };
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.GuidRepresentation = GuidRepresentation.PythonLegacy;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.IPv6 = !settings.IPv6;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.MaxConnectionIdleTime = new TimeSpan(1, 2, 3);
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.MaxConnectionLifeTime = new TimeSpan(1, 2, 3);
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.MaxConnectionPoolSize = settings.MaxConnectionPoolSize + 1;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.MinConnectionPoolSize = settings.MinConnectionPoolSize + 1;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.ReadPreference = ReadPreference.Secondary;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.ReplicaSetName = "abc";
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.SecondaryAcceptableLatency = new TimeSpan(1, 2, 3);
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.Server = new MongoServerAddress("someotherhost");
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.SocketTimeout = new TimeSpan(1, 2, 3);
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.SslSettings = new SslSettings { CheckCertificateRevocation = false };
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.UseSsl = !settings.UseSsl;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.VerifySslCertificate = !settings.VerifySslCertificate;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.WaitQueueSize = settings.WaitQueueSize + 1;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.WaitQueueTimeout = new TimeSpan(1, 2, 3);
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.WriteConcern = WriteConcern.W2;
            Assert.IsFalse(clone.Equals(settings));
        }
开发者ID:einaregilsson,项目名称:mongo-csharp-driver,代码行数:90,代码来源:MongoServerSettingsTests.cs

示例3: TestDefaults

        public void TestDefaults()
        {
            var settings = new MongoServerSettings();
            Assert.AreEqual(ConnectionMode.Direct, settings.ConnectionMode);
            Assert.AreEqual(MongoDefaults.ConnectTimeout, settings.ConnectTimeout);
            Assert.AreEqual(null, settings.DefaultCredentials);
            Assert.AreEqual(MongoDefaults.MaxConnectionIdleTime, settings.MaxConnectionIdleTime);
            Assert.AreEqual(MongoDefaults.MaxConnectionLifeTime, settings.MaxConnectionLifeTime);
            Assert.AreEqual(MongoDefaults.MaxConnectionPoolSize, settings.MaxConnectionPoolSize);
            Assert.AreEqual(MongoDefaults.MinConnectionPoolSize, settings.MinConnectionPoolSize);
            Assert.AreEqual(null, settings.ReplicaSetName);
            Assert.AreEqual(SafeMode.False, settings.SafeMode);
            Assert.AreEqual(null, settings.Server);
            Assert.AreEqual(null, settings.Servers);
            Assert.AreEqual(MongoDefaults.SocketTimeout, settings.SocketTimeout);
            Assert.AreEqual(MongoDefaults.ComputedWaitQueueSize, settings.WaitQueueSize);
            Assert.AreEqual(MongoDefaults.WaitQueueTimeout, settings.WaitQueueTimeout);

            Assert.IsFalse(settings.IsFrozen);
            var hashCode = settings.GetHashCode();
            var stringRepresentation = settings.ToString();
            Assert.AreEqual(settings, settings);

            settings.Freeze();
            Assert.IsTrue(settings.IsFrozen);
            Assert.AreEqual(hashCode, settings.GetHashCode());
            Assert.AreEqual(stringRepresentation, settings.ToString());

            var clone = settings.Clone();
            Assert.IsFalse(clone.IsFrozen);
            Assert.AreEqual(settings, clone);
        }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:32,代码来源:MongoServerSettingsTests.cs


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