示例#1
0
        public static void RunUpdateCheck()
        {
            UpdateCheck uc = new UpdateCheck();

            uc.ShowDialog();
            uc.Dispose();
        }
示例#2
0
        // Check for Updates
        private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UpdateCheck uc = new UpdateCheck();

            uc.ShowDialog();
            uc.Dispose();
        }
示例#3
0
        public static void TestDoubleDisposeAndObjectDisposedException()
        {
            SetupAssembly.FakeRuntimeEnvironment.WebCallerCreator = () =>
            {
                return(new FakeWebCaller(@"{""U"":""http://localhost/AxCrypt/Downloads.html"",""V"":""2.0.307.0"",""R"":307,""S"":0,""M"":""OK""}"));
            };

            DateTime utcNow = DateTime.UtcNow;

            SetupAssembly.FakeRuntimeEnvironment.TimeFunction = () => { return(utcNow); };

            Version          thisVersion      = new Version(2, 0, 300, 0);
            Version          newVersion       = new Version(2, 0, 307, 0);
            Uri              restApiUrl       = new Uri("http://localhost/RestApi.asxh/axcrypt2version");
            Uri              updateWebPageUrl = new Uri("http://www.axantum.com/");
            VersionEventArgs eventArgs        = null;
            UpdateCheck      updateCheck      = new UpdateCheck(thisVersion);

            updateCheck.VersionUpdate += (object sender, VersionEventArgs e) =>
            {
                eventArgs = e;
            };
            updateCheck.CheckInBackground(DateTime.MinValue, UpdateCheck.VersionUnknown.ToString(), restApiUrl, updateWebPageUrl);
            updateCheck.WaitForBackgroundCheckComplete();
            updateCheck.Dispose();

            Assert.DoesNotThrow(updateCheck.Dispose);
            Assert.Throws <ObjectDisposedException>(() => { updateCheck.CheckInBackground(DateTime.MinValue, UpdateCheck.VersionUnknown.ToString(), restApiUrl, updateWebPageUrl); });
            Assert.Throws <ObjectDisposedException>(updateCheck.WaitForBackgroundCheckComplete);

            Assert.That(eventArgs, Is.Not.Null, "The VersionUpdate event should be called with non-null VersionEventArgs.");
            Assert.That(eventArgs.VersionUpdateStatus, Is.EqualTo(VersionUpdateStatus.NewerVersionIsAvailable), "The new version was newer.");
            Assert.That(eventArgs.UpdateWebpageUrl, Is.EqualTo(new Uri("http://localhost/AxCrypt/Downloads.html")), "The right URL should be passed in the event args.");
            Assert.That(eventArgs.Version, Is.EqualTo(newVersion), "The new version should be passed back.");
        }
示例#4
0
        public static void TestDoubleDisposeAndObjectDisposedException()
        {
            SetupAssembly.FakeRuntimeEnvironment.WebCallerCreator = () =>
            {
                return new FakeWebCaller(@"{""U"":""http://localhost/AxCrypt/Downloads.html"",""V"":""2.0.307.0"",""R"":307,""S"":0,""M"":""OK""}");
            };

            DateTime utcNow = DateTime.UtcNow;
            SetupAssembly.FakeRuntimeEnvironment.TimeFunction = () => { return utcNow; };

            Version thisVersion = new Version(2, 0, 300, 0);
            Version newVersion = new Version(2, 0, 307, 0);
            Uri restApiUrl = new Uri("http://localhost/RestApi.asxh/axcrypt2version");
            Uri updateWebPageUrl = new Uri("http://www.axantum.com/");
            VersionEventArgs eventArgs = null;
            UpdateCheck updateCheck = new UpdateCheck(thisVersion);
            updateCheck.VersionUpdate += (object sender, VersionEventArgs e) =>
            {
                eventArgs = e;
            };
            updateCheck.CheckInBackground(DateTime.MinValue, UpdateCheck.VersionUnknown.ToString(), restApiUrl, updateWebPageUrl);
            updateCheck.WaitForBackgroundCheckComplete();
            updateCheck.Dispose();

            Assert.DoesNotThrow(updateCheck.Dispose);
            Assert.Throws<ObjectDisposedException>(() => { updateCheck.CheckInBackground(DateTime.MinValue, UpdateCheck.VersionUnknown.ToString(), restApiUrl, updateWebPageUrl); });
            Assert.Throws<ObjectDisposedException>(updateCheck.WaitForBackgroundCheckComplete);

            Assert.That(eventArgs, Is.Not.Null, "The VersionUpdate event should be called with non-null VersionEventArgs.");
            Assert.That(eventArgs.VersionUpdateStatus, Is.EqualTo(VersionUpdateStatus.NewerVersionIsAvailable), "The new version was newer.");
            Assert.That(eventArgs.UpdateWebpageUrl, Is.EqualTo(new Uri("http://localhost/AxCrypt/Downloads.html")), "The right URL should be passed in the event args.");
            Assert.That(eventArgs.Version, Is.EqualTo(newVersion), "The new version should be passed back.");
        }