Skip to content

Commit

Permalink
Use Assert.Fail()
Browse files Browse the repository at this point in the history
  • Loading branch information
terrajobst committed Oct 2, 2024
1 parent a9f9c71 commit 42606d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/NQuery.Tests/Binding/IntrinsicOperatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public void IntrinsicOperator_UnarySignaturesAreCorrect()
var syntaxTree = SyntaxTree.ParseExpression(source);
var syntaxTreeSource = syntaxTree.Root.ToString();
if (syntaxTreeSource != source)
Assert.True(false, $"Source should have been {syntaxTreeSource} but is {source}");
Assert.Fail($"Source should have been {syntaxTreeSource} but is {source}");

var expression = (UnaryExpressionSyntax)syntaxTree.Root.Root;
var compilation = Compilation.Empty.WithSyntaxTree(syntaxTree);
var semanticModel = compilation.GetSemanticModel();

var argumentType = GetExpressionTypeString(semanticModel.GetExpressionType(expression.Expression));
if (testCase.Argument != argumentType)
Assert.True(false, $"Left should be of type '{testCase.Argument}' but has type '{argumentType}");
Assert.Fail($"Left should be of type '{testCase.Argument}' but has type '{argumentType}");

var diagnostic = syntaxTree.GetDiagnostics().Concat(semanticModel.GetDiagnostics()).SingleOrDefault();
var expressionType = semanticModel.GetExpressionType(expression);
Expand All @@ -44,7 +44,7 @@ public void IntrinsicOperator_UnarySignaturesAreCorrect()
{
issues.Insert(0, $"{issues.Count} errors:");
var issueText = string.Join(Environment.NewLine, issues);
Assert.True(false, issueText);
Assert.Fail(issueText);
}
}

Expand All @@ -62,19 +62,19 @@ public void IntrinsicOperator_BinarySignaturesAreCorrect()
var syntaxTree = SyntaxTree.ParseExpression(source);
var syntaxTreeSource = syntaxTree.Root.ToString();
if (syntaxTreeSource != source)
Assert.True(false, $"Source should have been {syntaxTreeSource} but is {source}");
Assert.Fail($"Source should have been {syntaxTreeSource} but is {source}");

var expression = (BinaryExpressionSyntax)syntaxTree.Root.Root;
var compilation = Compilation.Empty.WithSyntaxTree(syntaxTree);
var semanticModel = compilation.GetSemanticModel();

var leftType = GetExpressionTypeString(semanticModel.GetExpressionType(expression.Left));
if (testCase.Left != leftType)
Assert.True(false, $"Left should be of type '{testCase.Left}' but has type '{leftType}");
Assert.Fail($"Left should be of type '{testCase.Left}' but has type '{leftType}");

var rightType = GetExpressionTypeString(semanticModel.GetExpressionType(expression.Right));
if (testCase.Right != rightType)
Assert.True(false, $"Right should be of type '{testCase.Right}' but has type '{rightType}");
Assert.Fail($"Right should be of type '{testCase.Right}' but has type '{rightType}");

var diagnostic = syntaxTree.GetDiagnostics().Concat(semanticModel.GetDiagnostics()).SingleOrDefault();
var expressionType = semanticModel.GetExpressionType(expression);
Expand All @@ -93,7 +93,7 @@ public void IntrinsicOperator_BinarySignaturesAreCorrect()
{
issues.Insert(0, $"{issues.Count} errors:");
var issueText = string.Join(Environment.NewLine, issues);
Assert.True(false, issueText);
Assert.Fail(issueText);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/NQuery.Tests/QueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Query_ExecuteSchemaReaderThrows_IfQueryCannotBeParsed()
try
{
query.ExecuteSchemaReader();
Assert.True(false, "Should have thrown an exception.");
Assert.Fail("Should have thrown an exception.");
}
catch (CompilationException ex)
{
Expand All @@ -59,7 +59,7 @@ public void Query_ExecuteReaderThrows_IfQueryCannotBeParsed()
try
{
query.ExecuteReader();
Assert.True(false, "Should have thrown an exception.");
Assert.Fail("Should have thrown an exception.");
}
catch (CompilationException ex)
{
Expand Down

0 comments on commit 42606d4

Please sign in to comment.