public void TestRemove()
        {
            SetUp();

            var site     = Path.Combine("Website1", "web.config");
            var expected = "expected_remove1.site.config";
            var document = XDocument.Load(site);
            var node     = document.Root.XPathSelectElement("/configuration/system.webServer");

            document.Save(expected);

            var item = new ResponseHeadersItem(null);

            item.Name  = "Server";
            item.Value = "Jexus";
            _feature.AddItem(item);

            Assert.Equal("Server", _feature.SelectedItem.Name);
            Assert.Equal(2, _feature.Items.Count);
            _feature.Remove();
            Assert.Null(_feature.SelectedItem);
            Assert.Single(_feature.Items);

            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();

            var site     = Path.Combine("Website1", "web.config");
            var expected = "expected_edit.site.config";
            var document = XDocument.Load(site);
            var node     = document.Root.XPathSelectElement("/configuration/system.webServer");

            node?.Add(
                new XElement("httpProtocol",
                             new XElement("customHeaders",
                                          new XElement("add",
                                                       new XAttribute("name", "Server"),
                                                       new XAttribute("value", "Jexus")))));
            document.Save(expected);

            var item = new ResponseHeadersItem(null);

            item.Name  = "Server";
            item.Value = "Jexus";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("Server", _feature.SelectedItem.Name);

            const string Original     = @"original.config";
            const string OriginalMono = @"original.mono.config";

            XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current);
            XmlAssert.Equal(expected, site);
        }
Ejemplo n.º 3
0
        public async void TestAdd()
        {
            await this.SetUp();

            var item = new ResponseHeadersItem(null);

            item.Name  = "Server";
            item.Value = "Jexus";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("Server", _feature.SelectedItem.Name);

            const string Original     = @"original.config";
            const string OriginalMono = @"original.mono.config";

            XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current);
            XmlAssert.Equal(Path.Combine("ResponseHeaders", "expected_add.site.config"), Path.Combine("Website1", "web.config"));
        }
Ejemplo n.º 4
0
        public async void TestAdd()
        {
            await this.SetUp();

            const string Expected     = @"expected_add.config";
            const string ExpectedMono = @"expected_add.mono.config";

            var item = new ResponseHeadersItem(null);

            item.Name  = "Server";
            item.Value = "Jexus";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("Server", _feature.SelectedItem.Name);
            Assert.Equal(2, _feature.Items.Count);
            XmlAssert.Equal(
                Helper.IsRunningOnMono()
                    ? Path.Combine("ResponseHeaders", ExpectedMono)
                    : Path.Combine("ResponseHeaders", Expected),
                Current);
        }
Ejemplo n.º 5
0
        public void TestAdd()
        {
            SetUp();
            const string Expected = @"expected_add.config";
            var          document = XDocument.Load(Current);
            var          node     = document.Root.XPathSelectElement("/configuration/system.webServer/httpProtocol/customHeaders/add");
            var          add      = new XElement("add");

            add.SetAttributeValue("name", "Server");
            add.SetAttributeValue("value", "Jexus");
            node?.AddAfterSelf(add);
            document.Save(Expected);

            var item = new ResponseHeadersItem(null);

            item.Name  = "Server";
            item.Value = "Jexus";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("Server", _feature.SelectedItem.Name);
            Assert.Equal(2, _feature.Items.Count);
            XmlAssert.Equal(Expected, Current);
        }