示例#1
0
        internal override ConfigurationCommand Execute(XmlElement configurationElement)
        {
            var undoCommand = ConfigurationCommandFactory.CreateUndoCommandForUpdate(this, configurationElement);

            foreach (var attributeSpecification in AttributeSpecifications)
            {
                attributeSpecification.Execute(configurationElement);
            }
            return(undoCommand);
        }
        public void CreateUndoCommandSucceedsForUpdate()
        {
            var elementToUpdate = Files.Load("web-original.config").AsXmlDocument().SelectSingleNode("/configuration/appSettings/add[@key='first_setting']") as XmlElement;
            var command         = ConfigurationCommandFactory.CreateUndoCommandForUpdate(
                new ElementUpdateCommand(
                    "/configuration/appSettings/add[@key='first_setting']",
                    new[] {
                new AttributeSpecification {
                    Name = "value", Value = "test", NamespaceUri = string.Empty
                }
            }),
                elementToUpdate);

            command.Should().BeEquivalentTo(
                new ElementUpdateCommand(
                    "/configuration/appSettings/add[@key='first_setting']",
                    new[] {
                new AttributeSpecification {
                    Name = "value", Value = "", NamespaceUri = string.Empty
                }
            }));
        }