This could maybe eventually go to https://github.com/hatton/NetSparkle. My hesitation is that it's kind of specific to our way of using TeamCity and our build scripts There are two levels of indirection here to give us maximum forward compatibility and control over what upgrades happen in what channels. First, we go use a url based on our channel ("http://bloomlibrary.org/channels/UpgradeTable{channel}.txt) to download a file. Then, in that file, we search for a row that matches our version number to decide which upgrades folder to use.
 public void LookupURLOfUpdate_NoLineForDesiredVersion_ReportsError()
 {
     var t = new UpdateVersionTable();
     t.TextContentsOfTable = @"0.0.0,3.1.99999, http://first.com/first";
     t.RunningVersion = Version.Parse("3.2.0");
     var lookupResult = t.LookupURLOfUpdate();
     Assert.That(lookupResult.URL, Is.Null.Or.Empty);
     Assert.That(lookupResult.Error.Message, Is.EqualTo("http://bloomlibrary.org/channels/UpgradeTableTestChannel.txt contains no record for this version of Bloom"));
 }
 public void LookupURLOfUpdate_TooManyCommas_LogsErrorGivesNoURL()
 {
     var t = new UpdateVersionTable();
     t.TextContentsOfTable = @"0.0.0,3,1,99999, http://first.com/first"; // too many commas
     t.RunningVersion = Version.Parse("3.2.0");
     var lookupResult = t.LookupURLOfUpdate();
     Assert.That(lookupResult.URL, Is.Null.Or.Empty);
     Assert.IsTrue(lookupResult.Error.Message.StartsWith("Could not parse a line of the UpdateVersionTable"));
 }
 public void LookupURLOfUpdate_BadVersionNumber_LogsErrorGivesNoURL()
 {
     var t = new UpdateVersionTable();
     t.TextContentsOfTable = @"random,3.1.99999, http://first.com/first"; // bad version number
     t.RunningVersion = Version.Parse("3.2.0");
     var lookupResult = t.LookupURLOfUpdate();
     Assert.That(lookupResult.URL, Is.Null.Or.Empty);
     Assert.IsTrue(lookupResult.Error.Message.StartsWith("Could not parse a version number in the UpdateVersionTable"));
 }
 public void LookupURLOfUpdate_CanReadTableForAlphaFromServer()
 {
     var t = new UpdateVersionTable();
     t.URLOfTable = "http://bloomlibrary.org/channels/UpgradeTableAlpha.txt";
     t.RunningVersion = Version.Parse("2.0.2000");
     //the full result will be something like
     //"https://s3.amazonaws.com/bloomlibrary.org/deltasAlpha"
     //this just checks the part that is less likely to break (independent of channel)
     Assert.That(t.LookupURLOfUpdate().URL.StartsWith("https://s3.amazonaws.com/bloomlibrary.org/deltas"));
 }
 public void LookupURLOfUpdate_AllWell_ReportsNoErrorAndReturnsUrl()
 {
     var t = new UpdateVersionTable();
     t.TextContentsOfTable = @"0.0.0,3.2.99999, http://first.com/first";
     t.RunningVersion = Version.Parse("3.2.0");
     var lookupResult = t.LookupURLOfUpdate();
     Assert.IsFalse(lookupResult.IsConnectivityError);
     Assert.IsNull(lookupResult.Error);
     Assert.That(lookupResult.URL, Is.EqualTo("http://first.com/first"));
 }
        public ApplicationContainer()
        {
            var builder = new ContainerBuilder();

            //builder.RegisterModule<WhiteboxProfilingModule>();

            //default to InstancePerDependency, i.e., they it will make a new
            //one each time someone asks for one
            builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly());

            builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly())
            .Where(t => t.GetInterfaces().Contains(typeof(ICommand))).InstancePerLifetimeScope();

            builder.Register <Sparkle>(c =>
            {
                string url;
                try
                {
                    var updateTable = new UpdateVersionTable();
                    url             = updateTable.GetAppcastUrl();
                }
                catch (Exception)
                {
                    url = "";
                    Logger.WriteEvent("Could not retrieve UpdateVersionTable from the internet");
                }
                var s = new Sparkle(url, Resources.Bloom);
                s.CustomInstallerArguments = "/qb";
                s.DoLaunchAfterUpdate      = false;
                return(s);
            }).InstancePerLifetimeScope();


            builder.Register(c => LocalizationManager).SingleInstance();

            if (Settings.Default.MruProjects == null)
            {
                Settings.Default.MruProjects = new MostRecentPathsList();
            }
            builder.RegisterInstance(Settings.Default.MruProjects).SingleInstance();

            //this is to prevent some problems we were getting while waiting for a browser to navigate and being forced to call Application.DoEvents().
            //HtmlThumbnailer & ConfigurationDialog, at least, use this.
            builder.Register(c => new NavigationIsolator()).InstancePerLifetimeScope();

            builder.Register <HtmlThumbNailer>(c => new HtmlThumbNailer(c.Resolve <NavigationIsolator>())).SingleInstance();

            _container = builder.Build();
        }
 public void ThisVersionTooLarge_ReturnsEmptyString()
 {
     var t = new UpdateVersionTable();
     t.RunningVersion = Version.Parse("99.99.99");
     t.TextContentsOfTable = @"# the format is min,max,url
                                                 0.0.0,1.1.999, http://example.com/appcast.xml";
     Assert.IsEmpty(t.LookupURLOfUpdate().URL);
 }
 public void ServerAddressIsBogus_ErrorIsCorrect()
 {
     var t = new UpdateVersionTable {URLOfTable = "http://notthere7blah/foo.txt"};
     //the jenkins server gets a ProtocolError, while my desktop gets a NameResolutionFailure
     var e = t.LookupURLOfUpdate().Error.Status;
     Assert.IsTrue(e  == WebExceptionStatus.NameResolutionFailure || e == WebExceptionStatus.ProtocolError );
 }
 public void FileForThisChannelIsMissing_ErrorIsCorrect()
 {
     var t = new UpdateVersionTable { URLOfTable = "http://bloomlibrary.org/channels/UpgradeTableSomethingBogus.txt"};
     Assert.AreEqual(WebExceptionStatus.ProtocolError, t.LookupURLOfUpdate().Error.Status);
 }
        public void ValueOnUpperBound_ReturnsCorrectUrl()
        {
            var t = new UpdateVersionTable();
            t.TextContentsOfTable = @"# the format is min,max,url
                                                        0.0.0,1.1.999, http://first.com/first
                                                        2.1.1,2.9.999, http://second.com/second
                                                        3.2.2,3.9.999, http://third.com/third";

            t.RunningVersion = Version.Parse("1.1.999");
            Assert.AreEqual("http://first.com/first", t.LookupURLOfUpdate().URL);
            t.RunningVersion = Version.Parse("2.9.999");
            Assert.AreEqual("http://second.com/second", t.LookupURLOfUpdate().URL);
            t.RunningVersion = Version.Parse("3.9.999");
            Assert.AreEqual("http://third.com/third", t.LookupURLOfUpdate().URL);
        }