public void GetVersion_returns_version_part_of_filename() { var namingConvention = new DefaultNamingConvention(); var version = namingConvention.GetVersionFromFilename("Test.App-1.0.0.1.zip"); Assert.That(version, Is.EqualTo(new Version(1, 0, 0, 1))); }
/// <summary> /// Создает новый экзмемпляр класса <see cref="TopologyProviderTests"/>. /// </summary> public TopologyProviderTests() { var namingConvention = new DefaultNamingConvention( new ServiceInfoAccessor( new ServiceInfo("1.2.0-rc1", "MyAwesomeApplication", "app-hcsa-1245", "Production")) ); _topologyProvider = new DefaultTopologyProvider(namingConvention); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); initializeLogging(); // Workflow // 1. read configuration var config = new ConfigurationReader().Read(); // 2. check whether there is a new version or not var updatesProvider = new UpdatesProviderFactory(config).Create(); var namingConvention = new DefaultNamingConvention(); try { var lastVersionFilename = updatesProvider.GetLastVersionFilename(namingConvention); var lastVersion = namingConvention.GetVersionFromFilename(lastVersionFilename); var currentVersion = new CurrentVersionProvider(config).GetCurrentVersion(); if (lastVersion > currentVersion) { log.InfoFormat("Current version: {0}", currentVersion); log.InfoFormat("Last version available: {0}", lastVersion); // 3. if there is a new version, download it var downloadProgressNotificator = new DownloadProgressForm(); var localFilename = updatesProvider.Download(lastVersionFilename, downloadProgressNotificator); // 4. then activate it var activator = new DefaultActivator(config, null); activator.Activate(localFilename); } } catch (UpdatesProviderInaccessibleException ex) { // ignore errors when updates provider is inaccessible } catch (Exception ex) { log.Error("Error updating", ex); } try { Process.Start(config.ApplicationExe); } catch (Exception ex) { log.Fatal("Cannot start application", ex); } }
public void GetLastVersionFilename_returns_last_version_filename_that_verifies_convention() { var namingConvention = new DefaultNamingConvention(); var configuration = new LauncherConfiguration { ApplicationExe = "Test.App.exe" }; var fileList = new[] { "Test.App-1.0.0.0.zip", "Test.App-1.0.2.0.zip", "Test.Other-2.0.2.0.zip", }; var lastVersionFilename = namingConvention.GetLastVersionFilename(fileList, configuration); Assert.That(lastVersionFilename, Is.EqualTo("Test.App-1.0.2.0.zip")); }
/// <summary> /// Создает новый экземпляр класса <see cref="AcknowledgementBehaviorTests"/>. /// </summary> public AcknowledgementBehaviorTests() { var namingConvention = new DefaultNamingConvention( new ServiceInfoAccessor( new ServiceInfo("Test", "MyApp", "Test", "Test")) ); var topologyProvider = new DefaultTopologyProvider(namingConvention); var retryComputerResolver = new Mock <INamedResolver <string, IRetryDelayComputer> >(); retryComputerResolver.Setup(x => x.GetRequired(It.IsAny <string>())) .Returns((string retryPolicyType) => { if (retryPolicyType == RetryPolicyType.Constant) { return(new ConstantRetryDelayComputer()); } if (retryPolicyType == RetryPolicyType.Exponential) { return(new ExponentialRetryDelayComputer()); } if (retryPolicyType == RetryPolicyType.Linear) { return(new LinearRetryDelayComputer()); } throw new ArgumentOutOfRangeException( nameof(retryPolicyType), retryPolicyType, "Неопределена политика подсчета времени ретрая." ); }); _acknowledgementBehaviour = new DefaultAcknowledgementBehaviour( retryComputerResolver.Object, namingConvention, topologyProvider, NullLogger <DefaultAcknowledgementBehaviour> .Instance ); _configurationManager = new DefaultConfigurationManager(ConfigurationHelper.GetConfiguration()); }