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


C# MongoConnectionStringBuilder.ToString方法代码示例

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


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

示例1: TestDefaults

 public void TestDefaults() {
     string connectionString = "server=localhost";
     var builder = new MongoConnectionStringBuilder(connectionString);
     Assert.IsNull(builder.Username);
     Assert.IsNull(builder.Password);
     Assert.AreEqual(1, builder.Servers.Count());
     Assert.AreEqual("localhost", builder.Servers.Single().Host);
     Assert.AreEqual(27017, builder.Servers.Single().Port);
     Assert.IsNull(builder.DatabaseName);
     Assert.AreEqual(ConnectionMode.Direct, builder.ConnectionMode);
     Assert.AreEqual(MongoDefaults.ConnectTimeout, builder.ConnectTimeout);
     Assert.AreEqual(MongoDefaults.GuidRepresentation, builder.GuidRepresentation);
     Assert.AreEqual(false, builder.IPv6);
     Assert.AreEqual(MongoDefaults.MaxConnectionIdleTime, builder.MaxConnectionIdleTime);
     Assert.AreEqual(MongoDefaults.MaxConnectionLifeTime, builder.MaxConnectionLifeTime);
     Assert.AreEqual(MongoDefaults.MaxConnectionPoolSize, builder.MaxConnectionPoolSize);
     Assert.AreEqual(null, builder.ReplicaSetName);
     Assert.IsNull(builder.SafeMode);
     Assert.AreEqual(false, builder.SlaveOk);
     Assert.AreEqual(MongoDefaults.SocketTimeout, builder.SocketTimeout);
     Assert.AreEqual(MongoDefaults.WaitQueueMultiple, builder.WaitQueueMultiple);
     Assert.AreEqual(MongoDefaults.WaitQueueSize, builder.WaitQueueSize);
     Assert.AreEqual(MongoDefaults.WaitQueueTimeout, builder.WaitQueueTimeout);
     Assert.AreEqual(connectionString, builder.ToString());
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:25,代码来源:MongoConnectionStringBuilderTests.cs

示例2: TestDefaults

        public void TestDefaults()
        {
            var builder = new MongoConnectionStringBuilder();
            Assert.AreEqual(null, builder.Username);
            Assert.AreEqual(null, builder.Password);
            Assert.AreEqual(null, builder.Server);
            Assert.AreEqual(null, builder.Servers);
            Assert.AreEqual(null, builder.DatabaseName);
            Assert.AreEqual(ConnectionMode.Automatic, builder.ConnectionMode);
            Assert.AreEqual(MongoDefaults.ConnectTimeout, builder.ConnectTimeout);
            Assert.AreEqual(MongoDefaults.GuidRepresentation, builder.GuidRepresentation);
            Assert.AreEqual(false, builder.IPv6);
            Assert.AreEqual(MongoDefaults.MaxConnectionIdleTime, builder.MaxConnectionIdleTime);
            Assert.AreEqual(MongoDefaults.MaxConnectionLifeTime, builder.MaxConnectionLifeTime);
            Assert.AreEqual(MongoDefaults.MaxConnectionPoolSize, builder.MaxConnectionPoolSize);
            Assert.AreEqual(MongoDefaults.MinConnectionPoolSize, builder.MinConnectionPoolSize);
            Assert.AreEqual(null, builder.ReadPreference);
            Assert.AreEqual(null, builder.ReplicaSetName);
            Assert.AreEqual(null, builder.SafeMode);
            Assert.AreEqual(MongoDefaults.SecondaryAcceptableLatency, builder.SecondaryAcceptableLatency);
#pragma warning disable 618
            Assert.AreEqual(false, builder.SlaveOk);
#pragma warning restore
            Assert.AreEqual(MongoDefaults.SocketTimeout, builder.SocketTimeout);
            Assert.AreEqual(false, builder.UseSsl);
            Assert.AreEqual(MongoDefaults.WaitQueueMultiple, builder.WaitQueueMultiple);
            Assert.AreEqual(MongoDefaults.WaitQueueSize, builder.WaitQueueSize);
            Assert.AreEqual(MongoDefaults.WaitQueueTimeout, builder.WaitQueueTimeout);
            Assert.AreEqual(MongoDefaults.ComputedWaitQueueSize, builder.ComputedWaitQueueSize);

            var connectionString = ""; // not actually a valid connection string because it's missing the host
            Assert.AreEqual(connectionString, builder.ToString());
        }
开发者ID:staywellandy,项目名称:mongo-csharp-driver,代码行数:33,代码来源:MongoConnectionStringBuilderTests.cs

示例3: TestConnectTimeout

        public void TestConnectTimeout()
        {
            string connectionString = "server=localhost;connectTimeout=123";
            var builder = new MongoConnectionStringBuilder(connectionString);
            Assert.AreEqual(TimeSpan.FromSeconds(123), builder.ConnectTimeout);
            Assert.AreEqual(connectionString + "s", builder.ToString()); // "s" units added

            connectionString = "server=localhost;connectTimeout=123ms";
            builder = new MongoConnectionStringBuilder(connectionString);
            Assert.AreEqual(TimeSpan.FromMilliseconds(123), builder.ConnectTimeout);
            Assert.AreEqual(connectionString, builder.ToString());

            connectionString = "server=localhost;connectTimeout=123s";
            builder = new MongoConnectionStringBuilder(connectionString);
            Assert.AreEqual(TimeSpan.FromSeconds(123), builder.ConnectTimeout);
            Assert.AreEqual(connectionString, builder.ToString());

            connectionString = "server=localhost;connectTimeout=123m";
            builder = new MongoConnectionStringBuilder(connectionString);
            Assert.AreEqual(TimeSpan.FromMinutes(123), builder.ConnectTimeout);
            Assert.AreEqual(connectionString, builder.ToString());

            connectionString = "server=localhost;connectTimeout=123h";
            builder = new MongoConnectionStringBuilder(connectionString);
            Assert.AreEqual(TimeSpan.FromHours(123), builder.ConnectTimeout);
            Assert.AreEqual(connectionString, builder.ToString());
        }
开发者ID:javanal,项目名称:mongo-csharp-driver,代码行数:27,代码来源:MongoConnectionStringBuilderTests.cs

示例4: TestToStringOutput

        public void TestToStringOutput()
        {
            var builder = new MongoConnectionStringBuilder { Password = "testpassword", Username = "testusername", ConnectionLifetime = TimeSpan.FromSeconds (50), MaximumPoolSize = 101, MinimumPoolSize = 202, ConnectionTimeout = TimeSpan.FromSeconds(60)};
            builder.AddServer ("testserver1", 555);
            builder.AddServer ("testserver2");

            Assert.AreEqual ("Username=testusername;Password=testpassword;Server=testserver1:555,testserver2;MaximumPoolSize=101;MinimumPoolSize=202;ConnectionTimeout=60;ConnectionLifetime=50", builder.ToString ());
        }
开发者ID:kvnsmth,项目名称:mongodb-csharp,代码行数:8,代码来源:TestConnectionStringBuilder.cs

示例5: TestHostWithPort

 public void TestHostWithPort() {
     string connectionString = "server=mongo.xyz.com:12345";
     var builder = new MongoConnectionStringBuilder(connectionString);
     Assert.IsNull(builder.Username);
     Assert.IsNull(builder.Password);
     Assert.AreEqual(1, builder.Servers.Count());
     Assert.AreEqual("mongo.xyz.com", builder.Servers.Single().Host);
     Assert.AreEqual(12345, builder.Servers.Single().Port);
     Assert.AreEqual(ConnectionMode.Direct, builder.ConnectionMode);
     Assert.AreEqual(null, builder.ReplicaSetName);
     Assert.AreEqual(connectionString, builder.ToString());
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:12,代码来源:MongoConnectionStringBuilderTests.cs

示例6: TestConnectionMode

        public void TestConnectionMode()
        {
            string connectionString = "server=localhost;connect=direct";
            var builder = new MongoConnectionStringBuilder(connectionString);
            Assert.AreEqual(ConnectionMode.Direct, builder.ConnectionMode);
            Assert.AreEqual(connectionString, builder.ToString());

            connectionString = "server=localhost;connect=replicaSet";
            builder = new MongoConnectionStringBuilder(connectionString);
            Assert.AreEqual(ConnectionMode.ReplicaSet, builder.ConnectionMode);
            Assert.AreEqual(connectionString, builder.ToString());
        }
开发者ID:javanal,项目名称:mongo-csharp-driver,代码行数:12,代码来源:MongoConnectionStringBuilderTests.cs

示例7: CREATE_CLIENT

   public void CREATE_CLIENT()
   {
 
       MongoConnectionStringBuilder builder = new MongoConnectionStringBuilder();
       builder.Journal = true;
       builder.Server = new MongoServerAddress("localhost");
       string connectionString = builder.ToString();
      
       client = new MongoClient(connectionString);
       
       //client.GetServer().GetDatabase("EventStore").Drop();
       BsonClassMap.RegisterClassMap<Events.SampleEvent>();
       BsonClassMap.RegisterClassMap<Events.SampleID>();
   }
开发者ID:jcwrequests,项目名称:WYS.MongoDB.EventStore,代码行数:14,代码来源:EventStore.cs

示例8: TestHost

        public void TestHost()
        {
            var builder = new MongoConnectionStringBuilder() { Server = new MongoServerAddress("mongo.xyz.com") };
            Assert.IsNull(builder.Username);
            Assert.IsNull(builder.Password);
            Assert.AreEqual(1, builder.Servers.Count());
            Assert.AreEqual("mongo.xyz.com", builder.Server.Host);
            Assert.AreEqual(27017, builder.Server.Port);
            Assert.AreEqual(null, builder.DatabaseName);
            Assert.AreEqual(ConnectionMode.Automatic, builder.ConnectionMode);

            var connectionString = "server=mongo.xyz.com";
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoConnectionStringBuilder(connectionString).ToString());
        }
开发者ID:staywellandy,项目名称:mongo-csharp-driver,代码行数:15,代码来源:MongoConnectionStringBuilderTests.cs

示例9: TestAll

 public void TestAll()
 {
     string connectionString = "server=localhost;connect=replicaSet;replicaSet=name;slaveOk=true;safe=true;fsync=true;j=true;w=2;wtimeout=2s;guids=PythonLegacy";
     var builder = new MongoConnectionStringBuilder(connectionString);
     Assert.IsNull(builder.Username);
     Assert.IsNull(builder.Password);
     Assert.AreEqual(1, builder.Servers.Count());
     Assert.AreEqual("localhost", builder.Server.Host);
     Assert.AreEqual(27017, builder.Server.Port);
     Assert.AreEqual(null, builder.DatabaseName);
     Assert.AreEqual(ConnectionMode.ReplicaSet, builder.ConnectionMode);
     Assert.AreEqual("name", builder.ReplicaSetName);
     Assert.AreEqual(GuidRepresentation.PythonLegacy, builder.GuidRepresentation);
     Assert.AreEqual(new SafeMode(true) { FSync = true, J = true, W = 2, WTimeout = TimeSpan.FromSeconds(2) }, builder.SafeMode);
     Assert.AreEqual(true, builder.SlaveOk);
     Assert.AreEqual(connectionString, builder.ToString());
 }
开发者ID:javanal,项目名称:mongo-csharp-driver,代码行数:17,代码来源:MongoConnectionStringBuilderTests.cs

示例10: TestUsernamePasswordLocalhostDatabase

 public void TestUsernamePasswordLocalhostDatabase()
 {
     string connectionString = "server=localhost;database=database;username=username;password=password";
     var builder = new MongoConnectionStringBuilder(connectionString);
     Assert.AreEqual("username", builder.Username);
     Assert.AreEqual("password", builder.Password);
     Assert.AreEqual(1, builder.Servers.Count());
     Assert.AreEqual("localhost", builder.Servers.Single().Host);
     Assert.AreEqual(27017, builder.Servers.Single().Port);
     Assert.AreEqual("database", builder.DatabaseName);
     Assert.AreEqual(ConnectionMode.Direct, builder.ConnectionMode);
     Assert.AreEqual(null, builder.ReplicaSetName);
     Assert.AreEqual(connectionString, builder.ToString());
 }
开发者ID:javanal,项目名称:mongo-csharp-driver,代码行数:14,代码来源:MongoConnectionStringBuilderTests.cs

示例11: TestTwoHostsWithPorts

 public void TestTwoHostsWithPorts()
 {
     string connectionString = "server=mongo1.xyz.com:12345,mongo2.xyz.com:23456";
     var builder = new MongoConnectionStringBuilder(connectionString);
     Assert.IsNull(builder.Username);
     Assert.IsNull(builder.Password);
     Assert.AreEqual(2, builder.Servers.Count());
     Assert.AreEqual("mongo1.xyz.com", builder.Servers.First().Host);
     Assert.AreEqual(12345, builder.Servers.First().Port);
     Assert.AreEqual("mongo2.xyz.com", builder.Servers.Skip(1).Single().Host);
     Assert.AreEqual(23456, builder.Servers.Skip(1).Single().Port);
     Assert.AreEqual(ConnectionMode.ReplicaSet, builder.ConnectionMode);
     Assert.AreEqual(null, builder.ReplicaSetName);
     Assert.AreEqual(connectionString, builder.ToString());
 }
开发者ID:javanal,项目名称:mongo-csharp-driver,代码行数:15,代码来源:MongoConnectionStringBuilderTests.cs

示例12: TestSlaveOkTrue

 public void TestSlaveOkTrue()
 {
     string connectionString = "server=localhost;slaveOk=true";
     var builder = new MongoConnectionStringBuilder(connectionString);
     Assert.AreEqual(true, builder.SlaveOk);
     Assert.AreEqual(connectionString, builder.ToString());
 }
开发者ID:javanal,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoConnectionStringBuilderTests.cs

示例13: TestSafeModeWMajority

 public void TestSafeModeWMajority()
 {
     string connectionString = "server=localhost;w=majority";
     var builder = new MongoConnectionStringBuilder(connectionString);
     Assert.AreEqual(new SafeMode(true) { WMode = "majority" }, builder.SafeMode);
     Assert.AreEqual("server=localhost;safe=true;w=majority", builder.ToString()); // safe=true added
 }
开发者ID:javanal,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoConnectionStringBuilderTests.cs

示例14: TestIpV6

 public void TestIpV6()
 {
     string connectionString = "server=localhost;ipv6=true";
     var builder = new MongoConnectionStringBuilder(connectionString);
     Assert.AreEqual(true, builder.IPv6);
     Assert.AreEqual(connectionString, builder.ToString());
 }
开发者ID:javanal,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoConnectionStringBuilderTests.cs

示例15: TestWaitQueueTimeout

 public void TestWaitQueueTimeout()
 {
     string connectionString = "server=localhost;waitQueueTimeout=123ms";
     var builder = new MongoConnectionStringBuilder(connectionString);
     Assert.AreEqual(TimeSpan.FromMilliseconds(123), builder.WaitQueueTimeout);
     Assert.AreEqual(connectionString, builder.ToString());
 }
开发者ID:javanal,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoConnectionStringBuilderTests.cs


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