public void GetTypeFromSqlDbType_InvalidTypes(SqlDbType sqlDbType)
        {
            SPSSchema schema = new SPSSchema();

            Assert.IsNull(schema.GetSystemTypeFromSqlDbType_Test(sqlDbType.ToString()));
            Assert.IsNull(schema.GetSystemTypeFromSqlDbType_Test(sqlDbType));
        }
        public void Constructor()
        {
            SPSSchema schema = new SPSSchema();

            Assert.IsNotNull(schema);
            Assert.IsNotNull(schema.Schema);
        }
        public void AddParameterSql_DuplicateType()
        {
            SPSSchema schema = new SPSSchema();

            schema.AddParameterSql("Test", SqlDbType.Int);
            schema.AddParameterSql("Test", SqlDbType.Int);
        }
        //[ExpectedException(typeof(DuplicateNameException))]
        public void AddParameterSql_DuplicateType()
        {
            SPSSchema schema = new SPSSchema();

            schema.AddParameterSql("Test", SqlDbType.Int);
            schema.AddParameterSql("Test", SqlDbType.Int);
            Assert.AreEqual(1, schema.Schema.Count);
        }
        public void GetTypeFromSqlDbType(SqlDbType sqlDbType, Type expectedType)
        {
            SPSSchema schema = new SPSSchema();

            Trace.WriteLine(string.Format("{0},{1}", expectedType, sqlDbType));

            Assert.IsTrue(expectedType == schema.GetSystemTypeFromSqlDbType_Test(sqlDbType.ToString()));
            Assert.IsTrue(expectedType == schema.GetSystemTypeFromSqlDbType_Test(sqlDbType));
        }
        public void AddParameterSql_NullParameter(SqlDbType sqlDbType)
        {
            SPSSchema schema = new SPSSchema();

            schema.AddParameterSql(null, sqlDbType);
            Assert.IsTrue(schema.Schema.Count == 1);
            Trace.WriteLine(string.Format("{0}", schema.Schema[0].Name));
            Assert.IsTrue(schema.Schema[0].PropertyType.Equals(schema.GetSystemTypeFromSqlDbType_Test(sqlDbType)));
        }
        public void AddParameter_StringType(Type type)
        {
            SPSSchema schema = new SPSSchema();

            schema.AddParameter(type.ToString(), type.ToString());
            Assert.IsTrue(schema.Schema.Count == 1);
            Trace.WriteLine(string.Format("{0},{1},{2}", type, schema.Schema[0].Name, schema.Schema[0].PropertyType));
            Assert.IsTrue(schema.Schema[0].Name == type.ToString());
            Assert.IsTrue(schema.Schema[0].PropertyType.Equals(type));
        }
        /// <summary>
        /// Gets the Schema.
        /// </summary>
        /// <returns>
        /// Describing the variables in the query
        /// </returns>
        public PropertyDescriptorCollection GetSchema()
        {
            SPSSchema schema = new SPSSchema();

            foreach (SPSKeyValuePair keyValuePair in _variableFunctions)
            {
                schema.AddParameter(keyValuePair.Key, typeof(string));
            }

            return(schema.Schema);
        }
        //#region Public properties

        ///// <summary>
        ///// Gets the variables values.
        ///// </summary>
        ///// <value>The variables values.</value>
        //public SPSKeyValueList VariablesValues
        //{
        //    get { return _variableValues; }
        //}

        //#endregion

        #region Public methods

        /// <summary>
        /// Gets the Schema.
        /// </summary>
        /// <returns>
        /// Describing the variables in the query
        /// </returns>
        public PropertyDescriptorCollection GetSchema()
        {
            ParseParametersFormulas();

            SPSSchema schema = new SPSSchema();

            foreach (SPSKeyValuePair keyValuePair in _parameterFormulas)
            {
                schema.AddParameter(keyValuePair.Key, typeof(string));
            }

            return(schema.Schema);
        }
Example #10
0
        public void ConnectionParametersConsumer(IWebPartParameters parameters)
        {
            if (parameters != null && Config != null)
            {
                SPSSchema schemaBuilder = new SPSSchema();

                // Add each necesary parameter
                foreach (IdentityColumn column in Config.DataBase.Table.IdentityColumnCollection)
                {
                    schemaBuilder.AddParameterSql(column.Name, column.Type.ToString());
                }

                // Set the schema
                parameters.SetConsumerSchema(schemaBuilder.Schema);

                // The get parameters callback
                parameters.GetParametersData(ConsumeParameterValues);
            }
        }
        public void ConnectionParametersConsumer(IWebPartParameters parameters)
        {
            Debug.WriteLine("ConnectionParametersConsumer " + Title);

            if (parameters != null && Config != null)
            {
                SPSSchema schema = new SPSSchema();

                // Add each necesary parameter
                foreach (Param param in Config.Filter)
                {
                    schema.AddParameterSql(param.Name, param.Type);
                }

                // Set the schema
                parameters.SetConsumerSchema(schema.Schema);

                // The get parameters callback
                parameters.GetParametersData(ConsumeParameterValues);
            }
        }
Example #12
0
 public SPSParametersProvider_Tests()
 {
     schema = new SPSSchema();
     schema.AddParameter("Test1", typeof(string));
     schema.AddParameter("Test2", typeof(int));
 }
        public void AddParameterSql_NullType()
        {
            SPSSchema schema = new SPSSchema();

            schema.AddParameterSql("Test", null);
        }
        public void AddParameterSql_BadType()
        {
            SPSSchema schema = new SPSSchema();

            schema.AddParameterSql("Test", "BadType");
        }