void WebAppTreeNode_TreeNodePopulate(object sender, TreeViewCancelEventArgs e)
        {
            WebApplicationInfo webAppInfo = e.Node.Tag as WebApplicationInfo;
            bool preCheck = (((webAppInfo.Application.IsAdministrationWebApplication || webAppInfo.IsSRP) && InstallConfiguration.SuggestDeploymentToCentralAdminWebApplication) || ((!(webAppInfo.Application.IsAdministrationWebApplication || webAppInfo.IsSRP)) && InstallConfiguration.SuggestDeploymentToAllContentWebApplications));

            if (webAppInfo != null)
            {
                if (webAppInfo.Application.Sites.Count >= SiteCollectionCountWarning)
                {
                    string msg = String.Format(res.ManySitesWarning, webAppInfo.Application.Sites.Count);
                    if (MessageBox.Show(msg, res.ManySites, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        e.Cancel = true;
                    }
                }
                if (!e.Cancel)
                {
                    foreach (SPSite site in webAppInfo.Application.Sites)
                    {
                        SiteCollectionInfo siteCollInfo = new SiteCollectionInfo(site, false);
                        ExtendedTreeNode.AddNewExtendedTreeNode(e.Node.Nodes, siteCollInfo.ToString(), siteCollInfo).Checked = preCheck;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void SpecifyingBrowserCompatibilityModeForIe()
        {
            // Arrange
            const string webSiteName = "TestEasyWebSite";

            // create Virtual Application and deploy files
            WebServer          server  = WebServer.Create();
            WebApplicationInfo appInfo = server.CreateWebApplication(webSiteName);

            server.DeployWebApplication(appInfo.Name, new List <DeploymentItem>
            {
                new DeploymentItem {
                    Type = DeploymentItemType.Directory, Path = webSiteName
                }
            });

            server.SetCustomHeaders(
                Path.Combine(appInfo.PhysicalPath, "web.config"),
                new Dictionary <string, string> {
                { "X-UA-Compatible", " IE=8" }
            });

            // create browser object using config settings
            using (var browserManager = new BrowserManager())
            {
                var browser = browserManager.CreateBrowser(BrowserType.Ie, false);

                // Act
                browser.Navigate().GoToUrl(appInfo.VirtualPath + "/default.html");

                // Assert
                Assert.AreEqual("[This is my label]", browser.FindElement(By.Id("myLabel")).Text);
            }
        }
Ejemplo n.º 3
0
        void WebAppTreeNode_TreeNodePopulate(object sender, TreeViewCancelEventArgs e)
        {
            WebApplicationInfo webAppInfo = e.Node.Tag as WebApplicationInfo;

            if (webAppInfo != null)
            {
                if (webAppInfo.Application.Sites.Count >= SiteCollectionCountWarning)
                {
                    string msg = String.Format(FormattedSiteCollectionCountWarningMessage, webAppInfo.Application.Sites.Count);
                    if (MessageBox.Show(msg, "Large Number of Site Collections", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        e.Cancel = true;
                    }
                }
                if (!e.Cancel)
                {
                    foreach (SPSite site in webAppInfo.Application.Sites)
                    {
                        try
                        {
                            SiteCollectionInfo siteCollInfo = new SiteCollectionInfo(site, false);
                            ExtendedTreeNode.AddNewExtendedTreeNode(e.Node.Nodes, siteCollInfo.ToString(), siteCollInfo);
                        }
                        finally
                        {
                            // guarantee SPSite is released ASAP even in face of exception
                            site.Dispose();
                        }
                    }
                }
            }
        }
        private void ConfigureWebApplicationList()
        {
            bool       defaultDeployToSRP = InstallConfiguration.DefaultDeployToSRP;
            bool       required           = InstallConfiguration.RequireDeploymentToAllContentWebApplications;
            CheckState defaultCheckState  = defaultDeployToSRP ? CheckState.Unchecked : CheckState.Checked;
            Collection <SPWebApplication> applications = new Collection <SPWebApplication> ();

            foreach (SPWebApplication application in SPWebService.ContentService.WebApplications)
            {
                WebApplicationInfo webAppInfo = new WebApplicationInfo(application, required);
                if (required)
                {
                    webApplicationsCheckedListBox.Items.Add(webAppInfo, CheckState.Indeterminate);
                }
                else
                {
                    webApplicationsCheckedListBox.Items.Add(webAppInfo, InstallConfiguration.SuggestDeploymentToAllContentWebApplications ? CheckState.Checked : ((defaultDeployToSRP && !webAppInfo.IsSRP) ? CheckState.Unchecked : CheckState.Checked));
                }
            }
            required = InstallConfiguration.RequireDeploymentToCentralAdminWebApplication;
            foreach (SPWebApplication application in SPWebService.AdministrationService.WebApplications)
            {
                WebApplicationInfo webAppInfo = new WebApplicationInfo(application, required);
                if (required)
                {
                    webApplicationsCheckedListBox.Items.Add(webAppInfo, CheckState.Indeterminate);
                }
                else
                {
                    webApplicationsCheckedListBox.Items.Add(webAppInfo, (InstallConfiguration.SuggestDeploymentToCentralAdminWebApplication && webAppInfo.Application.IsAdministrationWebApplication) ? CheckState.Checked : (webAppInfo.Application.IsAdministrationWebApplication ? CheckState.Unchecked : defaultCheckState));
                }
            }
        }
 private void PopulateTreeViewForWebApps(TreeNodeCollection treeNodes, SPWebApplicationCollection webApps)
 {
     foreach (SPWebApplication application in webApps)
     {
         WebApplicationInfo webAppInfo     = new WebApplicationInfo(application, false);
         ExtendedTreeNode   webAppTreeNode = ExtendedTreeNode.AddNewExtendedTreeNode(treeNodes, webAppInfo.ToString(), true, webAppInfo);
         webAppTreeNode.TreeNodePopulate += new ExtendedTreeNode.TreeNodeEventHandler(WebAppTreeNode_TreeNodePopulate);
     }
 }
Ejemplo n.º 6
0
        private void webApplicationsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            WebApplicationInfo info = (WebApplicationInfo)webApplicationsCheckedListBox.Items[e.Index];

            if (info.Required)
            {
                e.NewValue = CheckState.Indeterminate;
            }
        }
 private void PopulateTreeViewForWebApps(TreeNodeCollection treeNodes, SPWebApplicationCollection webApps)
 {
     foreach (SPWebApplication application in webApps)
     {
         WebApplicationInfo webAppInfo     = new WebApplicationInfo(application, false);
         ExtendedTreeNode   webAppTreeNode = ExtendedTreeNode.AddNewExtendedTreeNode(treeNodes, webAppInfo.ToString(), true, webAppInfo);
         webAppTreeNode.Checked           = (((application.IsAdministrationWebApplication || webAppInfo.IsSRP) && InstallConfiguration.SuggestDeploymentToCentralAdminWebApplication) || ((!(application.IsAdministrationWebApplication || webAppInfo.IsSRP)) && InstallConfiguration.SuggestDeploymentToAllContentWebApplications));
         webAppTreeNode.TreeNodePopulate += new ExtendedTreeNode.TreeNodeEventHandler(WebAppTreeNode_TreeNodePopulate);
     }
 }
Ejemplo n.º 8
0
        protected internal override void Close(InstallOptions options)
        {
            foreach (TreeNode webAppTreeNode in siteCollectionsTreeView.Nodes)
            {
                // Add the web application as a target
                if (webAppTreeNode.Checked)
                {
                    WebApplicationInfo webAppInfo = webAppTreeNode.Tag as WebApplicationInfo;
                    if (webAppInfo != null)
                    {
                        options.WebApplicationTargets.Add(webAppInfo.Application);

                        ExtendedTreeNode extendedWebAppTreeNode = webAppTreeNode as ExtendedTreeNode;
                        if (extendedWebAppTreeNode != null)
                        {
                            if (!extendedWebAppTreeNode.Populated)
                            {
                                // Add ALL site collections within the web app as targets
                                foreach (SPSite siteCollection in webAppInfo.Application.Sites)
                                {
                                    try
                                    {
                                        SiteLoc siteLoc = new SiteLoc(siteCollection);
                                        siteLoc.featureList.AddRange(_featureIds); // add all known features for now (be nice to let user choose)
                                        options.SiteCollectionTargets.Add(siteLoc);
                                    }
                                    finally
                                    {
                                        // guarantee SPSite is released ASAP even in face of exception
                                        siteCollection.Dispose();
                                    }
                                }
                            }
                            else
                            {
                                // Add the checked site collections within this web application as targets
                                foreach (TreeNode siteCollTreeNode in webAppTreeNode.Nodes)
                                {
                                    if (siteCollTreeNode.Checked)
                                    {
                                        SiteCollectionInfo siteCollInfo = siteCollTreeNode.Tag as SiteCollectionInfo;
                                        if (siteCollInfo != null)
                                        {
                                            SiteLoc siteLoc = new SiteLoc(siteCollInfo.SiteCollection);
                                            siteLoc.featureList.AddRange(_featureIds); // add all known features for now (be nice to let user choose)
                                            options.SiteCollectionTargets.Add(siteLoc);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public void SetupWebsite()
        {
            // common logic to arrange the test website
            _server  = WebServer.Create();
            _appInfo = _server.CreateWebApplication("TestEasyWAP");

            _server.DeployWebApplication(_appInfo.Name, new List <DeploymentItem>
            {
                new DeploymentItem {
                    Type = DeploymentItemType.Directory, Path = WebSiteName
                }
            });
        }
        public WebServerAndBrowsersSngleWebsitesTest()
        {
            if (Server == null)
            {
                Server = WebServer.Create();

                AppInfo = Server.CreateWebApplication(WebSiteName);
                Server.DeployWebApplication(AppInfo.Name, new List <DeploymentItem>
                {
                    new DeploymentItem {
                        Type = DeploymentItemType.Directory, Path = WebSiteName
                    }
                });
            }
        }
Ejemplo n.º 11
0
        public void MultipleBrowsersTest()
        {
            // Arrange
            const string webSiteName = "TestEasyWAP";

            // Create server object
            WebServerSettings settings = new WebServerSettings
            {
                HostName         = Environment.MachineName,                             // machine anme or empty (in this case localhost will be used)
                RootPhysicalPath = TestEasyHelpers.Tools.GetUniqueTempPath(webSiteName) // needed only when web server type is IISExpress
            };

            WebServer          server  = WebServer.Create("IISExpress", settings);
            WebApplicationInfo appInfo = server.CreateWebApplication(webSiteName);

            server.DeployWebApplication(appInfo.Name, new List <DeploymentItem>
            {
                new DeploymentItem {
                    Type = DeploymentItemType.Directory, Path = webSiteName
                }
            });
            server.BuildWebApplication(webSiteName);

            // create browser object
            using (BrowserManager browserManager = new BrowserManager())
            {
                List <IWebDriver> myBrowsers = new List <IWebDriver>
                {
                    browserManager.CreateBrowser(remote: false),
                    browserManager.CreateBrowser(remote: false),
                    browserManager.CreateBrowser(remote: false)
                };

                foreach (var browser in myBrowsers)
                {
                    // Act
                    browser.Navigate().GoToUrl(appInfo.VirtualPath + "/SamplePostWebForm.aspx");

                    browser.FindElement(By.Id("Button1")).Click();
                    browser.WaitForPageLoaded();


                    // Assert
                    Assert.AreEqual("[Clicked!]", browser.FindElement(By.Id("TextBox1")).GetAttribute("value"));
                }
            }
        }
        private void ConfigureWebApplicationList()
        {
            bool defaultDeployToAdmin = InstallConfiguration.DefaultDeployToAdminWebApplications;
              bool defaultDeployToSRP = InstallConfiguration.DefaultDeployToSRP;
              bool defaultDeployToContent = InstallConfiguration.DefaultDeployToContentWebApplications;

              bool required = InstallConfiguration.RequireDeploymentToCentralAdminWebApplication;
              CheckState defaultCheckState = defaultDeployToAdmin ? CheckState.Checked : CheckState.Unchecked;
              Collection<SPWebApplication> applications = new Collection<SPWebApplication>();
              foreach (SPWebApplication application in SPWebService.AdministrationService.WebApplications)
              {
            WebApplicationInfo webAppInfo = new WebApplicationInfo(application, required);
            if (required)
            {
              webApplicationsCheckedListBox.Items.Add(webAppInfo, CheckState.Indeterminate);
            }
            else
            {
              webApplicationsCheckedListBox.Items.Add(webAppInfo, defaultCheckState);
            }
              }

              required = InstallConfiguration.RequireDeploymentToAllContentWebApplications;
              foreach (SPWebApplication application in SPWebService.ContentService.WebApplications)
              {
            WebApplicationInfo webAppInfo = new WebApplicationInfo(application, required);
            if (required)
            {
              webApplicationsCheckedListBox.Items.Add(webAppInfo, CheckState.Indeterminate);
            }
            else
            {
              if (defaultDeployToSRP && !webAppInfo.IsSRP)
              {
            defaultCheckState = CheckState.Unchecked;
              }
              else
              {
            defaultCheckState = (defaultDeployToContent ? CheckState.Checked : CheckState.Unchecked);
              }
              webApplicationsCheckedListBox.Items.Add(webAppInfo, defaultCheckState);
            }
              }
        }
        protected internal override void Close(InstallOptions options)
        {
            foreach (TreeNode webAppTreeNode in siteCollectionsTreeView.Nodes)
            {
                // Add the web application as a target
                if (webAppTreeNode.Checked)
                {
                    WebApplicationInfo webAppInfo = webAppTreeNode.Tag as WebApplicationInfo;
                    if (webAppInfo != null)
                    {
                        options.WebApplicationTargets.Add(webAppInfo.Application);

                        ExtendedTreeNode extendedWebAppTreeNode = webAppTreeNode as ExtendedTreeNode;
                        if (extendedWebAppTreeNode != null)
                        {
                            if (!extendedWebAppTreeNode.Populated)
                            {
                                // Add ALL site collections within the web app as targets
                                foreach (SPSite siteCollection in webAppInfo.Application.Sites)
                                {
                                    options.SiteCollectionTargets.Add(siteCollection);
                                }
                            }
                            else
                            {
                                // Add the checked site collections within this web application as targets
                                foreach (TreeNode siteCollTreeNode in webAppTreeNode.Nodes)
                                {
                                    if (siteCollTreeNode.Checked)
                                    {
                                        SiteCollectionInfo siteCollInfo = siteCollTreeNode.Tag as SiteCollectionInfo;
                                        if (siteCollInfo != null)
                                        {
                                            options.SiteCollectionTargets.Add(siteCollInfo.SiteCollection);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
        private void CreateWebServer(string deployPath, string connectionString)
        {
            const int MaxRetries = 3;
            int       attempt    = 0;

            while (true)
            {
                try
                {
                    _webServer          = WebServer.Create("iisexpress");
                    _webApplicationInfo = _webServer.CreateWebApplication(ApplicationName);
                    _webServer.DeployWebApplication(_webApplicationInfo.Name, new List <DeploymentItem>
                    {
                        new DeploymentItem {
                            Type = DeploymentItemType.Directory, Path = deployPath
                        }
                    });

                    _webConfigFilePath = Path.Combine(_webServer.RootPhysicalPath, ApplicationName, "web.config");
                    SetStorageConnectionString(connectionString);

                    _virtualPath = _webApplicationInfo.VirtualPath;

                    return;
                }
                catch
                {
                    if (attempt++ < MaxRetries)
                    {
                        // Swallow any startup errors and retry after a short
                        // period
                        // We're seeing some File IO issues from TestEasy that look
                        // like timing issues
                        Thread.Sleep(2000);
                    }
                    else
                    {
                        // We're unable to create the server even after retries
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public void CustomServerAndBrowserUsingConfigTest()
        {
            // Arrange
            const string webSiteName = "TestEasyWAP";

            // Create server using Config settings
            WebServerSettings settings = new WebServerSettings
            {
                HostName         = TestEasyConfig.Instance.Client.Remote ? Environment.MachineName : "",
                RootPhysicalPath = (TestEasyConfig.Instance.WebServer.Type.Equals("IISExpress", StringComparison.InvariantCultureIgnoreCase))
                    ? TestEasyHelpers.Tools.GetUniqueTempPath(webSiteName)
                    : ""
            };

            WebServer          server  = WebServer.Create(TestEasyConfig.Instance.WebServer.Type, settings);
            WebApplicationInfo appInfo = server.CreateWebApplication(webSiteName);

            server.DeployWebApplication(appInfo.Name, new List <DeploymentItem>
            {
                new DeploymentItem {
                    Type = DeploymentItemType.Directory, Path = webSiteName
                }
            });
            server.BuildWebApplication(webSiteName);

            // create browser object using config settings
            using (var browserManager = new BrowserManager())
            {
                var browser = browserManager.CreateBrowser();

                // Act
                browser.Navigate().GoToUrl(appInfo.VirtualPath + "/SamplePostWebForm.aspx");

                browser.FindElement(By.XPath("//input[@name='Button1']")).Click();
                browser.WaitForPageLoaded();

                // Assert
                Assert.AreEqual("[Clicked!]", browser.FindElement(By.Id("TextBox1")).GetAttribute("value"));
            }
        }
 private void PopulateTreeViewForWebApps(TreeNodeCollection treeNodes, SPWebApplicationCollection webApps)
 {
     foreach (SPWebApplication application in webApps)
       {
     WebApplicationInfo webAppInfo = new WebApplicationInfo(application, false);
     ExtendedTreeNode webAppTreeNode = ExtendedTreeNode.AddNewExtendedTreeNode(treeNodes, webAppInfo.ToString(), true, webAppInfo);
     webAppTreeNode.TreeNodePopulate += new ExtendedTreeNode.TreeNodeEventHandler(WebAppTreeNode_TreeNodePopulate);
       }
 }