-
Notifications
You must be signed in to change notification settings - Fork 4
/
AutoDeconstructable_AT.cs
40 lines (27 loc) · 1.41 KB
/
AutoDeconstructable_AT.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using ApprovalTests;
using ApprovalTests.Reporters;
using ApprovalTests.Writers;
using Nemesis.TextParsers.CodeGen.Deconstructable;
using static Nemesis.TextParsers.CodeGen.Tests.CodeGenUtils;
namespace Nemesis.TextParsers.CodeGen.Tests.ApprovalTests;
[TestFixture, Explicit]
[UseReporter(typeof(VisualStudioReporter), typeof(ClipboardReporter))]
internal class AutoDeconstructable_AT
{
[Test] public void ApprovalTestsRecord() => RunCase("Record");
[Test] public void ApprovalTestsStruct() => RunCase("ReadOnlyStruct");
[Test] public void ApprovalTestsLarge() => RunCase("Large");
[Test] public void ApprovalTestsComplexTypes() => RunCase("ComplexType");
[Test] public void ApprovalTestsSimpleWrapperStruct() => RunCase("SimpleWrapperStruct");
private static void RunCase(string index)
{
var (_, source, _) = AutoDeconstructableTests.GetAutoDeconstructableCases().SingleOrDefault(t => t.name == index);
Assert.That(source, Is.Not.Null);
Assert.That(source, Is.Not.Empty);
var compilation = CreateValidCompilation(source);
var generatedTrees = GetGeneratedTreesOnly(compilation, new AutoDeconstructableGenerator(), AutoDeconstructableGenerator.ATTRIBUTE_NAME);
var actual = ScrubGeneratorComments(generatedTrees.Single());
actual = NormalizeNewLines(actual);
Approvals.Verify(WriterFactory.CreateTextWriter(actual, "cs"));
}
}