public void WhenAddApplicationPool_IfAppPoolDoesNotExist_ShouldAdd() { // Arrange const string configPath = "app.config"; _mock.MockIisExpressConfig_ApplicationConfigFound(configPath) .MockIisExpressConfig_RealDocumentInitialized(configPath); var config = new IisExpressConfig(configPath, _mock.FileSystem.Object); config.Root.Document.Descendants("applicationPools").Remove(); // Act var pool = config.AddApplicationPool("mypool", @"aaa", "mmm", "qqq"); //Assert var xapppools = config.Root.Document.Descendants("applicationPools").ToList(); var processModel = pool.Descendants().First(); Assert.True(xapppools.Any()); Assert.Equal(2, xapppools.Descendants().Count()); Assert.Equal(@"mypool", pool.Attribute("name").Value); Assert.Equal(@"aaa", pool.Attribute("managedRuntimeVersion").Value); Assert.Equal(@"mmm", pool.Attribute("managedPipelineMode").Value); Assert.Equal(@"qqq", processModel.Attribute("identityType").Value); }
public void WhenAddApplication_IfAppDoesNotExist_ShouldAdd() { // Arrange const string configPath = "app.config"; _mock.MockIisExpressConfig_ApplicationConfigFound(configPath) .MockIisExpressConfig_RealDocumentInitialized(configPath); // Act var config = new IisExpressConfig(configPath, _mock.FileSystem.Object); var app = config.AddApplication("MyApp", @"c:\somepath"); //Assert XElement site = null; var xDefaultSites = config.Root.Document.Descendants("site").Where(s => s.Attribute("id").Value == "1").ToList(); if (xDefaultSites.Any()) { site = xDefaultSites.First(); } var xapplications = site.Descendants("application").ToList(); Assert.True(xapplications.Any(a => a.Attribute("path").Value.Equals("/MyApp", StringComparison.InvariantCultureIgnoreCase))); Assert.Equal(@"c:\somepath", app.Descendants().First().Attribute("physicalPath").Value); }
public void WhenAddBinding_IfAppDoesNotExist_ShouldAdd() { // Arrange const string configPath = "app.config"; _mock.MockIisExpressConfig_ApplicationConfigFound(configPath) .MockIisExpressConfig_RealDocumentInitialized(configPath); var config = new IisExpressConfig(configPath, _mock.FileSystem.Object); XElement site = null; var xDefaultSites = config.Root.Document.Descendants("site").Where(s => s.Attribute("id").Value == "1").ToList(); if (xDefaultSites.Any()) { site = xDefaultSites.First(); } site.Descendants("bindings").Remove(); // Act var binding = config.AddBinding("http", @"xxxx"); //Assert Assert.True(site.Descendants("bindings").Any()); Assert.Equal(@"xxxx", binding.Attribute("bindingInformation").Value); }
public void WhenLoadSchema_IfXDocumentNotLoaded_ShouldThrow() { // Arrange const string configPath = "unknownapp.config"; _mock.MockIisExpressConfig_ApplicationConfigFound(configPath) .MockIisExpressConfig_DocumentNotLoaded(configPath); // Act var exception = Assert.Throws <Exception>( () => new IisExpressConfig(configPath, _mock.FileSystem.Object)); // Assert Assert.Equal(string.Format("Somethng went wrong while loading xml schema from config file: '{0}'", configPath), exception.Message); }
public void WhenGetApplicationProperty_IfAppNotFound_ShouldReturnNull() { // Arrange const string configPath = "app.config"; _mock.MockIisExpressConfig_ApplicationConfigFound(configPath) .MockIisExpressConfig_RealDocumentInitialized(configPath); // Act var config = new IisExpressConfig(configPath, _mock.FileSystem.Object); var property = config.GetApplicationProperty("unknownapp", "unknownproperty"); // Assert Assert.Null(property); }
public void WhenRemoveBinding_IfAppDoesNotExist_ShouldAdd() { // Arrange const string configPath = "app.config"; _mock.MockIisExpressConfig_ApplicationConfigFound(configPath) .MockIisExpressConfig_RealDocumentInitialized(configPath); var config = new IisExpressConfig(configPath, _mock.FileSystem.Object); XElement site = null; var xDefaultSites = config.Root.Document.Descendants("site").Where(s => s.Attribute("id").Value == "1").ToList(); if (xDefaultSites.Any()) { site = xDefaultSites.First(); } var xbindings = site.Descendants("bindings").First(); Assert.Equal(2, xbindings.Descendants().Count()); // Act config.RemoveBinding("http"); config.RemoveBinding("https"); //Assert Assert.False(xbindings.Descendants().Any()); }
public void WhenRemoveAllApplications_ShouldRemove() { // Arrange const string configPath = "app.config"; _mock.MockIisExpressConfig_ApplicationConfigFound(configPath) .MockIisExpressConfig_RealDocumentInitialized(configPath); // Act var config = new IisExpressConfig(configPath, _mock.FileSystem.Object); config.RemoveAllApplications(); //Assert XElement site = null; var xDefaultSites = config.Root.Document.Descendants("site").Where(s => s.Attribute("id").Value == "1").ToList(); if (xDefaultSites.Any()) { site = xDefaultSites.First(); } var xapplications = site.Descendants("application").ToList(); Assert.False(xapplications.Any(a => a.Attribute("path").Value.Equals("/", StringComparison.InvariantCultureIgnoreCase))); }
public void WhenStoreSchema_ShouldStore() { // Arrange const string configPath = "app.config"; _mock.MockIisExpressConfig_ApplicationConfigFound(configPath) .MockIisExpressConfig_RealDocumentInitialized(configPath) .MockIisExpressConfig_StoreSchema(configPath); var config = new IisExpressConfig(configPath, _mock.FileSystem.Object); // Act, Assert config.StoreSchema(); }
public void WhenSetDefaultApplicationPool_ShouldSet() { // Arrange const string configPath = "app.config"; _mock.MockIisExpressConfig_ApplicationConfigFound(configPath) .MockIisExpressConfig_RealDocumentInitialized(configPath); var config = new IisExpressConfig(configPath, _mock.FileSystem.Object); // Act config.SetDefaultApplicationPool("mypool"); //Assert var xappPoolDefaults = config.Root.Document.Descendants("applicationDefaults").First(); Assert.Equal(@"mypool", xappPoolDefaults.Attribute("applicationPool").Value); }