public void TestStart()
        {
            TestLifeCycle lifecycle = new TestLifeCycle();
            TestListener listener = new TestListener();
            lifecycle.AddLifeCycleListener(listener);
            ((StdErrLog)Log.Logger).HideStacks = true;
            lifecycle.Cause = cause;

            try
            {
                lifecycle.Start();
                Assert.IsTrue(false);
            }
            catch(Exception e)
            {
                Assert.AreEqual(cause, e);
                Assert.AreEqual(cause, listener.Cause);
            }
            lifecycle.Cause = null;
            ((StdErrLog)Log.Logger).HideStacks = false;

            lifecycle.Start();

            // check that the starting event has been thrown
            Assert.IsTrue(listener.Starting, "The staring event didn't occur");

            // check that the started event has been thrown
            Assert.IsTrue(listener.Started, "The started event didn't occur");

            // check that the starting event occurs before the started event
            Assert.IsTrue(listener.StartingTime <= listener.StartedTime, "The starting event must occur before the started event");

            // check that the lifecycle's state is started
            Assert.IsTrue(lifecycle.IsStarted, "The lifecycle state is not started");
        }
예제 #2
0
        public void TestStop()
        {
            TestLifeCycle lifecycle = new TestLifeCycle();
            TestListener  listener  = new TestListener();

            lifecycle.AddLifeCycleListener(listener);


            // need to set the state to something other than stopped or stopping or
            // else
            // Stop() will return without doing anything

            lifecycle.Start();

            ((StdErrLog)Log.Logger).HideStacks = true;
            lifecycle.Cause = cause;

            try
            {
                lifecycle.Stop();
                Assert.IsTrue(false);
            }
            catch (Exception e)
            {
                Assert.AreEqual(cause, e);
                Assert.AreEqual(cause, listener.Cause);
            }


            lifecycle.Cause = null;
            ((StdErrLog)Log.Logger).HideStacks = false;

            lifecycle.Stop();

            // check that the stopping event has been thrown
            Assert.IsTrue(listener.Stopping, "The stopping event didn't occur");

            // check that the stopped event has been thrown
            Assert.IsTrue(listener.Stopped, "The stopped event didn't occur");

            // check that the stopping event occurs before the stopped event
            Assert.IsTrue(listener.StoppingTime <= listener.StoppedTime, "The stopping event must occur before the stopped event");

            // check that the lifecycle's state is stopped
            Assert.IsTrue(lifecycle.IsStopped, "The lifecycle state is not stooped");
        }
예제 #3
0
        public void TestStart()
        {
            TestLifeCycle lifecycle = new TestLifeCycle();
            TestListener  listener  = new TestListener();

            lifecycle.AddLifeCycleListener(listener);
            ((StdErrLog)Log.Logger).HideStacks = true;
            lifecycle.Cause = cause;

            try
            {
                lifecycle.Start();
                Assert.IsTrue(false);
            }
            catch (Exception e)
            {
                Assert.AreEqual(cause, e);
                Assert.AreEqual(cause, listener.Cause);
            }
            lifecycle.Cause = null;
            ((StdErrLog)Log.Logger).HideStacks = false;


            lifecycle.Start();

            // check that the starting event has been thrown
            Assert.IsTrue(listener.Starting, "The staring event didn't occur");


            // check that the started event has been thrown
            Assert.IsTrue(listener.Started, "The started event didn't occur");

            // check that the starting event occurs before the started event
            Assert.IsTrue(listener.StartingTime <= listener.StartedTime, "The starting event must occur before the started event");

            // check that the lifecycle's state is started
            Assert.IsTrue(lifecycle.IsStarted, "The lifecycle state is not started");
        }
        public void TestStop()
        {
            TestLifeCycle lifecycle = new TestLifeCycle();
            TestListener listener = new TestListener();
            lifecycle.AddLifeCycleListener(listener);

            // need to set the state to something other than stopped or stopping or
            // else
            // Stop() will return without doing anything

            lifecycle.Start();

            ((StdErrLog)Log.Logger).HideStacks = true;
            lifecycle.Cause = cause;

            try
            {
                lifecycle.Stop();
                Assert.IsTrue(false);
            }
            catch(Exception e)
            {
                Assert.AreEqual(cause, e);
                Assert.AreEqual(cause, listener.Cause);
            }

            lifecycle.Cause = null;
            ((StdErrLog)Log.Logger).HideStacks = false;

            lifecycle.Stop();

            // check that the stopping event has been thrown
            Assert.IsTrue(listener.Stopping, "The stopping event didn't occur");

            // check that the stopped event has been thrown
            Assert.IsTrue(listener.Stopped, "The stopped event didn't occur");

            // check that the stopping event occurs before the stopped event
            Assert.IsTrue(listener.StoppingTime <= listener.StoppedTime, "The stopping event must occur before the stopped event");

            // check that the lifecycle's state is stopped
            Assert.IsTrue(lifecycle.IsStopped, "The lifecycle state is not stooped");
        }