@@ -74,6 +74,57 @@ public void AsTool_WithWebSearch_ImageUnderstanding()
7474 Assert . True ( tool . WebSearch . EnableImageUnderstanding ) ;
7575 }
7676
77+ [ Fact ]
78+ public void AsTool_WithWebSearch_UserLocation ( )
79+ {
80+ var webSearch = new GrokSearchTool
81+ {
82+ Country = "US" ,
83+ Region = "California" ,
84+ City = "San Francisco" ,
85+ Timezone = "America/Los_Angeles"
86+ } ;
87+
88+ var tool = webSearch . AsProtocolTool ( ) ;
89+
90+ Assert . NotNull ( tool ? . WebSearch ) ;
91+ Assert . NotNull ( tool . WebSearch . UserLocation ) ;
92+ Assert . Equal ( "US" , tool . WebSearch . UserLocation . Country ) ;
93+ Assert . Equal ( "California" , tool . WebSearch . UserLocation . Region ) ;
94+ Assert . Equal ( "San Francisco" , tool . WebSearch . UserLocation . City ) ;
95+ Assert . Equal ( "America/Los_Angeles" , tool . WebSearch . UserLocation . Timezone ) ;
96+ }
97+
98+ [ Fact ]
99+ public void AsTool_WithWebSearch_UserLocation_PartialFields ( )
100+ {
101+ var webSearch = new GrokSearchTool
102+ {
103+ Country = "DE" ,
104+ City = "Berlin"
105+ } ;
106+
107+ var tool = webSearch . AsProtocolTool ( ) ;
108+
109+ Assert . NotNull ( tool ? . WebSearch ) ;
110+ Assert . NotNull ( tool . WebSearch . UserLocation ) ;
111+ Assert . Equal ( "DE" , tool . WebSearch . UserLocation . Country ) ;
112+ Assert . Equal ( "Berlin" , tool . WebSearch . UserLocation . City ) ;
113+ Assert . Empty ( tool . WebSearch . UserLocation . Region ) ;
114+ Assert . Empty ( tool . WebSearch . UserLocation . Timezone ) ;
115+ }
116+
117+ [ Fact ]
118+ public void AsTool_WithWebSearch_NoUserLocation ( )
119+ {
120+ var webSearch = new GrokSearchTool ( ) ;
121+
122+ var tool = webSearch . AsProtocolTool ( ) ;
123+
124+ Assert . NotNull ( tool ? . WebSearch ) ;
125+ Assert . Null ( tool . WebSearch . UserLocation ) ;
126+ }
127+
77128 [ Fact ]
78129 public void AsTool_WithXSearch_ThrowsIfAllowedAndExcluded ( )
79130 {
0 commit comments