Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Scenes.Tests.Controls InteractiveButtonTests
Namespace: DeltaEngine.Scenes.Tests.Controls
Assembly: DeltaEngine.Scenes.Tests (in DeltaEngine.Scenes.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The InteractiveButtonTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
InteractiveButtonTests | Initializes a new instance of the InteractiveButtonTests class |
Methods
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test, ApproveFirstFrameScreenshot] public void RenderDisabledInteractiveButton() { button.IsEnabled = false; }
[Test, CloseAfterFirstFrame] public void DefaultsToEnabled() { Assert.IsTrue(button.IsEnabled); }
[Test, CloseAfterFirstFrame] public void BeginningClickMakesItShrink() { if (mouse == null) return; //ncrunch: no coverage SetMouseState(State.Pressing, Vector2D.Half); Assert.IsTrue(button.Size.Width < BaseSize.Width); }
[Test, CloseAfterFirstFrame] public void FinishingClickMakesItGrow() { if (mouse == null) return; //ncrunch: no coverage SetMouseState(State.Pressing, Vector2D.Half); SetMouseState(State.Releasing, Vector2D.Half); Assert.IsTrue(button.Size.Width > BaseSize.Width); }
[Test, CloseAfterFirstFrame] public void EnteringMakesItGrow() { if (mouse == null) return; //ncrunch: no coverage SetMouseState(State.Released, Vector2D.Half); Assert.IsTrue(button.Size.Width > BaseSize.Width); }
[Test, CloseAfterFirstFrame] public void ExitingMakesItNormalize() { SetMouseState(State.Released, Vector2D.Half); SetMouseState(State.Released, new Vector2D(0.0f, 0.22f)); Assert.AreEqual(BaseSize.Width, button.Size.Width, 0.05f); Assert.AreEqual(BaseSize.Height, button.Size.Height, 0.05f); }
[Test, CloseAfterFirstFrame] public void BeginningClickDoesNothingIfDisabled() { button.IsEnabled = false; SetMouseState(State.Pressing, Vector2D.Half); Assert.AreEqual(BaseSize.Width, button.Size.Width, 0.05f); }
[Test] public void RenderInteractiveButtonAttachedToMouse() { new Command(point => button.DrawArea = Rectangle.FromCenter(point, button.DrawArea.Size)). Add(new MouseMovementTrigger()); }
[Test] public void DrawLoadedButton() { button.Text = "Original"; var stream = BinaryDataExtensions.SaveToMemoryStream(button); var loadedButton = (InteractiveButton)stream.CreateFromMemoryStream(); loadedButton.Text = "Loaded"; loadedButton.DrawArea = loadedButton.DrawArea.Move(0.0f, 0.15f); }
[Test, CloseAfterFirstFrame, Ignore] //ncrunch: no coverage start public void SaveAndLoad() { var stream = BinaryDataExtensions.SaveToMemoryStream(button); var loadedButton = (InteractiveButton)stream.CreateFromMemoryStream(); Assert.AreEqual(Center, loadedButton.DrawArea); Assert.AreEqual("Click Me", loadedButton.Text); }
[Test, CloseAfterFirstFrame, Ignore] public void LoadWithoutBinaryDataExtensions() { var stream = BinaryDataExtensions.SaveToMemoryStream(button); button.Text = "Original"; var loadedButton = new InteractiveButton(); loadedButton.LoadFromStream(stream); Assert.AreEqual(Center, loadedButton.DrawArea); Assert.AreEqual("Click Me", loadedButton.Text); loadedButton.DrawArea = loadedButton.DrawArea.Move(new Vector2D(0.0f, 0.2f)); }
See Also