public void TestRemove() { SetUp(); var site = Path.Combine("Website1", "web.config"); var expected = "expected_remove1.site.config"; var document = XDocument.Load(site); document.Save(expected); var item = new HttpErrorsItem(null); item.Status = 455; item.Path = "c:\\test.htm"; _feature.AddItem(item); Assert.Equal(455U, _feature.SelectedItem.Status); Assert.Equal(10, _feature.Items.Count); _feature.Remove(); Assert.Null(_feature.SelectedItem); Assert.Equal(9, _feature.Items.Count); const string Original = @"original.config"; const string OriginalMono = @"original.mono.config"; XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current); XmlAssert.Equal(expected, site); }
public void TestAdd() { SetUp(); const string Expected = @"expected_add.config"; var document = XDocument.Load(Current); var node = document.Root?.XPathSelectElement("/configuration/system.webServer/httpErrors"); var element = new XElement("error"); element.SetAttributeValue("statusCode", "455"); element.SetAttributeValue("subStatusCode", "1"); element.SetAttributeValue("path", "c:\\test.htm"); node?.Add(element); document.Save(Expected); var item = new HttpErrorsItem(null); item.Status = 455; item.Substatus = 1; item.Path = "c:\\test.htm"; _feature.AddItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal(455U, _feature.SelectedItem.Status); Assert.Equal(1, _feature.SelectedItem.Substatus); Assert.Equal(10, _feature.Items.Count); XmlAssert.Equal(Expected, Current); }
public async void TestRemove() { await this.SetUp(); var item = new HttpErrorsItem(null); item.Status = 455; item.Path = "c:\\test.htm"; _feature.AddItem(item); Assert.Equal(455U, _feature.SelectedItem.Status); Assert.Equal(10, _feature.Items.Count); _feature.Remove(); Assert.Null(_feature.SelectedItem); Assert.Equal(9, _feature.Items.Count); const string Original = @"original.config"; const string OriginalMono = @"original.mono.config"; XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current); XmlAssert.Equal(Path.Combine("HttpErrors", "expected_remove1.site.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 HttpErrorsItem(null); item.Status = 455; item.Substatus = 1; item.Path = "c:\\test.htm"; _feature.AddItem(item); Assert.NotNull(_feature.SelectedItem); Assert.Equal(455U, _feature.SelectedItem.Status); Assert.Equal(1, _feature.SelectedItem.Substatus); Assert.Equal(10, _feature.Items.Count); XmlAssert.Equal( Helper.IsRunningOnMono() ? Path.Combine("HttpErrors", ExpectedMono) : Path.Combine("HttpErrors", Expected), Current); }