public static void Main(string[] args) { #if DEBUG Process p = Process.GetCurrentProcess(); ShowWindow(p.MainWindowHandle, MAXIMIZE); #endif try { var rootFolder = GetRootFolder(); using ILoggerProvider loggerProvider = GetNLogProvider(rootFolder); var cubesEnvironment = new CubesEnvironment(rootFolder, loggerProvider.CreateLogger(typeof(CubesEnvironment).FullName)); cubesEnvironment.PrepareHost(); CreateHostBuilder(args, cubesEnvironment) .Build() .Run(); } catch (Exception ex) { Console.WriteLine("Cubes Host stopped because of exception!"); Console.WriteLine(ex.ToString()); new NLogLoggerProvider() .CreateLogger(typeof(CubesEnvironment).FullName) .LogError(ex, "Cubes Host stopped because of exception!"); } finally { // Ensure to flush and stop internal timers/threads // before application-exit (Avoid segmentation fault on Linux) NLog.LogManager.Shutdown(); } }
public void PrepareEnvironmentFolders_CreatesNeededFolders() { // Arrange var fileSystem = new MockFileSystem(); var loggerMock = mockRepository.Create <ILogger>(); loggerMock .Setup(i => i.Log( It.IsAny <LogLevel>(), It.IsAny <EventId>(), It.IsAny <Object>(), It.IsAny <Exception>(), It.IsAny <Func <Object, Exception, string> >())) .Verifiable(); var unitUnderTest = new CubesEnvironment("C:\\Cubes", loggerMock.Object, fileSystem); // Act unitUnderTest.PrepareHost(); // Assert loggerMock.Verify(m => m.Log( It.IsAny <LogLevel>(), It.IsAny <EventId>(), It.IsAny <Object>(), It.IsAny <Exception>(), It.IsAny <Func <Object, Exception, string> >()), Times.Exactly(2)); Assert.True(fileSystem.Directory.Exists(unitUnderTest.GetAppsFolder())); Assert.True(fileSystem.Directory.Exists(unitUnderTest.GetStorageFolder())); Assert.True(fileSystem.Directory.Exists(unitUnderTest.GetSettingsFolder())); Assert.True(fileSystem.Directory.Exists(unitUnderTest.GetFolder(CubesFolderKind.Content))); Assert.True(fileSystem.Directory.Exists(unitUnderTest.GetFolder(CubesFolderKind.Temp))); Assert.True(fileSystem.Directory.Exists(unitUnderTest.GetFolder(CubesFolderKind.Logs))); }
public static void Main(string[] args) { #if (DEBUG && WINDOWS) Process p = Process.GetCurrentProcess(); ShowWindow(p.MainWindowHandle, MAXIMIZE); #endif try { var rootFolder = CubesEnvironmentHelpers.GetRootFolder(args); var adminPath = CubesEnvironmentHelpers.GetAdminPath(args); var applications = CubesEnvironmentHelpers.GetApplications(rootFolder, args); using var loggerProvider = GetNLogProvider(rootFolder); var cubesEnvironment = new CubesEnvironment( rootFolder: rootFolder, adminPath: adminPath, applications: applications, logger: loggerProvider.CreateLogger(typeof(CubesEnvironment).FullName)); cubesEnvironment.PrepareHost(); CreateHostBuilder(args, cubesEnvironment) .Build() .Run(); } catch (Exception ex) { Console.WriteLine("Cubes Host stopped because of exception!"); Console.WriteLine(ex.ToString()); new NLogLoggerProvider() .CreateLogger(typeof(CubesEnvironment).FullName) .LogError(ex, "Cubes Host stopped because of exception!"); #if DEBUG Console.WriteLine("Press any key to continue ..."); Console.ReadKey(true); #endif } finally { // Ensure to flush and stop internal timers/threads // before application-exit (Avoid segmentation fault on Linux) LogManager.Shutdown(); } }