Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DocumentationTests.cs 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Net;
  4. using System.Text;
  5. using NUnit.Framework;
  6. using UnityEditor;
  7. using UnityEngine;
  8. using UnityEngine.Rendering.Universal;
  9. namespace Documentation
  10. {
  11. // https://jira.unity3d.com/browse/URP-1990
  12. // class DocumentationTests
  13. // {
  14. // private bool TestURL(string url)
  15. // {
  16. // try
  17. // {
  18. // HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
  19. // // Timeout set to 10 seconds
  20. // request.Timeout = 10000;
  21. // // Only get header information
  22. // request.Method = "HEAD";
  23. // using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
  24. // {
  25. // int statusCode = (int)response.StatusCode;
  26. // // Successful requests
  27. // if (statusCode >= 100 && statusCode < 400)
  28. // return true;
  29. // // Server Errors
  30. // if (statusCode >= 500 && statusCode <= 510)
  31. // return false;
  32. // }
  33. // }
  34. // catch
  35. // {
  36. // // ignored
  37. // }
  38. // return false;
  39. // }
  40. // [Test]
  41. // public void TestURPHelpURLAttributes()
  42. // {
  43. // // Start with checking a bad URL to make sure TestURL() works.
  44. // string badURL = "https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@16.0/manual/incorrect-url";
  45. // bool badURLResults = TestURL(badURL);
  46. // Assert.IsFalse(badURLResults, "TestURL() failed. A broken URL should have been detected.");
  47. // // Find everything that uses URPHelpURLAttribute
  48. // TypeCache.TypeCollection typesWithHelpUrls = TypeCache.GetTypesWithAttribute<URPHelpURLAttribute>();
  49. // // Check if all the URLs are valid.
  50. // bool allURLsAreValid = true;
  51. // StringBuilder failures = new ();
  52. // foreach (Type type in typesWithHelpUrls)
  53. // {
  54. // Debug.Log("Checking \"" + type.FullName + "\"");
  55. // object[] attributes = type.GetCustomAttributes(typeof(URPHelpURLAttribute), false);
  56. // for (int i = 0; i < attributes.Length; i++)
  57. // {
  58. // URPHelpURLAttribute attribute = attributes[i] as URPHelpURLAttribute;
  59. // Assert.IsNotNull(attribute);
  60. // string url = attribute.URL;
  61. // bool urlIsValid = TestURL(url);
  62. // Debug.Log("\t" + url);
  63. // Debug.Log(urlIsValid ? "\tSuccess!\n" : "\tFailure!\n");
  64. // if (urlIsValid)
  65. // continue;
  66. // allURLsAreValid = false;
  67. // failures.AppendLine("\t" + type.FullName);
  68. // failures.AppendLine("\t" + url);
  69. // failures.AppendLine();
  70. // }
  71. // }
  72. // if (!allURLsAreValid)
  73. // Assert.Fail("The following URLs failed:\n" + failures);
  74. // }
  75. // }
  76. }