public void constructor_with_innerException_should_initialize_subject()
        {
            var subject = new MongoConnectionException(_connectionId, _message, _innerException);

            subject.ConnectionId.Should().BeSameAs(_connectionId);
            subject.InnerException.Should().BeSameAs(_innerException);
            subject.Message.Should().BeSameAs(_message);
        }
        public void constructor_with_innerException_should_initialize_subject()
        {
            var subject = new MongoConnectionException(_connectionId, _message, _innerException);

            subject.ConnectionId.Should().BeSameAs(_connectionId);
            subject.InnerException.Should().BeSameAs(_innerException);
            subject.Message.Should().BeSameAs(_message);
        }
        public void Serialization_should_work()
        {
            var subject = new MongoConnectionException(_connectionId, _message, _innerException);

            var formatter = new BinaryFormatter();
            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, subject);
                stream.Position = 0;
                var rehydrated = (MongoConnectionException)formatter.Deserialize(stream);

                rehydrated.ConnectionId.Should().Be(subject.ConnectionId);
                rehydrated.Message.Should().Be(subject.Message);
                rehydrated.InnerException.Message.Should().Be(subject.InnerException.Message); // Exception does not override Equals
            }
        }
        public void Serialization_should_work()
        {
            var subject = new MongoConnectionException(_connectionId, _message, _innerException);

            var formatter = new BinaryFormatter();

            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, subject);
                stream.Position = 0;
                var rehydrated = (MongoConnectionException)formatter.Deserialize(stream);

                rehydrated.ConnectionId.Should().Be(subject.ConnectionId);
                rehydrated.Message.Should().Be(subject.Message);
                rehydrated.InnerException.Message.Should().Be(subject.InnerException.Message); // Exception does not override Equals
            }
        }
Example #5
0
 private static string MongoConnectionExceptionHandle(MongoConnectionException ex,
     List<TreeNode> trvMongoDb,
     TreeNode connectionNode, string mongoConnKey)
 {
     //暂时不处理任何异常,简单跳过
     //无法连接的理由:
     //1.服务器没有启动
     //2.认证模式不正确
     if (!GuiConfig.IsUseDefaultLanguage)
     {
         connectionNode.Text += "[" + GuiConfig.GetText("ExceptionNotConnected") + "]";
         Utility.ExceptionDeal(ex, GuiConfig.GetText("ExceptionNotConnected"), GuiConfig.GetText("ExceptionNotConnectedNote"));
     }
     else
     {
         connectionNode.Text += "[Exception]";
         Utility.ExceptionDeal(ex, "Not Connected", "Mongo Server may not Startup or Auth Mode is not correct");
     }
     connectionNode.Tag = ConstMgr.ConnectionExceptionTag + ":" + mongoConnKey;
     trvMongoDb.Add(connectionNode);
     return mongoConnKey;
 }
 public DriverException(string message, MongoConnectionException innerException)
     : base(message, innerException)
 {
 }