@@ -29,6 +29,55 @@ private EndpointCollection CreateEndpointWithScript()
2929 return EndpointCollectionReader . ReadFromDirectory ( dc . DirectoryName ) ;
3030 }
3131
32+ private EndpointCollection CreateEndpointWithParam ( JSONParam jsonParam )
33+ {
34+ dc . AddFile ( "endpoint\\ endpoint.json" , JsonConvert . SerializeObject ( DataUtils . CreateScriptEndpoint ( "endpoint" , "script.csscript" ) ) ) ;
35+ dc . AddFile ( "endpoint\\ script.csscript" , "return GetParam(\" greeting\" ) + \" \" + GetParam(\" subject\" );" ) ;
36+ dc . AddFile ( "endpoint\\ params.json" , JsonConvert . SerializeObject ( new [ ] {
37+ jsonParam
38+ } ) ) ;
39+
40+ return EndpointCollectionReader . ReadFromDirectory ( dc . DirectoryName ) ;
41+ }
42+
43+ [ Fact ]
44+ public void MissingNameGivesError ( )
45+ {
46+ var ae = Assert . Throws < ArgumentException > ( ( ) => {
47+ CreateEndpointWithParam ( new JSONParam { @default = "foo" , description = "bar" } ) ;
48+ } ) ;
49+ Assert . Equal ( "Parameter missing name" , ae . Message ) ;
50+ }
51+
52+ [ Fact ]
53+ public void InvalidNameGivesError ( )
54+ {
55+ var ae = Assert . Throws < ArgumentException > ( ( ) => {
56+ CreateEndpointWithParam ( new JSONParam { name = "æøå" , @default = "foo" , description = "bar" } ) ;
57+ } ) ;
58+ Assert . Equal ( "Invalid parameter name: 'æøå'" , ae . Message ) ;
59+ }
60+
61+ [ Fact ]
62+ public void MissingDefaultGivesError ( )
63+ {
64+ var ae = Assert . Throws < ArgumentException > ( ( ) => {
65+ CreateEndpointWithParam ( new JSONParam { name = "abc" , description = "bar" } ) ;
66+ } ) ;
67+
68+ Assert . Equal ( "Missing default value for parameter 'abc'" , ae . Message ) ;
69+ }
70+
71+ [ Fact ]
72+ public void MissingDescriptionGivesError ( )
73+ {
74+ var ae = Assert . Throws < ArgumentException > ( ( ) => {
75+ CreateEndpointWithParam ( new JSONParam { name = "abc" , @default = "bar" } ) ;
76+ } ) ;
77+ Assert . Equal ( "Missing description for parameter 'abc'" , ae . Message ) ;
78+ }
79+
80+
3281 [ Fact ]
3382 public void ValueAndDefaultWorksAsExpected ( )
3483 {
@@ -41,6 +90,11 @@ public void ValueAndDefaultWorksAsExpected()
4190 Assert . False ( ep . ValueIsDefault ) ;
4291 }
4392
93+ public void RequireNameDefaultAndDescription ( )
94+ {
95+
96+ }
97+
4498 [ Fact ]
4599 public void CanReadParams ( )
46100 {
0 commit comments