public void ExecuteThrowsWhenElementAlreadyExists() { var action = new ConfigurationElementInsertionAction("/configuration", "appSettings"); Invoking(() => action.Execute(ResourceManager.Load(Assembly.GetExecutingAssembly(), "Be.Stateless.Resources.web-original.config", XDocument.Load))) .Should().Throw<InvalidOperationException>() .WithMessage("The configuration element already exists at '/configuration/appSettings'."); }
public void ExecuteSucceeds() { var document = ResourceManager.Load(Assembly.GetExecutingAssembly(), "Be.Stateless.Resources.web-original.config", XDocument.Load); var action = new ConfigurationElementInsertionAction("/configuration", "test"); action.Execute(document); document.XPathSelectElement("/configuration/test").Should().NotBeNull(); }
public void ExecuteSucceedsWithAttributeUpdate() { var document = ResourceManager.Load(Assembly.GetExecutingAssembly(), "Be.Stateless.Resources.web-original.config", XDocument.Load); var action = new ConfigurationElementInsertionAction("/configuration", "test", new[] { new XAttribute("{urn:test}test", "value1"), new XAttribute("test", "value2") }); action.Execute(document); document.XPathSelectElement("/configuration/test").Should().NotBeNull(); document.XPathSelectElement("/configuration/test[@*[local-name() = 'test' and namespace-uri()='urn:test']='value1']").Should().NotBeNull(); document.XPathSelectElement("/configuration/test[@test='value2']").Should().NotBeNull(); }
public ConfigurationElementUpsertionAction( string configurationElementSelector, ConfigurationElementInsertionAction insertionAction, ConfigurationElementUpdateAction updateAction) : base(configurationElementSelector) { InsertionAction = insertionAction ?? throw new ArgumentNullException(nameof(insertionAction)); UpdateAction = updateAction ?? throw new ArgumentNullException(nameof(updateAction)); }