EnumExtensionTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Tests.Extensions EnumExtensionTests

Namespace: DeltaEngine.Tests.Extensions
Assembly: DeltaEngine.Tests (in DeltaEngine.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class EnumExtensionTests

The EnumExtensionTests type exposes the following members.

Constructors

  NameDescription
Public methodEnumExtensionTests
Initializes a new instance of the EnumExtensionTests class
Top
Methods

  NameDescription
Public methodGetCount
Public methodGetIndex
Public methodGetValues
Public methodTextToEnum
Top
Examples

[Test]
public void GetValues()
{
    Array enumValues = TestEnum.SomeValue.GetEnumValues();
    Assert.AreEqual(2, enumValues.Length);
    Assert.AreEqual(TestEnum.SomeValue, enumValues.GetValue(0));
    Assert.AreEqual(TestEnum.AnotherValue, enumValues.GetValue(1));
}
[Test]
public void GetCount()
{
    Assert.AreEqual(2, TestEnum.SomeValue.GetCount());
    Assert.AreEqual(2, TestEnum.AnotherValue.GetCount());
    Assert.AreEqual(2, EnumExtensions.GetCount<TestEnum>());
}
[Test]
public void TextToEnum()
{
    Assert.AreEqual(TestEnum.AnotherValue, "AnotherValue".TryParse(TestEnum.AnotherValue));
    Assert.AreEqual(TestEnum.SomeValue, "InvalidValue".TryParse(TestEnum.SomeValue));
}
[Test]
public void GetIndex()
{
    Assert.AreEqual(0, EnumExtensions.GetIndex(FlagsEnum.Red));
    Assert.AreEqual(1, EnumExtensions.GetIndex(FlagsEnum.Green));
    Assert.AreEqual(2, EnumExtensions.GetIndex(FlagsEnum.Blue));
    Assert.AreEqual(-1, EnumExtensions.GetIndex((FlagsEnum)17));
}
See Also