NodeSystemTests.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections.Immutable;
  2. using System.Reflection;
  3. using ChunkyImageLib.DataHolders;
  4. using PixiEditor.ChangeableDocument.Changeables.Animations;
  5. using PixiEditor.ChangeableDocument.Changeables.Graph;
  6. using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
  7. using PixiEditor.ChangeableDocument.Changeables.Interfaces;
  8. using PixiEditor.ChangeableDocument.Changes.NodeGraph;
  9. using PixiEditor.ChangeableDocument.Rendering;
  10. using PixiEditor.DrawingApi.Core.Bridge;
  11. using PixiEditor.DrawingApi.Skia;
  12. using PixiEditor.Numerics;
  13. namespace PixiEditor.Backend.Tests;
  14. public class NodeSystemTests
  15. {
  16. public NodeSystemTests()
  17. {
  18. DrawingBackendApi.SetupBackend(new SkiaDrawingBackend());
  19. }
  20. [Fact]
  21. public void TestThatNodeGraphExecutesEmptyOutputNode()
  22. {
  23. NodeGraph graph = new NodeGraph();
  24. OutputNode outputNode = new OutputNode();
  25. graph.AddNode(outputNode);
  26. using RenderingContext context = new RenderingContext(0, VecI.Zero, ChunkResolution.Full, new VecI(1, 1));
  27. graph.Execute(context);
  28. Assert.Null(outputNode.CachedResult);
  29. }
  30. [Fact]
  31. public void TestThatCreateSimpleNodeDoesntThrow()
  32. {
  33. var allNodeTypes = typeof(Node).Assembly.GetTypes()
  34. .Where(x => x.IsAssignableTo(typeof(Node)) && x is { IsAbstract: false, IsInterface: false }).ToList();
  35. IReadOnlyDocument target = new MockDocument();
  36. foreach (var type in allNodeTypes)
  37. {
  38. if(type.GetCustomAttribute<PairNodeAttribute>() != null) continue;
  39. var node = NodeOperations.CreateNode(type, target);
  40. Assert.NotNull(node);
  41. }
  42. }
  43. }