Helpers.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System;
  4. using System.IO;
  5. using Microsoft.AspNetCore.Server.IntegrationTesting;
  6. namespace ServerComparison.FunctionalTests
  7. {
  8. public class Helpers
  9. {
  10. public static string GetApplicationPath()
  11. {
  12. var applicationBasePath = AppContext.BaseDirectory;
  13. var directoryInfo = new DirectoryInfo(applicationBasePath);
  14. do
  15. {
  16. var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, "FunctionalTests.sln"));
  17. if (solutionFileInfo.Exists)
  18. {
  19. return Path.GetFullPath(Path.Combine(directoryInfo.FullName, "testassets", "ServerComparison.TestSites"));
  20. }
  21. directoryInfo = directoryInfo.Parent;
  22. }
  23. while (directoryInfo.Parent != null);
  24. throw new Exception($"Solution root could not be found using {applicationBasePath}");
  25. }
  26. public static string GetNginxConfigContent(string nginxConfig)
  27. {
  28. var applicationBasePath = AppContext.BaseDirectory;
  29. var content = File.ReadAllText(Path.Combine(applicationBasePath, nginxConfig));
  30. return content;
  31. }
  32. }
  33. }