SW-Wiktor-Bombola/SW-Unity/Library/PackageCache/com.unity.ugui@1.0.0/Tests/Runtime/Slider/SliderTests.cs
2021-12-04 15:15:29 +01:00

41 lines
1007 B
C#

using NUnit.Framework;
using UnityEngine.UI;
using UnityEngine;
[Category("Slider")]
public class SliderTests
{
private Slider slider;
private GameObject emptyGO;
[SetUp]
public void Setup()
{
var rootChildGO = new GameObject("root child");
rootChildGO.AddComponent<Canvas>();
var sliderGameObject = new GameObject("Slider");
slider = sliderGameObject.AddComponent<Slider>();
emptyGO = new GameObject("base", typeof(RectTransform));
sliderGameObject.transform.SetParent(rootChildGO.transform);
emptyGO.transform.SetParent(sliderGameObject.transform);
}
[Test]
public void SetSliderValueWithoutNotifyWillNotNotify()
{
slider.value = 0;
bool calledOnValueChanged = false;
slider.onValueChanged.AddListener(f => { calledOnValueChanged = true; });
slider.SetValueWithoutNotify(1);
Assert.IsTrue(slider.value == 1);
Assert.IsFalse(calledOnValueChanged);
}
}