-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve InvalidCastException on Rule0044 (#799)
- Loading branch information
Showing
6 changed files
with
519 additions
and
431 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,41 @@ | ||
namespace BusinessCentral.LinterCop.Test; | ||
|
||
public class Rule0044 | ||
{ | ||
private string _testCaseDir = ""; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_testCaseDir = Path.Combine(Directory.GetParent(Environment.CurrentDirectory)!.Parent!.Parent!.FullName, | ||
"TestCases", "Rule0044"); | ||
} | ||
|
||
#if !LessThenSpring2024 | ||
[Test] | ||
[TestCase("1")] | ||
[TestCase("2")] | ||
#endif | ||
public async Task HasDiagnostic(string testCase) | ||
{ | ||
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "HasDiagnostic", $"{testCase}.al")) | ||
.ConfigureAwait(false); | ||
|
||
var fixture = RoslynFixtureFactory.Create<Rule0044AnalyzeTransferFields>(); | ||
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0044AnalyzeTransferFields.Id); | ||
} | ||
|
||
#if !LessThenSpring2024 | ||
[Test] | ||
[TestCase("1")] | ||
[TestCase("2")] | ||
#endif | ||
public async Task NoDiagnostic(string testCase) | ||
{ | ||
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "NoDiagnostic", $"{testCase}.al")) | ||
.ConfigureAwait(false); | ||
|
||
var fixture = RoslynFixtureFactory.Create<Rule0044AnalyzeTransferFields>(); | ||
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0044AnalyzeTransferFields.Id); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
BusinessCentral.LinterCop.Test/TestCases/Rule0044/HasDiagnostic/1.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,30 @@ | ||
tableextension 50100 Customer extends Customer | ||
{ | ||
fields | ||
{ | ||
[|field(50100; MyField; Code[20]) { }|] | ||
} | ||
} | ||
|
||
tableextension 50101 Contact extends Contact | ||
{ | ||
fields | ||
{ | ||
field(50100; MyField; Integer) { } | ||
} | ||
} | ||
|
||
table 18 Customer | ||
{ | ||
fields | ||
{ | ||
field(1; "No."; Code[20]) { } | ||
} | ||
} | ||
table 5050 Contact | ||
{ | ||
fields | ||
{ | ||
field(1; "No."; Code[20]) { } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
BusinessCentral.LinterCop.Test/TestCases/Rule0044/HasDiagnostic/2.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,25 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
var | ||
MyTableA: Record MyTableA; | ||
MyTableB: Record MyTableB; | ||
begin | ||
[|MyTableA.TransferFields(MyTableB)|]; | ||
end; | ||
} | ||
|
||
table 50100 MyTableA | ||
{ | ||
fields | ||
{ | ||
field(1; "No."; Code[10]) { } | ||
} | ||
} | ||
table 50101 MyTableB | ||
{ | ||
fields | ||
{ | ||
field(1; "No."; Code[20]) { } | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
BusinessCentral.LinterCop.Test/TestCases/Rule0044/NoDiagnostic/1.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,30 @@ | ||
tableextension 50100 Customer extends Customer | ||
{ | ||
fields | ||
{ | ||
[|field(50100; MyField; Integer) { }|] | ||
} | ||
} | ||
|
||
tableextension 50101 Contact extends Contact | ||
{ | ||
fields | ||
{ | ||
field(50100; MyField; Integer) { } | ||
} | ||
} | ||
|
||
table 18 Customer | ||
{ | ||
fields | ||
{ | ||
field(1; "No."; Code[20]) { } | ||
} | ||
} | ||
table 5050 Contact | ||
{ | ||
fields | ||
{ | ||
field(1; "No."; Code[20]) { } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
BusinessCentral.LinterCop.Test/TestCases/Rule0044/NoDiagnostic/2.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,25 @@ | ||
codeunit 50100 MyCodeunit | ||
{ | ||
procedure MyProcedure() | ||
var | ||
MyTableA: Record MyTableA; | ||
MyTableB: Record MyTableB; | ||
begin | ||
[|MyTableA.TransferFields(MyTableB)|]; | ||
end; | ||
} | ||
|
||
table 50100 MyTableA | ||
{ | ||
fields | ||
{ | ||
field(1; "No."; Code[20]) { } | ||
} | ||
} | ||
table 50101 MyTableB | ||
{ | ||
fields | ||
{ | ||
field(1; "No."; Code[20]) { } | ||
} | ||
} |
Oops, something went wrong.