Skip to content

Commit

Permalink
added source changed test
Browse files Browse the repository at this point in the history
  • Loading branch information
jkurdek committed Apr 26, 2024
1 parent 7d1b69c commit bb8c8cf
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ public void DoesNotRegenerateCodeWhenNoChanges()
RunGeneratorOnTwoSourcesAndVerifyResults(source, source, reason => Assert.True(reason == IncrementalStepRunReason.Unchanged || reason == IncrementalStepRunReason.Cached));
}

[Fact]
public void DoesRegenerateCodeWhenSourceChanged()
{
var source = """
using Microsoft.Maui.Controls;
var label = new Label();
label.SetBinding(Label.RotationProperty, static (string s) => s.Length);
""";

var newSource = """
using Microsoft.Maui.Controls;
var label = new Label();
label.SetBinding(Label.RotationProperty, static (string s) => s);
""";

RunGeneratorOnTwoSourcesAndVerifyResults(source, newSource, reason => Assert.True(reason == IncrementalStepRunReason.Modified));
}

[Fact]
public void DoesRegenerateCodeWhenNewCodeInsertedAbove()
{
Expand Down Expand Up @@ -102,6 +120,7 @@ private static void RunGeneratorOnTwoSourcesAndVerifyResults(string source1, str
.SelectMany(x => x.Outputs)
.Select(x => x.Reason);

Console.WriteLine(string.Join(", ", newReasons));
Assert.All(newReasons, reason => assert(reason));
}

Expand Down

0 comments on commit bb8c8cf

Please sign in to comment.