StaticWebAssetsGeneratePackagePropsFileTest.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 Microsoft.AspNetCore.StaticWebAssets.Tasks;
  4. using Microsoft.Build.Framework;
  5. using Moq;
  6. namespace Microsoft.AspNetCore.Razor.Tasks
  7. {
  8. public class StaticWebAssetsGeneratePackagePropsFileTest
  9. {
  10. [Fact]
  11. public void WritesPropsFile_WithProvidedImportPath()
  12. {
  13. // Arrange
  14. var file = Path.GetTempFileName();
  15. var expectedDocument = @"<Project>
  16. <Import Project=""Microsoft.AspNetCore.StaticWebAssets.props"" />
  17. </Project>";
  18. try
  19. {
  20. var buildEngine = new Mock<IBuildEngine>();
  21. var task = new StaticWebAssetsGeneratePackagePropsFile
  22. {
  23. BuildEngine = buildEngine.Object,
  24. PropsFileImport = "Microsoft.AspNetCore.StaticWebAssets.props",
  25. BuildTargetPath = file
  26. };
  27. // Act
  28. var result = task.Execute();
  29. // Assert
  30. result.Should().Be(true);
  31. var document = File.ReadAllText(file);
  32. document.Should().Contain(expectedDocument);
  33. }
  34. finally
  35. {
  36. if (File.Exists(file))
  37. {
  38. File.Delete(file);
  39. }
  40. }
  41. }
  42. }
  43. }