public void ShouldCreateValidInterface() { var source = TestData.ValidSource; var generatorDiagnostics = GeneratorTestFactory.GetDiagnostics(source); generatorDiagnostics.Any(x => x.Severity == DiagnosticSeverity.Error).ShouldBeFalse(); }
public void ShouldCreateValidInterface() { var source = TestData.ValidSource; var generatedSourceCodeText = GeneratorTestFactory.GetGeneratedSourceCodeText(source); generatedSourceCodeText.ShouldBe(TestData.ValidGeneratedSourceCodeText); }
public void ShouldFailGeneratorWithCode_CSBLJS0002_BecauseTaskWithGenericType() { var source = TestData.InvalidSourceWrongReturnTypeT; var generatorDiagnostics = GeneratorTestFactory.GetDiagnostics(source); var(expectedErrorCode, _) = DiagnosticTypesTuples.MethodInvalidReturnTypeErrorTuple; generatorDiagnostics.Any(diagnostic => { return(diagnostic.Id == expectedErrorCode && diagnostic.GetMessage() == "Method 'ShowNamePrompt' in interface 'BlazorJSInterop.SourceGenerator.Test.TestData.IJSService' does not have valid return type. It should be 'System.Threading.Tasks.ValueTask'"); }).ShouldBeTrue(); }
public void ShouldFailGeneratorWithCode_CSBLJS0001() { var source = TestData.InvalidSourceMissingMethodAttribute; var generatorDiagnostics = GeneratorTestFactory.GetDiagnostics(source); var(expectedErrorCode, _) = DiagnosticTypesTuples.MethodWithoutAttributeErrorTuple; generatorDiagnostics.Any(diagnostic => { return(diagnostic.Id == expectedErrorCode && diagnostic.GetMessage() == "Method 'ShowHelloWorldAlert' in interface 'BlazorJSInterop.SourceGenerator.Test.TestData.IJSService' does not have attribute 'BlazorJSInterop.SourceGenerator.Attributes.BlazorJSInteropMethodAttribute'"); }).ShouldBeTrue(); }