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


C# MongoUrl.ToString方法代码示例

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


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

示例1: TestDefaults

        public void TestDefaults()
        {
            string connectionString = "mongodb://localhost";
            MongoUrl url = new MongoUrl(connectionString);
            Assert.IsNull(url.DefaultCredentials);
            Assert.AreEqual(1, url.Servers.Count());
            Assert.AreEqual("localhost", url.Servers.Single().Host);
            Assert.AreEqual(27017, url.Servers.Single().Port);
            Assert.IsNull(url.DatabaseName);
            Assert.AreEqual(ConnectionMode.Automatic, url.ConnectionMode);
            Assert.AreEqual(MongoDefaults.ConnectTimeout, url.ConnectTimeout);
            Assert.AreEqual(MongoDefaults.GuidRepresentation, url.GuidRepresentation);
            Assert.AreEqual(false, url.IPv6);
            Assert.AreEqual(MongoDefaults.MaxConnectionIdleTime, url.MaxConnectionIdleTime);
            Assert.AreEqual(MongoDefaults.MaxConnectionLifeTime, url.MaxConnectionLifeTime);
            Assert.AreEqual(MongoDefaults.MaxConnectionPoolSize, url.MaxConnectionPoolSize);
            Assert.AreEqual(null, url.ReplicaSetName);
            Assert.AreEqual(null, url.SafeMode);
            Assert.AreEqual(MongoDefaults.SecondaryAcceptableLatency, url.SecondaryAcceptableLatency);
#pragma warning disable 618
            Assert.AreEqual(false, url.SlaveOk);
#pragma warning restore
            Assert.AreEqual(MongoDefaults.SocketTimeout, url.SocketTimeout);
            Assert.AreEqual(false, url.UseSsl);
            Assert.AreEqual(MongoDefaults.WaitQueueMultiple, url.WaitQueueMultiple);
            Assert.AreEqual(MongoDefaults.WaitQueueSize, url.WaitQueueSize);
            Assert.AreEqual(MongoDefaults.WaitQueueTimeout, url.WaitQueueTimeout);
            Assert.AreEqual(connectionString, url.ToString());
        }
开发者ID:staywellandy,项目名称:mongo-csharp-driver,代码行数:29,代码来源:MongoUrlTests.cs

示例2: TestConnectTimeout

        public void TestConnectTimeout()
        {
            string connectionString = "mongodb://localhost/?connectTimeout=123";
            MongoUrl url = new MongoUrl(connectionString);
            Assert.AreEqual(TimeSpan.FromSeconds(123), url.ConnectTimeout);
            Assert.AreEqual(connectionString + "s", url.ToString()); // "s" units added

            connectionString = "mongodb://localhost/?connectTimeout=123ms";
            url = new MongoUrl(connectionString);
            Assert.AreEqual(TimeSpan.FromMilliseconds(123), url.ConnectTimeout);
            Assert.AreEqual(connectionString, url.ToString());

            connectionString = "mongodb://localhost/?connectTimeout=123s";
            url = new MongoUrl(connectionString);
            Assert.AreEqual(TimeSpan.FromSeconds(123), url.ConnectTimeout);
            Assert.AreEqual(connectionString, url.ToString());

            connectionString = "mongodb://localhost/?connectTimeout=123m";
            url = new MongoUrl(connectionString);
            Assert.AreEqual(TimeSpan.FromMinutes(123), url.ConnectTimeout);
            Assert.AreEqual(connectionString, url.ToString());

            connectionString = "mongodb://localhost/?connectTimeout=123h";
            url = new MongoUrl(connectionString);
            Assert.AreEqual(TimeSpan.FromHours(123), url.ConnectTimeout);
            Assert.AreEqual(connectionString, url.ToString());

            connectionString = "mongodb://localhost/?connectTimeoutMS=123";
            url = new MongoUrl(connectionString);
            Assert.AreEqual(TimeSpan.FromMilliseconds(123), url.ConnectTimeout);
            Assert.AreEqual("mongodb://localhost/?connectTimeout=123ms", url.ToString()); // changed to "ms" suffix
        }
开发者ID:vshlos,项目名称:mongo-csharp-driver,代码行数:32,代码来源:MongoUrlTests.cs

示例3: TestHostWithPort

 public void TestHostWithPort() {
     string connectionString = "mongodb://mongo.xyz.com:12345";
     MongoUrl url = new MongoUrl(connectionString);
     Assert.IsNull(url.DefaultCredentials);
     Assert.AreEqual(1, url.Servers.Count());
     Assert.AreEqual("mongo.xyz.com", url.Servers.Single().Host);
     Assert.AreEqual(12345, url.Servers.Single().Port);
     Assert.AreEqual(ConnectionMode.Direct, url.ConnectionMode);
     Assert.AreEqual(null, url.ReplicaSetName);
     Assert.AreEqual(connectionString, url.ToString());
 }
开发者ID:ebix,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoUrlTests.cs

示例4: TestConnectionMode

        public void TestConnectionMode()
        {
            string connectionString = "mongodb://localhost/?connect=direct";
            MongoUrl url = new MongoUrl(connectionString);
            Assert.AreEqual(ConnectionMode.Direct, url.ConnectionMode);
            Assert.AreEqual("mongodb://localhost", url.ToString()); // connect=direct dropped

            connectionString = "mongodb://localhost/?connect=replicaSet";
            url = new MongoUrl(connectionString);
            Assert.AreEqual(ConnectionMode.ReplicaSet, url.ConnectionMode);
            Assert.AreEqual(connectionString, url.ToString());
        }
开发者ID:vshlos,项目名称:mongo-csharp-driver,代码行数:12,代码来源:MongoUrlTests.cs

示例5: TestAll

 public void TestAll()
 {
     string connectionString = "mongodb://localhost/?connect=replicaSet;replicaSet=name;slaveOk=true;safe=true;fsync=true;w=2;wtimeout=2s";
     MongoUrl url = new MongoUrl(connectionString);
     Assert.IsNull(url.DefaultCredentials);
     Assert.AreEqual(1, url.Servers.Count());
     Assert.AreEqual("localhost", url.Server.Host);
     Assert.AreEqual(27017, url.Server.Port);
     Assert.AreEqual(null, url.DatabaseName);
     Assert.AreEqual(ConnectionMode.ReplicaSet, url.ConnectionMode);
     Assert.AreEqual("name", url.ReplicaSetName);
     Assert.AreEqual(SafeMode.Create(true, true, 2, TimeSpan.FromSeconds(2)), url.SafeMode);
     Assert.AreEqual(true, url.SlaveOk);
     Assert.AreEqual(connectionString, url.ToString());
 }
开发者ID:jenrom,项目名称:mongo-csharp-driver,代码行数:15,代码来源:MongoUrlTests.cs

示例6: TestDirectConnectionMode

 public void TestDirectConnectionMode()
 {
     string connectionString = "mongodb://localhost/?connect=direct";
     MongoUrl url = new MongoUrl(connectionString);
     Assert.IsNull(url.Credentials);
     Assert.AreEqual(1, url.Servers.Count());
     Assert.AreEqual("localhost", url.Server.Host);
     Assert.AreEqual(27017, url.Server.Port);
     Assert.AreEqual(null, url.DatabaseName);
     Assert.AreEqual(ConnectionMode.Direct, url.ConnectionMode);
     Assert.AreEqual(null, url.ReplicaSetName);
     Assert.AreEqual(SafeMode.False, url.SafeMode);
     Assert.AreEqual(false, url.SlaveOk);
     Assert.AreEqual("mongodb://localhost", url.ToString()); // connect=direct dropped
 }
开发者ID:kenegozi,项目名称:mongo-csharp-driver,代码行数:15,代码来源:MongoUrlTests.cs

示例7: TestHost

 public void TestHost()
 {
     string connectionString = "mongodb://mongo.xyz.com";
     MongoUrl url = new MongoUrl(connectionString);
     Assert.IsNull(url.Credentials);
     Assert.AreEqual(1, url.Servers.Count());
     Assert.AreEqual("mongo.xyz.com", url.Servers.Single().Host);
     Assert.AreEqual(27017, url.Servers.Single().Port);
     Assert.IsNull(url.DatabaseName);
     Assert.AreEqual(ConnectionMode.Direct, url.ConnectionMode);
     Assert.AreEqual(null, url.ReplicaSetName);
     Assert.AreEqual(SafeMode.False, url.SafeMode);
     Assert.AreEqual(false, url.SlaveOk);
     Assert.AreEqual(connectionString, url.ToString());
 }
开发者ID:kenegozi,项目名称:mongo-csharp-driver,代码行数:15,代码来源:MongoUrlTests.cs

示例8: TestAll

 public void TestAll()
 {
     string connectionString = "mongodb://localhost/?connect=replicaSet;replicaSet=name;readPreference=secondary;safe=true;fsync=true;w=2;wtimeout=2s;guids=PythonLegacy";
     MongoUrl url = new MongoUrl(connectionString);
     Assert.IsNull(url.DefaultCredentials);
     Assert.AreEqual(1, url.Servers.Count());
     Assert.AreEqual("localhost", url.Server.Host);
     Assert.AreEqual(27017, url.Server.Port);
     Assert.AreEqual(null, url.DatabaseName);
     Assert.AreEqual(ConnectionMode.ReplicaSet, url.ConnectionMode);
     Assert.AreEqual("name", url.ReplicaSetName);
     Assert.AreEqual(GuidRepresentation.PythonLegacy, url.GuidRepresentation);
     Assert.AreEqual(SafeMode.Create(true, true, 2, TimeSpan.FromSeconds(2)), url.SafeMode);
     Assert.AreEqual(ReadPreference.Secondary, url.ReadPreference);
     Assert.AreEqual(connectionString, url.ToString());
 }
开发者ID:kamaradclimber,项目名称:mongo-csharp-driver,代码行数:16,代码来源:MongoUrlTests.cs

示例9: TestDefaults

 public void TestDefaults() {
     string connectionString = "mongodb://localhost";
     MongoUrl url = new MongoUrl(connectionString);
     Assert.IsNull(url.DefaultCredentials);
     Assert.AreEqual(1, url.Servers.Count());
     Assert.AreEqual("localhost", url.Servers.Single().Host);
     Assert.AreEqual(27017, url.Servers.Single().Port);
     Assert.IsNull(url.DatabaseName);
     Assert.AreEqual(ConnectionMode.Direct, url.ConnectionMode);
     Assert.AreEqual(MongoDefaults.ConnectTimeout, url.ConnectTimeout);
     Assert.AreEqual(false, url.IPv6);
     Assert.AreEqual(MongoDefaults.MaxConnectionIdleTime, url.MaxConnectionIdleTime);
     Assert.AreEqual(MongoDefaults.MaxConnectionLifeTime, url.MaxConnectionLifeTime);
     Assert.AreEqual(MongoDefaults.MaxConnectionPoolSize, url.MaxConnectionPoolSize);
     Assert.AreEqual(null, url.ReplicaSetName);
     Assert.AreEqual(SafeMode.False, url.SafeMode);
     Assert.AreEqual(false, url.SlaveOk);
     Assert.AreEqual(MongoDefaults.SocketTimeout, url.SocketTimeout);
     Assert.AreEqual(MongoDefaults.WaitQueueMultiple, url.WaitQueueMultiple);
     Assert.AreEqual(MongoDefaults.WaitQueueSize, url.WaitQueueSize);
     Assert.AreEqual(MongoDefaults.WaitQueueTimeout, url.WaitQueueTimeout);
     Assert.AreEqual(connectionString, url.ToString());
 }
开发者ID:ebix,项目名称:mongo-csharp-driver,代码行数:23,代码来源:MongoUrlTests.cs

示例10: TestReplicaSetName

 public void TestReplicaSetName()
 {
     string connectionString = "mongodb://localhost/?replicaSet=name";
     MongoUrl url = new MongoUrl(connectionString);
     Assert.AreEqual(ConnectionMode.Automatic, url.ConnectionMode);
     Assert.AreEqual("name", url.ReplicaSetName);
     Assert.AreEqual("mongodb://localhost/?replicaSet=name", url.ToString());
 }
开发者ID:staywellandy,项目名称:mongo-csharp-driver,代码行数:8,代码来源:MongoUrlTests.cs

示例11: TestMinConnectionPoolSize

 public void TestMinConnectionPoolSize()
 {
     string connectionString = "mongodb://localhost/?minPoolSize=123";
     MongoUrl url = new MongoUrl(connectionString);
     Assert.AreEqual(123, url.MinConnectionPoolSize);
     Assert.AreEqual(connectionString, url.ToString());
 }
开发者ID:staywellandy,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoUrlTests.cs

示例12: TestAll

        public void TestAll()
        {
            string connectionString = "mongodb://localhost/?connect=replicaSet;replicaSet=name;slaveOk=true;safe=true;fsync=true;w=2;wtimeout=2s;secondaryAcceptableLatency=12s;uuidRepresentation=PythonLegacy";
            MongoUrl url = new MongoUrl(connectionString);
            Assert.IsNull(url.DefaultCredentials);
            Assert.AreEqual(1, url.Servers.Count());
            Assert.AreEqual("localhost", url.Server.Host);
            Assert.AreEqual(27017, url.Server.Port);
            Assert.AreEqual(null, url.DatabaseName);
            Assert.AreEqual(ConnectionMode.ReplicaSet, url.ConnectionMode);
            Assert.AreEqual("name", url.ReplicaSetName);
            Assert.AreEqual(GuidRepresentation.PythonLegacy, url.GuidRepresentation);
            Assert.AreEqual(SafeMode.Create(true, true, 2, TimeSpan.FromSeconds(2)), url.SafeMode);
            Assert.AreEqual(TimeSpan.FromSeconds(12), url.SecondaryAcceptableLatency);
#pragma warning disable 618
            Assert.AreEqual(true, url.SlaveOk);
#pragma warning restore
            Assert.AreEqual(connectionString, url.ToString());
        }
开发者ID:staywellandy,项目名称:mongo-csharp-driver,代码行数:19,代码来源:MongoUrlTests.cs

示例13: TestWaitQueueSize

 public void TestWaitQueueSize()
 {
     string connectionString = "mongodb://localhost/?waitQueueSize=123";
     MongoUrl url = new MongoUrl(connectionString);
     Assert.AreEqual(0, url.WaitQueueMultiple);
     Assert.AreEqual(123, url.WaitQueueSize);
     Assert.AreEqual(connectionString, url.ToString());
 }
开发者ID:staywellandy,项目名称:mongo-csharp-driver,代码行数:8,代码来源:MongoUrlTests.cs

示例14: TestSlaveOkTrue

        public void TestSlaveOkTrue()
        {
            string connectionString = "mongodb://localhost/?slaveOk=true";
            MongoUrl url = new MongoUrl(connectionString);
#pragma warning disable 618
            Assert.AreEqual(true, url.SlaveOk);
#pragma warning restore
            Assert.AreEqual(connectionString, url.ToString());
        }
开发者ID:staywellandy,项目名称:mongo-csharp-driver,代码行数:9,代码来源:MongoUrlTests.cs

示例15: TestSafeModeTrueFSyncTrueW2WTimeout

 public void TestSafeModeTrueFSyncTrueW2WTimeout()
 {
     string connectionString = "mongodb://localhost/?safe=true;fsync=true;w=2;wtimeout=2s";
     MongoUrl url = new MongoUrl(connectionString);
     Assert.AreEqual(SafeMode.Create(true, true, 2, TimeSpan.FromSeconds(2)), url.SafeMode);
     Assert.AreEqual(connectionString, url.ToString());
 }
开发者ID:staywellandy,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoUrlTests.cs


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