public void TestRemove() { 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); document.Save(Expected); var item = new IpSecurityItem(null); item.Address = "12.0.0.0"; _feature.AddItem(item); Assert.Equal("12.0.0.0", _feature.SelectedItem.Address); Assert.Equal(2, _feature.Items.Count); _feature.Remove(); 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 async void TestRemove() { await this.SetUp(); var item = new IpSecurityItem(null); item.Address = "12.0.0.0"; _feature.AddItem(item); Assert.Equal("12.0.0.0", _feature.SelectedItem.Address); Assert.Equal(2, _feature.Items.Count); _feature.Remove(); Assert.Null(_feature.SelectedItem); Assert.Equal(1, _feature.Items.Count); const string Expected = @"expected_remove1.site.config"; const string ExpectedMono = @"expected_remove1.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); }