浏览代码

added edit-mode test

/main
Steven Leal 4 年前
当前提交
ad891f00
共有 2 个文件被更改,包括 52 次插入0 次删除
  1. 49
      com.unity.perception/Tests/Editor/RandomizerEditorTests.cs
  2. 3
      com.unity.perception/Tests/Editor/RandomizerEditorTests.cs.meta

49
com.unity.perception/Tests/Editor/RandomizerEditorTests.cs


using NUnit.Framework;
using UnityEngine;
using UnityEngine.Experimental.Perception.Randomization.Randomizers;
using UnityEngine.Experimental.Perception.Randomization.Scenarios;
namespace EditorTests
{
[TestFixture]
public class RandomizerEditorTests
{
GameObject m_TestObject;
FixedLengthScenario m_Scenario;
[SetUp]
public void Setup()
{
m_TestObject = new GameObject();
m_Scenario = m_TestObject.AddComponent<FixedLengthScenario>();
}
[TearDown]
public void TearDown()
{
Object.DestroyImmediate(m_TestObject);
}
[Test]
public void RandomizerOnCreateMethodNotCalledInEditMode()
{
// TestRandomizer.OnCreate() should NOT be called here while in edit-mode
// if ScenarioBase.CreateRandomizer<>() was coded correctly
Assert.DoesNotThrow(() =>
{
m_Scenario.CreateRandomizer<ErrorsOnCreateTestRandomizer>();
});
}
}
[AddRandomizerMenu("Test Randomizers/Errors OnCreate Test Randomizer")]
class ErrorsOnCreateTestRandomizer : Randomizer
{
public GameObject testGameObject;
protected override void OnCreate()
{
testGameObject.transform.position = Vector3.zero;
}
}
}

3
com.unity.perception/Tests/Editor/RandomizerEditorTests.cs.meta


fileFormatVersion: 2
guid: 26d4a82fa0c640349e6d89fe1c536b72
timeCreated: 1610137610
正在加载...
取消
保存