Skip to content

Commit b7f121c

Browse files
committed
Update unit tests for the two new analyzers
1 parent 1b02376 commit b7f121c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Test_SourceGeneratorsDiagnostics.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,27 +1337,27 @@ public partial class SampleViewModel : ObservableValidator
13371337
}
13381338

13391339
[TestMethod]
1340-
public void InvalidTypeForNotifyPropertyChangedRecipientsError()
1340+
public async Task InvalidTypeForNotifyPropertyChangedRecipientsError()
13411341
{
13421342
string source = """
13431343
using CommunityToolkit.Mvvm.ComponentModel;
13441344
13451345
namespace MyApp
13461346
{
13471347
[NotifyPropertyChangedRecipients]
1348-
public partial class MyViewModel : ObservableObject
1348+
public partial class {|MVVMTK0027:MyViewModel|} : ObservableObject
13491349
{
13501350
[ObservableProperty]
13511351
public int number;
13521352
}
13531353
}
13541354
""";
13551355

1356-
VerifyGeneratedDiagnostics<ObservablePropertyGenerator>(source, "MVVMTK0027");
1356+
await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration<InvalidClassLevelNotifyPropertyChangedRecipientsAttributeAnalyzer>(source, LanguageVersion.CSharp8);
13571357
}
13581358

13591359
[TestMethod]
1360-
public void InvalidTypeForNotifyDataErrorInfoError()
1360+
public async Task InvalidTypeForNotifyDataErrorInfoError()
13611361
{
13621362
string source = """
13631363
using System.ComponentModel.DataAnnotations;
@@ -1366,16 +1366,13 @@ public void InvalidTypeForNotifyDataErrorInfoError()
13661366
namespace MyApp
13671367
{
13681368
[NotifyDataErrorInfo]
1369-
public partial class SampleViewModel : ObservableObject
1369+
public partial class {|MVVMTK0028:SampleViewModel|} : ObservableObject
13701370
{
1371-
[ObservableProperty]
1372-
[Required]
1373-
private string name;
13741371
}
13751372
}
13761373
""";
13771374

1378-
VerifyGeneratedDiagnostics<ObservablePropertyGenerator>(source, "MVVMTK0006", "MVVMTK0028");
1375+
await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration<InvalidClassLevelNotifyDataErrorInfoAttributeAnalyzer>(source, LanguageVersion.CSharp8);
13791376
}
13801377

13811378
[TestMethod]

0 commit comments

Comments
 (0)