33using System . Linq ;
44using Microsoft . CodeAnalysis ;
55using Microsoft . Maui . Controls . SourceGen ;
6- using NUnit . Framework ;
6+ using Xunit ;
77
88using static Microsoft . Maui . Controls . Xaml . UnitTests . SourceGen . SourceGeneratorDriver ;
99
@@ -14,7 +14,7 @@ public class SourceGenXamlTests : SourceGenTestsBase
1414 private record AdditionalXamlFile ( string Path , string Content , string ? RelativePath = null , string ? TargetPath = null , string ? ManifestResourceName = null , string ? TargetFramework = null )
1515 : AdditionalFile ( Text : SourceGeneratorDriver . ToAdditionalText ( Path , Content ) , Kind : "Xaml" , RelativePath : RelativePath ?? Path , TargetPath : TargetPath , ManifestResourceName : ManifestResourceName , TargetFramework : TargetFramework ) ;
1616
17- [ Test ]
17+ [ Fact ]
1818 public void TestCodeBehindGenerator_BasicXaml ( )
1919 {
2020 var xaml =
@@ -30,14 +30,14 @@ public void TestCodeBehindGenerator_BasicXaml()
3030 var compilation = SourceGeneratorDriver . CreateMauiCompilation ( ) ;
3131 var result = SourceGeneratorDriver . RunGenerator < CodeBehindGenerator > ( compilation , new AdditionalXamlFile ( "Test.xaml" , xaml ) ) ;
3232
33- Assert . IsFalse ( result . Diagnostics . Any ( ) ) ;
33+ Assert . False ( result . Diagnostics . Any ( ) ) ;
3434
3535 var generated = result . Results . Single ( ) . GeneratedSources . Single ( ) . SourceText . ToString ( ) ;
3636
37- Assert . IsTrue ( generated . Contains ( "Microsoft.Maui.Controls.Button MyButton" , StringComparison . Ordinal ) ) ;
37+ Assert . Contains ( "Microsoft.Maui.Controls.Button MyButton" , generated , StringComparison . Ordinal ) ;
3838 }
3939
40- [ Test ]
40+ [ Fact ]
4141 public void TestCodeBehindGenerator_LocalXaml ( )
4242 {
4343 var xaml =
@@ -54,14 +54,14 @@ public void TestCodeBehindGenerator_LocalXaml()
5454 var compilation = SourceGeneratorDriver . CreateMauiCompilation ( ) ;
5555 var result = SourceGeneratorDriver . RunGenerator < CodeBehindGenerator > ( compilation , new AdditionalXamlFile ( "Test.xaml" , xaml ) ) ;
5656
57- Assert . IsFalse ( result . Diagnostics . Any ( ) ) ;
57+ Assert . False ( result . Diagnostics . Any ( ) ) ;
5858
5959 var generated = result . Results . Single ( ) . GeneratedSources . Single ( ) . SourceText . ToString ( ) ;
6060
61- Assert . IsTrue ( generated . Contains ( "Test.TestControl MyTestControl" , StringComparison . Ordinal ) ) ;
61+ Assert . Contains ( "Test.TestControl MyTestControl" , generated , StringComparison . Ordinal ) ;
6262 }
6363
64- [ Test ]
64+ [ Fact ]
6565 public void TestCodeBehindGenerator_CompilationClone ( )
6666 {
6767 var xaml =
@@ -83,8 +83,8 @@ public void TestCodeBehindGenerator_CompilationClone()
8383 var output1 = result1 . GeneratedSources . Single ( ) . SourceText . ToString ( ) ;
8484 var output2 = result2 . GeneratedSources . Single ( ) . SourceText . ToString ( ) ;
8585
86- Assert . IsTrue ( result1 . TrackedSteps . All ( s => s . Value . Single ( ) . Outputs . Single ( ) . Reason == IncrementalStepRunReason . New ) ) ;
87- Assert . AreEqual ( output1 , output2 ) ;
86+ Assert . True ( result1 . TrackedSteps . All ( s => s . Value . Single ( ) . Outputs . Single ( ) . Reason == IncrementalStepRunReason . New ) ) ;
87+ Assert . Equal ( output1 , output2 ) ;
8888
8989 ( GeneratorDriver , Compilation ) ApplyChanges ( GeneratorDriver driver , Compilation compilation )
9090 {
@@ -104,7 +104,7 @@ public void TestCodeBehindGenerator_CompilationClone()
104104 VerifyStepRunReasons ( result2 , expectedReasons ) ;
105105 }
106106
107- [ Test ]
107+ [ Fact ]
108108 public void TestCodeBehindGenerator_ReferenceAdded ( )
109109 {
110110 var xaml =
@@ -126,8 +126,8 @@ public void TestCodeBehindGenerator_ReferenceAdded()
126126 var output1 = result1 . GeneratedSources . Single ( ) . SourceText . ToString ( ) ;
127127 var output2 = result2 . GeneratedSources . Single ( ) . SourceText . ToString ( ) ;
128128
129- Assert . IsTrue ( result1 . TrackedSteps . All ( s => s . Value . Single ( ) . Outputs . Single ( ) . Reason == IncrementalStepRunReason . New ) ) ;
130- Assert . AreEqual ( output1 , output2 ) ;
129+ Assert . True ( result1 . TrackedSteps . All ( s => s . Value . Single ( ) . Outputs . Single ( ) . Reason == IncrementalStepRunReason . New ) ) ;
130+ Assert . Equal ( output1 , output2 ) ;
131131
132132 ( GeneratorDriver , Compilation ) ApplyChanges ( GeneratorDriver driver , Compilation compilation )
133133 {
@@ -147,7 +147,7 @@ public void TestCodeBehindGenerator_ReferenceAdded()
147147 VerifyStepRunReasons ( result2 , expectedReasons ) ;
148148 }
149149
150- [ Test ]
150+ [ Fact ]
151151 public void TestCodeBehindGenerator_ModifiedXaml ( )
152152 {
153153 var xaml =
@@ -180,13 +180,13 @@ public void TestCodeBehindGenerator_ModifiedXaml()
180180 var output1 = result1 . GeneratedSources . Single ( ) . SourceText . ToString ( ) ;
181181 var output2 = result2 . GeneratedSources . Single ( ) . SourceText . ToString ( ) ;
182182
183- Assert . IsTrue ( result1 . TrackedSteps . All ( s => s . Value . Single ( ) . Outputs . Single ( ) . Reason == IncrementalStepRunReason . New ) ) ;
184- Assert . AreNotEqual ( output1 , output2 ) ;
183+ Assert . True ( result1 . TrackedSteps . All ( s => s . Value . Single ( ) . Outputs . Single ( ) . Reason == IncrementalStepRunReason . New ) ) ;
184+ Assert . NotEqual ( output1 , output2 ) ;
185185
186- Assert . IsTrue ( output1 . Contains ( "MyButton" , StringComparison . Ordinal ) ) ;
187- Assert . IsFalse ( output1 . Contains ( "MyButton2" , StringComparison . Ordinal ) ) ;
188- Assert . IsTrue ( output2 . Contains ( "MyButton" , StringComparison . Ordinal ) ) ;
189- Assert . IsTrue ( output2 . Contains ( "MyButton2" , StringComparison . Ordinal ) ) ;
186+ Assert . Contains ( "MyButton" , output1 , StringComparison . Ordinal ) ;
187+ Assert . DoesNotContain ( "MyButton2" , output1 , StringComparison . Ordinal ) ;
188+ Assert . Contains ( "MyButton" , output2 , StringComparison . Ordinal ) ;
189+ Assert . Contains ( "MyButton2" , output2 , StringComparison . Ordinal ) ;
190190
191191 ( GeneratorDriver , Compilation ) ApplyChanges ( GeneratorDriver driver , Compilation compilation )
192192 {
0 commit comments