Ejemplo n.º 1
0
        /// <summary>
        /// Starts a newly created project from the web API project template with a given set of <paramref name="projectOptions"/>.
        /// </summary>
        /// <param name="projectOptions">The project options to control the functionality of the to-be-created project from this template.</param>
        /// <param name="outputWriter">The output logger to add telemetry information during the creation and startup process.</param>
        /// <returns>
        ///     A web API project with a full set of endpoint services to interact with the API.
        /// </returns>
        public static async Task <WebApiProject> StartNewAsync(WebApiProjectOptions projectOptions, ITestOutputHelper outputWriter)
        {
            Guard.NotNull(projectOptions, nameof(projectOptions), "Cannot create a web API project without a set of project argument options");
            Guard.NotNull(outputWriter, nameof(outputWriter), "Cannot create web API services without a test output logger");

            return(await StartNewAsync(TestConfig.Create(), projectOptions, outputWriter));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a project from the web API project template with a given set of <paramref name="projectOptions"/>.
        /// </summary>
        /// <param name="configuration">The configuration to control the hosting of the to-be-created project.</param>
        /// <param name="projectOptions">The project options to control the functionality of the to-be-created project from this template.</param>
        /// <param name="outputWriter">The output logger to add telemetry information during the creation and startup process.</param>
        /// <returns>
        ///     A not yet started web API project with a full set of endpoint services to interact with the API.
        /// </returns>
        /// <remarks>
        ///     Before the project can be interacted with, the project must be started by calling the <see cref="StartAsync" /> method.
        /// </remarks>
        public static WebApiProject CreateNew(TestConfig configuration, WebApiProjectOptions projectOptions, ITestOutputHelper outputWriter)
        {
            Guard.NotNull(configuration, nameof(configuration), "Cannot create a web API project from the template without a test configuration");
            Guard.NotNull(projectOptions, nameof(projectOptions), "Cannot create a web API project without a set of project argument options");
            Guard.NotNull(outputWriter, nameof(outputWriter), "Cannot create web API services without a test output logger");

            DirectoryInfo templateDirectory = configuration.GetWebApiProjectDirectory();
            DirectoryInfo fixtureDirectory  = configuration.GetFixtureProjectDirectory();
            Uri           baseUrl           = configuration.CreateWebApiBaseUrl();
            var           project           = new WebApiProject(baseUrl, configuration, templateDirectory, fixtureDirectory, outputWriter);

            project.CreateNewProject(projectOptions);

            return(project);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a project from the web API project template with a given set of <paramref name="projectOptions"/>.
        /// </summary>
        /// <param name="configuration">The configuration to control the hosting of the to-be-created project.</param>
        /// <param name="projectOptions">The project options to control the functionality of the to-be-created project from this template.</param>
        /// <param name="outputWriter">The output logger to add telemetry information during the creation and startup process.</param>
        /// <returns>
        ///     A not yet started web API project with a full set of endpoint services to interact with the API.
        /// </returns>
        /// <remarks>
        ///     Before the project can be interacted with, the project must be started by calling the <see cref="StartAsync" /> method.
        /// </remarks>
        public static WebApiProject CreateNew(TestConfig configuration, WebApiProjectOptions projectOptions, ITestOutputHelper outputWriter)
        {
            Guard.NotNull(configuration, nameof(configuration), "Cannot create a web API project from the template without a test configuration");
            Guard.NotNull(projectOptions, nameof(projectOptions), "Cannot create a web API project without a set of project argument options");
            Guard.NotNull(outputWriter, nameof(outputWriter), "Cannot create web API services without a test output logger");

            DirectoryInfo templateDirectory = configuration.GetWebApiProjectDirectory();
            DirectoryInfo fixtureDirectory  = configuration.GetFixtureProjectDirectory();
            Uri           baseUrl           = configuration.GenerateRandomLocalhostUrl();
            var           project           = new WebApiProject(baseUrl, configuration, templateDirectory, fixtureDirectory, outputWriter);

            project.CreateNewProject(projectOptions);
            project.UpdateFileInProject("Program.cs", contents => project.RemovesUserErrorsFromContents(contents));

            return(project);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Starts a newly created project from the web API project template with a given set of <paramref name="projectOptions"/>.
        /// </summary>
        /// <param name="configuration">The configuration to control the hosting of the to-be-created project.</param>
        /// <param name="projectOptions">The project options to control the functionality of the to-be-created project from this template.</param>
        /// <param name="outputWriter">The output logger to add telemetry information during the creation and startup process.</param>
        /// <returns>
        ///     A web API project with a full set of endpoint services to interact with the API.
        /// </returns>
        public static async Task <WebApiProject> StartNewAsync(TestConfig configuration, WebApiProjectOptions projectOptions, ITestOutputHelper outputWriter)
        {
            Guard.NotNull(configuration, nameof(configuration), "Cannot create a web API project from the template without a test configuration");
            Guard.NotNull(projectOptions, nameof(projectOptions), "Cannot create a web API project without a set of project argument options");
            Guard.NotNull(outputWriter, nameof(outputWriter), "Cannot create web API services without a test output logger");

            WebApiProject project = CreateNew(configuration, projectOptions, outputWriter);
            await project.StartAsync();

            return(project);
        }