public void TestRevert() { SetUp(); const string Expected = @"expected_add.site.config"; var document = XDocument.Load(Current); var node = new XElement("location"); node.SetAttributeValue("path", "WebSite1"); document.Root?.Add(node); var web = new XElement("system.webServer"); node.Add(web); var security = new XElement("security"); web.Add(security); document.Save(Expected); var item = new IpSecurityItem(null); item.Address = "12.0.0.0"; _feature.AddItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal("12.0.0.0", _feature.SelectedItem.Address); _feature.Revert(); Assert.Null(_feature.SelectedItem); Assert.Single(_feature.Items); XmlAssert.Equal(Expected, Current); XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config")); }
public void TestAdd() { SetUp(); const string Expected = @"expected_add.site.config"; var document = XDocument.Load(Current); document.Root?.Add( new XElement("location", new XAttribute("path", "WebSite1"), new XElement("system.webServer", new XElement("security", new XElement("ipSecurity", new XElement("add", new XAttribute("ipAddress", "12.0.0.0"))))))); document.Save(Expected); var item = new IpSecurityItem(null); item.Address = "12.0.0.0"; _feature.AddItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal("12.0.0.0", _feature.SelectedItem.Address); XmlAssert.Equal(Expected, Current); XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config")); }
public async void TestAdd() { await this.SetUp(); var item = new IpSecurityItem(null); item.Address = "12.0.0.0"; _feature.AddItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal("12.0.0.0", _feature.SelectedItem.Address); const string Expected = @"expected_add.site.config"; const string ExpectedMono = @"expected_add.site.mono.config"; XmlAssert.Equal(Path.Combine("IpSecurity", Helper.IsRunningOnMono() ? ExpectedMono : Expected), Current); XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config")); }
public async void TestAdd() { await this.SetUp(); const string Expected = @"expected_add.config"; const string ExpectedMono = @"expected_add.mono.config"; var item = new IpSecurityItem(null); item.Address = "12.0.0.0"; item.Allowed = true; _feature.AddItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal("12.0.0.0", _feature.SelectedItem.Address); Assert.Equal(true, _feature.SelectedItem.Allowed); Assert.Equal(2, _feature.Items.Count); XmlAssert.Equal( Helper.IsRunningOnMono() ? Path.Combine("IpSecurity", ExpectedMono) : Path.Combine("IpSecurity", Expected), Current); }
public void TestAdd() { SetUp(); const string Expected = @"expected_add.config"; var document = XDocument.Load(Current); var node = document.Root?.XPathSelectElement("/configuration/system.webServer/security/ipSecurity"); node?.Add( new XElement("add", new XAttribute("ipAddress", "12.0.0.0"), new XAttribute("allowed", "true"))); document.Save(Expected); var item = new IpSecurityItem(null); item.Address = "12.0.0.0"; item.Allowed = true; _feature.AddItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal("12.0.0.0", _feature.SelectedItem.Address); Assert.True(_feature.SelectedItem.Allowed); Assert.Equal(2, _feature.Items.Count); XmlAssert.Equal(Expected, Current); }