本文整理汇总了C#中MongoClientSettings.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# MongoClientSettings.Freeze方法的具体用法?C# MongoClientSettings.Freeze怎么用?C# MongoClientSettings.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoClientSettings
的用法示例。
在下文中一共展示了MongoClientSettings.Freeze方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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; });
}
示例2: TestApplicationName
public void TestApplicationName()
{
var settings = new MongoClientSettings();
Assert.Equal(null, settings.ApplicationName);
var applicationName = "app";
settings.ApplicationName = applicationName;
Assert.Equal(applicationName, settings.ApplicationName);
settings.Freeze();
Assert.Equal(applicationName, settings.ApplicationName);
Assert.Throws<InvalidOperationException>(() => { settings.ApplicationName = applicationName; });
}
示例3: 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; });
}
示例4: 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; });
}
示例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: TestLocalThreshold
public void TestLocalThreshold()
{
var settings = new MongoClientSettings();
Assert.AreEqual(MongoDefaults.LocalThreshold, settings.LocalThreshold);
var localThreshold = new TimeSpan(1, 2, 3);
settings.LocalThreshold = localThreshold;
Assert.AreEqual(localThreshold, settings.LocalThreshold);
settings.Freeze();
Assert.AreEqual(localThreshold, settings.LocalThreshold);
Assert.Throws<InvalidOperationException>(() => { settings.LocalThreshold = localThreshold; });
}
示例7: 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; });
}
示例8: 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; });
}
示例9: TestServersWithOneServer
public void TestServersWithOneServer()
{
var settings = new MongoClientSettings();
Assert.Equal(_localHost, settings.Server);
Assert.True(new[] { _localHost }.SequenceEqual(settings.Servers));
var server = new MongoServerAddress("server");
var servers = new[] { server };
settings.Servers = servers;
Assert.Equal(server, settings.Server);
Assert.True(servers.SequenceEqual(settings.Servers));
settings.Freeze();
Assert.Equal(server, settings.Server);
Assert.True(servers.SequenceEqual(settings.Servers));
Assert.Throws<InvalidOperationException>(() => { settings.Server = server; });
}
示例10: 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; });
}
示例11: 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; });
}
示例12: 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; });
}
示例13: 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; });
}
示例14: TestFreeze
public void TestFreeze()
{
var settings = new MongoClientSettings();
Assert.IsFalse(settings.IsFrozen);
var hashCode = settings.GetHashCode();
var stringRepresentation = settings.ToString();
settings.Freeze();
Assert.IsTrue(settings.IsFrozen);
Assert.AreEqual(hashCode, settings.GetHashCode());
Assert.AreEqual(stringRepresentation, settings.ToString());
}
示例15: TestWaitQueueTimeout
public void TestWaitQueueTimeout()
{
var settings = new MongoClientSettings();
Assert.Equal(MongoDefaults.WaitQueueTimeout, settings.WaitQueueTimeout);
var waitQueueTimeout = new TimeSpan(1, 2, 3);
settings.WaitQueueTimeout = waitQueueTimeout;
Assert.Equal(waitQueueTimeout, settings.WaitQueueTimeout);
settings.Freeze();
Assert.Equal(waitQueueTimeout, settings.WaitQueueTimeout);
Assert.Throws<InvalidOperationException>(() => { settings.WaitQueueTimeout = waitQueueTimeout; });
}