Esempio n. 1
0
        /// <summary>
        ///     Patches the configuration elements with type attribute.
        /// </summary>
        /// <param name="root">The assembly binding.</param>
        private static void PatchConfigElementsWithTypeAttribute(XmlNode root)
        {
            if (root == null)
            {
                return;
            }

            foreach (XmlNode node in root.ChildNodes)
            {
                PatchConfigElementsWithTypeAttribute(node);
            }

            if (knowTypes.ContainsKey(root.Name) && !XmlUtil.HasAttribute("type", root))
            {
                var type = knowTypes[root.Name];

                var attributes = XmlUtil.GetAttributes(root);

                var keys = attributes.AllKeys.Where(k => type.GetProperty(k, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase) != null);
                foreach (var name in keys)
                {
                    XmlUtil.AddElement(name, root, attributes[name]);
                }

                XmlUtil.AddAttribute("type", type.AssemblyQualifiedName, root);
            }
        }
Esempio n. 2
0
        public void ChangeTemplateThrowsIfNoDbItemFound(
            [Greedy] FakeDataProvider sut,
            ItemDefinition def)
        {
            var doc      = new XmlDocument();
            var template = doc.AppendChild(doc.CreateElement("template"));

            XmlUtil.AddAttribute("name", "template", template);
            var changes = new TemplateChangeList(
                Template.Parse(template, new TemplateCollection()),
                Template.Parse(template, new TemplateCollection()));

            Action action = () => sut.ChangeTemplate(def, changes, null);

            action.ShouldThrow <InvalidOperationException>()
            .WithMessage("Unable to change item template. The item '{0}' is not found.".FormatWith(def.ID));
        }
Esempio n. 3
0
        public virtual void Expects(string pipelineName, PipelineArgs pipelineArgs)
        {
            Assert.ArgumentNotNullOrEmpty(pipelineName, "pipelineName");

            this.expectedCalls[pipelineName] = pipelineArgs;
            this.lastUsedPipelineName        = pipelineName;

            var path          = "/sitecore/pipelines/" + pipelineName + "/processor";
            var processorNode = XmlUtil.EnsurePath(path, this.config);

            processorNode.RemoveAll();

            var type  = typeof(PipelineWatcherProcessor);
            var value = type + ", " + type.Assembly.GetName().Name;

            XmlUtil.AddAttribute("type", value, processorNode);

            var expectedName = "<param desc=\"expectedName\">{0}</param>".FormatWith(pipelineName);

            XmlUtil.AddXml(expectedName, processorNode);
        }