Use HttpClient from Fixture instrad of creating a new one per test
This commit is contained in:
parent
0e54281e8b
commit
755957b694
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
|
|
@ -40,13 +39,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
using (var deployer = Fixture.CreateDeployment(flavor))
|
||||
{
|
||||
var deploymentResult = deployer.Deploy();
|
||||
var httpClient = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri)
|
||||
};
|
||||
|
||||
// Act
|
||||
var response = await httpClient.GetStringWithRetryAsync("Manage/Home", Fixture.Logger);
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
deploymentResult.ApplicationBaseUri + "Manage/Home",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationConsumingPrecompiledViews.Manage.Home.Index.txt", response);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Xunit;
|
||||
|
|
@ -37,13 +35,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
using (var deployer = Fixture.CreateDeployment(flavor))
|
||||
{
|
||||
var deploymentResult = deployer.Deploy();
|
||||
var httpClient = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri)
|
||||
};
|
||||
|
||||
// Act
|
||||
var response = await httpClient.GetStringWithRetryAsync("", Fixture.Logger);
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
deploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationWithConfigureMvc.Home.Index.txt", response);
|
||||
|
|
@ -58,13 +54,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
using (var deployer = Fixture.CreateDeployment(flavor))
|
||||
{
|
||||
var deploymentResult = deployer.Deploy();
|
||||
var httpClient = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri)
|
||||
};
|
||||
|
||||
// Act
|
||||
var response = await httpClient.GetStringWithRetryAsync("Home/ViewWithPreprocessor", Fixture.Logger);
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
deploymentResult.ApplicationBaseUri + "Home/ViewWithPreprocessor",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent(
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Xunit;
|
||||
|
|
@ -44,13 +42,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
using (var deployer = Fixture.CreateDeployment(flavor))
|
||||
{
|
||||
var deploymentResult = deployer.Deploy();
|
||||
var httpClient = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri)
|
||||
};
|
||||
|
||||
// Act
|
||||
var response = await httpClient.GetStringWithRetryAsync($"Home/{url}", Fixture.Logger);
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
$"{deploymentResult.ApplicationBaseUri}Home/{url}",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.{url}.txt", response);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Xunit;
|
||||
|
|
@ -36,13 +34,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
using (var deployer = Fixture.CreateDeployment(flavor))
|
||||
{
|
||||
var deploymentResult = deployer.Deploy();
|
||||
var httpClient = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri)
|
||||
};
|
||||
|
||||
// Act
|
||||
var response = await httpClient.GetStringWithRetryAsync("", Fixture.Logger);
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
deploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("SimpleAppTest.Home.Index.txt", response);
|
||||
|
|
|
|||
Loading…
Reference in New Issue