public void AssembleAcknowledgements_FindsSILCoreAcknowledgements()
        {
            var html = AcknowledgementsProvider.AssembleAcknowledgements();

            Assert.That(html, Contains.Substring("<a href='http://www.codeplex.com/DotNetZip'>Ionic.Zip</a>"));
            Assert.That(html, Contains.Substring("<a href='https://www.nuget.org/packages/NDesk.DBus/'>NDesk.DBus</a>"));
            Assert.That(html, Contains.Substring("<a href='https://www.nuget.org/packages/Newtonsoft.Json/'>Json.NET</a>"));
        }
Esempio n. 2
0
        private void SILAboutBoxShown(object sender, EventArgs e)
        {
            //review: EB had changed from Navigate to this in ab66af23393f74b767ffd78c2182bd1fdc8eb963, presumably to
            // get around the AllowNavigation=false problem. It may work on Linux, but it didn't on Windows, which would just show a blank browser.
            //_browser.Url = new Uri(_pathToAboutBoxHtml);
            // So I've instead modified the browser wrapper to always let the first navigation get through, regardless
            var filePath     = AcknowledgementsProvider.GetFullNonUriFileName(_pathToAboutBoxHtml);
            var aboutBoxHtml = File.ReadAllText(filePath);

            if (!aboutBoxHtml.Contains(DependencyMarker))
            {
                _browser.Navigate(_pathToAboutBoxHtml);
            }
            else
            {
                // Without a charset='UTF-8' meta tag attribute, things like copyright symbols don't show up correctly.
                Debug.Assert(aboutBoxHtml.Contains(" charset"), "At a minimum, the About Box html should contain a meta charset='UTF-8' tag.");
                var insertableAcknowledgements = AcknowledgementsProvider.AssembleAcknowledgements();
                var newHtmlContents            = aboutBoxHtml.Replace(DependencyMarker, insertableAcknowledgements);
                // Create a temporary file with the DependencyMarker replaced with our collected Acknowledgements.
                // This file will be deleted OnClosed.
                // This means that if your project uses the DependencyMarker in your html file, you will not be able to
                // link to a file on a relative path for css styles or images.
                // ----------
                // Comments on possible ways around this limitation from John Thomson:
                //		1.Document that an About Box HTML file which uses dependency injection must live in its own folder
                // with all dependent files, and copy the whole folder to a temp folder.
                // (could work but is a nuisance, especially for anyone who doesn't need any dependencies)
                //		2.Document that an About Box HTML file which uses dependency injection may only use a few common kinds
                // of relative links, search for matching links, and copy the appropriate files to a temp directory along
                // with the temp file.
                // (I rather like this idea. A fairly simple regular expression will search for src or rel followed by a value
                // with no path separators...something like(src | rel) = (['"])([^/\]*)\1 (or something similar...
                // handle white space...). That will catch all references to images, stylesheets, and scripts,
                // and if the bit of the RegEx that matches the filename corresponds to an existing file in the same folder
                // as the HTML we can just copy it. Unless they're doing relative paths to different folders that will do it,
                // and I think it's reasonable to have SOME restrictions in the interests of simplicity.
                // ----------
                _tempAboutBoxHtmlFile = new TempFile(newHtmlContents);
                _browser.Navigate(_tempAboutBoxHtmlFile.Path);
            }
        }
        public void AssembleAcknowledgements_FindsSILCoreAcknowledgements()
        {
            var html = AcknowledgementsProvider.AssembleAcknowledgements();

            Assert.That(html, Contains.Substring("<a href='https://www.nuget.org/packages/Newtonsoft.Json/'>Json.NET</a>"));
        }