Esempio n. 1
0
        public static WebsiteManager CreateWebsiteManager()
        {
            WebsiteManager manager = new WebsiteManager(CakeHelper.CreateEnvironment(), new DebugLog());

            manager.SetServer();

            return(manager);
        }
Esempio n. 2
0
        //Managers
        public static ApplicationPoolManager CreateApplicationPoolManager()
        {
            ApplicationPoolManager manager = new ApplicationPoolManager(CakeHelper.CreateEnvironment(), new DebugLog());

            manager.SetServer();

            return(manager);
        }
Esempio n. 3
0
 public static ApplicationSettings GetApplicationSettings(string name)
 {
     return(new ApplicationSettings
     {
         ApplicationPath = "/Test",
         ApplicationPool = CakeHelper.GetAppPoolSettings().Name,
         PhysicalDirectory = "./Test/App/",
         SiteName = name,
     });
 }
Esempio n. 4
0
        private void Cleanup(WebsiteSettings websiteSettings)
        {
            var path = websiteSettings.PhysicalDirectory.ToString();

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Esempio n. 5
0
        private WebsiteSettings CreateWebSite()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings();

            CakeHelper.DeleteWebsite(settings.Name);
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.Create(settings);

            return(settings);
        }
Esempio n. 6
0
        public void Should_Delete_WebFarm()
        {
            // Arrange
            var settings = CakeHelper.GetWebFarmSettings();
            CakeHelper.CreateWebFarm(settings);

            // Act
            CakeHelper.CreateWebFarmManager().Delete(settings.Name);

            // Assert
            Assert.Null(CakeHelper.GetWebFarm(settings.Name));
        }
Esempio n. 7
0
        public void Should_Delete_Website()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings("Wasp");

            CakeHelper.CreateWebsite(settings);

            // Act
            CakeHelper.CreateWebsiteManager().Delete(settings.Name);

            // Assert
            CakeHelper.GetWebsite(settings.Name).ShouldBeNull();
        }
Esempio n. 8
0
        public void Should_Create_Delete_AppPool()
        {
            // Arrange
            var settings = CakeHelper.GetAppPoolSettings("Bart");

            // Create
            CakeHelper.CreateApplicationPoolManager().Create(settings);
            CakeHelper.GetPool(settings.Name).ShouldNotBeNull();

            // Delete
            CakeHelper.DeletePool(settings.Name);
            CakeHelper.GetPool(settings.Name).ShouldBeNull();
        }
Esempio n. 9
0
        public void Should_Set_Server_Unavailable()
        {
            // Arrange
            var settings = CakeHelper.GetWebFarmSettings();
            CakeHelper.CreateWebFarm(settings);

            // Act
            WebFarmManager manager = CakeHelper.CreateWebFarmManager();
            manager.SetServerUnavailable(settings.Name, settings.Servers[0]);

            // Assert
            Assert.True(manager.GetServerState(settings.Name, settings.Servers[0]) == "Unavailable");
        }
Esempio n. 10
0
        public void Should_Delete_AppPool()
        {
            // Arrange
            var settings = CakeHelper.GetAppPoolSettings();

            CakeHelper.CreatePool(settings);

            // Act
            CakeHelper.CreateApplicationPoolManager().Delete(settings.Name);

            // Assert
            Assert.Null(CakeHelper.GetPool(settings.Name));
        }
Esempio n. 11
0
        public void Should_Set_Server_Unavailable_Gracefully()
        {
            // Arrange
            var settings = CakeHelper.GetWebFarmSettings();

            CakeHelper.CreateWebFarm(settings);

            // Act
            WebFarmManager manager = CakeHelper.CreateWebFarmManager();

            manager.SetServerUnavailableGracefully(settings.Name, settings.Servers[0]);

            // Assert
            manager.GetServerState(settings.Name, settings.Servers[0]).ShouldBe("Unavailable");
        }
Esempio n. 12
0
        public void Should_Create_WebFarm()
        {
            // Arrange
            var settings = CakeHelper.GetWebFarmSettings();

            CakeHelper.DeleteWebFarm(settings.Name);

            // Act
            WebFarmManager manager = CakeHelper.CreateWebFarmManager();

            manager.Create(settings);

            // Assert
            CakeHelper.GetWebFarm(settings.Name).ShouldNotBeNull();
        }
Esempio n. 13
0
        public void Should_Create_Website()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings("Deadpool");

            CakeHelper.DeleteWebsite(settings.Name);

            // Act
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.Create(settings);

            // Assert
            Assert.NotNull(CakeHelper.GetWebsite(settings.Name));
        }
Esempio n. 14
0
        public void Should_Add_MsmqFormatName_Binding()
        {
            // Arrange
            var             settings        = CreateWebSite();
            BindingSettings bindingSettings = IISBindings.MsmqFormatName;

            // Act
            Act(settings.Name, bindingSettings);

            // Assert
            var website = CakeHelper.GetWebsite(settings.Name);

            Assert.NotNull(website);
            Assert.Equal(2, website.Bindings.Count);
            Assert.Contains(website.Bindings, b => b.Protocol == BindingProtocol.MsmqFormatName.ToString() &&
                            b.BindingInformation == bindingSettings.BindingInformation);
        }
Esempio n. 15
0
        public void Should_Add_MsmqFormatName_Binding()
        {
            // Arrange
            var             settings        = CreateWebSite();
            BindingSettings bindingSettings = IISBindings.MsmqFormatName;

            // Act
            Act(settings.Name, bindingSettings);

            // Assert
            var website = CakeHelper.GetWebsite(settings.Name);

            website.ShouldNotBeNull();
            website.Bindings.Count.ShouldBe(2);
            website.Bindings.ShouldContain(b => b.Protocol == BindingProtocol.MsmqFormatName.ToString() &&
                                           b.BindingInformation == bindingSettings.BindingInformation);
        }
Esempio n. 16
0
        public void Should_Stop_AppPool()
        {
            // Arrange
            var settings = CakeHelper.GetAppPoolSettings();

            CakeHelper.CreatePool(settings);
            CakeHelper.StartPool(settings.Name);

            // Act
            CakeHelper.CreateApplicationPoolManager().Stop(settings.Name);

            // Assert
            ApplicationPool pool = CakeHelper.GetPool(settings.Name);

            Assert.NotNull(pool);
            Assert.True(pool.State == ObjectState.Stopped);
        }
Esempio n. 17
0
        public void Should_Stop_Website()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings("HumanTourch");

            CakeHelper.CreateWebsite(settings);
            CakeHelper.StartWebsite(settings.Name);

            // Act
            CakeHelper.CreateWebsiteManager().Stop(settings.Name);

            // Assert
            Site site = CakeHelper.GetWebsite(settings.Name);

            Assert.NotNull(site);
            Assert.True(site.State == ObjectState.Stopped);
        }
Esempio n. 18
0
        public void Should_Start_Website()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings("Sunspot");

            CakeHelper.CreateWebsite(settings);
            CakeHelper.StopWebsite(settings.Name);

            // Act
            CakeHelper.CreateWebsiteManager().Start(settings.Name);

            // Assert
            Site site = CakeHelper.GetWebsite(settings.Name);

            site.ShouldNotBeNull();
            site.State.ShouldBe(ObjectState.Started);
        }
Esempio n. 19
0
        public static WebsiteSettings GetWebsiteSettings(string name = "Superman")
        {
            WebsiteSettings settings = new WebsiteSettings
            {
                Name = name,
                PhysicalDirectory = "./Test/" + name,
                ApplicationPool   = CakeHelper.GetAppPoolSettings(),
                ServerAutoStart   = true,
                Overwrite         = false
            };

            settings.Binding = IISBindings.Http
                               .SetHostName(name + ".web")
                               .SetIpAddress("*")
                               .SetPort(80);

            return(settings);
        }
Esempio n. 20
0
        public void Should_Create_Application()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings();

            CakeHelper.DeleteWebsite(websiteSettings.Name);
            CakeHelper.CreateWebsite(websiteSettings);

            var appSettings = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            // Act
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();
            var            added   = manager.AddApplication(appSettings);

            // Assert
            Assert.True(added);
            Assert.NotNull(CakeHelper.GetApplication(websiteSettings.Name, appSettings.ApplicationPath));
        }
Esempio n. 21
0
        public void Should_Stop_AppPool()
        {
            // Arrange
            var settings = CakeHelper.GetAppPoolSettings("Marg");

            CakeHelper.CreatePool(settings);
            CakeHelper.StartPool(settings.Name);

            // Act
            CakeHelper.CreateApplicationPoolManager().Stop(settings.Name);

            // Assert
            ApplicationPool pool = CakeHelper.GetPool(settings.Name);

            pool.ShouldNotBeNull();
            pool.State.ShouldBe(ObjectState.Stopped);

            CakeHelper.DeletePool(settings.Name);
        }
Esempio n. 22
0
        public void Should_Create_Application()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Superman");

            CakeHelper.DeleteWebsite(websiteSettings.Name);

            // Act
            CakeHelper.CreateWebsite(websiteSettings);
            var appSettings = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            WebsiteManager manager = CakeHelper.CreateWebsiteManager();
            var            added   = manager.AddApplication(appSettings);

            // Assert
            added.ShouldBeTrue();
            CakeHelper.GetApplication(websiteSettings.Name, appSettings.ApplicationPath).ShouldNotBeNull();

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Esempio n. 23
0
        public void Should_Create_Website_With_DirectoryBrowsing_In_Settings()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Iron");

            websiteSettings.EnableDirectoryBrowsing = true;
            // Make sure the web.config exists
            CakeHelper.CreateWebConfig(websiteSettings);

            // Act
            var manager = CakeHelper.CreateWebsiteManager();

            manager.Create(websiteSettings);

            // Assert
            var value = CakeHelper.GetWebConfigurationValue(websiteSettings.Name, null, "system.webServer/directoryBrowse", "enabled");

            Assert.True((bool)value);

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Esempio n. 24
0
        public void Should_Create_Website_Without_DirectoryBrowsing()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Stark");

            // Make sure the web.config exists
            CakeHelper.CreateWebConfig(websiteSettings);

            // Act
            var manager = CakeHelper.CreateWebsiteManager();

            manager.Create(websiteSettings);
            manager.SetWebConfiguration(websiteSettings.Name, null, config => config.DisableDirectoryBrowsing());

            // Assert
            var value = CakeHelper.GetWebConfigurationValue(websiteSettings.Name, null, "system.webServer/directoryBrowse", "enabled");

            Assert.False((bool)value);

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Esempio n. 25
0
        public void Should_Create_Website_With_Predefined_EnabledProtocols()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings("Vision");

            settings.AlternateEnabledProtocols = "http,net.msmq,net.tcp";
            CakeHelper.DeleteWebsite(settings.Name);

            // Act
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.Create(settings);

            // Assert
            var website = CakeHelper.GetWebsite(settings.Name);

            website.ShouldNotBeNull();
            website.ApplicationDefaults.EnabledProtocols.Contains(BindingProtocol.Http.ToString());
            website.ApplicationDefaults.EnabledProtocols.Contains(BindingProtocol.NetMsmq.ToString());
            website.ApplicationDefaults.EnabledProtocols.Contains(BindingProtocol.NetTcp.ToString());
        }
Esempio n. 26
0
        public void Should_Create_Delete_RewriteRule()
        {
            // Arrange
            const string ruleName = "force https";
            var          settings = CakeHelper.GetRewriteRuleSettings(ruleName);

            //Don't exists
            CakeHelper.ExistsRewriteRule(ruleName).ShouldBeFalse();

            //Try to delete
            CakeHelper.DeleteRewriteRule(ruleName).ShouldBeFalse();

            // Create
            CakeHelper.CreateRewriteRule(settings);


            //Exists
            CakeHelper.ExistsRewriteRule(ruleName).ShouldBeTrue();

            //Delete
            CakeHelper.DeleteRewriteRule(ruleName).ShouldBeTrue();
        }
Esempio n. 27
0
        public void Should_Create_Application_With_DirectoryBrowsing()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Hulk");
            var appSettings     = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            // Make sure the web.config exists
            CakeHelper.CreateWebConfig(appSettings);

            // Act
            var manager = CakeHelper.CreateWebsiteManager();

            manager.Create(websiteSettings);
            manager.AddApplication(appSettings);
            manager.SetWebConfiguration(websiteSettings.Name, appSettings.ApplicationPath, config => config.EnableDirectoryBrowsing());

            // Assert
            var value = CakeHelper.GetWebConfigurationValue(websiteSettings.Name, appSettings.ApplicationPath, "system.webServer/directoryBrowse", "enabled");

            Assert.True((bool)value);

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Esempio n. 28
0
        //WebFarm
        public static void CreateWebFarm(WebFarmSettings settings)
        {
            WebFarmManager manager = CakeHelper.CreateWebFarmManager();

            manager.Create(settings);
        }
Esempio n. 29
0
        //Pool
        public static void CreatePool(ApplicationPoolSettings settings)
        {
            ApplicationPoolManager manager = CakeHelper.CreateApplicationPoolManager();

            manager.Create(settings);
        }
Esempio n. 30
0
        //Website
        public static void CreateWebsite(WebsiteSettings settings)
        {
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.Create(settings);
        }