Ejemplo n.º 1
0
        public void GetObjectData()
        {
            Type type = typeof(HsqlDataSourceException);
            FormatterConverter converter = new FormatterConverter();
            SerializationInfo  info      = new SerializationInfo(type, converter);
            StreamingContext   context   = new StreamingContext();

            HsqlDataSourceException testSubject = new HsqlDataSourceException("foo", -1, "42001");

            testSubject.GetObjectData(info, context);

            Console.WriteLine("Member Count: {0}", info.MemberCount);

            foreach (SerializationEntry item in info)
            {
                Console.WriteLine("Name: {0},  Type: {1},  Value: {2}", item.Name, item.ObjectType, item.Value);

                if (item.Name == "m_code")
                {
                    Assert.AreEqual(-1, item.Value);
                }
                else if (item.Name == "m_state")
                {
                    Assert.AreEqual("42001", item.Value);
                }
                else if (item.Name == "Message")
                {
                    Assert.AreEqual("foo", item.Value);
                }
            }


            //Assert.Fail("TODO");
        }
        public void GetObjectData()
        {
            Type type = typeof(HsqlDataSourceException);
            FormatterConverter converter = new FormatterConverter();
            SerializationInfo info = new SerializationInfo(type, converter);
            StreamingContext context = new StreamingContext();

            HsqlDataSourceException testSubject = new HsqlDataSourceException("foo", -1, "42001");

            testSubject.GetObjectData(info, context);

            Console.WriteLine("Member Count: {0}", info.MemberCount);

            foreach(SerializationEntry item in info)
            {
                Console.WriteLine("Name: {0},  Type: {1},  Value: {2}", item.Name, item.ObjectType, item.Value);

                if (item.Name == "m_code")
                {
                    Assert.AreEqual(-1, item.Value);
                }
                else if (item.Name == "m_state")
                {
                    Assert.AreEqual("42001", item.Value);
                }
                else if (item.Name == "Message")
                {
                    Assert.AreEqual("foo", item.Value);
                }
            }

            //Assert.Fail("TODO");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Computes and returns the supported command type given a stipulated command type and command object.
        /// </summary>
        /// <remarks>
        /// If the returned type does not match the stipulated type,
        /// a warning event is raised on the given command object.
        /// </remarks>
        /// <param name="commandType">Type of the command.</param>
        /// <param name="command">The command.</param>
        /// <returns>the supported command type</returns>
        private static CommandType ToSupportedCommandType(CommandType commandType, HsqlCommand command)
        {
            switch (commandType)
            {
            case CommandType.StoredProcedure:
            case CommandType.TableDirect:
            case CommandType.Text:
            {
                return(commandType);
            }

            default:
            {
                ArgumentException ex = new ArgumentException(
                    "commandType", string.Format(
                        "[{0}] is not a valid command type", commandType));
                HsqlDataSourceException hex = new HsqlDataSourceException("Warning.", ex);

                command.OnWarning(new HsqlWarningEventArgs(hex));

                return(CommandType.Text);
            }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Retreives an <c>HsqlDataSourceException</c> indicating that
        /// an invalid identifier token was encountered
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns>a new <c>HsqlDataSourceException</c>.</returns>
        public static HsqlDataSourceException InvalidIdentifier(object token)
        {
            HsqlException he = HsqlTrace.error(HsqlTrace.INVALID_IDENTIFIER, token);
            HsqlDataSourceException ex = new HsqlDataSourceException(he);

            return ex;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Retreives an <c>HsqlDataSourceException</c> indicating that
        /// an invalid wait state was encountered.
        /// </summary>
        /// <remarks>
        /// An invalid wait state occurs when an attempt is made
        /// to query the state of the last read token after it has
        /// been pushed back on to front of the token stream but
        /// before a subsequent ReadToken() invocation has occured.
        /// Presently, this can happen only between an invocation of
        /// <see cref="IsGetThis(string)"/> that returns <c>false</c>
        /// and a subsequenct invocation of <see cref="ReadToken()"/>,
        /// typically via <c>GetNextXXX(...)</c> or <c>GetThis(string)</c>.
        /// </remarks>
        /// <returns>a new <c>HsqlDataSourceException</c>.</returns>
        public static HsqlDataSourceException IllegalWaitState()
        {
            HsqlException he
                = HsqlTrace.error(HsqlTrace.ASSERT_FAILED,
                              "Querying state when in Wait mode");
            HsqlDataSourceException ex = new HsqlDataSourceException(he);

            return ex;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Retreives an <c>HsqlDataSourceException</c> indicating that
        /// the maximum legal identifier chain length has been exceeded.
        /// </summary>
        /// <returns>a new <c>HsqlDataSourceException</c>.</returns>
        public static HsqlDataSourceException IdentiferChainLengthExceeded()
        {
            HsqlException he = HsqlTrace.error(HsqlTrace.THREE_PART_IDENTIFIER);
            HsqlDataSourceException ex = new HsqlDataSourceException(he);

            return ex;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Retreives an <c>HsqlDataSourceException</c> indicating that
        /// an unexpected token was encountered
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns>a new <c>HsqlDataSourceException</c>.</returns>
        public static HsqlDataSourceException UnexpectedToken(object token)
        {
            HsqlException he = HsqlTrace.error(HsqlTrace.UNEXPECTED_TOKEN, token);
            HsqlDataSourceException ex = new HsqlDataSourceException(he);

            return ex;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Retreives an <c>HsqlDataSourceException</c> indicating that
        /// the end of the token stream was reached in an unexpected
        /// fashion.
        /// </summary>
        /// <returns>a new <c>HsqlDataSourceException</c>.</returns>
        public static HsqlDataSourceException UnexpectedEndOfCommand()
        {
            HsqlException he = HsqlTrace.error(HsqlTrace.UNEXPECTED_END_OF_COMMAND);
            HsqlDataSourceException ex = new HsqlDataSourceException(he);

            return ex;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Retreives an <c>HsqlDataSourceException</c> indicating that
        /// the specified <c>match</c> value did not match the
        /// specified <c>token</c>.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="match">The value to match.</param>
        /// <returns>a new <c>HsqlDataSourceException</c>.</returns>
        public static HsqlDataSourceException MatchFailed(object token,
            object match)
        {
            object[] parms = new object[] { token, match };
            HsqlException he = HsqlTrace.error(HsqlTrace.UNEXPECTED_TOKEN,
                HsqlTrace.TOKEN_REQUIRED, parms);
            HsqlDataSourceException ex = new HsqlDataSourceException(he);

            return ex;
        }