Пример #1
0
        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);
        }
Пример #3
0
        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();
        }
Пример #4
0
        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();
        }