-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #912 from StefanMaron/prerelease
Merge 'prerelease' into master
- Loading branch information
Showing
22 changed files
with
278 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace BusinessCentral.LinterCop.Test; | ||
|
||
public class Rule0048 | ||
{ | ||
private string _testCaseDir = ""; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_testCaseDir = Path.Combine(Directory.GetParent(Environment.CurrentDirectory)!.Parent!.Parent!.FullName, | ||
"TestCases", "Rule0048"); | ||
} | ||
|
||
#if !LessThenSpring2024 | ||
[Test] | ||
[TestCase("ErrorWithLiteralExpression")] | ||
[TestCase("ErrorWithStrSubstNo")] | ||
[TestCase("ErrorWithTextVariable")] | ||
#endif | ||
public async Task HasDiagnostic(string testCase) | ||
{ | ||
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "HasDiagnostic", $"{testCase}.al")) | ||
.ConfigureAwait(false); | ||
|
||
var fixture = RoslynFixtureFactory.Create<Rule0048ErrorWithTextConstant>(); | ||
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0048ErrorWithTextConstant.Id); | ||
} | ||
|
||
[Test] | ||
[TestCase("ErrorWithErrorInfo")] | ||
[TestCase("ErrorWithLabel")] | ||
#if !LessThenFall2024 | ||
[TestCase("ErrorWiththisLabel")] | ||
#endif | ||
public async Task NoDiagnostic(string testCase) | ||
{ | ||
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "NoDiagnostic", $"{testCase}.al")) | ||
.ConfigureAwait(false); | ||
|
||
var fixture = RoslynFixtureFactory.Create<Rule0048ErrorWithTextConstant>(); | ||
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0048ErrorWithTextConstant.Id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...nessCentral.LinterCop.Test/TestCases/Rule0048/HasDiagnostic/ErrorWithLiteralExpression.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
begin | ||
[|Error('Something went wrong...')|]; | ||
end; | ||
} |
18 changes: 18 additions & 0 deletions
18
BusinessCentral.LinterCop.Test/TestCases/Rule0048/HasDiagnostic/ErrorWithStrSubstNo.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
var | ||
MyTable: Record MyTable; | ||
UnexpectedErr: Label '%1 is not an valid Record.'; | ||
begin | ||
[|Error(StrSubstNo(UnexpectedErr, MyTable.MyField))|]; | ||
end; | ||
} | ||
|
||
table 50100 MyTable | ||
{ | ||
fields | ||
{ | ||
field(1; MyField; Integer) { } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
BusinessCentral.LinterCop.Test/TestCases/Rule0048/HasDiagnostic/ErrorWithTextVariable.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
var | ||
UnexpectedErr: Text; | ||
begin | ||
[|Error(UnexpectedErr)|]; | ||
end; | ||
} |
10 changes: 10 additions & 0 deletions
10
BusinessCentral.LinterCop.Test/TestCases/Rule0048/NoDiagnostic/ErrorWithErrorInfo.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
var | ||
MyErrorInfo: ErrorInfo; | ||
begin | ||
MyErrorInfo := ErrorInfo.Create(GetLastErrorText()); | ||
[|Error(MyErrorInfo)|]; | ||
end; | ||
} |
9 changes: 9 additions & 0 deletions
9
BusinessCentral.LinterCop.Test/TestCases/Rule0048/NoDiagnostic/ErrorWithLabel.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
var | ||
UnexpectedErr: Label 'Something went wrong...'; | ||
begin | ||
[|Error(UnexpectedErr)|]; | ||
end; | ||
} |
10 changes: 10 additions & 0 deletions
10
BusinessCentral.LinterCop.Test/TestCases/Rule0048/NoDiagnostic/ErrorWiththisLabel.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
var | ||
UnexpectedErr: Label 'Something went wrong...'; | ||
|
||
procedure MyProcedure() | ||
begin | ||
[|Error(this.UnexpectedErr)|]; | ||
end; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
BusinessCentral.LinterCop.Test/TestCases/Rule0051/HasDiagnostic/ValidateFieldCode.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
var | ||
MyTable: Record MyTable; | ||
MyVar: Code[20]; | ||
begin | ||
MyTable.Validate(MyField, [|MyVar|]); | ||
end; | ||
} | ||
|
||
table 50100 MyTable | ||
{ | ||
fields | ||
{ | ||
field(1; MyField; Code[10]) { } | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
BusinessCentral.LinterCop.Test/TestCases/Rule0051/NoDiagnostic/ValidateFieldCode.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
var | ||
MyTable: Record MyTable; | ||
MyVar: Code[10]; | ||
begin | ||
MyTable.Validate(MyField, [|MyVar|]); | ||
end; | ||
} | ||
|
||
table 50100 MyTable | ||
{ | ||
fields | ||
{ | ||
field(1; MyField; Code[10]) { } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
BusinessCentral.LinterCop.Test/TestCases/Rule0075/HasDiagnostic/RecordGetEnum.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
var | ||
MyTable: Record MyTable; | ||
MyEnum: Enum MyEnum; | ||
begin | ||
[|MyTable.Get(MyEnum::MyValue)|]; | ||
end; | ||
} | ||
|
||
table 50100 MyTable | ||
{ | ||
fields { field(1; MyField; Code[20]) { } } | ||
} | ||
enum 50100 MyEnum | ||
{ | ||
value(0; MyValue) { } | ||
} |
19 changes: 19 additions & 0 deletions
19
BusinessCentral.LinterCop.Test/TestCases/Rule0075/NoDiagnostic/RecordGetEnum.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
var | ||
MyTable: Record MyTable; | ||
MyEnum: Enum MyEnum; | ||
begin | ||
[|MyTable.Get(MyEnum::MyValue)|]; | ||
end; | ||
} | ||
|
||
table 50100 MyTable | ||
{ | ||
fields { field(1; MyField; Enum MyEnum) { } } | ||
} | ||
enum 50100 MyEnum | ||
{ | ||
value(0; MyValue) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.