diff --git a/DynamicEnums/DynamicEnum.cs b/DynamicEnums/DynamicEnum.cs
index 5cf45ab..427a65c 100644
--- a/DynamicEnums/DynamicEnum.cs
+++ b/DynamicEnums/DynamicEnum.cs
@@ -195,7 +195,7 @@ namespace DynamicEnums {
/// A value counts as explicitly defined if it has been added using , or .
///
/// The type whose values to get
- /// The defined values for the given type
+ /// The defined values for the given type, in the order they were added.
public static IEnumerable GetValues() where T : DynamicEnum {
return DynamicEnum.GetValues(typeof(T)).Cast();
}
@@ -205,10 +205,10 @@ namespace DynamicEnums {
/// A value counts as explicitly defined if it has been added using , or .
///
/// The type whose values to get.
- /// The defined values for the given type, excluding combined flags.
+ /// The defined values for the given type, in ascending value order, excluding combined flags.
public static IEnumerable GetUniqueValues() where T : DynamicEnum {
var used = BigInteger.Zero;
- foreach (var value in DynamicEnum.GetValues()) {
+ foreach (var value in DynamicEnum.GetValues().OrderBy(DynamicEnum.GetValue)) {
var iValue = DynamicEnum.GetValue(value);
if ((used & iValue) == 0) {
yield return value;
@@ -222,7 +222,7 @@ namespace DynamicEnums {
/// A value counts as explicitly defined if it has been added using , or .
///
/// The type whose values to get
- /// The defined values for the given type
+ /// The defined values for the given type, in the order they were added.
public static IEnumerable GetValues(Type type) {
return DynamicEnum.GetStorage(type).Values.Values;
}
diff --git a/Tests/EnumTests.cs b/Tests/EnumTests.cs
index acc421b..51a127e 100644
--- a/Tests/EnumTests.cs
+++ b/Tests/EnumTests.cs
@@ -40,20 +40,20 @@ public class EnumTests {
[Test]
public void TestDynamicEnums() {
+ var combined = DynamicEnum.Add("Combined", (1 << 7) | (1 << 13));
var flags = new TestDynamicEnum[100];
for (var i = 0; i < flags.Length; i++)
flags[i] = DynamicEnum.AddFlag("Flag" + i);
var zero = DynamicEnum.Add("Zero", 0);
- var combined = DynamicEnum.Add("Combined", DynamicEnum.GetValue(DynamicEnum.Or(flags[7], flags[13])));
- var test = DynamicEnum.Add("Test", 10);
+ DynamicEnum.Add("Test", 10);
Assert.AreEqual(DynamicEnum.GetEnumValue(10).ToString(), "TestModified");
Assert.AreEqual(
- flags.Append(zero).Append(combined),
+ flags.Append(zero).Prepend(combined),
DynamicEnum.GetValues());
Assert.AreEqual(
- flags.Append(zero),
+ flags.Prepend(zero),
DynamicEnum.GetUniqueValues());
Assert.AreEqual(DynamicEnum.GetValue(flags[7]), BigInteger.One << 7);
@@ -89,10 +89,10 @@ public class EnumTests {
Assert.False(DynamicEnum.IsDefined(DynamicEnum.Or(combined, flags[49])));
Assert.AreEqual(
- new[] {flags[0], flags[7], flags[13], combined},
+ new[] {combined, flags[0], flags[7], flags[13]},
DynamicEnum.GetFlags(DynamicEnum.Or(DynamicEnum.Or(flags[0], flags[13]), flags[7]), false));
Assert.AreEqual(
- new[] {flags[0], flags[7], flags[13], zero, combined},
+ new[] {combined, flags[0], flags[7], flags[13], zero},
DynamicEnum.GetFlags(DynamicEnum.Or(DynamicEnum.Or(flags[0], flags[13]), flags[7])));
Assert.AreEqual(
@@ -106,12 +106,12 @@ public class EnumTests {
Zero = 0,
One = 1,
Two = 2,
- Eight = 8,
- Sixteen = 16,
EightSixteen = TestEnum.Eight | TestEnum.Sixteen,
+ Eight = 8,
+ OneTwentyEightTwoOne = TestEnum.OneTwentyEight | TestEnum.Two | TestEnum.One,
ThirtyTwo = 32,
+ Sixteen = 16,
OneTwentyEight = 128,
- OneTwentyEightTwoOne = TestEnum.OneTwentyEight | TestEnum.Two | TestEnum.One
}