@@ -208,4 +208,193 @@ public async Task Stream_WithValidJson_StreamsOperationEvents()
208208 CreateAccountOperationResponseTest . AssertCreateAccountOperationData ) ;
209209 await streamableTest . Run ( ) ;
210210 }
211+
212+ /// <summary>
213+ /// Verifies that OperationsRequestBuilder.Operation correctly retrieves and deserializes operation data from URI.
214+ /// </summary>
215+ [ TestMethod ]
216+ public async Task Operation_WithValidUri_ReturnsDeserializedOperation ( )
217+ {
218+ // Arrange
219+ using var server = await Utils . CreateTestServerWithJson ( "Responses/Operations/createAccount.json" ) ;
220+ var uri = new Uri ( "https://horizon-testnet.stellar.org/operations/100000" ) ;
221+
222+ // Act
223+ var operation = await server . Operations . Operation ( uri ) ;
224+
225+ // Assert
226+ CreateAccountOperationResponseTest . AssertCreateAccountOperationData ( operation ) ;
227+ }
228+
229+ /// <summary>
230+ /// Verifies that OperationsRequestBuilder.ForAccount throws ArgumentException when account ID is invalid.
231+ /// </summary>
232+ [ TestMethod ]
233+ [ ExpectedException ( typeof ( ArgumentException ) ) ]
234+ public void ForAccount_WithInvalidAccountId_ThrowsArgumentException ( )
235+ {
236+ // Arrange
237+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
238+
239+ // Act & Assert
240+ _ = server . Operations . ForAccount ( "INVALID_ACCOUNT_ID" ) ;
241+ }
242+
243+ /// <summary>
244+ /// Verifies that OperationsRequestBuilder.ForAccount throws ArgumentException when account is null.
245+ /// </summary>
246+ [ TestMethod ]
247+ [ ExpectedException ( typeof ( ArgumentNullException ) ) ]
248+ public void ForAccount_WithNullAccount_ThrowsArgumentException ( )
249+ {
250+ // Arrange
251+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
252+
253+ // Act & Assert
254+ _ = server . Operations . ForAccount ( null ! ) ;
255+ }
256+
257+ /// <summary>
258+ /// Verifies that OperationsRequestBuilder.ForAccount throws ArgumentException when account is empty.
259+ /// </summary>
260+ [ TestMethod ]
261+ [ ExpectedException ( typeof ( ArgumentException ) ) ]
262+ public void ForAccount_WithEmptyAccount_ThrowsArgumentException ( )
263+ {
264+ // Arrange
265+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
266+
267+ // Act & Assert
268+ _ = server . Operations . ForAccount ( "" ) ;
269+ }
270+
271+ /// <summary>
272+ /// Verifies that OperationsRequestBuilder.ForClaimableBalance throws ArgumentException when balance ID is null.
273+ /// </summary>
274+ [ TestMethod ]
275+ [ ExpectedException ( typeof ( ArgumentNullException ) ) ]
276+ public void ForClaimableBalance_WithNullBalanceId_ThrowsArgumentException ( )
277+ {
278+ // Arrange
279+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
280+
281+ // Act & Assert
282+ _ = server . Operations . ForClaimableBalance ( null ! ) ;
283+ }
284+
285+ /// <summary>
286+ /// Verifies that OperationsRequestBuilder.ForClaimableBalance throws ArgumentException when balance ID format is invalid.
287+ /// </summary>
288+ [ TestMethod ]
289+ [ ExpectedException ( typeof ( ArgumentException ) ) ]
290+ public void ForClaimableBalance_WithInvalidFormat_ThrowsArgumentException ( )
291+ {
292+ // Arrange
293+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
294+
295+ // Act & Assert
296+ _ = server . Operations . ForClaimableBalance ( "invalid_format" ) ;
297+ }
298+
299+ /// <summary>
300+ /// Verifies that OperationsRequestBuilder.ForTransaction throws ArgumentException when transaction ID is null.
301+ /// </summary>
302+ [ TestMethod ]
303+ [ ExpectedException ( typeof ( ArgumentNullException ) ) ]
304+ public void ForTransaction_WithNullTransactionId_ThrowsArgumentException ( )
305+ {
306+ // Arrange
307+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
308+
309+ // Act & Assert
310+ _ = server . Operations . ForTransaction ( null ! ) ;
311+ }
312+
313+ /// <summary>
314+ /// Verifies that OperationsRequestBuilder.ForTransaction throws ArgumentException when transaction ID is empty.
315+ /// </summary>
316+ [ TestMethod ]
317+ [ ExpectedException ( typeof ( ArgumentException ) ) ]
318+ public void ForTransaction_WithEmptyTransactionId_ThrowsArgumentException ( )
319+ {
320+ // Arrange
321+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
322+
323+ // Act & Assert
324+ _ = server . Operations . ForTransaction ( "" ) ;
325+ }
326+
327+ /// <summary>
328+ /// Verifies that OperationsRequestBuilder.ForLiquidityPool correctly constructs URI for liquidity pool operations.
329+ /// </summary>
330+ [ TestMethod ]
331+ public void ForLiquidityPool_WithValidPoolId_BuildsCorrectUri ( )
332+ {
333+ // Arrange
334+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
335+ const string poolId = "cc22414997d7e3d9a9ac3b1d65ca9cc3e5f35ce33e0bd6a885648b11aaa3b72d" ;
336+
337+ // Act
338+ var uri = server . Operations
339+ . ForLiquidityPool ( poolId )
340+ . Limit ( 50 )
341+ . Order ( OrderDirection . ASC )
342+ . BuildUri ( ) ;
343+
344+ // Assert
345+ Assert . AreEqual (
346+ $ "https://horizon-testnet.stellar.org/liquidity_pools/{ poolId } /operations?limit=50&order=asc",
347+ uri . ToString ( ) ) ;
348+ }
349+
350+ /// <summary>
351+ /// Verifies that OperationsRequestBuilder.ForLiquidityPool throws ArgumentException when pool ID is null.
352+ /// </summary>
353+ [ TestMethod ]
354+ [ ExpectedException ( typeof ( ArgumentNullException ) ) ]
355+ public void ForLiquidityPool_WithNullPoolId_ThrowsArgumentException ( )
356+ {
357+ // Arrange
358+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
359+
360+ // Act & Assert
361+ _ = server . Operations . ForLiquidityPool ( null ! ) ;
362+ }
363+
364+ /// <summary>
365+ /// Verifies that OperationsRequestBuilder.ForLiquidityPool throws ArgumentException when pool ID is empty.
366+ /// </summary>
367+ [ TestMethod ]
368+ [ ExpectedException ( typeof ( ArgumentException ) ) ]
369+ public void ForLiquidityPool_WithEmptyPoolId_ThrowsArgumentException ( )
370+ {
371+ // Arrange
372+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
373+
374+ // Act & Assert
375+ _ = server . Operations . ForLiquidityPool ( "" ) ;
376+ }
377+
378+ /// <summary>
379+ /// Verifies that OperationsRequestBuilder.IncludeFailed correctly adds include_failed parameter with false value.
380+ /// </summary>
381+ [ TestMethod ]
382+ public void IncludeFailed_WithFalseValue_AddsIncludeFailedParameter ( )
383+ {
384+ // Arrange
385+ using var server = Utils . CreateTestServerWithContent ( "" ) ;
386+
387+ // Act
388+ var uri = server . Operations
389+ . ForLedger ( 200000000000L )
390+ . IncludeFailed ( false )
391+ . Limit ( 50 )
392+ . Order ( OrderDirection . ASC )
393+ . BuildUri ( ) ;
394+
395+ // Assert
396+ Assert . AreEqual (
397+ "https://horizon-testnet.stellar.org/ledgers/200000000000/operations?include_failed=false&limit=50&order=asc" ,
398+ uri . ToString ( ) ) ;
399+ }
211400}
0 commit comments