public void Initialize() { FileUtils.CopyDir(_dataRootPath, _applicationsRootPath, overwrite: true).Wait(); const string exeName = "TestProcess.exe"; string[] testAppsRelPath = { Path.Combine("test.myapp", "1.0.0"), Path.Combine("test.myapp", "1.0.1"), }; foreach (string testAppRelPath in testAppsRelPath) { TestUtils.CopyExe(exeName, Path.Combine(_applicationsRootPath, testAppRelPath)); } _applicationFactory = new ConfigurableApplicationFactory(new ApplicationConfigParser(new ApplicationConfigSymbolResolver(DeploymentId, InstanceId)), new SelfRestartingProcessFactory(0), new ProcessStopper(0)); _applicationPool = new ApplicationPool(); }
public async Task TestRemoveApplication() { int startCallCount = 0; int stopCallCount = 0; AppIdentity appIdentity = new AppIdentity("test.myapp", new Version(1, 0, 0)); IApplication application = new StubIApplication() { Start = () => { startCallCount++; return Task.FromResult(true); }, Stop = () => { stopCallCount++; return Task.FromResult(true); }, IdentityGet = () => appIdentity }; _applicationPool = new ApplicationPool(); await _applicationPool.AddApplication(application); Assert.IsTrue(_applicationPool.HasApplication(appIdentity)); Assert.AreEqual(1, startCallCount); Assert.AreEqual(0, stopCallCount); await _applicationPool.RemoveApplication(appIdentity); Assert.AreEqual(1, stopCallCount); }