BuildWithComponentsIntegrationTest.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.Runtime.CompilerServices;
  4. namespace Microsoft.NET.Sdk.Razor.Tests
  5. {
  6. public class BuildWithComponentsIntegrationTest : AspNetSdkTest
  7. {
  8. public BuildWithComponentsIntegrationTest(ITestOutputHelper log) : base(log) { }
  9. [CoreMSBuildOnlyFact]
  10. public void Build_Components_WithDotNetCoreMSBuild_Works() => Build_ComponentsWorks();
  11. [RequiresMSBuildVersionFact("17.10.0.8101")]
  12. public void Build_Components_WithDesktopMSBuild_Works() => Build_ComponentsWorks();
  13. [Fact]
  14. public void Building_NetstandardComponentLibrary()
  15. {
  16. var testAsset = "RazorComponentLibrary";
  17. var projectDirectory = CreateAspNetSdkTestAsset(testAsset);
  18. // Build
  19. var build = new BuildCommand(projectDirectory);
  20. build.Execute().Should().Pass();
  21. string outputPath = build.GetOutputDirectory("netstandard2.0").ToString();
  22. new FileInfo(Path.Combine(outputPath, "ComponentLibrary.dll")).Should().Exist();
  23. new FileInfo(Path.Combine(outputPath, "ComponentLibrary.pdb")).Should().Exist();
  24. new FileInfo(Path.Combine(outputPath, "ComponentLibrary.Views.dll")).Should().NotExist();
  25. new FileInfo(Path.Combine(outputPath, "ComponentLibrary.Views.pdb")).Should().NotExist();
  26. }
  27. private void Build_ComponentsWorks([CallerMemberName] string callerName = "")
  28. {
  29. var testAsset = "RazorMvcWithComponents";
  30. var projectDirectory = CreateAspNetSdkTestAsset(testAsset, callerName);
  31. var build = new BuildCommand(projectDirectory);
  32. build.Execute().Should().Pass();
  33. string outputPath = build.GetOutputDirectory(DefaultTfm).ToString();
  34. new FileInfo(Path.Combine(outputPath, "MvcWithComponents.dll")).Should().Exist();
  35. new FileInfo(Path.Combine(outputPath, "MvcWithComponents.pdb")).Should().Exist();
  36. new FileInfo(Path.Combine(outputPath, "MvcWithComponents.Views.dll")).Should().NotExist();
  37. new FileInfo(Path.Combine(outputPath, "MvcWithComponents.Views.pdb")).Should().NotExist();
  38. new FileInfo(Path.Combine(outputPath, "MvcWithComponents.dll")).AssemblyShould().ContainType("MvcWithComponents.TestComponent");
  39. new FileInfo(Path.Combine(outputPath, "MvcWithComponents.dll")).AssemblyShould().ContainType("MvcWithComponents.Views.Shared.NavMenu");
  40. // Components should appear in the app assembly.
  41. new FileInfo(Path.Combine(outputPath, "MvcWithComponents.dll")).AssemblyShould().ContainType("MvcWithComponents.Components.Counter");
  42. // Views should also appear in the app assembly.
  43. new FileInfo(Path.Combine(outputPath, "MvcWithComponents.dll")).AssemblyShould().ContainType("AspNetCoreGeneratedDocument.Views_Home_Index");
  44. }
  45. }
  46. }