Inheritance Hierarchy
DeltaEngine.Tests.Extensions EnumExtensionTests
Namespace: DeltaEngine.Tests.Extensions
Assembly: DeltaEngine.Tests (in DeltaEngine.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The EnumExtensionTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
EnumExtensionTests | Initializes a new instance of the EnumExtensionTests class |
Methods
Name | Description | |
---|---|---|
GetCount | ||
GetIndex | ||
GetValues | ||
TextToEnum |
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