Example #1
0
        public void DependencyFault()
        {
            ManagerMockTwo o = ManagerMockTwo.Instantiate(applicationManagerMock.Object);

            o.Start();

            ManagerMockWithDependency test = ManagerMockWithDependency.Instantiate(applicationManagerMock.Object, o);

            // start the manager and assert that it is running
            IResult start = test.Start();

            Assert.Equal(State.Running, test.State);

            // fault the manager upon which the test manager is dependent ensure that this manager stops.start the other manager
            // and ensure that this manager remains stopped.
            o.Fault();
            Assert.Equal(State.Faulted, o.State);
            Assert.Equal(State.Stopped, test.State);
            Assert.Equal(true, test.AutomaticRestartPending);

            o.Start();
            Assert.Equal(State.Running, o.State);

            // wait 1500ms for the manager to restart (the restart timer is set for 500ms)
            Thread.Sleep(1500);

            // assert that the manager has restarted.
            Assert.Equal(State.Running, test.State);
        }
Example #2
0
        public void DependencyStop()
        {
            ManagerMockTwo o = ManagerMockTwo.Instantiate(applicationManagerMock.Object);

            o.Start();

            ManagerMockWithDependency test = ManagerMockWithDependency.Instantiate(applicationManagerMock.Object, o);

            // start the manager and assert that it is running
            IResult start = test.Start();

            Assert.Equal(State.Running, test.State);

            // stop the other manager (the manager upon which this test manager is dependent) ensure that this manager stops.
            // restart the other manager and ensure that this manager remains stopped.
            o.Stop();
            Assert.Equal(State.Stopped, o.State);
            Assert.Equal(State.Stopped, test.State);
            Assert.Equal(false, test.AutomaticRestartPending);

            o.Start();
            Assert.Equal(State.Running, o.State);
            Assert.Equal(State.Stopped, test.State);

            // restart this manager in preparation for the next
            test.Start();
            Assert.Equal(State.Running, test.State);

            // stop the other manager with the restart flag
            o.Stop(StopType.Restart);
            Assert.Equal(State.Stopped, o.State);
            Assert.Equal(State.Stopped, test.State);
            Assert.Equal(true, test.AutomaticRestartPending);

            o.Start();
            Assert.Equal(State.Running, o.State);

            // wait 1500ms for the manager to restart (the restart timer is set for 500ms)
            Thread.Sleep(1000);

            // assert that the manager has restarted.
            Assert.Equal(State.Running, test.State);
        }
Example #3
0
 /// <summary>
 ///     Instantiates the Manager.
 /// </summary>
 /// <param name="manager">The ApplicationManager dependency.</param>
 /// <param name="otherManager">A second Manager dependency.</param>
 /// <returns>The instantiated Manager.</returns>
 public static ManagerMockWithDependency Instantiate(IApplicationManager manager, IManager otherManager)
 {
     // remove the code that makes this a singleton so that test runners can get a fresh instance each time.
     instance = new ManagerMockWithDependency(manager, otherManager);
     return(instance);
 }