您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

57 行
2.2 KiB

using System.Linq;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.UnitTests
{
[TestFixture]
public class PropertyGeneratorTests
{
[TestFixtureSetUp]
public void RunBeforeAnyTests()
{
Debug.unityLogger.logHandler = new ConsoleLogHandler();
}
private const string kPropertyName = "ThePropertyName";
private const string kPropertyDescription = "ThePropertyDescription";
[Test]
public void TestCanAddPropertyChunkToPropertyGenerator()
{
var chunk = new FloatPropertyChunk(kPropertyName, kPropertyDescription, 0.5f, PropertyChunk.HideState.Visible);
var generator = new PropertyGenerator();
generator.AddShaderProperty(chunk);
Assert.AreNotEqual(string.Empty, generator.GetShaderString(0));
}
[Test]
public void TestCanGetShaderStringWithIndentWorks()
{
var chunk = new FloatPropertyChunk(kPropertyName, kPropertyDescription, 0.5f, PropertyChunk.HideState.Visible);
var generator = new PropertyGenerator();
generator.AddShaderProperty(chunk);
Assert.AreEqual(0, generator.GetShaderString(0).Count(x => x == '\t'));
Assert.AreEqual(1, generator.GetShaderString(1).Count(x => x == '\t'));
Assert.AreEqual(2, generator.GetShaderString(2).Count(x => x == '\t'));
}
[Test]
public void TestCanGetConfiguredTextureInfos()
{
var chunk = new TexturePropertyChunk(kPropertyName, kPropertyDescription, null, TextureType.Bump, PropertyChunk.HideState.Visible, TexturePropertyChunk.ModifiableState.Modifiable);
var generator = new PropertyGenerator();
generator.AddShaderProperty(chunk);
var infos = generator.GetConfiguredTexutres();
Assert.AreEqual(1, infos.Count);
Assert.AreEqual(kPropertyName, infos[0].name);
Assert.AreEqual(0, infos[0].textureId);
Assert.AreEqual(TexturePropertyChunk.ModifiableState.Modifiable, infos[0].modifiable);
}
}
}