|
1 |
| -#pragma warning disable IDE0058 // Expression value is never used |
2 |
| - |
3 |
| -namespace UnitTests; |
4 |
| - |
5 |
| -public class EventsTests |
6 |
| -{ |
7 |
| - private const string SnapshotsDirectory = "Snapshots/Events"; |
8 |
| - |
9 |
| - [Fact] |
10 |
| - public async Task SimpleEvents_AssertResults() |
11 |
| - { |
12 |
| - var source = """ |
13 |
| - using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
14 |
| - namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
15 |
| -
|
16 |
| - [GenerateInterfaceAttribute] |
17 |
| - public class MyClass : IMyClass |
18 |
| - { |
19 |
| - public event EventHandler? MyEvent; |
20 |
| -
|
21 |
| - public void HandEvents() |
22 |
| - { |
23 |
| - MyEvent?.Invoke(this, EventArgs.Empty); |
24 |
| - } |
25 |
| - } |
26 |
| - """; |
27 |
| - |
28 |
| - await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
29 |
| - } |
30 |
| - |
31 |
| - [Fact] |
32 |
| - public async Task ActionEvents_AssertResults() |
33 |
| - { |
34 |
| - var source = """ |
35 |
| - using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
36 |
| - namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
37 |
| -
|
38 |
| - [GenerateInterfaceAttribute] |
39 |
| - public class MyClass : IMyClass |
40 |
| - { |
41 |
| - public event Action<int>? MyEvent1; |
42 |
| - public event Action<int, string, double, float, NonDemoClass1>? MyEvent2; |
43 |
| -
|
44 |
| - public void HandEvents() |
45 |
| - { |
46 |
| - MyEvent1?.Invoke(1); |
47 |
| - MyEvent2?.Invoke(1, "2", 3.0, 4.0f, new NonDemoClass1()); |
48 |
| - } |
49 |
| - } |
50 |
| - """; |
51 |
| - |
52 |
| - await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
53 |
| - } |
54 |
| - |
55 |
| - [Fact] |
56 |
| - public async Task CustomEvents_AssertResults() |
57 |
| - { |
58 |
| - var source = """ |
59 |
| - using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
60 |
| - namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
61 |
| -
|
62 |
| - public delegate void MyEventDelegate(object sender, EventArgs e); |
| 1 | +//#pragma warning disable IDE0058 // Expression value is never used |
| 2 | + |
| 3 | +//namespace UnitTests; |
| 4 | + |
| 5 | +//public class EventsTests |
| 6 | +//{ |
| 7 | +// private const string SnapshotsDirectory = "Snapshots/Events"; |
| 8 | + |
| 9 | +// [Fact] |
| 10 | +// public async Task SimpleEvents_AssertResults() |
| 11 | +// { |
| 12 | +// var source = """ |
| 13 | +// using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
| 14 | +// namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
| 15 | + |
| 16 | +// [GenerateInterfaceAttribute] |
| 17 | +// public class MyClass : IMyClass |
| 18 | +// { |
| 19 | +// public event EventHandler? MyEvent; |
| 20 | + |
| 21 | +// public void HandEvents() |
| 22 | +// { |
| 23 | +// MyEvent?.Invoke(this, EventArgs.Empty); |
| 24 | +// } |
| 25 | +// } |
| 26 | +// """; |
| 27 | + |
| 28 | +// await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
| 29 | +// } |
| 30 | + |
| 31 | +// [Fact] |
| 32 | +// public async Task ActionEvents_AssertResults() |
| 33 | +// { |
| 34 | +// var source = """ |
| 35 | +// using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
| 36 | +// namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
| 37 | + |
| 38 | +// [GenerateInterfaceAttribute] |
| 39 | +// public class MyClass : IMyClass |
| 40 | +// { |
| 41 | +// public event Action<int>? MyEvent1; |
| 42 | +// public event Action<int, string, double, float, NonDemoClass1>? MyEvent2; |
| 43 | + |
| 44 | +// public void HandEvents() |
| 45 | +// { |
| 46 | +// MyEvent1?.Invoke(1); |
| 47 | +// MyEvent2?.Invoke(1, "2", 3.0, 4.0f, new NonDemoClass1()); |
| 48 | +// } |
| 49 | +// } |
| 50 | +// """; |
| 51 | + |
| 52 | +// await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
| 53 | +// } |
| 54 | + |
| 55 | +// [Fact] |
| 56 | +// public async Task CustomEvents_AssertResults() |
| 57 | +// { |
| 58 | +// var source = """ |
| 59 | +// using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
| 60 | +// namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
| 61 | + |
| 62 | +// public delegate void MyEventDelegate(object sender, EventArgs e); |
63 | 63 |
|
64 |
| - [GenerateInterfaceAttribute] |
65 |
| - public class MyClass : IMyClass |
66 |
| - { |
67 |
| - public event MyEventDelegate MyEvent; |
| 64 | +// [GenerateInterfaceAttribute] |
| 65 | +// public class MyClass : IMyClass |
| 66 | +// { |
| 67 | +// public event MyEventDelegate MyEvent; |
68 | 68 |
|
69 |
| - public void HandEvents() |
70 |
| - { |
71 |
| - MyEvent?.Invoke(this, EventArgs.Empty); |
72 |
| - } |
73 |
| - } |
74 |
| - """; |
75 |
| - |
76 |
| - await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
77 |
| - } |
78 |
| - |
79 |
| - |
80 |
| - [Fact] |
81 |
| - public async Task WithExcludedEvents_AssertResults() |
82 |
| - { |
83 |
| - var source = """ |
84 |
| - using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
85 |
| - namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
86 |
| -
|
87 |
| - [GenerateInterfaceAttribute] |
88 |
| - public class MyClass : IMyClass |
89 |
| - { |
90 |
| - public event EventHandler? MyEvent; |
| 69 | +// public void HandEvents() |
| 70 | +// { |
| 71 | +// MyEvent?.Invoke(this, EventArgs.Empty); |
| 72 | +// } |
| 73 | +// } |
| 74 | +// """; |
| 75 | + |
| 76 | +// await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
| 77 | +// } |
| 78 | + |
| 79 | + |
| 80 | +// [Fact] |
| 81 | +// public async Task WithExcludedEvents_AssertResults() |
| 82 | +// { |
| 83 | +// var source = """ |
| 84 | +// using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
| 85 | +// namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
| 86 | + |
| 87 | +// [GenerateInterfaceAttribute] |
| 88 | +// public class MyClass : IMyClass |
| 89 | +// { |
| 90 | +// public event EventHandler? MyEvent; |
91 | 91 |
|
92 |
| - [ExcludeFromGeneratedInterface] |
93 |
| - public event EventHandler? MyEvent2; |
| 92 | +// [ExcludeFromGeneratedInterface] |
| 93 | +// public event EventHandler? MyEvent2; |
94 | 94 |
|
95 |
| - [ExcludeFromGeneratedInterfaceAttribute] |
96 |
| - public event EventHandler? MyEvent3; |
97 |
| -
|
98 |
| - public void HandEvents() |
99 |
| - { |
100 |
| - MyEvent?.Invoke(this, EventArgs.Empty); |
101 |
| - MyEvent2?.Invoke(this, EventArgs.Empty); |
102 |
| - MyEvent3?.Invoke(this, EventArgs.Empty); |
103 |
| - } |
104 |
| - } |
105 |
| - """; |
106 |
| - |
107 |
| - await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
108 |
| - } |
109 |
| - |
110 |
| - [Fact] |
111 |
| - public async Task EventWithComments_AssertCommentsAppearInGeneratedInterfaceEvents() |
112 |
| - { |
113 |
| - var source = """ |
114 |
| - using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
115 |
| - namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
116 |
| -
|
117 |
| - [GenerateInterfaceAttribute] |
118 |
| - public class MyClass : IMyClass |
119 |
| - { |
120 |
| - /// <summary> |
121 |
| - /// Some comments for my event |
122 |
| - /// </summary> |
123 |
| - public event EventHandler? MyEvent; |
124 |
| -
|
125 |
| - /// Single line tripple comment that will appear in generated interface |
126 |
| - public event EventHandler? MyEvent2; |
127 |
| -
|
128 |
| - //Single line comment that won't appear in generated interface |
129 |
| - public event EventHandler? MyEvent3; |
| 95 | +// [ExcludeFromGeneratedInterfaceAttribute] |
| 96 | +// public event EventHandler? MyEvent3; |
| 97 | + |
| 98 | +// public void HandEvents() |
| 99 | +// { |
| 100 | +// MyEvent?.Invoke(this, EventArgs.Empty); |
| 101 | +// MyEvent2?.Invoke(this, EventArgs.Empty); |
| 102 | +// MyEvent3?.Invoke(this, EventArgs.Empty); |
| 103 | +// } |
| 104 | +// } |
| 105 | +// """; |
| 106 | + |
| 107 | +// await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
| 108 | +// } |
| 109 | + |
| 110 | +// [Fact] |
| 111 | +// public async Task EventWithComments_AssertCommentsAppearInGeneratedInterfaceEvents() |
| 112 | +// { |
| 113 | +// var source = """ |
| 114 | +// using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
| 115 | +// namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
| 116 | + |
| 117 | +// [GenerateInterfaceAttribute] |
| 118 | +// public class MyClass : IMyClass |
| 119 | +// { |
| 120 | +// /// <summary> |
| 121 | +// /// Some comments for my event |
| 122 | +// /// </summary> |
| 123 | +// public event EventHandler? MyEvent; |
| 124 | + |
| 125 | +// /// Single line tripple comment that will appear in generated interface |
| 126 | +// public event EventHandler? MyEvent2; |
| 127 | + |
| 128 | +// //Single line comment that won't appear in generated interface |
| 129 | +// public event EventHandler? MyEvent3; |
130 | 130 |
|
131 |
| - public void HandEvents() |
132 |
| - { |
133 |
| - MyEvent?.Invoke(this, EventArgs.Empty); |
134 |
| - MyEvent2?.Invoke(this, EventArgs.Empty); |
135 |
| - } |
136 |
| - } |
137 |
| - """; |
138 |
| - |
139 |
| - await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
140 |
| - } |
141 |
| - |
142 |
| - [Fact] |
143 |
| - public async Task ImplementsInterfaceEvent_AssertEventNotInGeneratedInterface() |
144 |
| - { |
145 |
| - var source = """ |
146 |
| - using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
147 |
| - namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
148 |
| -
|
149 |
| - public interface IMyInterface |
150 |
| - { |
151 |
| - event EventHandler? MyInterfaceEvent; |
152 |
| - } |
153 |
| -
|
154 |
| - [GenerateInterfaceAttribute] |
155 |
| - public class MyClass : IMyClass, IMyInterface |
156 |
| - { |
157 |
| - public event EventHandler? MyInterfaceEvent; |
158 |
| - public event EventHandler? MyEvent; |
159 |
| -
|
160 |
| - public void HandEvents() |
161 |
| - { |
162 |
| - MyEvent?.Invoke(this, EventArgs.Empty); |
163 |
| - } |
164 |
| - } |
165 |
| - """; |
166 |
| - |
167 |
| - await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
168 |
| - } |
169 |
| -} |
170 |
| -#pragma warning restore IDE0058 // Expression value is never used |
| 131 | +// public void HandEvents() |
| 132 | +// { |
| 133 | +// MyEvent?.Invoke(this, EventArgs.Empty); |
| 134 | +// MyEvent2?.Invoke(this, EventArgs.Empty); |
| 135 | +// } |
| 136 | +// } |
| 137 | +// """; |
| 138 | + |
| 139 | +// await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
| 140 | +// } |
| 141 | + |
| 142 | +// [Fact] |
| 143 | +// public async Task ImplementsInterfaceEvent_AssertEventNotInGeneratedInterface() |
| 144 | +// { |
| 145 | +// var source = """ |
| 146 | +// using ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes; |
| 147 | +// namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.SampleClasses; |
| 148 | + |
| 149 | +// public interface IMyInterface |
| 150 | +// { |
| 151 | +// event EventHandler? MyInterfaceEvent; |
| 152 | +// } |
| 153 | + |
| 154 | +// [GenerateInterfaceAttribute] |
| 155 | +// public class MyClass : IMyClass, IMyInterface |
| 156 | +// { |
| 157 | +// public event EventHandler? MyInterfaceEvent; |
| 158 | +// public event EventHandler? MyEvent; |
| 159 | + |
| 160 | +// public void HandEvents() |
| 161 | +// { |
| 162 | +// MyEvent?.Invoke(this, EventArgs.Empty); |
| 163 | +// } |
| 164 | +// } |
| 165 | +// """; |
| 166 | + |
| 167 | +// await TestHelper.VerifyAsync(source, SnapshotsDirectory); |
| 168 | +// } |
| 169 | +//} |
| 170 | +//#pragma warning restore IDE0058 // Expression value is never used |
0 commit comments