InteractiveButtonTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  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

public class InteractiveButtonTests : TestWithMocksOrVisually

The InteractiveButtonTests type exposes the following members.

Constructors

  NameDescription
Public methodInteractiveButtonTests
Initializes a new instance of the InteractiveButtonTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodBeginningClickDoesNothingIfDisabled
Public methodBeginningClickMakesItShrink
Public methodDefaultsToEnabled
Public methodDrawLoadedButton
Public methodEnteringMakesItGrow
Public methodExitingMakesItNormalize
Public methodFinishingClickMakesItGrow
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodLoadWithoutBinaryDataExtensions
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Public methodRenderDisabledInteractiveButton
Public methodRenderInteractiveButton
Public methodRenderInteractiveButtonAttachedToMouse
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodSaveAndLoad
Public methodSetUp
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
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