64 lines
2.9 KiB
C#
64 lines
2.9 KiB
C#
// 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.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Testing;
|
|
using Templates.Test.Helpers;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Templates.Test
|
|
{
|
|
public class RazorClassLibraryTemplateTest
|
|
{
|
|
public RazorClassLibraryTemplateTest(ProjectFactoryFixture projectFactory, ITestOutputHelper output)
|
|
{
|
|
ProjectFactory = projectFactory;
|
|
Output = output;
|
|
}
|
|
|
|
public Project Project { get; set; }
|
|
|
|
public ProjectFactoryFixture ProjectFactory { get; }
|
|
public ITestOutputHelper Output { get; }
|
|
|
|
[Fact]
|
|
public async Task RazorClassLibraryTemplate_WithViews_Async()
|
|
{
|
|
Project = await ProjectFactory.GetOrCreateProject("razorclasslibwithviews", Output);
|
|
|
|
var createResult = await Project.RunDotNetNewAsync("razorclasslib", args: new[] { "--support-pages-and-views", "true" });
|
|
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", Project, createResult));
|
|
|
|
var publishResult = await Project.RunDotNetPublishAsync();
|
|
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));
|
|
|
|
// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
|
|
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
|
|
// later, while the opposite is not true.
|
|
|
|
var buildResult = await Project.RunDotNetBuildAsync();
|
|
Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", Project, buildResult));
|
|
}
|
|
|
|
[Fact]
|
|
public async Task RazorClassLibraryTemplateAsync()
|
|
{
|
|
Project = await ProjectFactory.GetOrCreateProject("razorclasslib", Output);
|
|
|
|
var createResult = await Project.RunDotNetNewAsync("razorclasslib");
|
|
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", Project, createResult));
|
|
|
|
var publishResult = await Project.RunDotNetPublishAsync();
|
|
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));
|
|
|
|
// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
|
|
// The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
|
|
// later, while the opposite is not true.
|
|
|
|
var buildResult = await Project.RunDotNetBuildAsync();
|
|
Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", Project, buildResult));
|
|
}
|
|
}
|
|
}
|