public void InstallNextComponent_WithUnknownVersionComponent_FailsInstallation() { var unknownVersion = new Version(int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue); var currentVersion = new Version("0.0.0.1"); var latestVersion = new Version("0.0.0.2"); var component = new InstallationComponent("dshajdkh", OtherActions.DoNothing(), OtherActions.DoNothing(), OtherActions.DoNothing()); // Does nothing on installation or rollback var installationComponents = new Dictionary <int, InstallationComponent>(); installationComponents.Add(0, component); A.CallTo(() => discovery.Discover()) .Returns(new List <InstallationVersion> { new TestInstallationVersion(currentVersion, new Dictionary <int, InstallationComponent>()), new TestInstallationVersion(latestVersion, installationComponents), }); var dispatcher = A.Fake <IDataAccessDispatcher>(); A.CallTo(() => dispatcher.Dispatch(A <DataAccessAction <Solution> > ._)) .Returns(new Solution { Name = "TestSolution", DisplayName = "Test Solution", Version = currentVersion.ToString() }); var result = new InstallationService(discovery, dispatcher).InstallNextComponent(int.MaxValue, latestVersion); Assert.False(result.IsSuccess); Assert.False(result.MoreToInstall); Assert.NotNull(result.ErrorMessage); }
protected void RegisterNextComponent(InstallationComponent installationComponent) { var nextComponentKey = !installationComponents.Any() ? 0 : installationComponents.Keys.OrderByDescending(k => k).First() + 1; installationComponents.Add(nextComponentKey, installationComponent); }
public ComponentDefinition(InstallationComponent component, string installationDirectory, string applicationFileName, string shortName, string description) { this.Component = component; this.InstallationDirectory = installationDirectory; this.ApplicationFileName = applicationFileName; this.ShortName = shortName; this.Description = description; }
private void RegisterComponents() { var createBuildVersioningTypeOption = new InstallationComponent("Adding build versioning type option", BuildInstallationActions.CreateBuildVersioningTypeField(), OtherActions.DoNothing(), OtherActions.DoNothing()); RegisterNextComponent(createBuildVersioningTypeOption); }
public void InstallNextComponent_ForTwoNewVersionsWithTwoComponents_InstallationIsNotComplete_AndGivesDetailsOfNextComponentToInstall() { var currentVersion = new Version("0.0.0.1"); var firstNewVersion = new Version("0.0.0.2"); var secondNewVersion = new Version("0.0.0.3"); var firstComponentDescription = "dhjskldsa"; var secondComponentDescription = "DLAOIEHJK"; var firstComponent = new InstallationComponent(firstComponentDescription, OtherActions.DoNothing(), OtherActions.DoNothing(), OtherActions.DoNothing()); // Does nothing on installation or rollback var secondComponent = new InstallationComponent(secondComponentDescription, OtherActions.DoNothing(), OtherActions.DoNothing(), OtherActions.DoNothing()); var firstNewVersionComponents = new Dictionary <int, InstallationComponent>(); firstNewVersionComponents.Add(0, firstComponent); var secondNewVersionComponents = new Dictionary <int, InstallationComponent>(); secondNewVersionComponents.Add(0, secondComponent); A.CallTo(() => discovery.Discover()) .Returns(new List <InstallationVersion> { new TestInstallationVersion(currentVersion, new Dictionary <int, InstallationComponent>()), new TestInstallationVersion(firstNewVersion, firstNewVersionComponents), new TestInstallationVersion(secondNewVersion, secondNewVersionComponents), }); var dispatcher = A.Fake <IDataAccessDispatcher>(); A.CallTo(() => dispatcher.Dispatch(A <DataAccessAction <Solution> > ._)) .Returns(new Solution { Name = "TestSolution", DisplayName = "Test Solution", Version = currentVersion.ToString() }); var installation = new InstallationService(discovery, dispatcher); var startInstallationResult = installation.StartInstallation(); var result = installation.InstallNextComponent(startInstallationResult.NextComponentId.Value, startInstallationResult.Version); Assert.True(result.IsSuccess); Assert.True(result.MoreToInstall); Assert.Equal(secondComponentDescription, result.NextComponentDescription); Assert.True(result.NextComponentId.HasValue); Assert.Equal(0, result.NextComponentId.Value); Assert.NotNull(result.NextComponentVersion); Assert.Equal(0, secondNewVersion.CompareTo(result.NextComponentVersion)); }
private void RegisterComponents() { var createEntity = new InstallationComponent("Creating build entity", BuildInstallationActions.CreateEntity(), OtherActions.DoNothing(), OtherActions.DoNothing()); var createName = new InstallationComponent("Creating build entity name", BuildInstallationActions.CreateNameField(), OtherActions.DoNothing(), OtherActions.DoNothing()); // Rollback is covered by deletion of entity in first component RegisterNextComponent(createEntity); RegisterNextComponent(createName); }
public async Task <InstallationPackage> DownloadPackage(InstallationComponent component) { string owner = ""; string repository = ""; string packageName = ""; switch (component) { case InstallationComponent.Client: { owner = "PMDShift"; repository = "CrowClient"; packageName = "PMDShift-C-Windows.zip"; } break; case InstallationComponent.Editor: { owner = "PMDShift"; repository = "CrowClient"; packageName = "PMDShift-Editors-Windows.zip"; } break; case InstallationComponent.LegacyClient: { owner = "PMDShift"; repository = "Client"; packageName = "PMDShift.zip"; } break; } if (!string.IsNullOrEmpty(owner) && !string.IsNullOrEmpty(repository)) { var release = await client.Repository.Release.GetLatest(owner, repository); var assetPackage = release.Assets.Where(x => x.Name == packageName).FirstOrDefault(); if (assetPackage != null) { var packageTempFile = Path.GetTempFileName(); await webClient.DownloadFileTaskAsync(assetPackage.BrowserDownloadUrl, packageTempFile); return(new InstallationPackage(component, packageTempFile)); } } return(null); }
public void InstallNextComponent_ForTwoNewVersionsWithTwoComponents_UpdatesSolutionVersionAsFirstComponentInstalled() { var currentVersion = new Version("0.0.0.1"); var firstNewVersion = new Version("0.0.0.2"); var secondNewVersion = new Version("0.0.0.3"); var firstComponentDescription = "dhjskldsa"; var secondComponentDescription = "DLAOIEHJK"; var firstComponent = new InstallationComponent(firstComponentDescription, OtherActions.DoNothing(), OtherActions.DoNothing(), OtherActions.DoNothing()); // Does nothing on installation or rollback var secondComponent = new InstallationComponent(secondComponentDescription, OtherActions.DoNothing(), OtherActions.DoNothing(), OtherActions.DoNothing()); var firstNewVersionComponents = new Dictionary <int, InstallationComponent>(); firstNewVersionComponents.Add(0, firstComponent); var secondNewVersionComponents = new Dictionary <int, InstallationComponent>(); secondNewVersionComponents.Add(0, secondComponent); A.CallTo(() => discovery.Discover()) .Returns(new List <InstallationVersion> { new TestInstallationVersion(currentVersion, new Dictionary <int, InstallationComponent>()), new TestInstallationVersion(firstNewVersion, firstNewVersionComponents), new TestInstallationVersion(secondNewVersion, secondNewVersionComponents), }); var dispatcher = A.Fake <IDataAccessDispatcher>(); A.CallTo(() => dispatcher.Dispatch(A <DataAccessAction <Solution> > ._)) .Returns(new Solution { Name = "TestSolution", DisplayName = "Test Solution", Version = currentVersion.ToString() }); var installation = new Services.Installation.InstallationService(discovery, dispatcher); var startInstallationResult = installation.StartInstallation(); var result = installation.InstallNextComponent(startInstallationResult.NextComponentId.Value, startInstallationResult.NextComponentVersion); A.CallTo(() => dispatcher.Dispatch(A <DataAccessAction> ._)) .MustHaveHappened(); }
public static string GetInstallationDirectory(this InstallationComponent component) { switch (component) { case InstallationComponent.Client: return("Client"); case InstallationComponent.Editor: return("Editor"); case InstallationComponent.LegacyClient: return("LegacyClient"); default: throw new InvalidOperationException(); } }
public void StartInstallation_ForNewVersionWithOneComponent_InstallationIsNotComplete_AndReturnsDetailsOfFirstComponent() { var currentVersion = new Version("0.0.0.1"); var latestVersion = new Version("0.0.0.2"); var componentDescription = "dhjskldsa"; var componentInstall = new InstallationComponent(componentDescription, OtherActions.DoNothing(), OtherActions.DoNothing(), OtherActions.DoNothing()); var components = new Dictionary <int, InstallationComponent>(); components.Add(0, componentInstall); A.CallTo(() => discovery.Discover()) .Returns(new List <InstallationVersion> { new TestInstallationVersion(currentVersion, new Dictionary <int, InstallationComponent>()), new TestInstallationVersion(latestVersion, components), }); var dispatcher = A.Fake <IDataAccessDispatcher>(); A.CallTo(() => dispatcher.Dispatch(A <DataAccessAction <Solution> > ._)) .Returns(new Solution { Name = "TestSolution", DisplayName = "Test Solution", Version = currentVersion.ToString() }); var result = new InstallationService(discovery, dispatcher).StartInstallation(); Assert.True(result.IsSuccess); Assert.Equal(componentDescription, result.NextComponentDescription); Assert.Equal(0, result.NextComponentId); Assert.Equal("0.0.0.2", result.NextComponentVersion.ToString()); Assert.True(result.MoreToInstall); }
public InstallationPackage(InstallationComponent component, string path) { this.Component = component; this.Path = path; }