Skip to content

Commit

Permalink
check for warningID map completeness
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Young committed Sep 6, 2015
1 parent f1e04ee commit 09a0a7c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions Prequel.Tests/Prequel.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlParserFactoryTests.cs" />
<Compile Include="TempFile.cs" />
<Compile Include="WarningTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Prequel\Prequel.Library.csproj">
Expand Down
26 changes: 26 additions & 0 deletions Prequel.Tests/WarningTests.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Check that the warning map contains all the IDs. Ideally should be enforced at compile time
/// </summary>
[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);
}
}
}
}
4 changes: 3 additions & 1 deletion Prequel/Warning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ namespace Prequel
{
public enum WarningID
{
Min = UndeclaredVariableUsed,
UndeclaredVariableUsed = 1,
UnusedVariableDeclared,
ProcedureWithoutNoCount,
ProcedureWithSPPrefix
ProcedureWithSPPrefix,
Max = ProcedureWithSPPrefix
}

public enum WarningLevel
Expand Down

0 comments on commit 09a0a7c

Please sign in to comment.