public void TestMoveDown()
        {
            SetUp();
            const string Expected = @"expected_up.config";
            var          document = XDocument.Load(Current);
            var          node     = document.Root.XPathSelectElement("/configuration/system.webServer/isapiFilters");
            var          node1    = document.Root.XPathSelectElement("/configuration/system.webServer/isapiFilters/filter[@name='ASP.Net_2.0.50727.0']");
            var          node2    = document.Root.XPathSelectElement("/configuration/system.webServer/isapiFilters/filter[@name='ASP.Net_2.0.50727.0-64']");

            node1?.Remove();
            node2?.Remove();
            node?.AddFirst(node1);
            node?.AddFirst(node2);
            document.Save(Expected);

            _feature.SelectedItem = _feature.Items[0];
            var other = "ASP.Net_2.0.50727.0";

            Assert.Equal(other, _feature.Items[1].Name);
            var selected = "ASP.Net_2.0.50727-64";

            Assert.Equal(selected, _feature.Items[0].Name);
            _feature.MoveDown();
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal(selected, _feature.SelectedItem.Name);
            Assert.Equal(other, _feature.Items[0].Name);
            Assert.Equal(selected, _feature.Items[1].Name);
            XmlAssert.Equal(Expected, Current);
        }
Ejemplo n.º 2
0
        public async void TestMoveDown()
        {
            await SetUp();

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

            _feature.SelectedItem = _feature.Items[0];
            var other = "ASP.Net_2.0.50727.0";

            Assert.Equal(other, _feature.Items[1].Name);
            var selected = "ASP.Net_2.0.50727-64";

            Assert.Equal(selected, _feature.Items[0].Name);
            _feature.MoveDown();
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal(selected, _feature.SelectedItem.Name);
            Assert.Equal(other, _feature.Items[0].Name);
            Assert.Equal(selected, _feature.Items[1].Name);
            XmlAssert.Equal(
                Helper.IsRunningOnMono()
                    ? Path.Combine("IsapiFilters", ExpectedMono)
                    : Path.Combine("IsapiFilters", Expected),
                Current);
        }
        public async void TestMoveDown()
        {
            await SetUp();

            var item = new IsapiFiltersItem(null);

            item.Name = "test";
            item.Path = "c:\\test.dll";
            _feature.AddItem(item);

            var last     = 5;
            var previous = last - 1;

            _feature.SelectedItem = _feature.Items[previous];
            var expected = "test";

            Assert.Equal(expected, _feature.Items[last].Name);
            var original = "ASP.Net_4.0_64bit";

            Assert.Equal(original, _feature.Items[previous].Name);
            _feature.MoveDown();
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal(original, _feature.SelectedItem.Name);
            Assert.Equal(expected, _feature.Items[previous].Name);
            Assert.Equal(original, _feature.Items[last].Name);

            const string Expected     = @"expected_up1.site.config";
            const string ExpectedMono = @"expected_up.site.mono.config";

            XmlAssert.Equal(Path.Combine("IsapiFilters", Helper.IsRunningOnMono() ? ExpectedMono : Expected), Current);
            XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config"));
        }
        public void TestMoveDown()
        {
            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("isapiFilters",
                                                       new XElement("remove",
                                                                    new XAttribute("name", "ASP.Net_4.0_64bit")),
                                                       new XElement("filter",
                                                                    new XAttribute("name", "test"),
                                                                    new XAttribute("path", "c:\\test.dll")),
                                                       new XElement("filter",
                                                                    new XAttribute("enableCache", "true"),
                                                                    new XAttribute("name", "ASP.Net_4.0_64bit"),
                                                                    new XAttribute("path", @"%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_filter.dll"),
                                                                    new XAttribute("preCondition", "bitness64,runtimeVersionv4.0"))))));
            document.Save(Expected);

            var item = new IsapiFiltersItem(null);

            item.Name = "test";
            item.Path = "c:\\test.dll";
            _feature.AddItem(item);

            var last     = 5;
            var previous = last - 1;

            _feature.SelectedItem = _feature.Items[previous];
            var expected = "test";

            Assert.Equal(expected, _feature.Items[last].Name);
            var original = "ASP.Net_4.0_64bit";

            Assert.Equal(original, _feature.Items[previous].Name);
            _feature.MoveDown();
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal(original, _feature.SelectedItem.Name);
            Assert.Equal(expected, _feature.Items[previous].Name);
            Assert.Equal(original, _feature.Items[last].Name);

            XmlAssert.Equal(Expected, Current);
            XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config"));
        }