Ejemplo n.º 1
0
        public ConceptApplicationRepositoryTest()
        {
            var configuration = new ConfigurationBuilder(new ConsoleLogProvider())
                                .Build();

            LegacyUtilities.Initialize(configuration);
        }
Ejemplo n.º 2
0
        public DatabaseCleanerTest()
        {
            var configuration = new ConfigurationBuilder(new ConsoleLogProvider())
                                .Build();

            LegacyUtilities.Initialize(configuration);
        }
Ejemplo n.º 3
0
        static int Main(string[] args)
        {
            try
            {
                var appRootFolder = AppDomain.CurrentDomain.BaseDirectory;
                var logProvider   = new ConsoleLogProvider();
                var host          = Host.Find(appRootFolder, logProvider);
                var configuration = host.RhetosRuntime.BuildConfiguration(logProvider, host.ConfigurationFolder,
                                                                          configurationBuilder => configurationBuilder.AddConfigurationManagerConfiguration());

                LegacyUtilities.Initialize(configuration);

                string connectionString = SqlUtility.ConnectionString;
                Console.WriteLine("SQL connection: " + SqlUtility.SqlConnectionInfo(connectionString));
                var sqlExecuter = GetSqlExecuterImplementation(connectionString);

                var databaseCleaner = new DatabaseCleaner(new ConsoleLogProvider(), sqlExecuter);
                databaseCleaner.DeleteAllMigrationData();
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine(ex);
                if (Environment.UserInteractive)
                {
                    Thread.Sleep(3000);
                }
                return(1);
            }
        }
Ejemplo n.º 4
0
        public SqlUtilityTest()
        {
            var configuration = new ConfigurationBuilder(new ConsoleLogProvider())
                                .AddConfigurationManagerConfiguration()
                                .Build();

            LegacyUtilities.Initialize(configuration);
        }
Ejemplo n.º 5
0
        public void ChecklDatabaseAvailability()
        {
            var configuration = new ConfigurationBuilder(new ConsoleLogProvider())
                                .AddConfigurationManagerConfiguration()
                                .Build();

            LegacyUtilities.Initialize(configuration);

            TestUtility.CheckDatabaseAvailability("MsSql");
        }
Ejemplo n.º 6
0
        private static void Build(string[] args, NLogProvider logProvider, string rhetosAppRootPath, out bool pauseOnError)
        {
            var logger = logProvider.GetLogger("DeployPackages");

            var configurationBuilder = new ConfigurationBuilder(logProvider)
                                       .AddOptions(new RhetosBuildEnvironment
            {
                ProjectFolder         = rhetosAppRootPath,
                OutputAssemblyName    = null,
                CacheFolder           = Path.Combine(rhetosAppRootPath, "GeneratedFilesCache"),
                GeneratedAssetsFolder = Path.Combine(rhetosAppRootPath, "bin", "Generated"),
                GeneratedSourceFolder = null,
            })
                                       .AddOptions(new LegacyPathsOptions
            {
                BinFolder       = Path.Combine(rhetosAppRootPath, "bin"),
                PluginsFolder   = Path.Combine(rhetosAppRootPath, "bin", "Plugins"),
                ResourcesFolder = Path.Combine(rhetosAppRootPath, "Resources"),
            })
                                       .AddKeyValue(ConfigurationProvider.GetKey((BuildOptions o) => o.GenerateAppSettings), false)
                                       .AddKeyValue(ConfigurationProvider.GetKey((BuildOptions o) => o.BuildResourcesFolder), true)
                                       .AddWebConfiguration(rhetosAppRootPath)
                                       .AddKeyValue(ConfigurationProvider.GetKey((ConfigurationProviderOptions o) => o.LegacyKeysWarning), true)
                                       .AddKeyValue(ConfigurationProvider.GetKey((LoggingOptions o) => o.DelayedLogTimout), 60.0)
                                       .AddConfigurationManagerConfiguration()
                                       .AddCommandLineArgumentsWithConfigurationPaths(args);

            var configuration = configurationBuilder.Build();

            var deployPackagesOptions = configuration.GetOptions <DeployPackagesOptions>();

            pauseOnError = !deployPackagesOptions.NoPause;
            if (deployPackagesOptions.StartPaused)
            {
                StartPaused();
            }

            if (!deployPackagesOptions.DatabaseOnly)
            {
                LegacyUtilities.Initialize(configuration);
                DeleteObsoleteFiles(rhetosAppRootPath, logProvider, logger);

                var installedPackages = DownloadPackages(deployPackagesOptions.IgnoreDependencies, logProvider, logger);

                var pluginAssemblies = Directory.GetFiles(Path.Combine(rhetosAppRootPath, "bin", "Plugins"), "*.dll", SearchOption.TopDirectoryOnly);
                var build            = new ApplicationBuild(configuration, logProvider, pluginAssemblies, installedPackages);
                build.GenerateApplication();
            }
            else
            {
                logger.Info("Skipped deleting old generated files (DeployDatabaseOnly).");
                logger.Info("Skipped download packages (DeployDatabaseOnly).");
                logger.Info("Skipped code generators (DeployDatabaseOnly).");
            }
        }
Ejemplo n.º 7
0
        public void SqlUtilityWorksCorrectly()
        {
            var configuration = new ConfigurationBuilder(new ConsoleLogProvider())
                                .AddConfigurationManagerConfiguration()
                                .Build();

            LegacyUtilities.Initialize(configuration);

            Assert.AreEqual("MsSql", SqlUtility.DatabaseLanguage);
            Assert.IsFalse(string.IsNullOrEmpty(SqlUtility.ConnectionString));
            Assert.AreEqual(31, SqlUtility.SqlCommandTimeout);
        }
Ejemplo n.º 8
0
        public IConfiguration GetRuntimeConfiguration()
        {
            string rhetosAppRootPath   = AppDomain.CurrentDomain.BaseDirectory;
            string currentAssemblyPath = GetType().Assembly.Location;
            var    allOtherAssemblies  = Directory.GetFiles(Path.GetDirectoryName(currentAssemblyPath), "*.dll")
                                         .Except(new[] { currentAssemblyPath })
                                         .Select(path => Path.GetFileName(path))
                                         .ToList();

            // Simulating common run-time configuration of application with DeployPackages.

            var configuration = new ConfigurationBuilder(new ConsoleLogProvider())
                                .AddOptions(new RhetosAppEnvironment
            {
                ApplicationRootFolder = rhetosAppRootPath
            })
                                .AddOptions(new RhetosAppOptions
            {
                RhetosRuntimePath = currentAssemblyPath,
            })
                                .AddOptions(new PluginScannerOptions
            {
                // Ignore other MEF plugins from assemblies that might get bundled in the same testing output folder.
                IgnoreAssemblyFiles = allOtherAssemblies
            })
                                .AddOptions(new LegacyPathsOptions
            {
                BinFolder       = Path.Combine(rhetosAppRootPath, "bin"),
                PluginsFolder   = Path.Combine(rhetosAppRootPath, "bin", "Plugins"),
                ResourcesFolder = Path.Combine(rhetosAppRootPath, "Resources"),
            })
                                .AddWebConfiguration(rhetosAppRootPath)
                                .AddConfigurationManagerConfiguration()
                                .Build();

            LegacyUtilities.Initialize(configuration);

            return(configuration);
        }
Ejemplo n.º 9
0
        internal static int Run(string[] args)
        {
            string errorMessage = null;

            try
            {
                var host          = Host.Find(AppDomain.CurrentDomain.BaseDirectory, new ConsoleLogProvider());
                var configuration = host.RhetosRuntime.BuildConfiguration(new ConsoleLogProvider(), host.ConfigurationFolder,
                                                                          configurationBuilder => configurationBuilder.AddConfigurationManagerConfiguration());
                LegacyUtilities.Initialize(configuration);

                CreateMembershipProviderTables();
            }
            catch (ApplicationException ex)
            {
                errorMessage = "CANCELED: " + ex.Message;
            }
            catch (Exception ex)
            {
                errorMessage = "ERROR: " + ex;
            }

            if (errorMessage != null)
            {
                Console.WriteLine();
                Console.WriteLine(errorMessage);
                if (!args.Any(arg => arg.Equals("/nopause")))
                {
                    Console.WriteLine();
                    Console.Write("Press any key to continue . . .");
                    Console.ReadKey(true);
                }
                return(1);
            }

            Console.WriteLine("ASP.NET membership tables created.");
            return(0);
        }
Ejemplo n.º 10
0
        public IConfiguration GetBuildConfiguration()
        {
            string rhetosAppRootPath = AppDomain.CurrentDomain.BaseDirectory;

            // This code is mostly copied from DeployPackages build-time configuration.

            var configuration = new ConfigurationBuilder(new ConsoleLogProvider())
                                .AddOptions(new RhetosBuildEnvironment
            {
                ProjectFolder         = rhetosAppRootPath,
                OutputAssemblyName    = null,
                CacheFolder           = Path.Combine(rhetosAppRootPath, "GeneratedFilesCache"),
                GeneratedAssetsFolder = Path.Combine(rhetosAppRootPath),     // Custom for testing
                GeneratedSourceFolder = null,
            })
                                .AddOptions(new LegacyPathsOptions
            {
                BinFolder       = Path.Combine(rhetosAppRootPath, "bin"),
                PluginsFolder   = Path.Combine(rhetosAppRootPath, "bin", "Plugins"),
                ResourcesFolder = Path.Combine(rhetosAppRootPath, "Resources"),
            })
                                .AddOptions(new LegacyPathsOptions
            {
                BinFolder       = Path.Combine(rhetosAppRootPath, "bin"),
                PluginsFolder   = Path.Combine(rhetosAppRootPath, "bin", "Plugins"),
                ResourcesFolder = Path.Combine(rhetosAppRootPath, "Resources"),
            })
                                .AddKeyValue($"{OptionsAttribute.GetConfigurationPath<BuildOptions>()}:{nameof(BuildOptions.GenerateAppSettings)}", false)
                                .AddKeyValue($"{OptionsAttribute.GetConfigurationPath<BuildOptions>()}:{nameof(BuildOptions.BuildResourcesFolder)}", true)
                                .AddWebConfiguration(rhetosAppRootPath)
                                .AddConfigurationManagerConfiguration()
                                .Build();

            LegacyUtilities.Initialize(configuration);

            return(configuration);
        }