PercentageBarTests ClassDelta Engine Documentation
Inheritance Hierarchy

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

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

The PercentageBarTests type exposes the following members.

Constructors

  NameDescription
Public methodPercentageBarTests
Initializes a new instance of the PercentageBarTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodChangeAlignment
Public methodChangeMaximum
Public methodChangeMaxWidth
Public methodChangeMinimum
Public methodChangePercentileColors
Public methodChangingValueToHighValueLerpsColorBetweenLastPercentileColors
Public methodChangingValueToLowValueLerpsColorBetweenFirstPercentileColors
Public methodChangingValueUpdatesDrawArea
Public methodDefaultValues
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Public methodRenderShrinkingCenterAlignedBar
Public methodRenderShrinkingLeftAlignedBar
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodSetUp
Public methodValueCannotGoAboveMaximum
Public methodValueCannotGoBelowMinimum
Public methodValueDecreasesIfAboveNewMaximum
Public methodValueIncreasesIfBelowNewMinimum
Public methodWhenOnlyOnePercentileColorStaysThatColor
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void RenderShrinkingLeftAlignedBar()
{
    bar.Start<Shrink>();
}
[Test]
public void RenderShrinkingCenterAlignedBar()
{
    bar.Alignment = PercentageBar.HorizontalAlignment.Center;
    bar.Start<Shrink>();
}
[Test, CloseAfterFirstFrame]
public void DefaultValues()
{
    Assert.AreEqual(0, bar.Minimum);
    Assert.AreEqual(100, bar.Maximum);
    Assert.AreEqual(100, bar.Value);
    Assert.AreEqual(Center, bar.DrawArea);
    Assert.AreEqual(Width, bar.MaxWidth);
    Assert.AreEqual(HighColor, bar.Color);
    Assert.AreEqual(PercentileColors, bar.PercentileColors);
    Assert.AreEqual(PercentageBar.HorizontalAlignment.Left, bar.Alignment);
}
[Test, CloseAfterFirstFrame]
public void ChangeMinimum()
{
    bar.Minimum = 10;
    Assert.AreEqual(10, bar.Minimum);
}
[Test, CloseAfterFirstFrame]
public void ChangeMaximum()
{
    bar.Maximum = 30;
    Assert.AreEqual(30, bar.Maximum);
}
[Test, CloseAfterFirstFrame]
public void ChangingValueUpdatesDrawArea()
{
    bar.Value = 60;
    Assert.AreEqual(60, bar.Value);
    Assert.AreEqual(new Rectangle(Left, Top, 0.6f * Width, Height), bar.DrawArea);
}
[Test, CloseAfterFirstFrame]
public void ChangingValueToLowValueLerpsColorBetweenFirstPercentileColors()
{
    bar.Value = 30;
    AssertColorsNearlyEqual(LowColor.Lerp(MidColor, 0.6f), bar.Color);
}
[Test, CloseAfterFirstFrame]
public void ChangingValueToHighValueLerpsColorBetweenLastPercentileColors()
{
    bar.Value = 60;
    AssertColorsNearlyEqual(MidColor.Lerp(HighColor, 0.2f), bar.Color);
}
[Test, CloseAfterFirstFrame]
public void ValueCannotGoBelowMinimum()
{
    bar.Value = -10;
    Assert.AreEqual(0, bar.Value);
    Assert.AreEqual(0, bar.DrawArea.Width);
    Assert.AreEqual(Color.Red, bar.Color);
}
[Test, CloseAfterFirstFrame]
public void ValueCannotGoAboveMaximum()
{
    bar.Value = 110;
    Assert.AreEqual(100, bar.Value);
    Assert.AreEqual(Width, bar.DrawArea.Width);
    Assert.AreEqual(Color.Green, bar.Color);
}
[Test, CloseAfterFirstFrame]
public void ValueIncreasesIfBelowNewMinimum()
{
    bar.Value = 50;
    bar.Minimum = 60;
    Assert.AreEqual(60, bar.Value);
    Assert.AreEqual(Color.Red, bar.Color);
}
[Test, CloseAfterFirstFrame]
public void ValueDecreasesIfAboveNewMaximum()
{
    bar.Value = 50;
    bar.Maximum = 40;
    Assert.AreEqual(40, bar.Value);
    Assert.AreEqual(Color.Green, bar.Color);
}
[Test, CloseAfterFirstFrame]
public void ChangeMaxWidth()
{
    bar.MaxWidth = 0.6f;
    Assert.AreEqual(0.6f, bar.MaxWidth);
    Assert.AreEqual(0.6f, bar.DrawArea.Width);
}
[Test, CloseAfterFirstFrame]
public void ChangeAlignment()
{
    bar.Alignment = PercentageBar.HorizontalAlignment.Center;
    Assert.AreEqual(PercentageBar.HorizontalAlignment.Center, bar.Alignment);
}
[Test, CloseAfterFirstFrame]
public void ChangePercentileColors()
{
    bar.Value = 50;
    var colors = new[] { Color.Black, Color.White };
    bar.PercentileColors = colors;
    Assert.AreEqual(colors, bar.PercentileColors);
    AssertColorsNearlyEqual(Color.Gray, bar.Color);
}
[Test, CloseAfterFirstFrame]
public void WhenOnlyOnePercentileColorStaysThatColor()
{
    bar.PercentileColors = new[] { Color.Blue };
    bar.Value = 75;
    Assert.AreEqual(Color.Blue, bar.Color);
}
See Also