ZoneCodeGenerator: Fix wrong exception being thrown in tests: Use TestFailedException instead of LoadingException

This commit is contained in:
Jan 2019-10-30 15:23:31 +01:00
parent 825b14bfd4
commit 9b12bd7e41
2 changed files with 6 additions and 6 deletions

View File

@ -33,18 +33,18 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
var assetType = state.Repository.GetDataTypeByName(assetTypeName);
if (assetType == null)
{
throw new LoadingException($"Could not find type '{assetTypeName}' to mark it as an asset.");
throw new TestFailedException($"Could not find type '{assetTypeName}' to mark it as an asset.");
}
if (!(assetType is DataTypeWithMembers assetTypeWithMembers))
{
throw new LoadingException($"Type of asset '{assetTypeName}' needs to be struct or union.");
throw new TestFailedException($"Type of asset '{assetTypeName}' needs to be struct or union.");
}
var assetInfo = state.Repository.GetInformationFor(assetTypeWithMembers);
if (assetInfo == null)
{
throw new LoadingException($"Could not find information for type '{assetTypeName}' to mark it as an asset.");
throw new TestFailedException($"Could not find information for type '{assetTypeName}' to mark it as an asset.");
}
var enumEntryName = NextMatch(AssetEnumEntryToken);
@ -52,7 +52,7 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
.SelectMany(_enum => _enum.Members)
.FirstOrDefault(member => member.Name.Equals(enumEntryName, StringComparison.CurrentCultureIgnoreCase));
assetInfo.AssetEnumEntry = enumEntry ?? throw new LoadingException(
assetInfo.AssetEnumEntry = enumEntry ?? throw new TestFailedException(
$"Could not find enum entry '{enumEntryName}' as an asset type index for asset type '{assetTypeName}'.");
}
}

View File

@ -27,12 +27,12 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
if (dataTypeToUse == null)
{
throw new LoadingException($"Could not find data type '{typeName}'");
throw new TestFailedException($"Could not find data type '{typeName}'");
}
if (!(dataTypeToUse is DataTypeWithMembers dataTypeWithMembersToUse))
{
throw new LoadingException($"To use data type '{typeName}' it must either be a struct or a union.");
throw new TestFailedException($"To use data type '{typeName}' it must either be a struct or a union.");
}
state.DataTypeInUse = dataTypeWithMembersToUse;