diff --git a/Prequel.Tests/Prequel.Tests.csproj b/Prequel.Tests/Prequel.Tests.csproj index b1fa052..330925c 100644 --- a/Prequel.Tests/Prequel.Tests.csproj +++ b/Prequel.Tests/Prequel.Tests.csproj @@ -71,6 +71,7 @@ + diff --git a/Prequel.Tests/WarningTests.cs b/Prequel.Tests/WarningTests.cs new file mode 100644 index 0000000..7635e68 --- /dev/null +++ b/Prequel.Tests/WarningTests.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; + + +namespace Prequel.Tests +{ + public class WarningTests + { + /// + /// Check that the warning map contains all the IDs. Ideally should be enforced at compile time + /// + [Fact] + public void AllWarningsInMap() + { + for (int id = (int)WarningID.Min; id < (int)WarningID.Max ; id++) + { + WarningID warningID = (WarningID)id; + Assert.Equal(warningID, Warning.WarningTypes[warningID].ID); + } + } + } +} diff --git a/Prequel/Warning.cs b/Prequel/Warning.cs index f98756d..1dc9762 100644 --- a/Prequel/Warning.cs +++ b/Prequel/Warning.cs @@ -8,10 +8,12 @@ namespace Prequel { public enum WarningID { + Min = UndeclaredVariableUsed, UndeclaredVariableUsed = 1, UnusedVariableDeclared, ProcedureWithoutNoCount, - ProcedureWithSPPrefix + ProcedureWithSPPrefix, + Max = ProcedureWithSPPrefix } public enum WarningLevel