浏览代码

[Material Graph] Fix tests.

/main
Tim Cooper 8 年前
当前提交
f17d4796
共有 3 个文件被更改,包括 9 次插入28 次删除
  1. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/AbstractMaterialGraphTests.cs
  2. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialGraphTests.cs
  3. 28
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PixelShaderNodeTests.cs

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/AbstractMaterialGraphTests.cs


}
[Test]
public void TestCanAddOnePixelShaderNode()
public void TestCanAddMultipleMasterNode()
{
var graph = new PixelGraph();
Assert.AreEqual(0, graph.GetNodes<AbstractMaterialNode>().Count());

Assert.AreEqual(0, graph.edges.Count());
Assert.AreEqual(1, graph.GetNodes<AbstractMaterialNode>().Count());
var psn2 = new MetallicMasterNode();
var psn2 = new SpecularMasterNode();
Assert.AreEqual(1, graph.GetNodes<AbstractMaterialNode>().Count());
Assert.AreEqual(2, graph.GetNodes<AbstractMaterialNode>().Count());
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialGraphTests.cs


graph.PostCreate();
Assert.AreEqual(1, graph.currentGraph.GetNodes<AbstractMaterialNode>().Count());
Assert.IsInstanceOf(typeof(MetallicMasterNode), graph.currentGraph.GetNodes<AbstractMaterialNode>().FirstOrDefault());
Assert.AreEqual(0, graph.currentGraph.GetNodes<AbstractMaterialNode>().Count());
}
}
}

28
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PixelShaderNodeTests.cs


private AbsoluteNode m_Abs;
private MetallicMasterNode m_PixelNode;
//TODO: Do not check in
/*
[TestFixtureSetUp]
public void RunBeforeAnyTests()
{

public void TestSetUp()
{
m_Graph = new PixelGraph();
m_PixelNode = new MetallicMasterNode();
m_Graph.AddNode(m_PixelNode);
m_Graph.AddNode(m_InputOne);
m_Graph.AddNode(m_PixelNode);
m_Graph.AddNode(m_Abs);

m_Graph.Connect(m_InputOne.GetSlotReference(Vector1Node.OutputSlotId), m_PixelNode.GetSlotReference(BaseLightFunction.NormalSlotId));
m_Graph.Connect(m_InputOne.GetSlotReference(Vector1Node.OutputSlotId), m_PixelNode.GetSlotReference(AbstractSurfaceMasterNode.NormalSlotId));
m_Graph.Connect(m_Abs.GetSlotReference(Function1Input.OutputSlotId), m_PixelNode.GetSlotReference(PBRMetalicLightFunction.AlbedoSlotId));
}
[Test]
public void TestNodeGeneratesLightFuntionProperly()
{
var generator = new ShaderGenerator();
m_PixelNode.GenerateLightFunction(generator);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
Assert.AreEqual(PBRMetalicLightFunction.LightFunctionName, generator.GetPragmaString());
m_Graph.Connect(m_Abs.GetSlotReference(Function1Input.OutputSlotId), m_PixelNode.GetSlotReference(AbstractSurfaceMasterNode.AlbedoSlotId));
}
[Test]

m_PixelNode.GenerateSurfaceOutput(generator);
Assert.AreEqual(string.Empty, generator.GetShaderString(0));
Assert.AreEqual(PBRMetalicLightFunction.SurfaceOutputStructureName, generator.GetPragmaString());
Assert.AreEqual(MetallicMasterNode.SurfaceOutputStructureName, generator.GetPragmaString());
}
[Test]

Assert.AreEqual(expected, generator.GetShaderString(0));
Assert.AreEqual(string.Empty, generator.GetPragmaString());
}
[Test]
public void TestPixelShaderNodeReturnsBuiltinPBRLights()
{
var lightingFuncs = PixelShaderNode.GetLightFunctions();
Assert.AreEqual(1, lightingFuncs.OfType<PBRMetalicLightFunction>().Count());
Assert.AreEqual(1, lightingFuncs.OfType<PBRSpecularLightFunction>().Count());
}*/
}
}
正在加载...
取消
保存