RadioDialogTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Scenes.Tests.Controls RadioDialogTests

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 RadioDialogTests : TestWithMocksOrVisually

The RadioDialogTests type exposes the following members.

Constructors

  NameDescription
Public methodRadioDialogTests
Initializes a new instance of the RadioDialogTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodClickingDisabledRadioButtonDoesNotCauseTheOthersToUnselect
Public methodClickingOneRadioButtonCausesTheOthersToUnselect
Public methodClickingRadioButtonDoesNotSelectItIfDisabled
Public methodClickingRadioButtonSelectsIt
Public methodDisablingDialogDisablesAllButtons
Public methodDrawLoadedRadioDialog
Public methodDrawLoadedRadioDialogAttachedToMouse
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodReEnableDialogEnablesAllButtons
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Public methodRenderGrowingRadioDialog
Public methodRenderRadioDialogAttachedToMouse
Public methodRenderRadioDialogWithThreeButtonsWithTheMiddleDisabled
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]
public void RenderRadioDialogWithThreeButtonsWithTheMiddleDisabled()
{
    var buttons = dialog.Get<List<RadioButton>>();
    buttons[1].IsEnabled = false;
    AdvanceTimeAndUpdateEntities();
    Assert.AreEqual(Color.Gray, buttons[0].Color);
    Assert.AreEqual(Color.DarkGray, buttons[1].Color);
}
[Test]
public void RenderGrowingRadioDialog()
{
    dialog.Start<Grow>();
    dialog.Start<SetText>();
}
[Test, CloseAfterFirstFrame]
public void ClickingRadioButtonSelectsIt()
{
    if (mouse == null)
        return; // ncrunch: no coverage 
    var buttons = dialog.Get<List<RadioButton>>();
    Assert.IsFalse(buttons[1].State.IsSelected);
    PressAndReleaseMouse(Vector2D.One);
    Assert.IsFalse(buttons[1].State.IsSelected);
    PressAndReleaseMouse(new Vector2D(0.35f, 0.5f));
    Assert.IsTrue(buttons[1].State.IsSelected);
}
[Test, CloseAfterFirstFrame]
public void ClickingOneRadioButtonCausesTheOthersToUnselect()
{
    if (mouse == null)
        return; //ncrunch: no coverage 
    var buttons = dialog.Get<List<RadioButton>>();
    PressAndReleaseMouse(new Vector2D(0.35f, 0.5f));
    Assert.IsTrue(buttons[1].State.IsSelected);
    PressAndReleaseMouse(new Vector2D(0.35f, 0.6f));
    Assert.IsFalse(buttons[1].State.IsSelected);
    Assert.IsTrue(buttons[2].State.IsSelected);
}
[Test, CloseAfterFirstFrame]
public void ClickingRadioButtonDoesNotSelectItIfDisabled()
{
    var buttons = dialog.Get<List<RadioButton>>();
    buttons[1].IsEnabled = false;
    PressAndReleaseMouse(new Vector2D(0.35f, 0.5f));
    Assert.IsFalse(buttons[1].State.IsSelected);
}
[Test, CloseAfterFirstFrame]
public void ClickingDisabledRadioButtonDoesNotCauseTheOthersToUnselect()
{
    if (mouse == null)
        return; //ncrunch: no coverage 
    var buttons = dialog.Get<List<RadioButton>>();
    buttons[2].IsEnabled = false;
    PressAndReleaseMouse(new Vector2D(0.35f, 0.5f));
    PressAndReleaseMouse(new Vector2D(0.35f, 0.6f));
    Assert.IsTrue(buttons[1].State.IsSelected);
    Assert.IsFalse(buttons[2].State.IsSelected);
}
[Test, CloseAfterFirstFrame]
public void DisablingDialogDisablesAllButtons()
{
    dialog.IsEnabled = false;
    var buttons = dialog.Get<List<RadioButton>>();
    foreach (RadioButton button in buttons)
        Assert.IsFalse(button.IsEnabled);
}
[Test, CloseAfterFirstFrame]
public void ReEnableDialogEnablesAllButtons()
{
    dialog.IsEnabled = false;
    dialog.IsEnabled = true;
    var buttons = dialog.Get<List<RadioButton>>();
    foreach (RadioButton button in buttons)
        Assert.IsTrue(button.IsEnabled);
}
[Test]
public void RenderRadioDialogAttachedToMouse()
{
    new Command(point => dialog.DrawArea = Rectangle.FromCenter(point, dialog.DrawArea.Size)).
        Add(new MouseMovementTrigger());
}
[Test, CloseAfterFirstFrame]
public void SaveAndLoad()
{
    var stream = BinaryDataExtensions.SaveToMemoryStream(dialog);
    var loadedDialog = (RadioDialog)stream.CreateFromMemoryStream();
    Assert.AreEqual(3, loadedDialog.Buttons.Count);
    Assert.AreEqual(dialog.Buttons[1].DrawArea, loadedDialog.Buttons[1].DrawArea);
    Assert.AreEqual(dialog.Buttons[1].Text, loadedDialog.Buttons[1].Text);
}
[Test]
public void DrawLoadedRadioDialog()
{
    var stream = BinaryDataExtensions.SaveToMemoryStream(dialog);
    dialog.IsActive = false;
    stream.CreateFromMemoryStream();
}
[Test]
public void DrawLoadedRadioDialogAttachedToMouse()
{
    var stream = BinaryDataExtensions.SaveToMemoryStream(dialog);
    dialog.IsActive = false;
    var loadedDialog = (RadioDialog)stream.CreateFromMemoryStream();
    new Command(point => loadedDialog.DrawArea = Rectangle.FromCenter(point,
        loadedDialog.DrawArea.Size)).Add(new MouseMovementTrigger());
}
See Also