Example #1
0
        public void Constructor()
        {
            ManagerMock test = ManagerMock.Instantiate(applicationManagerMock.Object);

            Assert.Equal(true, test.CheckDependency());
            Assert.Throws <DependencyNotResolvedException>(() => test.CheckBadDependency());

            test.Dispose();
        }
Example #2
0
        public void StartWithStoppedDependency()
        {
            Mock <IApplicationManager> a = new Mock <IApplicationManager>();

            a.Setup(m => m.State).Returns(State.Stopped);

            ManagerMock test = ManagerMock.Instantiate(a.Object);

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

            Assert.Equal(ResultCode.Failure, start.ResultCode);
        }
Example #3
0
        public void Start()
        {
            ManagerMock test = ManagerMock.Instantiate(applicationManagerMock.Object);

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

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

            // try to start again and assert that the operation fails
            IResult startAgain = test.Start();

            Assert.Equal(ResultCode.Failure, startAgain.ResultCode);
        }
Example #4
0
        public void Restart()
        {
            ManagerMock test = ManagerMock.Instantiate(applicationManagerMock.Object);

            // start the manager and assert that it is running
            test.Start();
            Assert.Equal(State.Running, test.State);

            // restart the manager and assert that the operation succeeded
            IResult restart = test.Restart();

            Assert.Equal(ResultCode.Success, restart.ResultCode);
            Assert.Equal(State.Running, test.State);
        }
Example #5
0
        public void StateProperty()
        {
            ManagerMock test = ManagerMock.Instantiate(applicationManagerMock.Object);

            Assert.Equal(State.Initialized, test.State);
        }
Example #6
0
        public void ManagerName()
        {
            ManagerMock test = ManagerMock.Instantiate(applicationManagerMock.Object);

            Assert.Equal("Mock Manager", test.ManagerName);
        }
Example #7
0
        public void EventProviderName()
        {
            ManagerMock test = ManagerMock.Instantiate(applicationManagerMock.Object);

            Assert.Equal(test.GetType().Name, test.EventProviderName);
        }
Example #8
0
        public void AutomaticRestartPending()
        {
            ManagerMock test = ManagerMock.Instantiate(applicationManagerMock.Object);

            Assert.Equal(false, test.AutomaticRestartPending);
        }
Example #9
0
 /// <summary>
 ///     Instantiates and returns the Manager.
 /// </summary>
 /// <param name="manager">The ApplicationManager dependency.</param>
 /// <returns>The instantiated Manager.</returns>
 public static ManagerMock Instantiate(IApplicationManager manager)
 {
     // remove the code that makes this a singleton so that test runners can get a fresh instance each time.
     instance = new ManagerMock(manager);
     return(instance);
 }