public DropdownEventListener(DropdownEx dd) { _dd = dd; _dd.onItemDeselected.AddListener(onItemDeselected); _dd.onItemSelected.AddListener(onItemSelected); _dd.onValueChanged.AddListener(onValueChanged); }
public IEnumerator CheckDefaults() { yield return(LoadTestScene()); Dropdown = GameObject.FindObjectOfType <DropdownEx>(); Assert.IsNotNull(Dropdown, "Expected to find DropdownEx instance"); Assert.IsTrue(Dropdown.options.Count == 3, "Expected 3 options after setup"); Assert.IsTrue(Dropdown.SelectedCount == 1, "Expected one option selected after setup"); Assert.IsFalse(Dropdown.AllowMultiSelect, "Expected multiple selections off by default"); var count = 0; foreach (var opt in Dropdown.SelectedOptions) { count++; } Assert.IsTrue(count == 1, "Expected one option selected by default"); Assert.IsTrue(Dropdown.value == 0, "Expected value to be zero by default"); for (int i = 0; i < Dropdown.options.Count; i++) { Assert.AreEqual("Option " + (i + 1).ToString(), Dropdown.options[i].text, "Unexpected option text: " + Dropdown.options[i].text); if (0 == i) { Assert.IsTrue(Dropdown.options[i].selected, "Expected first option selected"); } else { Assert.IsFalse(Dropdown.options[i].selected, string.Format("Expected all but first option deselected by default but option index {0} was selected", i)); } } }