@@ -440,6 +440,85 @@ public function getFiles(): array
440440 'scope ' => 'default ' ,
441441 'destination ' => '{{ spec.title | caseUcfirst }}/Enums/IEnum.cs ' ,
442442 'template ' => 'dotnet/Package/Enums/IEnum.cs.twig ' ,
443+ ],
444+ // Tests
445+ [
446+ 'scope ' => 'default ' ,
447+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/{{ spec.title | caseUcfirst }}.Tests.csproj ' ,
448+ 'template ' => 'dotnet/Package.Tests/Tests.csproj.twig ' ,
449+ ],
450+ [
451+ 'scope ' => 'default ' ,
452+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/.gitignore ' ,
453+ 'template ' => 'dotnet/Package.Tests/.gitignore ' ,
454+ ],
455+ [
456+ 'scope ' => 'default ' ,
457+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/ClientTests.cs ' ,
458+ 'template ' => 'dotnet/Package.Tests/ClientTests.cs.twig ' ,
459+ ],
460+ [
461+ 'scope ' => 'default ' ,
462+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/IDTests.cs ' ,
463+ 'template ' => 'dotnet/Package.Tests/IDTests.cs.twig ' ,
464+ ],
465+ [
466+ 'scope ' => 'default ' ,
467+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/PermissionTests.cs ' ,
468+ 'template ' => 'dotnet/Package.Tests/PermissionTests.cs.twig ' ,
469+ ],
470+ [
471+ 'scope ' => 'default ' ,
472+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/RoleTests.cs ' ,
473+ 'template ' => 'dotnet/Package.Tests/RoleTests.cs.twig ' ,
474+ ],
475+ [
476+ 'scope ' => 'default ' ,
477+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/QueryTests.cs ' ,
478+ 'template ' => 'dotnet/Package.Tests/QueryTests.cs.twig ' ,
479+ ],
480+ [
481+ 'scope ' => 'default ' ,
482+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/ExceptionTests.cs ' ,
483+ 'template ' => 'dotnet/Package.Tests/ExceptionTests.cs.twig ' ,
484+ ],
485+ [
486+ 'scope ' => 'default ' ,
487+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/UploadProgressTests.cs ' ,
488+ 'template ' => 'dotnet/Package.Tests/UploadProgressTests.cs.twig ' ,
489+ ],
490+ [
491+ 'scope ' => 'default ' ,
492+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/Models/InputFileTests.cs ' ,
493+ 'template ' => 'dotnet/Package.Tests/Models/InputFileTests.cs.twig ' ,
494+ ],
495+ [
496+ 'scope ' => 'default ' ,
497+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/Converters/ObjectToInferredTypesConverterTests.cs ' ,
498+ 'template ' => 'dotnet/Package.Tests/Converters/ObjectToInferredTypesConverterTests.cs.twig ' ,
499+ ],
500+ [
501+ 'scope ' => 'default ' ,
502+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/Converters/ValueClassConverterTests.cs ' ,
503+ 'template ' => 'dotnet/Package.Tests/Converters/ValueClassConverterTests.cs.twig ' ,
504+ ],
505+ // Tests for each definition (model)
506+ [
507+ 'scope ' => 'definition ' ,
508+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/Models/{{ definition.name | caseUcfirst | overrideIdentifier }}Tests.cs ' ,
509+ 'template ' => 'dotnet/Package.Tests/Models/ModelTests.cs.twig ' ,
510+ ],
511+ // Tests for each enum
512+ [
513+ 'scope ' => 'enum ' ,
514+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/Enums/{{ enum.name | caseUcfirst | overrideIdentifier }}Tests.cs ' ,
515+ 'template ' => 'dotnet/Package.Tests/Enums/EnumTests.cs.twig ' ,
516+ ],
517+ // Tests for each service
518+ [
519+ 'scope ' => 'service ' ,
520+ 'destination ' => '{{ spec.title | caseUcfirst }}.Tests/Services/{{service.name | caseUcfirst}}Tests.cs ' ,
521+ 'template ' => 'dotnet/Package.Tests/Services/ServiceTests.cs.twig ' ,
443522 ]
444523 ];
445524 }
@@ -463,6 +542,12 @@ public function getFilters(): array
463542 }
464543 return $ property ;
465544 }),
545+ new TwigFilter ('escapeCsString ' , function ($ value ) {
546+ if (is_string ($ value )) {
547+ return addcslashes ($ value , '\\" ' );
548+ }
549+ return $ value ;
550+ }),
466551 ];
467552 }
468553
@@ -495,6 +580,30 @@ public function getFunctions(): array
495580
496581 return $ result ;
497582 }, ['is_safe ' => ['html ' ]]),
583+ new TwigFunction ('test_item_type ' , function (array $ property ) {
584+ // For test templates: returns the item type for arrays without the List<> wrapper
585+ $ result = '' ;
586+
587+ if (isset ($ property ['sub_schema ' ]) && !empty ($ property ['sub_schema ' ])) {
588+ // Model type
589+ $ result = $ this ->toPascalCase ($ property ['sub_schema ' ]);
590+ $ result = 'Appwrite.Models. ' . $ result ;
591+ } elseif (isset ($ property ['enum ' ]) && !empty ($ property ['enum ' ])) {
592+ // Enum type
593+ $ enumName = $ property ['enumName ' ] ?? $ property ['name ' ];
594+ $ result = 'Appwrite.Enums. ' . $ this ->toPascalCase ($ enumName );
595+ } elseif (isset ($ property ['items ' ]) && isset ($ property ['items ' ]['type ' ])) {
596+ // Primitive array type (for definitions)
597+ $ result = $ this ->getTypeName ($ property ['items ' ]);
598+ } elseif (isset ($ property ['array ' ]) && isset ($ property ['array ' ]['type ' ])) {
599+ // Primitive array type (for method parameters)
600+ $ result = $ this ->getTypeName ($ property ['array ' ]);
601+ } else {
602+ $ result = 'object ' ;
603+ }
604+
605+ return $ result ;
606+ }, ['is_safe ' => ['html ' ]]),
498607 new TwigFunction ('property_name ' , function (array $ definition , array $ property ) {
499608 $ name = $ property ['name ' ];
500609 $ name = \str_replace ('$ ' , '' , $ name );
0 commit comments