public void TestCreateSeparatedSyntaxListWithPropertyAccessor()
        {
            // The call works for `SeparatedSyntaxList<T>`, not work for `SyntaxList<T>`.
            Assert.ThrowsAny <InvalidOperationException>(() => LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor <BlockSyntax, StatementSyntax>(typeof(BlockSyntax), nameof(BlockSyntax.Statements)));

            // The call *should* have been made with the first generic argument set to `BaseParameterListSyntax`
            // instead of `ParameterListSyntax`.
            Assert.ThrowsAny <InvalidOperationException>(() => LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor <ParameterListSyntax, ParameterSyntax>(typeof(BaseParameterListSyntax), nameof(BaseParameterListSyntax.Parameters)));
        }
        public void TestCreateSyntaxWithPropertyAccessor()
        {
            // The call *should* have been made with the first generic argument set to `BaseMethodDeclarationSyntax`
            // instead of `MethodDeclarationSyntax`.
            Assert.ThrowsAny <InvalidOperationException>(() => LightupHelpers.CreateSyntaxWithPropertyAccessor <MethodDeclarationSyntax, BlockSyntax>(typeof(BaseMethodDeclarationSyntax), nameof(BaseMethodDeclarationSyntax.Body)));

            // The call *should* have been made with the second generic argument set to `ArrowExpressionClauseSyntax`
            // instead of `BlockSyntax`.
            Assert.ThrowsAny <InvalidOperationException>(() => LightupHelpers.CreateSyntaxWithPropertyAccessor <MethodDeclarationSyntax, BlockSyntax>(typeof(MethodDeclarationSyntax), nameof(MethodDeclarationSyntax.ExpressionBody)));
        }
        public void TestCanAccessNonExistentMethodWithArgument(Type type)
        {
            var fallbackResult = new object();

            var accessor = LightupHelpers.CreateAccessorWithArgument <SyntaxNode, int, object?>(type, "parameterName", typeof(int), "argumentName", "NonExistentMethod", fallbackResult);

            Assert.NotNull(accessor);
            Assert.Same(fallbackResult, accessor(SyntaxFactory.AccessorList(), 0));
            Assert.Throws <NullReferenceException>(() => accessor(null !, 0));
        }
        public void TestCanAccessNonExistentSymbolProperty(Type type)
        {
            var fallbackResult = new object();

            var propertyAccessor = LightupHelpers.CreateSymbolPropertyAccessor <ISymbol, object>(type, "NonExistentProperty", fallbackResult);

            Assert.NotNull(propertyAccessor);
            Assert.Same(fallbackResult, propertyAccessor(new EmptySymbol()));
            Assert.Throws <NullReferenceException>(() => propertyAccessor(null !));

            var withPropertyAccessor = LightupHelpers.CreateSymbolWithPropertyAccessor <ISymbol, object>(type, "NonExistentProperty", fallbackResult);

            Assert.NotNull(withPropertyAccessor);
            Assert.NotNull(withPropertyAccessor(new EmptySymbol(), fallbackResult));
            Assert.ThrowsAny <NotSupportedException>(() => withPropertyAccessor(new EmptySymbol(), new object()));
            Assert.Throws <NullReferenceException>(() => withPropertyAccessor(null !, new object()));
        }
 public void TestCreateSeparatedSyntaxListPropertyAccessorValidateElementType()
 {
     // The call *should* have been made with the second generic argument set to `ParameterSyntax`
     // instead of `ArgumentSyntax`.
     Assert.ThrowsAny <InvalidOperationException>(() => LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor <BaseParameterListSyntax, ArgumentSyntax>(typeof(BaseParameterListSyntax), nameof(BaseParameterListSyntax.Parameters)));
 }
 public void TestCanWrapNullNode()
 {
     Assert.True(LightupHelpers.CanWrapNode(null, typeof(PatternSyntaxWrapper)));
 }