public async Task RestoreBuildTestRun_HealthCheckFalse_SuccessfulAsync()
        {
            await InstallTemplateAsync().ConfigureAwait(false);

            using (var tempDirectory = TempDirectory.NewTempDirectory())
            {
                var project = await tempDirectory
                              .DotnetNewAsync(
                    TemplateName,
                    "GraphQLTHealthCheckFalse",
                    DefaultArguments.ToArguments(new string[] { "health-check=false" }))
                              .ConfigureAwait(false);

                await project.DotnetRestoreAsync().ConfigureAwait(false);

                await project.DotnetBuildAsync().ConfigureAwait(false);

                await project.DotnetTestAsync().ConfigureAwait(false);

                await project
                .DotnetRunAsync(
                    Path.Join("Source", "GraphQLTHealthCheckFalse"),
                    ReadinessCheck.FaviconAsync,
                    async (httpClient, httpsClient) =>
                {
                    var statusResponse = await httpsClient
                                         .GetAsync(new Uri("status", UriKind.Relative))
                                         .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.NotFound, statusResponse.StatusCode);

                    var statusSelfResponse = await httpsClient
                                             .GetAsync(new Uri("status/self", UriKind.Relative))
                                             .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.NotFound, statusSelfResponse.StatusCode);
                })
                .ConfigureAwait(false);
            }
        }
示例#2
0
        public async Task RestoreBuildTest_NuGetDefaults_SuccessfulAsync(string name, params string[] arguments)
        {
            await InstallTemplateAsync().ConfigureAwait(false);

            using (var tempDirectory = TempDirectory.NewTempDirectory())
            {
                var dictionary = arguments
                                 .Select(x => x.Split('=', StringSplitOptions.RemoveEmptyEntries))
                                 .ToDictionary(x => x.First(), x => x.Last());
                var project = await tempDirectory.DotnetNewAsync(TemplateName, name, dictionary).ConfigureAwait(false);

                await project.DotnetRestoreAsync().ConfigureAwait(false);

                await project.DotnetBuildAsync().ConfigureAwait(false);

                if (!arguments.Contains("dotnet-framework=true") ||
                    (arguments.Contains("dotnet-framework=true") && Environment.OSVersion.Platform == PlatformID.Win32NT))
                {
                    // There seems to be a bug that stops xUnit working on Mono.
                    await project.DotnetTestAsync().ConfigureAwait(false);
                }
            }
        }
示例#3
0
        public async Task Run_Default_Successful()
        {
            using (var tempDirectory = TempDirectory.NewTempDirectory())
            {
                var project = await tempDirectory.DotnetNew("graphql", "Default");

                await project.DotnetRestore();

                await project.DotnetBuild();

                await project.DotnetRun(
                    @"Source\Default",
                    async (httpClient, httpsClient) =>
                {
                    var httpResponse = await httpClient.GetAsync("/");
                    Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);

                    var httpsResponse = await httpsClient.GetAsync("/");
                    Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);

                    var statusResponse = await httpsClient.GetAsync("status");
                    Assert.Equal(HttpStatusCode.OK, statusResponse.StatusCode);

                    var statusSelfResponse = await httpsClient.GetAsync("status/self");
                    Assert.Equal(HttpStatusCode.OK, statusSelfResponse.StatusCode);

                    var robotsTxtResponse = await httpsClient.GetAsync("robots.txt");
                    Assert.Equal(HttpStatusCode.OK, robotsTxtResponse.StatusCode);

                    var securityTxtResponse = await httpsClient.GetAsync(".well-known/security.txt");
                    Assert.Equal(HttpStatusCode.OK, securityTxtResponse.StatusCode);

                    var humansTxtResponse = await httpsClient.GetAsync("humans.txt");
                    Assert.Equal(HttpStatusCode.OK, humansTxtResponse.StatusCode);
                });
            }
        }
        public async Task RestoreBuildTestRun_AuthorizationFalse_DateOfBirthReturnedSuccessfullyAsync()
        {
            await InstallTemplateAsync().ConfigureAwait(false);

            using (var tempDirectory = TempDirectory.NewTempDirectory())
            {
                var project = await tempDirectory
                              .DotnetNewAsync(
                    TemplateName,
                    "GraphQLTAuthorizationFalse",
                    new Dictionary <string, string>()
                {
                    { "authorization", "false" },
                })
                              .ConfigureAwait(false);

                await project.DotnetRestoreAsync().ConfigureAwait(false);

                await project.DotnetBuildAsync().ConfigureAwait(false);

                await project.DotnetTestAsync().ConfigureAwait(false);

                await project
                .DotnetRunAsync(
                    @"Source\GraphQLTAuthorizationFalse",
                    ReadinessCheck.StatusSelfAsync,
                    async (httpClient, httpsClient) =>
                {
                    var httpResponse = await httpsClient
                                       .PostGraphQLAsync(
                        "query getHuman { human(id: \"94fbd693-2027-4804-bf40-ed427fe76fda\") { dateOfBirth } }")
                                       .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
                })
                .ConfigureAwait(false);
            }
        }
示例#5
0
        public async Task RestoreBuildTestRun_DockerFalse_SuccessfulAsync()
        {
            await InstallTemplateAsync().ConfigureAwait(false);

            using (var tempDirectory = TempDirectory.NewTempDirectory())
            {
                var project = await tempDirectory
                              .DotnetNewAsync(
                    TemplateName,
                    "ApiDockerFalse",
                    new Dictionary <string, string>()
                {
                    { "docker", "false" },
                })
                              .ConfigureAwait(false);

                await project.DotnetRestoreAsync().ConfigureAwait(false);

                await project.DotnetBuildAsync().ConfigureAwait(false);

                await project.DotnetTestAsync().ConfigureAwait(false);

                await project.DotnetToolRestoreAsync().ConfigureAwait(false);

                await project.DotnetCakeAsync(timeout : TimeSpan.FromMinutes(3)).ConfigureAwait(false);

                var files = new DirectoryInfo(project.DirectoryPath).GetFiles("*.*", SearchOption.AllDirectories);

                Assert.DoesNotContain(files, x => x.Name == ".dockerignore");
                Assert.DoesNotContain(files, x => x.Name == "Dockerfile");

                var cake = await File.ReadAllTextAsync(files.Single(x => x.Name == "build.cake").FullName).ConfigureAwait(false);

                Assert.DoesNotContain(cake, "Docker", StringComparison.Ordinal);
            }
        }
示例#6
0
        public async Task RestoreBuildTestRun_SwaggerFalse_SuccessfulAsync()
        {
            await InstallTemplateAsync().ConfigureAwait(false);

            using (var tempDirectory = TempDirectory.NewTempDirectory())
            {
                var project = await tempDirectory
                              .DotnetNewAsync(
                    TemplateName,
                    "ApiSwaggerFalse",
                    new Dictionary <string, string>()
                {
                    { "swagger", "false" },
                })
                              .ConfigureAwait(false);

                await project.DotnetRestoreAsync().ConfigureAwait(false);

                await project.DotnetBuildAsync().ConfigureAwait(false);

                await project.DotnetTestAsync().ConfigureAwait(false);

                await project
                .DotnetRunAsync(
                    @"Source\ApiSwaggerFalse",
                    ReadinessCheck.StatusSelfAsync,
                    async (httpClient, httpsClient) =>
                {
                    var swaggerJsonResponse = await httpsClient
                                              .GetAsync(new Uri("swagger/v1/swagger.json", UriKind.Relative))
                                              .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.NotFound, swaggerJsonResponse.StatusCode);
                })
                .ConfigureAwait(false);
            }
        }
示例#7
0
        public async Task Run_ApiDefaults_SuccessfulAsync()
        {
            await InstallTemplateAsync().ConfigureAwait(false);

            using (var tempDirectory = TempDirectory.NewTempDirectory())
            {
                var project = await tempDirectory.DotnetNewAsync("api", "ApiDefaults").ConfigureAwait(false);

                await project.DotnetRestoreAsync().ConfigureAwait(false);

                await project.DotnetBuildAsync().ConfigureAwait(false);

                await project
                .DotnetRunAsync(
                    @"Source\ApiDefaults",
                    ReadinessCheck.StatusSelfAsync,
                    async (httpClient, httpsClient) =>
                {
                    var httpResponse = await httpClient
                                       .GetAsync(new Uri("status", UriKind.Relative))
                                       .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);

                    var statusResponse = await httpsClient
                                         .GetAsync(new Uri("status", UriKind.Relative))
                                         .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.OK, statusResponse.StatusCode);
                    Assert.Equal(ContentType.Text, statusResponse.Content.Headers.ContentType.MediaType);

                    var statusSelfResponse = await httpsClient
                                             .GetAsync(new Uri("status/self", UriKind.Relative))
                                             .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.OK, statusSelfResponse.StatusCode);
                    Assert.Equal(ContentType.Text, statusSelfResponse.Content.Headers.ContentType.MediaType);

                    var carsResponse = await httpsClient
                                       .GetAsync(new Uri("cars", UriKind.Relative))
                                       .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.OK, carsResponse.StatusCode);
                    Assert.Equal(ContentType.RestfulJson, carsResponse.Content.Headers.ContentType.MediaType);

                    var postCarResponse = await httpsClient
                                          .PostAsJsonAsync(new Uri("cars", UriKind.Relative), new SaveCar())
                                          .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.BadRequest, postCarResponse.StatusCode);
                    Assert.Equal(ContentType.ProblemJson, postCarResponse.Content.Headers.ContentType.MediaType);

                    var notAcceptableCarsRequest = new HttpRequestMessage(
                        HttpMethod.Get,
                        new Uri("cars", UriKind.Relative));
                    notAcceptableCarsRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(ContentType.Text));
                    var notAcceptableCarsResponse = await httpsClient
                                                    .SendAsync(notAcceptableCarsRequest)
                                                    .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.NotAcceptable, notAcceptableCarsResponse.StatusCode);

                    var swaggerJsonResponse = await httpsClient
                                              .GetAsync(new Uri("swagger/v1/swagger.json", UriKind.Relative))
                                              .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.OK, swaggerJsonResponse.StatusCode);
                    Assert.Equal(ContentType.Json, swaggerJsonResponse.Content.Headers.ContentType.MediaType);

                    var robotsTxtResponse = await httpsClient
                                            .GetAsync(new Uri("robots.txt", UriKind.Relative))
                                            .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.OK, robotsTxtResponse.StatusCode);
                    Assert.Equal(ContentType.Text, robotsTxtResponse.Content.Headers.ContentType.MediaType);

                    var securityTxtResponse = await httpsClient
                                              .GetAsync(new Uri(".well-known/security.txt", UriKind.Relative))
                                              .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.OK, securityTxtResponse.StatusCode);
                    Assert.Equal(ContentType.Text, securityTxtResponse.Content.Headers.ContentType.MediaType);

                    var humansTxtResponse = await httpsClient
                                            .GetAsync(new Uri("humans.txt", UriKind.Relative))
                                            .ConfigureAwait(false);
                    Assert.Equal(HttpStatusCode.OK, humansTxtResponse.StatusCode);
                    Assert.Equal(ContentType.Text, humansTxtResponse.Content.Headers.ContentType.MediaType);
                },
                    timeout : TimeSpan.FromMinutes(2))
                .ConfigureAwait(false);
            }
        }