public void TestRemove()
        {
            SetUp();

            const string Expected = @"expected_add.site.config";
            var          document = XDocument.Load(Current);

            document.Root.Add(
                new XElement("location",
                             new XAttribute("path", "WebSite1")));
            document.Save(Expected);

            var item = new IsapiFiltersItem(null);

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

            Assert.Equal("test", _feature.SelectedItem.Name);
            Assert.Equal(6, _feature.Items.Count);
            _feature.Remove();
            Assert.Null(_feature.SelectedItem);
            Assert.Equal(5, _feature.Items.Count);

            XmlAssert.Equal(Expected, Current);
            XmlAssert.Equal(Path.Combine("Website1", "original.config"), Path.Combine("Website1", "web.config"));
        }
Beispiel #2
0
        public async void TestAdd()
        {
            await this.SetUp();

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

            var item = new IsapiFiltersItem(null);

            item.Name = "my cgi";
            item.Path = "c:\\test.dll";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("my cgi", _feature.SelectedItem.Name);
            Assert.Equal("c:\\test.dll", _feature.SelectedItem.Path);
            Assert.Equal(6, _feature.Items.Count);
            XmlAssert.Equal(
                Helper.IsRunningOnMono()
                    ? Path.Combine("IsapiFilters", ExpectedMono)
                    : Path.Combine("IsapiFilters", 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/isapiFilters");

            node?.Add(
                new XElement("filter",
                             new XAttribute("name", "my cgi"),
                             new XAttribute("path", "c:\\test.dll")));
            document.Save(Expected);

            var item = new IsapiFiltersItem(null);

            item.Name = "my cgi";
            item.Path = "c:\\test.dll";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("my cgi", _feature.SelectedItem.Name);
            Assert.Equal("c:\\test.dll", _feature.SelectedItem.Path);
            Assert.Equal(6, _feature.Items.Count);
            XmlAssert.Equal(Expected, Current);
        }
        public async void TestRemove()
        {
            await this.SetUp();

            var item = new IsapiFiltersItem(null);

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

            Assert.Equal("test", _feature.SelectedItem.Name);
            Assert.Equal(6, _feature.Items.Count);
            _feature.Remove();
            Assert.Null(_feature.SelectedItem);
            Assert.Equal(5, _feature.Items.Count);

            const string Expected     = @"expected_remove1.site.config";
            const string ExpectedMono = @"expected_remove1.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"));
        }