Skip to content

Commit

Permalink
Remove obsolote code
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Aug 22, 2023
1 parent fed3ae8 commit 5fbda60
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,12 @@ public class EnumInstructionAttribute : Attribute
/// </summary>
public bool Hide { get; set; }

/// <summary>
/// The title of the button generated for the enum value marked with this attribute.
/// </summary>
[Obsolete("Use Display Attribute instead")]
public string Title { get; }

/// <summary>
/// Create instruction attribute without title
/// </summary>
public EnumInstructionAttribute()
{

}

/// <summary>
/// Constructor with title
/// </summary>
[Obsolete("Use empty constructor and Display Attribute instead")]
public EnumInstructionAttribute(string title)
{
Title = title;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static IDictionary<string, int> ParseEnum(Type resultEnum, params string
var displayName = member.GetDisplayName();
var attribute = (EnumInstructionAttribute)member.GetCustomAttributes(typeof(EnumInstructionAttribute), false).FirstOrDefault();

var text = displayName ?? attribute?.Title ?? name;
var text = displayName ?? name;
var numericValue = (int)Enum.Parse(resultEnum, name);
allValues[text] = numericValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public void GetAllValuesIfNoResultIsDecorated()

private enum TestResults2
{
[EnumInstruction("Value1")]
[EnumInstruction, Display(Name = "Value1")]
Value1,
[EnumInstruction("Value2")]
[EnumInstruction, Display(Name = "Value2")]
Value2
}

Expand All @@ -47,7 +47,7 @@ public void GetAllValuesIfAllResultsAreDecorated()

private enum TestResults3
{
[EnumInstruction("Value1")]
[EnumInstruction, Display(Name = "Value1")]
Value1,
Value2
}
Expand Down Expand Up @@ -120,8 +120,6 @@ private enum TestResults6
{
[EnumInstruction, Display(Name = "Value 1")]
Value1,
[EnumInstruction("Value 2")]
Value2,
[Display(Name = "Value 3")]
Value3
}
Expand All @@ -130,12 +128,11 @@ private enum TestResults6
public void UsesDisplayResultsWhereFound()
{
// Act
var instructionResult = new EnumInstructionResult(typeof(TestResults6), result => { });
var instructionResult = EnumInstructionResult.PossibleResults(typeof(TestResults6));

// Assert
Assert.AreEqual(2, instructionResult.Results.Count(), "There should be two results, because one does not have the EnumInstruction attribute");
Assert.AreEqual("Value 1", instructionResult.Results[0]);
Assert.AreEqual("Value 2", instructionResult.Results[1]);
Assert.AreEqual(1, instructionResult.Count(), "There should be two results, because one does not have the EnumInstruction attribute");
Assert.AreEqual("Value 1", instructionResult[0]);
}
}
}

0 comments on commit 5fbda60

Please sign in to comment.