예제 #1
0
        public void ToString_should_return_string_representation()
        {
            var subject  = new ClusterDescription(new ClusterId(1), ClusterConnectionMode.Standalone, ClusterType.Standalone, new[] { __serverDescription1 });
            var expected = string.Format("{{ ClusterId : \"1\", ConnectionMode : \"Standalone\", Type : \"Standalone\", State : \"Disconnected\", Servers : [{0}] }}",
                                         __serverDescription1.ToString());

            subject.ToString().Should().Be(expected);
        }
예제 #2
0
        public void ToString_should_return_string_representation()
        {
#pragma warning disable CS0618 // Type or member is obsolete
            var subject = new ClusterDescription(new ClusterId(1), ClusterConnectionMode.Standalone, ClusterType.Standalone, new[] { __serverDescription1 });
#pragma warning restore CS0618 // Type or member is obsolete
            var expected = string.Format("{{ ClusterId : \"1\", ConnectionMode : \"Standalone\", Type : \"Standalone\", State : \"Disconnected\", Servers : [{0}] }}",
                                         __serverDescription1.ToString());
            subject.ToString().Should().Be(expected);
        }
예제 #3
0
        private string BuildTimeoutExceptionMessage(TimeSpan timeout, ClusterDescription clusterDescription)
        {
            var ms = (int)Math.Round(timeout.TotalMilliseconds);

            return(string.Format(
                       "A timeout occured after {0}ms selecting a server. Client view of cluster state is {1}.",
                       ms.ToString(),
                       clusterDescription.ToString()));
        }
예제 #4
0
        public void ToString_with_directConnection_should_return_string_representation([Values(null, false)] bool?directConnection)
        {
            var subject = new ClusterDescription(new ClusterId(1), directConnection, dnsMonitorException: null, ClusterType.Standalone, new[] { __serverDescription1 });
            var directConnectionString = directConnection.HasValue ? $", DirectConnection : \"{directConnection.Value.ToString()}\"" : string.Empty;
            var expected = string.Format("{{ ClusterId : \"1\"{1}, Type : \"Standalone\", State : \"Disconnected\", Servers : [{0}] }}",
                                         __serverDescription1.ToString(),
                                         directConnectionString);

            subject.ToString().Should().Be(expected);
        }
예제 #5
0
        public void ToString_should_return_string_representation_when_dnsMonitorException_is_not_null()
        {
            var dnsMonitorException = new Exception("DNS");
            var subject             = new ClusterDescription(new ClusterId(1), ClusterConnectionMode.Standalone, dnsMonitorException, ClusterType.Standalone, new[] { __serverDescription1 });
            var expected            = string.Format(
                "{{ ClusterId : \"1\", ConnectionMode : \"Standalone\", Type : \"Standalone\", State : \"Disconnected\", Servers : [{0}], DnsMonitorException : \"{1}\" }}",
                __serverDescription1,
                dnsMonitorException);

            subject.ToString().Should().Be(expected);
        }
예제 #6
0
        public void ToString_should_return_string_representation_when_dnsMonitorException_is_not_null()
        {
            var  dnsMonitorException = new Exception("DNS");
            bool?directConnection    = null;

#pragma warning disable CS0618 // Type or member is obsolete
            var connectionModeSwitch = ConnectionModeSwitch.UseConnectionMode;
            var subject = new ClusterDescription(new ClusterId(1), ClusterConnectionMode.Standalone, connectionModeSwitch, directConnection, dnsMonitorException, ClusterType.Standalone, new[] { __serverDescription1 });
#pragma warning restore CS0618 // Type or member is obsolete
            var expected = string.Format(
                "{{ ClusterId : \"1\", ConnectionMode : \"Standalone\", Type : \"Standalone\", State : \"Disconnected\", Servers : [{0}], DnsMonitorException : \"{1}\" }}",
                __serverDescription1,
                dnsMonitorException);
            subject.ToString().Should().Be(expected);
        }