浏览代码

[material graph] add tests for node configuration.

/main
Tim Cooper 8 年前
当前提交
df47a2ff
共有 2 个文件被更改,包括 50 次插入12 次删除
  1. 38
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Testing/UnitTests/SerializedGraphTests.cs
  2. 24
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/NodeUtils.cs

38
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Testing/UnitTests/SerializedGraphTests.cs


}
[Test]
public void TestExceptionIfBadNodeConfigurationWorks()
{
var node = new TestableNode();
Assert.DoesNotThrow(
() =>
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(
node,
new[] {TestableNode.Input0, TestableNode.Input1, TestableNode.Input2},
new[] {TestableNode.Output0, TestableNode.Output1, TestableNode.Output2,})
);
Assert.Throws<SlotConfigurationException>(
() =>
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(
node,
new[] {666, TestableNode.Input1, TestableNode.Input2},
new[] {TestableNode.Output0, TestableNode.Output1, TestableNode.Output2,})
);
Assert.Throws<SlotConfigurationException>(
() =>
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(
node,
new[] {TestableNode.Input0, TestableNode.Input1, TestableNode.Input2},
new[] {666, TestableNode.Output1, TestableNode.Output2,})
);
Assert.DoesNotThrow(
() =>
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(
node,
new[] {TestableNode.Input0},
new[] {TestableNode.Output0})
);
}
[Test]
public void TestConectionToSameInputReplacesOldInput()
{
var graph = new SerializableGraph();

24
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/NodeUtils.cs


namespace UnityEngine.Graphing
{
public static class NodeUtils
public class SlotConfigurationException : Exception
public class SlotConfigurationException : Exception
{
public SlotConfigurationException()
{ }
public SlotConfigurationException()
{ }
public SlotConfigurationException(string message)
: base(message)
{}
public SlotConfigurationException(string message)
: base(message)
{ }
public SlotConfigurationException(string message, Exception inner)
: base(message, inner)
{}
}
public SlotConfigurationException(string message, Exception inner)
: base(message, inner)
{ }
}
public static class NodeUtils
{
public static void SlotConfigurationExceptionIfBadConfiguration(INode node, IEnumerable<int> expectedInputSlots, IEnumerable<int> expectedOutputSlots )
{
var missingSlots = new List<int>();

正在加载...
取消
保存