@@ -851,6 +851,35 @@ public void TestAnalyzeRequiredOptionalProperties()
851
851
AssertSchemaEqual ( expected , schema ) ;
852
852
}
853
853
854
+ [ Theory ]
855
+ [ InlineData ( "123test" , "Package name must start with a letter and contain only letters, numbers, hyphens, and underscores" ) ]
856
+ [ InlineData ( "test!" , "Package name must start with a letter and contain only letters, numbers, hyphens, and underscores" ) ]
857
+ [ InlineData ( "test space" , "Package name must start with a letter and contain only letters, numbers, hyphens, and underscores" ) ]
858
+ [ InlineData ( "" , "Package name cannot be empty or whitespace" ) ]
859
+ [ InlineData ( " " , "Package name cannot be empty or whitespace" ) ]
860
+ [ InlineData ( null , "Package name cannot be empty or whitespace" ) ]
861
+ public void TestInvalidPackageNames ( string ? name , string expectedError )
862
+ {
863
+ var metadata = new Metadata ( name ! ) ;
864
+ var exception = Assert . Throws < ArgumentException > ( ( ) =>
865
+ ComponentAnalyzer . GenerateSchema ( metadata , typeof ( SelfSignedCertificate ) ) ) ;
866
+
867
+ Assert . Equal ( $ "{ expectedError } (Parameter 'metadata')", exception . Message ) ;
868
+ }
869
+
870
+ [ Theory ]
871
+ [ InlineData ( "test" ) ]
872
+ [ InlineData ( "test-package" ) ]
873
+ [ InlineData ( "test_package" ) ]
874
+ [ InlineData ( "test123" ) ]
875
+ [ InlineData ( "myPackage" ) ]
876
+ public void TestValidPackageNames ( string name )
877
+ {
878
+ var metadata = new Metadata ( name ) ;
879
+ var schema = ComponentAnalyzer . GenerateSchema ( metadata , typeof ( SelfSignedCertificate ) ) ;
880
+ Assert . Equal ( name , schema . Name ) ;
881
+ }
882
+
854
883
private readonly Metadata _metadata = new Metadata ( "my-component" , "0.0.1" , "Test package" ) ;
855
884
856
885
private static PackageSpec CreateBasePackageSpec (
0 commit comments