Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Scenes.Tests.Controls DropdownListTests
Namespace: DeltaEngine.Scenes.Tests.Controls
Assembly: DeltaEngine.Scenes.Tests (in DeltaEngine.Scenes.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The DropdownListTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
DropdownListTests | Initializes a new instance of the DropdownListTests class |
Methods
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test] public void RenderDropdownListWithTenValues() { SetToTenValues(); }
[Test, CloseAfterFirstFrame] public void DefaultProperties() { Assert.AreEqual(Values, dropdownList.Values); Assert.AreEqual(Values[0], dropdownList.SelectedValue); Assert.AreEqual(Center, dropdownList.DrawArea); Assert.AreEqual(Color.Gray, dropdownList.Color); Assert.AreEqual(3, dropdownList.SelectBox.texts.Count); Assert.IsFalse(dropdownList.IsPauseable); Assert.AreEqual(3, dropdownList.MaxDisplayCount); }
[Test, CloseAfterFirstFrame] public void NoValuesThrowsException() { Assert.Throws<SelectBox.MustBeAtLeastOneValue>(() => new DropdownList(Rectangle.Zero, null)); Assert.Throws<SelectBox.MustBeAtLeastOneValue>( () => new DropdownList(Rectangle.Zero, new List<object>())); }
[Test, CloseAfterFirstFrame] public void IfValuesAreChangedButStillContainSelectedValueItRemainsSelected() { var newValues = new List<object> { 1, "value 1", 2 }; dropdownList.Values = newValues; Assert.AreEqual(newValues, dropdownList.Values); Assert.AreEqual("value 1", dropdownList.SelectedValue); Assert.AreEqual(3, dropdownList.SelectBox.texts.Count); }
[Test, CloseAfterFirstFrame] public void IfValuesAreChangedAndNoLongerContainSelectedValueItRevertsToFirstValue() { var newValues = new List<object> { 1, 2 }; dropdownList.Values = newValues; Assert.AreEqual(1, dropdownList.SelectedValue); Assert.AreEqual(2, dropdownList.SelectBox.texts.Count); }
[Test, CloseAfterFirstFrame] public void IfSelectedValueIsChangedToSomethingInValuesThatIsOk() { dropdownList.SelectedValue = "value 3"; Assert.AreEqual("value 3", dropdownList.SelectedValue); }
[Test, CloseAfterFirstFrame] public void IfSelectedValueIsChangedToSomethingNotInValuesItThrowsAnException() { Assert.Throws<DropdownList.SelectedValueMustBeOneOfTheListOfValues>( () => dropdownList.SelectedValue = "value 4"); }
[Test, CloseAfterFirstFrame] public void HidingDropdownListHidesEverything() { dropdownList.IsVisible = false; Assert.IsFalse(dropdownList.SelectBox.IsVisible); Assert.IsFalse(dropdownList.Get<FontText>().IsVisible); foreach (FontText text in dropdownList.SelectBox.texts) Assert.IsFalse(text.IsVisible); }
[Test, CloseAfterFirstFrame] public void ClickingRevealsValues() { if (mouse == null) return; //ncrunch: no coverage Click(new Vector2D(0.5f, 0.31f)); Assert.IsTrue(dropdownList.SelectBox.IsVisible); }
[Test, CloseAfterFirstFrame] public void ClickToRevealValuesThenClickToSelectNewValueAndHideValues() { if (mouse == null) return; //ncrunch: no coverage Click(new Vector2D(0.5f, 0.31f)); Click(new Vector2D(0.5f, 0.41f)); Assert.AreEqual("value 2", dropdownList.SelectedValue); Assert.IsFalse(dropdownList.SelectBox.IsVisible); }
[Test, CloseAfterFirstFrame] public void HideSelectBoxAndThenClickOnSelectBoxLine() { if (mouse == null) return; //ncrunch: no coverage dropdownList.SelectBox.IsVisible = false; dropdownList.SelectBox.LineClicked(0); Assert.IsFalse(dropdownList.SelectBox.IsVisible); }
[Test, CloseAfterFirstFrame] public void ClickingHiddenSelectionBoxDoesNothing() { if (mouse == null) return; //ncrunch: no coverage Click(new Vector2D(0.5f, 0.41f)); Assert.AreEqual("value 1", dropdownList.SelectedValue); }
[Test, CloseAfterFirstFrame] public void ClickToRevealValuesThenMouseoverToChangeValueColor() { if (mouse == null) return; //ncrunch: no coverage Click(new Vector2D(0.5f, 0.31f)); MoveMouse(new Vector2D(0.5f, 0.41f)); Assert.AreEqual(Color.VeryLightGray, dropdownList.SelectBox.texts[0].Color); Assert.AreEqual(Color.White, dropdownList.SelectBox.texts[1].Color); Assert.AreEqual(Color.VeryLightGray, dropdownList.SelectBox.texts[2].Color); }
[Test, CloseAfterFirstFrame] public void WhenDisabledSelectionBoxIsHidden() { if (mouse == null) return; //ncrunch: no coverage Click(new Vector2D(0.5f, 0.31f)); dropdownList.IsEnabled = false; Assert.IsFalse(dropdownList.SelectBox.IsVisible); foreach (FontText text in dropdownList.SelectBox.texts) Assert.IsFalse(text.IsVisible); }
[Test] public void RenderGrowingDropdownList() { dropdownList.Values = new List<object> { "value 1", "value 2", "value 3", "value 4" }; dropdownList.Start<Grow>(); }
[Test] public void RenderDropdownListAttachedToMouse() { dropdownList.Values = new List<object> { "value 1", "value 2", "value 3", "value 4" }; new Command( point => dropdownList.DrawArea = //ncrunch: no coverage Rectangle.FromCenter(point, dropdownList.DrawArea.Size)).Add(new MouseMovementTrigger()); }
[Test, CloseAfterFirstFrame] public void ChangeMaxDisplayCount() { dropdownList.MaxDisplayCount = 4; Assert.AreEqual(4, dropdownList.MaxDisplayCount); }
[Test, CloseAfterFirstFrame] public void SaveAndLoad() { var stream = BinaryDataExtensions.SaveToMemoryStream(dropdownList); var loadedDropdownList = (DropdownList)stream.CreateFromMemoryStream(); Assert.AreEqual(dropdownList.DrawArea, loadedDropdownList.DrawArea); Assert.AreEqual(3, loadedDropdownList.Values.Count); Assert.AreEqual(dropdownList.Values[1].ToString(), loadedDropdownList.Values[1].ToString()); }
[Test] public void DrawLoadedSelectBox() { SetToTenValues(); var stream = BinaryDataExtensions.SaveToMemoryStream(dropdownList); dropdownList.IsActive = false; stream.CreateFromMemoryStream(); }
See Also