@@ -420,111 +420,6 @@ public void CanWalkCommitsFromBranch()
420
420
}
421
421
}
422
422
423
- [ Theory ]
424
- [ InlineData ( "i-do-numbers" ) ]
425
- [ InlineData ( "diff-test-cases" ) ]
426
- public void CanCheckoutAnExistingBranch ( string branchName )
427
- {
428
- TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo ( StandardTestRepoWorkingDirPath ) ;
429
- using ( var repo = new Repository ( path . RepositoryPath ) )
430
- {
431
- Branch master = repo . Branches [ "master" ] ;
432
- Assert . True ( master . IsCurrentRepositoryHead ) ;
433
-
434
- Branch branch = repo . Branches [ branchName ] ;
435
- Assert . NotNull ( branch ) ;
436
-
437
- Branch test = repo . Checkout ( branch ) ;
438
- Assert . False ( repo . Info . IsHeadDetached ) ;
439
-
440
- Assert . False ( test . IsRemote ) ;
441
- Assert . True ( test . IsCurrentRepositoryHead ) ;
442
- Assert . Equal ( repo . Head , test ) ;
443
-
444
- Assert . False ( master . IsCurrentRepositoryHead ) ;
445
- }
446
- }
447
-
448
- [ Theory ]
449
- [ InlineData ( "i-do-numbers" ) ]
450
- [ InlineData ( "diff-test-cases" ) ]
451
- public void CanCheckoutAnExistingBranchByName ( string branchName )
452
- {
453
- TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo ( StandardTestRepoWorkingDirPath ) ;
454
- using ( var repo = new Repository ( path . RepositoryPath ) )
455
- {
456
- Branch master = repo . Branches [ "master" ] ;
457
- Assert . True ( master . IsCurrentRepositoryHead ) ;
458
-
459
- Branch test = repo . Checkout ( branchName ) ;
460
- Assert . False ( repo . Info . IsHeadDetached ) ;
461
-
462
- Assert . False ( test . IsRemote ) ;
463
- Assert . True ( test . IsCurrentRepositoryHead ) ;
464
- Assert . Equal ( repo . Head , test ) ;
465
-
466
- Assert . False ( master . IsCurrentRepositoryHead ) ;
467
- }
468
- }
469
-
470
- [ Theory ]
471
- [ InlineData ( "6dcf9bf" ) ]
472
- [ InlineData ( "refs/tags/lw" ) ]
473
- public void CanCheckoutAnArbitraryCommit ( string commitPointer )
474
- {
475
- TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo ( StandardTestRepoWorkingDirPath ) ;
476
- using ( var repo = new Repository ( path . RepositoryPath ) )
477
- {
478
- Branch master = repo . Branches [ "master" ] ;
479
- Assert . True ( master . IsCurrentRepositoryHead ) ;
480
-
481
- Branch detachedHead = repo . Checkout ( commitPointer ) ;
482
-
483
- Assert . Equal ( repo . Head , detachedHead ) ;
484
- Assert . Equal ( repo . Lookup ( commitPointer ) . Sha , detachedHead . Tip . Sha ) ;
485
- Assert . True ( repo . Head . IsCurrentRepositoryHead ) ;
486
- Assert . True ( repo . Info . IsHeadDetached ) ;
487
-
488
- Assert . True ( detachedHead . IsCurrentRepositoryHead ) ;
489
- Assert . False ( detachedHead . IsRemote ) ;
490
- Assert . Equal ( detachedHead . Name , detachedHead . CanonicalName ) ;
491
-
492
- Assert . Equal ( "(no branch)" , detachedHead . CanonicalName ) ;
493
-
494
- Assert . False ( master . IsCurrentRepositoryHead ) ;
495
- }
496
- }
497
-
498
- [ Fact ]
499
- public void CheckingOutInABareRepoThrows ( )
500
- {
501
- using ( var repo = new Repository ( BareTestRepoPath ) )
502
- {
503
- Assert . Throws < InvalidOperationException > ( ( ) => repo . Checkout ( repo . Branches [ "refs/heads/test" ] ) ) ;
504
- Assert . Throws < InvalidOperationException > ( ( ) => repo . Checkout ( "refs/heads/test" ) ) ;
505
- }
506
- }
507
-
508
- [ Fact ]
509
- public void CheckingOutANonExistingBranchThrows ( )
510
- {
511
- using ( var repo = new Repository ( StandardTestRepoWorkingDirPath ) )
512
- {
513
- Assert . Throws < LibGit2SharpException > ( ( ) => repo . Checkout ( "i-do-not-exist" ) ) ;
514
- }
515
- }
516
-
517
- [ Fact ]
518
- public void CheckingOutABranchWithBadParamsThrows ( )
519
- {
520
- using ( var repo = new Repository ( StandardTestRepoWorkingDirPath ) )
521
- {
522
- Assert . Throws < ArgumentException > ( ( ) => repo . Checkout ( string . Empty ) ) ;
523
- Assert . Throws < ArgumentNullException > ( ( ) => repo . Checkout ( default ( Branch ) ) ) ;
524
- Assert . Throws < ArgumentNullException > ( ( ) => repo . Checkout ( default ( string ) ) ) ;
525
- }
526
- }
527
-
528
423
private void AssertRemoval ( string branchName , bool isRemote , bool shouldPreviouslyAssertExistence )
529
424
{
530
425
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo ( StandardTestRepoPath ) ;
0 commit comments