コード例 #1
0
ファイル: LocalOpsTest.cs プロジェクト: pjanec/dirigent
 /// <summary>
 /// Returns a string with comma separated appIdTuples of apps whose state matches given predicate;
 /// the apps go in alphabetical order ("m10.b", "m2.a"...)
 /// </summary>
 public string getAppsWithMatchingState(LocalOperations lo, Predicate<AppState> predicate)
 {
     var appIds =
         from a in lo.GetCurrentPlan().getAppDefs()
         where predicate( lo.GetAppState(a.AppIdTuple) )
         orderby a.AppIdTuple.ToString()
         select a.AppIdTuple.ToString();
     return string.Join(",", appIds.ToArray());
 }
コード例 #2
0
ファイル: LocalOpsTest.cs プロジェクト: pjanec/dirigent
        public void testRunApp()
        {
            var lo = new LocalOperations("m1", lf, appInitializedDetectorFactory );

            lo.SelectPlan( PlanRepo.plans["p1"] );

            AppState st;

            st = lo.GetAppState( ads["a"].AppIdTuple );
            Assert.AreEqual( st.Started, false, "not yet launched" );
            Assert.AreEqual( st.Running, false, "not yet running" );
            Assert.AreEqual( st.Killed, false, "not yet killed");
            Assert.AreEqual(st.Initialized, false, "not yet initialized");

            lo.LaunchApp( ads["a"].AppIdTuple );
            lo.tick( 10.0 );

            st = lo.GetAppState( ads["a"].AppIdTuple );
            Assert.AreEqual( st.Started, true, "launched" );
            Assert.AreEqual( st.Running, true, "running" );
            Assert.AreEqual(st.Killed, false, "not yet killed");
            Assert.AreEqual(st.Initialized, true, "initialized");

            lo.KillApp( ads["a"].AppIdTuple );
            lo.tick( 10.0 );

            st = lo.GetAppState( ads["a"].AppIdTuple );
            Assert.AreEqual( st.Started, true, "started after kill" );
            Assert.AreEqual(st.Killed, true, "killed after kill");
            Assert.AreEqual(st.Running, false, "not running after kill");
            Assert.AreEqual( st.Initialized, false, "not initialized after kill" );
        }