Update() 공개 메소드

public Update ( IEnumerable applicationsToRemove, IEnumerable applicationsToDeploy ) : Task
applicationsToRemove IEnumerable
applicationsToDeploy IEnumerable
리턴 Task
예제 #1
0
        public async Task TestUpdateApplication()
        {
            string updateSessionId = null;
	        IUpdateSessionManager updateSessionManager = new StubIUpdateSessionManager()
		        .TryStartUpdateSession(id =>
		        {
			        updateSessionId = id;
			        return Task.FromResult(true);
		        })
		        .EndUpdateSession(id => Task.FromResult(true));

            IApplicationPool applicationPool = new ApplicationPoolStub();
            IApplicationInstaller applicationInstaller = new ApplicationInstaller(_applicationsRoot, updateSessionManager, new ApplicationFactoryStub(), applicationPool);

            const string appId = "test.app";
            AppIdentity[] existingApps = { new AppIdentity(appId, new SemVersion(1, 0, 0)), new AppIdentity(appId, new SemVersion(1, 0, 1)) };
            AppIdentity[] newApps = { new AppIdentity(appId, new SemVersion(1, 0, 2)), new AppIdentity(appId, new SemVersion(2, 0, 0)) };

            foreach (var existingApp in existingApps)
            {
                string appPath = Path.Combine(_applicationsRoot, existingApp.Id, existingApp.Version.ToString());
                if (!Directory.Exists(appPath))
                {
                    Directory.CreateDirectory(appPath);
                }
                await applicationInstaller.Install(new AppInstallConfig(existingApp));
                Assert.True(applicationPool.HasApplication(existingApp));
            }

            await applicationInstaller.Update(existingApps, newApps.Select(appIdentity => new AppInstallConfig(appIdentity)));

            foreach (AppIdentity app in existingApps)
            {
                Assert.False(applicationPool.HasApplication(app));
            }

            foreach (AppIdentity app in newApps)
            {
                Assert.True(applicationPool.HasApplication(app));
            }

            Assert.Equal(appId, updateSessionId);
        }
예제 #2
0
        public async Task TestThatUpdateReturnsIfCannotStartUpdateSession()
        {
	        IUpdateSessionManager updateSessionManager = new StubIUpdateSessionManager()
		        .TryStartUpdateSession(id => Task.FromResult(false));

            IApplicationPool applicationPool = new ApplicationPoolStub();
            IApplicationInstaller applicationInstaller = new ApplicationInstaller(_applicationsRoot, updateSessionManager, new ApplicationFactoryStub(), applicationPool);

            AppIdentity existingApp = new AppIdentity("test.app", new SemVersion(1, 0, 0));
            await applicationInstaller.Install(new AppInstallConfig(existingApp));

            AppIdentity newApp = new AppIdentity(existingApp.Id, new SemVersion(1, 1, 0));
            await applicationInstaller.Update(new[] {existingApp}, new[] {new AppInstallConfig(newApp), });

            Assert.True(applicationPool.HasApplication(existingApp));
            Assert.False(applicationPool.HasApplication(newApp));
        }