Begin E2E testing for HostedInAspNet sample
This commit is contained in:
parent
4138b3a049
commit
4c15a74d14
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace HostedInAspNet.Server
|
||||
{
|
||||
|
|
@ -15,6 +16,9 @@ namespace HostedInAspNet.Server
|
|||
|
||||
public static IWebHost BuildWebHost(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseConfiguration(new ConfigurationBuilder()
|
||||
.AddCommandLine(args)
|
||||
.Build())
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
// 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.
|
||||
|
||||
namespace Microsoft.Blazor.E2ETest.Infrastructure.ServerFixtures
|
||||
{
|
||||
public enum AspNetEnvironment
|
||||
{
|
||||
Development,
|
||||
Production
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,8 @@ namespace Microsoft.Blazor.E2ETest.Infrastructure.ServerFixtures
|
|||
|
||||
public BuildWebHost BuildWebHostMethod { get; set; }
|
||||
|
||||
public AspNetEnvironment Environment { get; set; } = AspNetEnvironment.Production;
|
||||
|
||||
protected override IWebHost CreateWebHost()
|
||||
{
|
||||
if (BuildWebHostMethod == null)
|
||||
|
|
@ -29,7 +31,8 @@ namespace Microsoft.Blazor.E2ETest.Infrastructure.ServerFixtures
|
|||
return BuildWebHostMethod(new[]
|
||||
{
|
||||
"--urls", "http://127.0.0.1:0",
|
||||
"--contentroot", sampleSitePath
|
||||
"--contentroot", sampleSitePath,
|
||||
"--environment", Environment.ToString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\samples\BlazorStandalone\BlazorStandalone.csproj" />
|
||||
<ProjectReference Include="..\..\samples\HostedInAspNet.Server\HostedInAspNet.Server.csproj" />
|
||||
<ProjectReference Include="..\..\samples\MonoSanity\MonoSanity.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.Blazor.DevHost\Microsoft.Blazor.DevHost.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
// 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 Microsoft.Blazor.E2ETest.Infrastructure;
|
||||
using Microsoft.Blazor.E2ETest.Infrastructure.ServerFixtures;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Blazor.E2ETest.Tests
|
||||
{
|
||||
public class HostedInAspNetTest : ServerTestBase<AspNetSiteServerFixture>
|
||||
{
|
||||
public HostedInAspNetTest(BrowserFixture browserFixture, AspNetSiteServerFixture serverFixture)
|
||||
: base(browserFixture, serverFixture)
|
||||
{
|
||||
serverFixture.BuildWebHostMethod = HostedInAspNet.Server.Program.BuildWebHost;
|
||||
serverFixture.Environment = AspNetEnvironment.Development;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HasTitle()
|
||||
{
|
||||
Navigate("/", noReload: true);
|
||||
Assert.Equal("Sample Blazor app", Browser.Title);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue