, , OperandType OperandType:
Assert.Throws<InvalidEnumArgumentException>(delegate { ((OperandType)Int32.MaxValue).ToShortName(); } );
BTW 86%
UPDATE: Contract. , .
public static class OperandTypeExtensions
{
public static string ToShortName(this OperandType type)
{
switch (type)
{
case OperandType.None: return "<none>";
case OperandType.Int32: return "i32";
case OperandType.Int64: return "i64";
default:
throw new NotSupportedException();
}
}
}
default, OperandType enum, Contract , .
UPDATE2: 100% - , OperandType.None :
public static class OperandTypeExtensions
{
public static string ToShortName(this OperandType type)
{
Contract.Requires<InvalidEnumArgumentException>(Enum.IsDefined(typeof(OperandType), type));
switch (type)
{
case OperandType.Int32: return "i32";
case OperandType.Int64: return "i64";
default:
return "<none>";
}
}
}
:
CollectionAssert.AreEquivalent(Enum.GetValues(typeof(OperandType)),
new OperandType[] { OperandType.Int32,
OperandType.Int64,
OperandType.None });