public ElementUpsertionCommand(string configurationElementSelector, ElementInsertionCommand insertionCommand, ElementUpdateCommand updateCommand) : base(configurationElementSelector) { Arguments.Validation.Constraints .IsNotNull(insertionCommand, nameof(insertionCommand)) .Check() .IsNotNull(updateCommand, nameof(updateCommand)) .Check(); InsertionCommand = insertionCommand; UpdateCommand = updateCommand; }
public void ExecuteSucceedsWithDiscriminants() { var document = Files.Load("web-original.config").AsXmlDocument(); var command = new ElementUpdateCommand( "/configuration/appSettings/add[@key='first_setting']", new[] { new AttributeSpecification { Name = "value", Value = "updated-value" } }); command.Execute(document); document.SelectSingleNode("/configuration/appSettings/add[@key='first_setting']/@value") .Should().NotBeNull() .And.Subject.Value.Should().Be("updated-value"); }
public void ExecuteSucceeds() { var document = Files.Load("web-original.config").AsXmlDocument(); var command = new ElementUpdateCommand( "/configuration", new[] { new AttributeSpecification { Name = "test", NamespaceUri = "urn:test", Value = "value" } }); command.Execute(document); document.SelectSingleNode("/configuration/@*[local-name() = 'test' and namespace-uri()='urn:test']") .Should().NotBeNull() .And.Subject.Value.Should().Be("value"); }