public void testSeparationIntervals() { var appDefs = new List<AppDef>() { ads["a"], ads["b"], ads["c"], }; var ls = new LaunchSequencer(); Assert.AreEqual( true, ls.IsEmpty(), "empty after creation" ); ls.AddApps( appDefs ); Assert.AreEqual( false, ls.IsEmpty(), "non-empty after adding some apps" ); // first app should be returned immediately double t = 0.0; AppDef ad; ad = ls.GetNext( t ); Assert.AreEqual( appDefs[0], ad, "first app should be returned immediately" ); Assert.AreEqual( false, ls.IsEmpty(), "non-empty after first app returned" ); ad = ls.GetNext( t ); Assert.AreEqual( null, ad, "second app should wait" ); t += appDefs[0].SeparationInterval; ad = ls.GetNext( t ); Assert.AreEqual( appDefs[1], ad, "second app after the first app's separ. interval" ); Assert.AreEqual( false, ls.IsEmpty(), "non-empty after second app returned" ); ad = ls.GetNext( t ); Assert.AreEqual( null, ad, "third app should wait" ); t += appDefs[1].SeparationInterval; ad = ls.GetNext( t ); Assert.AreEqual( appDefs[2], ad, "third app after the second app's separ. interval" ); Assert.AreEqual( true, ls.IsEmpty(), "empty after last app returned" ); // add some next app ls.AddApps( new List<AppDef>() { ads["a"] } ); Assert.AreEqual( false, ls.IsEmpty(), "non-empty after refilled" ); t += appDefs[2].SeparationInterval; ad = ls.GetNext( t ); Assert.AreEqual( ads["a"], ad, "refill app after the last app's separ. interval" ); Assert.AreEqual( true, ls.IsEmpty(), "empty after last app returned" ); }
public LocalOperations( string machineId, ILauncherFactory launcherFactory, IAppInitializedDetectorFactory appAppInitializedDetectorFactory ) { this.launcherFactory = launcherFactory; this.appAppInitializedDetectorFactory = appAppInitializedDetectorFactory; appsState = new Dictionary<AppIdTuple,AppState>(); localApps = new Dictionary<AppIdTuple,LocalApp>(); currentPlan = null; planRepo = new List<ILaunchPlan>(); this.machineId = machineId; launchSequencer = new LaunchSequencer(); }
public LaunchSequencer launchSequencer; // non-null only when plan is running public PlanRuntimeInfo(ILaunchPlan plan) { this.Plan = plan; launchSequencer = new LaunchSequencer(); State = new PlanState(); }