public void TestRemove()
        {
            SetUp();

            var site     = Path.Combine("Website1", "web.config");
            var expected = "expected_remove.site.config";
            var document = XDocument.Load(site);

            document.Save(expected);

            var item = new HiddenSegmentsItem(null);

            item.Segment = "test";
            _feature.AddItem(item);

            Assert.Equal("test", _feature.SelectedItem.Segment);
            Assert.Equal(9, _feature.Items.Count);
            _feature.Remove();
            Assert.Null(_feature.SelectedItem);
            Assert.Equal(8, _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);
        }
Example #2
0
        public async void TestRemove()
        {
            await this.SetUp();

            var item = new HiddenSegmentsItem(null);

            item.Segment = "test";
            _feature.AddItem(item);

            Assert.Equal("test", _feature.SelectedItem.Segment);
            Assert.Equal(9, _feature.Items.Count);
            _feature.Remove();
            Assert.Null(_feature.SelectedItem);
            Assert.Equal(8, _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("RequestFiltering", "HiddenSegments", "expected_remove1.site.config"), Path.Combine("Website1", "web.config"));
        }
Example #3
0
        public async void TestAdd()
        {
            await this.SetUp();

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

            var item = new HiddenSegmentsItem(null);

            item.Segment = "test";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("test", _feature.SelectedItem.Segment);
            Assert.Equal(9, _feature.Items.Count);
            XmlAssert.Equal(
                Helper.IsRunningOnMono()
                    ? Path.Combine("RequestFiltering", "HiddenSegments", ExpectedMono)
                    : Path.Combine("RequestFiltering", "HiddenSegments", Expected),
                Current);
        }
Example #4
0
        public void TestAdd()
        {
            SetUp();
            const string Expected = @"expected_add.config";
            var          document = XDocument.Load(Current);
            var          node     = document.Root?.XPathSelectElement("/configuration/system.webServer/security/requestFiltering/hiddenSegments");

            node?.Add(
                new XElement("add",
                             new XAttribute("segment", "test")));
            document.Save(Expected);

            var item = new HiddenSegmentsItem(null);

            item.Segment = "test";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("test", _feature.SelectedItem.Segment);
            Assert.Equal(9, _feature.Items.Count);
            XmlAssert.Equal(Expected, Current);
        }