Skip to content

Commit

Permalink
fix tests for PropertyChangedGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
floribe2000 committed Oct 14, 2023
1 parent e1a84b9 commit 039ad41
Showing 1 changed file with 4 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Testing.Verifiers;
using WoWsShipBuilder.Data.Generator.PropertyChangedGenerator;

Expand Down Expand Up @@ -74,24 +73,19 @@ public partial class TestViewModel
public string Test
{
get => this.test;
set => global::ReactiveUI.IReactiveObjectExtensions.RaiseAndSetIfChanged(this, ref this.test, value);
set => global::{|CS0400:ReactiveUI|}.IReactiveObjectExtensions.RaiseAndSetIfChanged(this, ref this.test, value);
}
}
}

""";

var expectedDiagnostic = DiagnosticResult.CompilerError("CS0400")
.WithSpan(@"WoWsShipBuilder.Data.Generator\WoWsShipBuilder.Data.Generator.PropertyChangedGenerator.PropertyChangedSourceGenerator\Test.TestViewModel_test.g.cs", 10, 28, 10, 38)
.WithArguments("ReactiveUI");

await new CSharpSourceGeneratorTest<PropertyChangedSourceGenerator, NUnitVerifier>
{
TestState =
{
Sources = { source, AttributeClass },
GeneratedSources = { (typeof(PropertyChangedSourceGenerator), "Test.TestViewModel_test.g.cs", expected) },
ExpectedDiagnostics = { expectedDiagnostic },
},
}.RunAsync();
}
Expand Down Expand Up @@ -122,24 +116,19 @@ public partial class TestViewModel
public string? Test
{
get => this.test;
set => global::ReactiveUI.IReactiveObjectExtensions.RaiseAndSetIfChanged(this, ref this.test, value);
set => global::{|CS0400:ReactiveUI|}.IReactiveObjectExtensions.RaiseAndSetIfChanged(this, ref this.test, value);
}
}
}

""";

var expectedDiagnostic = DiagnosticResult.CompilerError("CS0400")
.WithSpan(@"WoWsShipBuilder.Data.Generator\WoWsShipBuilder.Data.Generator.PropertyChangedGenerator.PropertyChangedSourceGenerator\Test.TestViewModel_test.g.cs", 10, 28, 10, 38)
.WithArguments("ReactiveUI");

await new CSharpSourceGeneratorTest<PropertyChangedSourceGenerator, NUnitVerifier>
{
TestState =
{
Sources = { source, AttributeClass },
GeneratedSources = { (typeof(PropertyChangedSourceGenerator), "Test.TestViewModel_test.g.cs", expected) },
ExpectedDiagnostics = { expectedDiagnostic },
},
}.RunAsync();
}
Expand Down Expand Up @@ -170,24 +159,19 @@ public partial class TestViewModel
public int? Test
{
get => this.test;
set => global::ReactiveUI.IReactiveObjectExtensions.RaiseAndSetIfChanged(this, ref this.test, value);
set => global::{|CS0400:ReactiveUI|}.IReactiveObjectExtensions.RaiseAndSetIfChanged(this, ref this.test, value);
}
}
}

""";

var expectedDiagnostic = DiagnosticResult.CompilerError("CS0400")
.WithSpan(@"WoWsShipBuilder.Data.Generator\WoWsShipBuilder.Data.Generator.PropertyChangedGenerator.PropertyChangedSourceGenerator\Test.TestViewModel_test.g.cs", 10, 28, 10, 38)
.WithArguments("ReactiveUI");

await new CSharpSourceGeneratorTest<PropertyChangedSourceGenerator, NUnitVerifier>
{
TestState =
{
Sources = { source, AttributeClass },
GeneratedSources = { (typeof(PropertyChangedSourceGenerator), "Test.TestViewModel_test.g.cs", expected) },
ExpectedDiagnostics = { expectedDiagnostic },
},
}.RunAsync();
}
Expand Down Expand Up @@ -219,24 +203,19 @@ public partial class TestViewModel
public global::System.Collections.Generic.List<string?> Test
{
get => this.test;
set => global::ReactiveUI.IReactiveObjectExtensions.RaiseAndSetIfChanged(this, ref this.test, value);
set => global::{|CS0400:ReactiveUI|}.IReactiveObjectExtensions.RaiseAndSetIfChanged(this, ref this.test, value);
}
}
}

""";

var expectedDiagnostic = DiagnosticResult.CompilerError("CS0400")
.WithSpan(@"WoWsShipBuilder.Data.Generator\WoWsShipBuilder.Data.Generator.PropertyChangedGenerator.PropertyChangedSourceGenerator\Test.TestViewModel_test.g.cs", 10, 28, 10, 38)
.WithArguments("ReactiveUI");

await new CSharpSourceGeneratorTest<PropertyChangedSourceGenerator, NUnitVerifier>
{
TestState =
{
Sources = { source, AttributeClass },
GeneratedSources = { (typeof(PropertyChangedSourceGenerator), "Test.TestViewModel_test.g.cs", expected) },
ExpectedDiagnostics = { expectedDiagnostic },
},
}.RunAsync();
}
Expand Down

0 comments on commit 039ad41

Please sign in to comment.