SelectBoxTests ClassDelta Engine Documentation
Inheritance Hierarchy

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

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

The SelectBoxTests type exposes the following members.

Constructors

  NameDescription
Public methodSelectBoxTests
Initializes a new instance of the SelectBoxTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodDrawLoadedSelectBox
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Public methodRenderGrowingSelectBox
Public methodRenderSelectBoxAttachedToMouse
Public methodRenderSelectBoxWithTenValuesAndThreeLines
Public methodRenderSelectBoxWithThreeValuesAndThreeLines
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodSaveAndLoad
Public methodSetUp
Public methodSetValuesAsNull
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void RenderSelectBoxWithThreeValuesAndThreeLines()
{
    var text = new FontText(Font.Default, "", new Rectangle(0.4f, 0.7f, 0.2f, 0.1f));
    selectBox.LineClicked += lineNo => text.Text = selectBox.Values[lineNo] + " clicked";
}
[Test]
public void RenderSelectBoxWithTenValuesAndThreeLines()
{
    SetToTenValues();
    var text = new FontText(Font.Default, "", new Rectangle(0.4f, 0.7f, 0.2f, 0.1f));
    selectBox.LineClicked += lineNo => text.Text = selectBox.Values[lineNo] + " clicked";
}
[Test]
public void RenderSelectBoxAttachedToMouse()
{
    selectBox.Values = new List<object> { "value 1", "value 2", "value 3", "value 4" };
    new Command(
        point => selectBox.DrawArea = Rectangle.FromCenter(point, selectBox.DrawArea.Size)).Add(
            new MouseMovementTrigger());
}
[Test]
public void SetValuesAsNull()
{            
    Assert.Throws<SelectBox.MustBeAtLeastOneValue>(() => selectBox.Values = null);
}
[Test]
public void RenderGrowingSelectBox()
{
    selectBox.Values = new List<object> { "value 1", "value 2", "value 3", "value 4" };
    selectBox.Start<Grow>();
    var text = new FontText(Font.Default, "", new Rectangle(0.4f, 0.7f, 0.2f, 0.1f));
    selectBox.LineClicked += lineNo => text.Text = selectBox.Values[lineNo] + " clicked";
}
[Test, CloseAfterFirstFrame]
public void SaveAndLoad()
{
    var stream = BinaryDataExtensions.SaveToMemoryStream(selectBox);
    var loadedSelectBox = (SelectBox)stream.CreateFromMemoryStream();
    Assert.AreEqual(selectBox.DrawArea, loadedSelectBox.DrawArea);
    Assert.AreEqual(3, loadedSelectBox.Values.Count);
    Assert.AreEqual(selectBox.Values[1].ToString(), loadedSelectBox.Values[1].ToString());
}
[Test]
public void DrawLoadedSelectBox()
{
    SetToTenValues();
    var stream = BinaryDataExtensions.SaveToMemoryStream(selectBox);
    selectBox.IsActive = false;
    var loadedSelectBox = (SelectBox)stream.CreateFromMemoryStream(); 
    var text = new FontText(Font.Default, "", new Rectangle(0.4f, 0.7f, 0.2f, 0.1f));
    loadedSelectBox.LineClicked +=
        lineNo => text.Text = loadedSelectBox.Values[lineNo] + " clicked"; //ncrunch: no coverage
}
See Also