Example #1
0
        public static void AddStartupEnvironmentsWithServices(
            string solutionDirectory,
            string projectName,
            string dbName,
            List <ApiEnvironment> environments,
            SwaggerConfig swaggerConfig,
            int port,
            bool useJwtAuth,
            string projectBaseName,
            IFileSystem fileSystem)
        {
            AppSettingsBuilder.CreateWebApiAppSettings(solutionDirectory, dbName, projectBaseName);

            if (environments.Where(e => e.EnvironmentName == "Development").Count() == 0)
            {
                environments.Add(new ApiEnvironment {
                    EnvironmentName = "Development", ProfileName = $"{projectName} (Development)"
                });
            }

            foreach (var env in environments)
            {
                WebApiLaunchSettingsModifier.AddProfile(solutionDirectory, env, port, projectBaseName);
            }
            if (!swaggerConfig.IsSameOrEqualTo(new SwaggerConfig()))
            {
                SwaggerBuilder.RegisterSwaggerInStartup(solutionDirectory, projectBaseName);
            }
        }
Example #2
0
        public static void AddStartupEnvironmentsWithServices(
            string solutionDirectory,
            string solutionName,
            string dbName,
            List <ApiEnvironment> environments,
            SwaggerConfig swaggerConfig,
            int port,
            bool useJwtAuth,
            string projectBaseName = "")
        {
            // add a development environment by default for local work if none exists
            if (environments.Where(e => e.EnvironmentName == "Development").Count() == 0)
            {
                environments.Add(new ApiEnvironment {
                    EnvironmentName = "Development", ProfileName = $"{solutionName} (Development)"
                });
            }

            if (environments.Where(e => e.EnvironmentName == "Production").Count() == 0)
            {
                environments.Add(new ApiEnvironment {
                    EnvironmentName = "Production", ProfileName = $"{solutionName} (Production)"
                });
            }

            var sortedEnvironments = environments.OrderBy(e => e.EnvironmentName == "Development" ? 1 : 0).ToList(); // sets dev as default profile

            foreach (var env in sortedEnvironments)
            {
                // default startup is already built in cleanup phase
                if (env.EnvironmentName != "Production")
                {
                    StartupBuilder.CreateWebApiStartup(solutionDirectory, env.EnvironmentName, useJwtAuth, projectBaseName);
                }

                WebApiAppSettingsBuilder.CreateAppSettings(solutionDirectory, env, dbName, projectBaseName);
                WebApiLaunchSettingsModifier.AddProfile(solutionDirectory, env, port, projectBaseName);

                //services
                if (!swaggerConfig.IsSameOrEqualTo(new SwaggerConfig()))
                {
                    SwaggerBuilder.RegisterSwaggerInStartup(solutionDirectory, env, projectBaseName);
                }
            }

            // add an integration testing env to make sure that an in memory database is used
            var functionalEnv = new ApiEnvironment()
            {
                EnvironmentName = "FunctionalTesting"
            };

            WebApiAppSettingsBuilder.CreateAppSettings(solutionDirectory, functionalEnv, "", projectBaseName);
        }