本文整理汇总了C#中MongoDB.Driver.MongoClientSettings.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# MongoClientSettings.Freeze方法的具体用法?C# MongoClientSettings.Freeze怎么用?C# MongoClientSettings.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB.Driver.MongoClientSettings
的用法示例。
在下文中一共展示了MongoClientSettings.Freeze方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestConnectionMode
public void TestConnectionMode()
{
var settings = new MongoClientSettings();
Assert.AreEqual(ConnectionMode.Automatic, settings.ConnectionMode);
var connectionMode = ConnectionMode.Direct;
settings.ConnectionMode = connectionMode;
Assert.AreEqual(connectionMode, settings.ConnectionMode);
settings.Freeze();
Assert.AreEqual(connectionMode, settings.ConnectionMode);
Assert.Throws<InvalidOperationException>(() => { settings.ConnectionMode = connectionMode; });
}
示例2: TestConnectTimeout
public void TestConnectTimeout()
{
var settings = new MongoClientSettings();
Assert.AreEqual(MongoDefaults.ConnectTimeout, settings.ConnectTimeout);
var connectTimeout = new TimeSpan(1, 2, 3);
settings.ConnectTimeout = connectTimeout;
Assert.AreEqual(connectTimeout, settings.ConnectTimeout);
settings.Freeze();
Assert.AreEqual(connectTimeout, settings.ConnectTimeout);
Assert.Throws<InvalidOperationException>(() => { settings.ConnectTimeout = connectTimeout; });
}
示例3: TestWaitQueueSize
public void TestWaitQueueSize()
{
var settings = new MongoClientSettings();
Assert.AreEqual(MongoDefaults.ComputedWaitQueueSize, settings.WaitQueueSize);
var waitQueueSize = 123;
settings.WaitQueueSize = waitQueueSize;
Assert.AreEqual(waitQueueSize, settings.WaitQueueSize);
settings.Freeze();
Assert.AreEqual(waitQueueSize, settings.WaitQueueSize);
Assert.Throws<InvalidOperationException>(() => { settings.WaitQueueSize = waitQueueSize; });
}
示例4: TestVerifySslCertificate
public void TestVerifySslCertificate()
{
var settings = new MongoClientSettings();
Assert.AreEqual(true, settings.VerifySslCertificate);
var verifySslCertificate = false;
settings.VerifySslCertificate = verifySslCertificate;
Assert.AreEqual(verifySslCertificate, settings.VerifySslCertificate);
settings.Freeze();
Assert.AreEqual(verifySslCertificate, settings.VerifySslCertificate);
Assert.Throws<InvalidOperationException>(() => { settings.VerifySslCertificate = verifySslCertificate; });
}
示例5: TestUseSsl
public void TestUseSsl()
{
var settings = new MongoClientSettings();
Assert.AreEqual(false, settings.UseSsl);
var useSsl = true;
settings.UseSsl = useSsl;
Assert.AreEqual(useSsl, settings.UseSsl);
settings.Freeze();
Assert.AreEqual(useSsl, settings.UseSsl);
Assert.Throws<InvalidOperationException>(() => { settings.UseSsl = useSsl; });
}
示例6: TestServersWithTwoServers
public void TestServersWithTwoServers()
{
var settings = new MongoClientSettings();
Assert.AreEqual(_localHost, settings.Server);
Assert.IsTrue(new[] { _localHost }.SequenceEqual(settings.Servers));
var servers = new MongoServerAddress[]
{
new MongoServerAddress("server1"),
new MongoServerAddress("server2")
};
settings.Servers = servers;
Assert.Throws<InvalidOperationException>(() => { var s = settings.Server; });
Assert.IsTrue(servers.SequenceEqual(settings.Servers));
settings.Freeze();
Assert.Throws<InvalidOperationException>(() => { var s = settings.Server; });
Assert.IsTrue(servers.SequenceEqual(settings.Servers));
Assert.Throws<InvalidOperationException>(() => { settings.Servers = servers; });
}
示例7: TestWriteConcern
public void TestWriteConcern()
{
var settings = new MongoClientSettings();
Assert.AreEqual(WriteConcern.Acknowledged, settings.WriteConcern);
var writeConcern = new WriteConcern();
settings.WriteConcern = writeConcern;
Assert.AreSame(writeConcern, settings.WriteConcern);
settings.Freeze();
Assert.AreEqual(writeConcern, settings.WriteConcern);
Assert.Throws<InvalidOperationException>(() => { settings.WriteConcern = writeConcern; });
}
示例8: TestCredentialsStore
public void TestCredentialsStore()
{
var settings = new MongoClientSettings();
Assert.AreEqual("{}", settings.CredentialsStore.ToString());
var credentialsStore = new MongoCredentialsStore();
settings.CredentialsStore = credentialsStore;
Assert.AreSame(credentialsStore, settings.CredentialsStore);
Assert.IsFalse(settings.CredentialsStore.IsFrozen);
settings.Freeze();
Assert.AreSame(credentialsStore, settings.CredentialsStore);
Assert.IsTrue(settings.CredentialsStore.IsFrozen);
Assert.Throws<InvalidOperationException>(() => { settings.CredentialsStore = credentialsStore; });
}
示例9: TestReadPreference
public void TestReadPreference()
{
var settings = new MongoClientSettings();
Assert.AreEqual(ReadPreference.Primary, settings.ReadPreference);
var readPreference = new ReadPreference();
settings.ReadPreference = readPreference;
Assert.AreSame(readPreference, settings.ReadPreference);
Assert.IsFalse(settings.ReadPreference.IsFrozen);
settings.Freeze();
Assert.AreEqual(readPreference, settings.ReadPreference);
Assert.IsTrue(settings.ReadPreference.IsFrozen);
Assert.Throws<InvalidOperationException>(() => { settings.ReadPreference = readPreference; });
}
示例10: TestMinConnectionPoolSize
public void TestMinConnectionPoolSize()
{
var settings = new MongoClientSettings();
Assert.AreEqual(MongoDefaults.MinConnectionPoolSize, settings.MinConnectionPoolSize);
var minConnectionPoolSize = 123;
settings.MinConnectionPoolSize = minConnectionPoolSize;
Assert.AreEqual(minConnectionPoolSize, settings.MinConnectionPoolSize);
settings.Freeze();
Assert.AreEqual(minConnectionPoolSize, settings.MinConnectionPoolSize);
Assert.Throws<InvalidOperationException>(() => { settings.MinConnectionPoolSize = minConnectionPoolSize; });
}
示例11: TestMaxConnectionLifeTime
public void TestMaxConnectionLifeTime()
{
var settings = new MongoClientSettings();
Assert.AreEqual(MongoDefaults.MaxConnectionLifeTime, settings.MaxConnectionLifeTime);
var maxConnectionLifeTime = new TimeSpan(1, 2, 3);
settings.MaxConnectionLifeTime = maxConnectionLifeTime;
Assert.AreEqual(maxConnectionLifeTime, settings.MaxConnectionLifeTime);
settings.Freeze();
Assert.AreEqual(maxConnectionLifeTime, settings.MaxConnectionLifeTime);
Assert.Throws<InvalidOperationException>(() => { settings.MaxConnectionLifeTime = maxConnectionLifeTime; });
}
示例12: TestIPv6
public void TestIPv6()
{
var settings = new MongoClientSettings();
Assert.AreEqual(false, settings.IPv6);
var ipv6 = true;
settings.IPv6 = ipv6;
Assert.AreEqual(ipv6, settings.IPv6);
settings.Freeze();
Assert.AreEqual(ipv6, settings.IPv6);
Assert.Throws<InvalidOperationException>(() => { settings.IPv6 = ipv6; });
}
示例13: TestGuidRepresentation
public void TestGuidRepresentation()
{
var settings = new MongoClientSettings();
Assert.AreEqual(MongoDefaults.GuidRepresentation, settings.GuidRepresentation);
var guidRepresentation = GuidRepresentation.PythonLegacy;
settings.GuidRepresentation = guidRepresentation;
Assert.AreEqual(guidRepresentation, settings.GuidRepresentation);
settings.Freeze();
Assert.AreEqual(guidRepresentation, settings.GuidRepresentation);
Assert.Throws<InvalidOperationException>(() => { settings.GuidRepresentation = guidRepresentation; });
}
示例14: TestFreeze
public void TestFreeze()
{
var settings = new MongoClientSettings();
settings.ReadPreference = new ReadPreference();
settings.WriteConcern = new WriteConcern();
Assert.IsFalse(settings.IsFrozen);
Assert.IsFalse(settings.CredentialsStore.IsFrozen);
Assert.IsFalse(settings.ReadPreference.IsFrozen);
Assert.IsFalse(settings.WriteConcern.IsFrozen);
var hashCode = settings.GetHashCode();
var stringRepresentation = settings.ToString();
settings.Freeze();
Assert.IsTrue(settings.IsFrozen);
Assert.IsTrue(settings.CredentialsStore.IsFrozen);
Assert.IsTrue(settings.ReadPreference.IsFrozen);
Assert.IsTrue(settings.WriteConcern.IsFrozen);
Assert.AreEqual(hashCode, settings.GetHashCode());
Assert.AreEqual(stringRepresentation, settings.ToString());
}
示例15: TestSslSettings
public void TestSslSettings()
{
var settings = new MongoClientSettings();
Assert.AreEqual(null, settings.SslSettings);
var sslSettings = new SslSettings { CheckCertificateRevocation = false };
settings.SslSettings = sslSettings;
Assert.AreEqual(sslSettings, settings.SslSettings);
settings.Freeze();
Assert.AreEqual(sslSettings, settings.SslSettings);
Assert.Throws<InvalidOperationException>(() => { settings.SslSettings = sslSettings; });
}