Ingen beskrivning
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.

NamespaceTests.cs 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Reflection;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using NUnit.Framework;
  5. using UnityEngine;
  6. using UnityEditor.Graphing;
  7. using UnityEditor.ShaderGraph.Internal;
  8. namespace UnityEditor.ShaderGraph.UnitTests
  9. {
  10. [TestFixture]
  11. internal class NamespaceTests
  12. {
  13. [Test]
  14. public void NoDanglingNamespaces()
  15. {
  16. var myAssembly = Assembly.GetAssembly(typeof(AbstractMaterialNode));
  17. HashSet<string> namespaces = new HashSet<string>();
  18. foreach (var theType in myAssembly.GetTypes().Where(t => !string.IsNullOrEmpty(t.Namespace)))
  19. {
  20. namespaces.Add(theType.Namespace);
  21. }
  22. var invalidNames = new List<string>();
  23. foreach (var name in namespaces)
  24. {
  25. if (name.Contains("ShaderGraph"))
  26. continue;
  27. if (name.Contains("UnityEditor"))
  28. continue;
  29. if (name.Contains("UnityEngine"))
  30. continue;
  31. invalidNames.Add(name);
  32. }
  33. Assert.IsEmpty(invalidNames, "The following namespaces are invalid for the Shader Graph package:\n" + string.Join("\n", invalidNames));
  34. }
  35. }
  36. }