Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade more validator functional tests #1149

Merged
7 commits merged into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,10 @@ namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules
{
public class EndColumnMustNotBeLessThanStartColumnTests : ValidationSkimmerTestsBase<EndColumnMustNotBeLessThanStartColumn>
{
[Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnEqualsStartColumn))]
public void EndColumnMustNotBeLessThanStartColumn_EndColumnEqualsStartColumn()
{
Verify("EndColumnEqualsStartColumn.sarif");
}
[Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_ReportsInvalidSarif))]
public void EndColumnMustNotBeLessThanStartColumn_ReportsInvalidSarif() => Verify("Invalid.sarif");

[Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnEqualsStartColumnNoEndLine))]
public void EndColumnMustNotBeLessThanStartColumn_EndColumnEqualsStartColumnNoEndLine()
{
Verify("EndColumnEqualsStartColumnNoEndLine.sarif");
}

[Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnGreaterThanStartColumn))]
public void EndColumnMustNotBeLessThanStartColumn_EndColumnGreaterThanStartColumn()
{
Verify("EndColumnGreaterThanStartColumn.sarif");
}

[Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInCodeFlow))]
public void EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInCodeFlow()
{
Verify("EndColumnLessThanStartColumnInCodeFlow.sarif");
}

[Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInRelatedLocation))]
public void EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInRelatedLocation()
{
Verify("EndColumnLessThanStartColumnInRelatedLocation.sarif");
}

[Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInResultLocation))]
public void EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInResultLocation()
{
Verify("EndColumnLessThanStartColumnInResultLocation.sarif");
}

[Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnNotSpecified))]
public void EndColumnMustNotBeLessThanStartColumn_EndColumnNotSpecified()
{
Verify("EndColumnNotSpecified.sarif");
}
[Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_AcceptsValidSarif))]
public void EndColumnMustNotBeLessThanStartColumn_AcceptsValidSarif() => Verify("Valid.sarif");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,10 @@ namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules
{
public class EndLineMustNotBeLessThanStartLineTests : ValidationSkimmerTestsBase<EndLineMustNotBeLessThanStartLine>
{
[Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineEqualsStartLine))]
public void EndLineMustNotBeLessThanStartLine_EndLineEqualsStartLine()
{
Verify("EndLineEqualsStartLine.sarif");
}
[Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_ReportsInvalidSarif))]
public void EndLineMustNotBeLessThanStartLine_ReportsInvalidSarif() => Verify("Invalid.sarif");

[Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineGreaterThanStartLine))]
public void EndLineMustNotBeLessThanStartLine_EndLineGreaterThanStartLine()
{
Verify("EndLineGreaterThanStartLine.sarif");
}

[Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInCodeFlow))]
public void EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInCodeFlow()
{
Verify("EndLineLessThanStartLineInCodeFlow.sarif");
}

[Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInRelatedLocation))]
public void EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInRelatedLocation()
{
Verify("EndLineLessThanStartLineInRelatedLocation.sarif");
}

[Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineNotSpecified))]
public void EndLineMustNotBeLessThanStartLine_EndLineNotSpecified()
{
Verify("EndLineNotSpecified.sarif");
}

[Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInResultLocation))]
public void EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInResultLocation()
{
Verify("EndLineLessThanStartLineInResultLocation.sarif");
}
[Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_AcceptsValidSarif))]
public void EndLineMustNotBeLessThanStartLine_AcceptsValidSarif() => Verify("Valid.sarif");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,10 @@ namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules
{
public class EndTimeMustBeAfterStartTimeTests : ValidationSkimmerTestsBase<EndTimeMustBeAfterStartTime>
{
[Fact(DisplayName = nameof(EndTimeMustBeAfterStartTime_EndTimeIsAfterStartTime))]
public void EndTimeMustBeAfterStartTime_EndTimeIsAfterStartTime()
{
Verify("EndTimeIsAfterStartTime.sarif");
}
[Fact(DisplayName = nameof(EndTimeMustBeAfterStartTime_ReportsInvalidSarif))]
public void EndTimeMustBeAfterStartTime_ReportsInvalidSarif() => Verify("Invalid.sarif");

[Fact(DisplayName = nameof(EndTimeMustBeAfterStartTime_EndTimeEqualsStartTime))]
public void EndTimeMustBeAfterStartTime_EndTimeEqualsStartTime()
{
Verify("EndTimeEqualsStartTime.sarif");
}

[Fact(DisplayName = nameof(EndTimeMustBeAfterStartTime_EndTimeIsBeforeStartTime))]
public void EndTimeMustBeAfterStartTime_EndTimeIsBeforeStartTime()
{
Verify("EndTimeIsBeforeStartTime.sarif");
}
[Fact(DisplayName = nameof(EndTimeMustBeAfterStartTime_AcceptsValidSarif))]
public void EndTimeMustBeAfterStartTime_AcceptsValidSarif() => Verify("Valid.sarif");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,10 @@ namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules
{
public class MessagesShouldEndWithPeriodTests : ValidationSkimmerTestsBase<MessagesShouldEndWithPeriod>
{
[Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_PeriodsAfterAllMessages))]
public void MessagesShouldEndWithPeriod_PeriodsAfterAllMessages()
{
Verify("PeriodsAfterAllMessages.sarif");
}
[Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_ReportsInvalidSarif))]
public void MessagesShouldEndWithPeriod_ReportsInvalidSarif() => Verify("Invalid.sarif");

[Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_CodeFlowMessageWithoutPeriod))]
public void MessagesShouldEndWithPeriod_CodeFlowMessageWithoutPeriod()
{
Verify("CodeFlowMessageWithoutPeriod.sarif");
}

[Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_NotificationMessageWithoutPeriod))]
public void MessagesShouldEndWithPeriod_NotificationMessageWithoutPeriod()
{
Verify("NotificationMessageWithoutPeriod.sarif");
}

[Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_ResultMessageWithoutPeriod))]
public void MessagesShouldEndWithPeriod_ResultMessageWithoutPeriod()
{
Verify("ResultMessageWithoutPeriod.sarif");
}

[Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_RuleMessageWithoutPeriod))]
public void MessagesShouldEndWithPeriod_RuleMessageWithoutPeriod()
{
Verify("RuleMessageWithoutPeriod.sarif");
}

[Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_StackFrameMessageWithoutPeriod))]
public void MessagesShouldEndWithPeriod_StackFrameMessageWithoutPeriod()
{
Verify("StackFrameMessageWithoutPeriod.sarif");
}

[Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_StackMessageWithoutPeriod))]
public void MessagesShouldEndWithPeriod_StackMessageWithoutPeriod()
{
Verify("StackMessageWithoutPeriod.sarif");
}

[Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_ThreadFlowLocationMessageWithoutPeriod))]
public void MessagesShouldEndWithPeriod_ThreadFlowLocationMessageWithoutPeriod()
{
Verify("ThreadFlowLocationMessageWithoutPeriod.sarif");
}
[Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_AcceptsValidSarif))]
public void MessagesShouldEndWithPeriod_AcceptsValidSarif() => Verify("Valid.sarif");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,14 @@ protected void Verify(string testFileName, bool disablePrereleaseCompatibilityTr
// Verify that those detected result locations match the expected locations.
private void Verify(Run run, ExpectedValidationResults expectedResults)
{
run.Results.Count.Should().Be(expectedResults.ResultCount);

string[] detectedResultLocations = run.Results.Select(r => r.Message.Arguments[0]).OrderBy(loc => loc).ToArray();
string[] expectedResultLocations = expectedResults.ResultLocationPointers.OrderBy(loc => loc).ToArray();

// We could make this assertion at the start of the method. We delay it until here
// so that, during debugging, you can set a breakpoint here, and you'll have the
// detected and expected result location arrays available to compare.
run.Results.Count.Should().Be(expectedResults.ResultCount);

detectedResultLocations.Should().ContainInOrder(expectedResultLocations);
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading