Inheritance: MongoConnectionException
        public void constructor_with_innerException_should_initialize_subject()
        {
            var subject = new MongoAuthenticationException(_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 MongoAuthenticationException(_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 MongoAuthenticationException(_connectionId, _message, _innerException);

            var formatter = new BinaryFormatter();
            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, subject);
                stream.Position = 0;
                var rehydrated = (MongoAuthenticationException)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 MongoAuthenticationException(_connectionId, _message, _innerException);

            var formatter = new BinaryFormatter();

            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, subject);
                stream.Position = 0;
                var rehydrated = (MongoAuthenticationException)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
            }
        }
Ejemplo n.º 5
0
 private static void AuthenticationExceptionHandler(MongoAuthenticationException ex,
     List<TreeNode> trvMongoDb,
     TreeNode connectionNode,
     string mongoConnKey)
 {
     //需要验证的数据服务器,没有Admin权限无法获得数据库列表
     if (!GuiConfig.IsUseDefaultLanguage)
     {
         connectionNode.Text += "[" + GuiConfig.GetText("ExceptionAuthenticationException") + "]";
         Utility.ExceptionDeal(ex, GuiConfig.GetText("ExceptionAuthenticationException"), GuiConfig.GetText("ExceptionAuthenticationExceptionNote"));
     }
     else
     {
         connectionNode.Text += "[MongoAuthenticationException]";
         Utility.ExceptionDeal(ex, "MongoAuthenticationException:", "Please check UserName and Password");
     }
     connectionNode.Tag = ConstMgr.ConnectionExceptionTag + ":" + mongoConnKey;
     trvMongoDb.Add(connectionNode);
 }