RazorClassLibraryTemplateTest.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. using System.Threading.Tasks;
  4. using Microsoft.AspNetCore.Testing;
  5. using Templates.Test.Helpers;
  6. using Xunit;
  7. using Xunit.Abstractions;
  8. namespace Templates.Test;
  9. public class RazorClassLibraryTemplateTest : LoggedTest
  10. {
  11. public RazorClassLibraryTemplateTest(ProjectFactoryFixture projectFactory)
  12. {
  13. ProjectFactory = projectFactory;
  14. }
  15. public ProjectFactoryFixture ProjectFactory { get; }
  16. private ITestOutputHelper _output;
  17. public ITestOutputHelper Output
  18. {
  19. get
  20. {
  21. if (_output == null)
  22. {
  23. _output = new TestOutputLogger(Logger);
  24. }
  25. return _output;
  26. }
  27. }
  28. [Fact]
  29. public async Task RazorClassLibraryTemplate_WithViews_Async()
  30. {
  31. var project = await ProjectFactory.CreateProject(Output);
  32. var createResult = await project.RunDotNetNewAsync("razorclasslib", args: new[] { "--support-pages-and-views", "true" });
  33. Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult));
  34. var publishResult = await project.RunDotNetPublishAsync();
  35. Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult));
  36. // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
  37. // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
  38. // later, while the opposite is not true.
  39. var buildResult = await project.RunDotNetBuildAsync();
  40. Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult));
  41. }
  42. [ConditionalFact]
  43. [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/28090", Queues = HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)]
  44. public async Task RazorClassLibraryTemplateAsync()
  45. {
  46. var project = await ProjectFactory.CreateProject(Output);
  47. var createResult = await project.RunDotNetNewAsync("razorclasslib");
  48. Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult));
  49. var publishResult = await project.RunDotNetPublishAsync();
  50. Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult));
  51. // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
  52. // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build
  53. // later, while the opposite is not true.
  54. var buildResult = await project.RunDotNetBuildAsync();
  55. Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult));
  56. }
  57. }