public void StartFail() { IApplicationManager manager = ApplicationManager.Instantiate(new Type[] { typeof(MockManagerStartFail) }); Exception ex = Record.Exception(() => manager.Start()); Assert.NotNull(ex); Assert.IsType <ManagerStartException>(ex); }
public void StopFail() { IApplicationManager manager = ApplicationManager.Instantiate(new Type[] { typeof(MockManagerStopFail) }); IResult startResult = manager.Start(); Assert.NotEqual(ResultCode.Failure, startResult.ResultCode); Assert.Equal(State.Running, manager.State); Exception ex = Record.Exception(() => manager.Stop()); Assert.NotNull(ex); Assert.IsType <ManagerStopException>(ex); }
public void StartStop() { IApplicationManager manager = ApplicationManager.Instantiate(new Type[] { typeof(MockManager) }); IResult startResult = manager.Start(); Assert.NotEqual(ResultCode.Failure, startResult.ResultCode); Assert.Equal(State.Running, manager.State); IResult stopResult = manager.Stop(); Assert.NotEqual(ResultCode.Failure, stopResult.ResultCode); Assert.Equal(State.Stopped, manager.State); }
/// <summary> /// Entry point for the application logic. /// </summary> /// <param name="args">Command line arguments.</param> /// <exception cref="ApplicationStartException"> /// Thrown when an exception is encountered while starting the application. /// </exception> internal static void Start(string[] args) { logger.EnterMethod(xLogger.Params((object)args), true); logger.Heading(LogLevel.Debug, "Startup"); // this is the main try/catch for the application logic. If an unhandled exception is thrown anywhere in the // application it will be caught here and treated as a fatal error, stopping the application. try { // start the program manager. logger.SubHeading(LogLevel.Debug, applicationManager.ManagerName); logger.Info($"Starting the {applicationManager.ManagerName}..."); IResult managerStartResult = applicationManager.Start(); if (managerStartResult.ResultCode == ResultCode.Failure) { throw new ApplicationStartException($"The {applicationManager.ManagerName} failed to start: {managerStartResult.GetLastError()}"); } logger.Info($"{applicationManager.ManagerName} started."); logger.Info("Performing startup tasks..."); Startup(); logger.Info($"{applicationManager.ProductName} is running."); Console.ReadLine(); } catch (Exception ex) { logger.Exception(ex); throw new ApplicationStartException("Error starting the application. See the inner exception for details.", ex); } finally { logger.ExitMethod(true); } }