@@ -353,4 +353,101 @@ public async Task GetCommitRefs(CommitRefType type)
353353 Assert . That ( commitRefs , Is . Not . Empty ) ;
354354 }
355355 }
356+
357+ [ Test ]
358+ [ NGitLabRetry ]
359+ public async Task GetArchiveWithoutOptionalParameters ( )
360+ {
361+ // Arrange
362+ using var context = await RepositoryClientTestsContext . CreateAsync ( commitCount : 2 ) ;
363+
364+ // Act
365+ context . RepositoryClient . GetArchive ( ( stream ) => { } ) ;
366+
367+ // Assert
368+ var requestPathAndQuery = context . Context . LastRequest . RequestUri . PathAndQuery ;
369+
370+ Assert . Multiple ( ( ) =>
371+ {
372+ Assert . That ( requestPathAndQuery , Is . Not . Null ) ;
373+ Assert . That ( requestPathAndQuery . EndsWith ( "/archive" , StringComparison . OrdinalIgnoreCase ) , Is . True ) ;
374+ } ) ;
375+ }
376+
377+ [ Test ]
378+ [ NGitLabRetry ]
379+ public async Task GetArchiveAcceptsShaParameter ( )
380+ {
381+ // Arrange
382+ using var context = await RepositoryClientTestsContext . CreateAsync ( commitCount : 2 ) ;
383+ var firstCommitId = context . Commits [ 0 ] . Id . ToString ( ) ;
384+
385+ // Act
386+ context . RepositoryClient . GetArchive ( ( stream ) => { } , sha : firstCommitId ) ;
387+
388+ // Assert
389+ var requestPathAndQuery = context . Context . LastRequest . RequestUri . PathAndQuery ;
390+
391+ Assert . Multiple ( ( ) =>
392+ {
393+ Assert . That ( requestPathAndQuery , Is . Not . Null ) ;
394+ Assert . That ( requestPathAndQuery . Contains ( $ "?sha={ firstCommitId } ", StringComparison . OrdinalIgnoreCase ) , Is . True ) ;
395+ } ) ;
396+ }
397+
398+ [ Test ]
399+ [ NGitLabRetry ]
400+ public async Task GetArchiveAcceptsFormatParameter ( )
401+ {
402+ // Arrange
403+ using var context = await RepositoryClientTestsContext . CreateAsync ( commitCount : 2 ) ;
404+ var format = ".zip" ;
405+
406+ // Act
407+ context . RepositoryClient . GetArchive ( ( stream ) => { } , format : format ) ;
408+
409+ // Assert
410+ var requestPathAndQuery = context . Context . LastRequest . RequestUri . PathAndQuery ;
411+
412+ Assert . Multiple ( ( ) =>
413+ {
414+ Assert . That ( requestPathAndQuery , Is . Not . Null ) ;
415+ Assert . That ( requestPathAndQuery . Contains ( $ "/archive{ format } ", StringComparison . OrdinalIgnoreCase ) , Is . True ) ;
416+ } ) ;
417+ }
418+
419+ [ Test ]
420+ [ NGitLabRetry ]
421+ public async Task GetArchiveAcceptsShaAndFormatParametersTogether ( )
422+ {
423+ // Arrange
424+ using var context = await RepositoryClientTestsContext . CreateAsync ( commitCount : 2 ) ;
425+ var format = ".zip" ;
426+ var firstCommitId = context . Commits [ 0 ] . Id . ToString ( ) ;
427+
428+ // Act
429+ context . RepositoryClient . GetArchive ( ( stream ) => { } , sha : firstCommitId , format : format ) ;
430+
431+ // Assert
432+ var requestPathAndQuery = context . Context . LastRequest . RequestUri . PathAndQuery ;
433+
434+ Assert . Multiple ( ( ) =>
435+ {
436+ Assert . That ( requestPathAndQuery , Is . Not . Null ) ;
437+ Assert . That ( requestPathAndQuery . Contains ( $ "/archive{ format } ", StringComparison . OrdinalIgnoreCase ) , Is . True ) ;
438+ Assert . That ( requestPathAndQuery . Contains ( $ "?sha={ firstCommitId } ", StringComparison . OrdinalIgnoreCase ) , Is . True ) ;
439+ } ) ;
440+ }
441+
442+ [ Test ]
443+ [ NGitLabRetry ]
444+ public async Task GetArchiveThrowsExceptionWhenFormatDoesNotStartWithDot ( )
445+ {
446+ // Arrange
447+ using var context = await RepositoryClientTestsContext . CreateAsync ( commitCount : 2 ) ;
448+ var format = "zip" ;
449+
450+ // Act and Assert
451+ Assert . Throws < ArgumentException > ( ( ) => context . RepositoryClient . GetArchive ( ( stream ) => { } , format : format ) ) ;
452+ }
356453}
0 commit comments