Skip to content

Commit

Permalink
test: add reflection test for internal API
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Jan 7, 2025
1 parent eec85f3 commit 44baf5a
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Assets/Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Tests/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Assets/Tests/Editor/Coffee.UIEffect.EditorTests.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Coffee.UIEffect.EditorTests",
"references": [
"Coffee.UIEffect"
],
"optionalUnityReferences": [
"TestAssemblies"
],
"includePlatforms": [
"Editor"
]
}
7 changes: 7 additions & 0 deletions Assets/Tests/Editor/Coffee.UIEffect.EditorTests.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions Assets/Tests/Editor/ReflectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Reflection;
using NUnit.Framework;
using UnityEditor;

public class ReflectionTests
{
[Test]
public void ShaderVariantCollectionInspector_DrawShaderEntry()
{
var type = Type.GetType("UnityEditor.ShaderVariantCollectionInspector, UnityEditor");
Assert.IsNotNull(type, "'UnityEditor.ShaderVariantCollectionInspector, UnityEditor' is not found");

var miDrawShaderEntry = type.GetMethod("DrawShaderEntry", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.IsNotNull(miDrawShaderEntry);

var parameters = miDrawShaderEntry.GetParameters();
Assert.AreEqual(1, parameters.Length);
Assert.AreEqual(typeof(int), parameters[0].ParameterType);
}

[Test]
public void SerializedProperty_gradientValue()
{
var piGradient = typeof(SerializedProperty)
.GetProperty("gradientValue", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
Assert.IsNotNull(piGradient);

Assert.IsTrue(piGradient.CanRead);
Assert.IsTrue(piGradient.CanWrite);
}
}
11 changes: 11 additions & 0 deletions Assets/Tests/Editor/ReflectionTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 44baf5a

Please sign in to comment.