public void TestBasic() { SetUp(); Assert.False(_feature.IsEnabled); const string Expected = @"expected_remove.config"; var document = XDocument.Load(Current); document.Save(Expected); try { _feature.Enable(); Assert.True(_feature.IsEnabled); XmlAssert.Equal(Expected, Current); _feature.Disable(); Assert.False(_feature.IsEnabled); XmlAssert.Equal(Expected, Current); } catch (Exception ex) { // If not admin, this exception is expected. Assert.IsType <UnauthorizedAccessException>(ex); } }
public void TestEnable() { SetUp(); var site = Path.Combine("Website1", "web.config"); var expected = "expected_edit.site.config"; var document = XDocument.Load(site); var web = new XElement("system.web"); document.Root?.Add(web); var authen = new XElement("authentication"); web.Add(authen); authen.SetAttributeValue("mode", "Forms"); document.Save(expected); _feature.Enable(); Assert.True(_feature.IsEnabled); const string Original = @"original.config"; const string OriginalMono = @"original.mono.config"; XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current); XmlAssert.Equal(expected, site); }