Exemplo n.º 1
0
        public void Transform()
        {
            SPSKeyValueList list = new SPSKeyValueList();

            list.Add("key0", "value0");
            list.Add("key1", "value1");
            list.Add("key2", "value2");

            Mock <Page>    mockPage    = MockManager.MockObject <Page>(Constructor.Mocked);
            Mock <Control> mockControl = MockManager.MockObject <Control>(Constructor.Mocked);

            mockControl.MockedInstance.ID = "TestID";

            Mock <SPSXsltControl> xsltMockControl = MockManager.MockObject <SPSXsltControl>(Constructor.Mocked);

            xsltMockControl.ExpectGet("Page", mockPage.MockedInstance);
            xsltMockControl.ExpectGet("Parent", mockControl.MockedInstance);

            SPSXsltControl xsltControl = xsltMockControl.MockedInstance;

            Assert.IsNotNull(xsltControl);
            xsltControl.XmlData = TestData.GetResource("TestData.xml");
            xsltControl.Xsl     = TestData.GetResource("Test.xslt");
            StringWriter transform = xsltControl.Transform();
            string       output    = transform.ToString();

            Debug.WriteLine(output);

            Assert.IsTrue(output.Contains("TEST"));
            Assert.IsTrue(output.Contains("1"));
            Assert.IsTrue(output.Contains("2"));

            MockManager.Verify();
        }
Exemplo n.º 2
0
        public void Index()
        {
            SPSKeyValueList keyValues = new SPSKeyValueList();

            keyValues.Add(new SPSKeyValuePair("Key", "Value"));
            keyValues.Add(new SPSKeyValuePair("Key1", "Value1"));

            Assert.IsTrue(keyValues["Key"] == "Value");
            Assert.IsTrue(keyValues["Key1"] == "Value1");
        }
Exemplo n.º 3
0
        public void Contains()
        {
            SPSKeyValueList keyValues = new SPSKeyValueList();

            keyValues.Add(new SPSKeyValuePair("Key", "Value"));
            keyValues.Add(new SPSKeyValuePair("Key", "Value"));

            Assert.IsTrue(keyValues.Contains("Key"));
            Assert.IsFalse(keyValues.Contains("OtherKey"));
        }
Exemplo n.º 4
0
        public void ReplaceAllValues()
        {
            SPSKeyValueList keyValues = new SPSKeyValueList();

            keyValues.Add(new SPSKeyValuePair("Key", "Value"));
            keyValues.Add(new SPSKeyValuePair("Key", "Value"));

            keyValues.ReplaceAllValues("Key", "NewValue");

            Assert.IsTrue(keyValues[0].Value == "NewValue");
            Assert.IsTrue(keyValues[1].Value == "NewValue");
        }
Exemplo n.º 5
0
        public void AddKeyValuePair()
        {
            SPSKeyValueList keyValues = new SPSKeyValueList();

            keyValues.Add(new SPSKeyValuePair("Key", "Value"));
            keyValues.Add(new SPSKeyValuePair("Key", "Value"));


            Assert.IsTrue(keyValues.Count == 2);

            Assert.IsTrue(keyValues[0].Key == "Key");
            Assert.IsTrue(keyValues[0].Value == "Value");
            Assert.IsTrue(keyValues[1].Key == "Key");
            Assert.IsTrue(keyValues[1].Value == "Value");
        }
        public SPSXsltExtension_Test()
        {
            SPSKeyValueList list = new SPSKeyValueList();

            list.Add("key0", "value0");
            list.Add("key1", "value1");
            list.Add("key2", "value2");

            Mock <Page>    mockPage    = MockManager.MockObject <Page>(Constructor.Mocked);
            Mock <Control> mockControl = MockManager.MockObject <Control>(Constructor.Mocked);

            mockControl.MockedInstance.ID = "TestID";

            _extension = new SPSXsltExtension(mockControl.MockedInstance, mockPage.MockedInstance, list);
            MockManager.Verify();
        }
Exemplo n.º 7
0
        public SPSXsltExtension_Test()
        {
            SPSKeyValueList list = new SPSKeyValueList();

            list.Add("key0", "value0");
            list.Add("key1", "value1");
            list.Add("key2", "value2");

            Mock <Page>           mockPage           = MockManager.MockObject <Page>(Constructor.Mocked);
            SPSXsltCommandControl xsltCommandControl = new SPSXsltCommandControl
            {
                ID = "TestID"
            };

            _extension = new SPSXsltExtension(xsltCommandControl, mockPage.MockedInstance, list);

            MockManager.Verify();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Consumes the parameter values.
        /// </summary>
        /// <param name="parametersData">The parameters data.</param>
        public void ConsumeParameterValues(IDictionary parametersData)
        {
            Debug.WriteLine("ConsumeParameterValues");

            if (parametersData != null)
            {
                foreach (Object key in parametersData.Keys)
                {
                    _parameterValues.Add(key.ToString(), parametersData[key].ToString());

                    Debug.WriteLine("Parameter: " + key + " - " + parametersData[key]);
                }
            }
        }
Exemplo n.º 9
0
        public void SerializeDeserialize()
        {
            SPSKeyValueList keyValuesBefore = new SPSKeyValueList();

            SPSKeyValuePair keyValue0 = new SPSKeyValuePair("KeyA", "Value1");
            SPSKeyValuePair keyValue1 = new SPSKeyValuePair("KeyB", "Value2");

            keyValuesBefore.Add(keyValue0);
            keyValuesBefore.Add(keyValue1);

            string serialized = SPSKeyValueList.Serialize(keyValuesBefore);

            SPSKeyValueList keyValuesAfter = SPSKeyValueList.Deserialize(serialized);

            Assert.IsTrue(keyValuesAfter.Count == keyValuesBefore.Count);

            Assert.IsTrue(keyValuesAfter.Count == keyValuesBefore.Count);

            Assert.IsTrue(keyValuesAfter.Contains("KeyA"));
            Assert.IsTrue(keyValuesAfter.Contains("KeyB"));

            Assert.IsTrue(keyValuesAfter[0].Value == "Value1");
            Assert.IsTrue(keyValuesAfter[1].Value == "Value2");
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the row data.
        /// </summary>
        /// <returns>Contains the schema if no data, otherwise data and schema</returns>
        public SPSKeyValueList GetRowValues(int?selectedRow)
        {
            SPSKeyValueList keyValues = new SPSKeyValueList();

            // Generate Data
            if (selectedRow != null && HasResults)
            {
                DataRowView rowView = _dataTable.DefaultView[selectedRow.Value];

                foreach (DataColumn column in _dataTable.Columns)
                {
                    keyValues.Add(column.ColumnName, rowView[column.ColumnName].ToString());
                }
            }

            return(keyValues);
        }
        /// <summary>
        /// Gets the parameters.
        /// </summary>
        /// <returns>A list with parameters and values or functions</returns>
        private void GetParameters()
        {
            if (_camlQuery != null)
            {
                MatchCollection ms = _regex.Matches(_camlQuery);

                foreach (Match match in ms)
                {
                    Debug.WriteLine(string.Format("Parameter - {0} - {1}",
                                                  match.Groups[CAMLVariable].Value,
                                                  match.Groups[CAMLFunction].Value));

                    _variableFunctions.Add(match.Groups[CAMLVariable].Value,
                                           match.Groups[CAMLFunction].Value);
                }
            }
        }
        /// <summary>
        /// Gets the row data.
        /// </summary>
        /// <returns>Contains the schema if no data, otherwise data and schema</returns>
        public SPSKeyValueList GetDataValues()
        {
            SPSKeyValueList keyValues = new SPSKeyValueList();

            // Generate Data
            if (SelectedRow != null && HasResults)
            {
                DataRowView rowView = Data.Tables[0].DefaultView[SelectedRow.Value];
                foreach (DataColumn column in Data.Tables[0].Columns)
                {
                    keyValues.Add(column.ColumnName, rowView[column.ColumnName].ToString());
                }
                return(keyValues);
            }

            return(null);
        }
        /// <summary>
        /// Gets the parameters.
        /// </summary>
        /// <returns>A list with parameters and values or functions</returns>
        private void ParseParametersFormulas()
        {
            if (_camlQuery != null)
            {
                _parameterFormulas.Clear();

                MatchCollection ms = _regex.Matches(_camlQuery);

                foreach (Match match in ms)
                {
                    Debug.WriteLine(string.Format("Parameter - {0} - {1}",
                                                  match.Groups[CAMLVariable].Value,
                                                  match.Groups[CAMLFunction].Value));

                    _parameterFormulas.Add(match.Groups[CAMLVariable].Value,
                                           match.Groups[CAMLFunction].Value);
                }
            }
        }
Exemplo n.º 14
0
 private void GetDataFromConfigurationManager()
 {
     _properties.Add(FLD_SITE_NAME, SPSConfigurationManager.EnsureGetValue(_category, FLD_SITE_NAME));
     _properties.Add(FLD_SITE_URL, SPSConfigurationManager.EnsureGetValue(_category, FLD_SITE_URL));
     _properties.Add(FLD_TEMPLATE, SPSConfigurationManager.EnsureGetValue(_category, FLD_TEMPLATE));
     _properties.Add(TEMPLATE_MAP, SPSConfigurationManager.EnsureGetValue(_category, TEMPLATE_MAP));
     _properties.Add(OPT_LOG_ERROR, SPSConfigurationManager.EnsureGetValue(_category, OPT_LOG_ERROR));
     _properties.Add(OPT_HIDE_TEMPLATE_FIELD, SPSConfigurationManager.EnsureGetValue(_category, OPT_HIDE_TEMPLATE_FIELD));
     _properties.Add(OPT_FORCE_DUP, SPSConfigurationManager.EnsureGetValue(_category, OPT_FORCE_DUP));
     _properties.Add(OPT_ON_QUICKLAUNCH, SPSConfigurationManager.EnsureGetValue(_category, OPT_ON_QUICKLAUNCH));
     _properties.Add(OPT_ON_TOPNAVBAR, SPSConfigurationManager.EnsureGetValue(_category, OPT_ON_TOPNAVBAR));
     _properties.Add(OPT_UNIQUE_PERMISSIONS, SPSConfigurationManager.EnsureGetValue(_category, OPT_UNIQUE_PERMISSIONS));
     _properties.Add(OPT_NEW_PERMISSIONS, SPSConfigurationManager.EnsureGetValue(_category, OPT_NEW_PERMISSIONS));
     _properties.Add(OPT_ATTACH_DELETE_SITE, SPSConfigurationManager.EnsureGetValue(_category, OPT_ATTACH_DELETE_SITE));
 }
 /// <summary>
 /// Copies the variable values.
 /// </summary>
 /// <param name="keyValueList">The key value list.</param>
 public void CopyVariableValues(SPSKeyValueList keyValueList)
 {
     keyValueList.Clear();
     _variableValues.ForEach(pair => keyValueList.Add(pair));
 }
 /// <summary>
 /// Initializes the variable values.
 /// </summary>
 /// <param name="keyValueList">The key value list.</param>
 public void InitializeVariableValues(SPSKeyValueList keyValueList)
 {
     ClearVariableValues();
     keyValueList.ForEach(pair => _variableValues.Add(pair));
 }