diff --git a/src/Stack.Tests/Commands/Stack/NewStackCommandHandlerTests.cs b/src/Stack.Tests/Commands/Stack/NewStackCommandHandlerTests.cs index 755fd51..c37a384 100644 --- a/src/Stack.Tests/Commands/Stack/NewStackCommandHandlerTests.cs +++ b/src/Stack.Tests/Commands/Stack/NewStackCommandHandlerTests.cs @@ -15,17 +15,19 @@ public class NewStackCommandHandlerTests public async Task WithANewBranch_AndSwitchingToTheBranch_TheStackIsCreatedAndTheCurrentBranchIsChanged() { // Arrange - var gitOperations = Substitute.For(); + var sourceBranch = Some.BranchName(); + var newBranch = Some.BranchName(); + using var repo = new TestGitRepositoryBuilder() + .WithBranch(sourceBranch) + .Build(); + var stackConfig = Substitute.For(); var inputProvider = Substitute.For(); var outputProvider = Substitute.For(); + var gitOperations = new GitOperations(outputProvider, repo.GitOperationSettings); + var gitHubOperations = Substitute.For(); var handler = new NewStackCommandHandler(inputProvider, outputProvider, gitOperations, stackConfig); - var remoteUri = Some.HttpsUri().ToString(); - - gitOperations.GetRemoteUri().Returns(remoteUri); - gitOperations.GetLocalBranchesOrderedByMostRecentCommitterDate().Returns(["branch-1", "branch-2"]); - var stacks = new List(); stackConfig.Load().Returns(stacks); stackConfig @@ -33,40 +35,43 @@ public async Task WithANewBranch_AndSwitchingToTheBranch_TheStackIsCreatedAndThe .Do(ci => stacks = ci.ArgAt>(0)); inputProvider.Text(Questions.StackName).Returns("Stack1"); - inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns("branch-1"); + inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns(sourceBranch); inputProvider.Confirm(Questions.ConfirmAddOrCreateBranch).Returns(true); inputProvider.Select(Questions.AddOrCreateBranch, Arg.Any(), Arg.Any>()).Returns(BranchAction.Create); - inputProvider.Text(Questions.BranchName, Arg.Any()).Returns("new-branch"); + inputProvider.Text(Questions.BranchName, Arg.Any()).Returns(newBranch); inputProvider.Confirm(Questions.ConfirmSwitchToBranch).Returns(true); // Act var response = await handler.Handle(NewStackCommandInputs.Empty); // Assert - response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", "branch-1", BranchAction.Create, "new-branch")); + response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", sourceBranch, BranchAction.Create, newBranch)); stacks.Should().BeEquivalentTo(new List { - new("Stack1", remoteUri, "branch-1", ["new-branch"]) + new("Stack1", repo.RemoteUri, sourceBranch, [newBranch]) }); - gitOperations.Received().ChangeBranch("new-branch"); + gitOperations.GetCurrentBranch().Should().Be(newBranch); } [Fact] public async Task WithAnExistingBranch_AndSwitchingToTheBranch_TheStackIsCreatedAndTheCurrentBranchIsChanged() { // Arrange - var gitOperations = Substitute.For(); + var sourceBranch = Some.BranchName(); + var existingBranch = Some.BranchName(); + using var repo = new TestGitRepositoryBuilder() + .WithBranch(sourceBranch) + .WithBranch(existingBranch) + .Build(); + var stackConfig = Substitute.For(); var inputProvider = Substitute.For(); var outputProvider = Substitute.For(); + var gitOperations = new GitOperations(outputProvider, repo.GitOperationSettings); + var gitHubOperations = Substitute.For(); var handler = new NewStackCommandHandler(inputProvider, outputProvider, gitOperations, stackConfig); - var remoteUri = Some.HttpsUri().ToString(); - - gitOperations.GetRemoteUri().Returns(remoteUri); - gitOperations.GetLocalBranchesOrderedByMostRecentCommitterDate().Returns(["branch-1", "branch-2"]); - var stacks = new List(); stackConfig.Load().Returns(stacks); stackConfig @@ -74,39 +79,44 @@ public async Task WithAnExistingBranch_AndSwitchingToTheBranch_TheStackIsCreated .Do(ci => stacks = ci.ArgAt>(0)); inputProvider.Text(Questions.StackName).Returns("Stack1"); - inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns("branch-1"); + inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns(sourceBranch); inputProvider.Confirm(Questions.ConfirmAddOrCreateBranch).Returns(true); inputProvider.Select(Questions.AddOrCreateBranch, Arg.Any(), Arg.Any>()).Returns(BranchAction.Add); - inputProvider.Select(Questions.SelectBranch, Arg.Any()).Returns("branch-2"); + inputProvider.Select(Questions.SelectBranch, Arg.Any()).Returns(existingBranch); inputProvider.Confirm(Questions.ConfirmSwitchToBranch).Returns(true); // Act var response = await handler.Handle(NewStackCommandInputs.Empty); // Assert - response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", "branch-1", BranchAction.Add, "branch-2")); + response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", sourceBranch, BranchAction.Add, existingBranch)); stacks.Should().BeEquivalentTo(new List { - new("Stack1", remoteUri, "branch-1", ["branch-2"]) + new("Stack1", repo.RemoteUri, sourceBranch, [existingBranch]) }); - gitOperations.Received().ChangeBranch("branch-2"); + gitOperations.GetCurrentBranch().Should().Be(existingBranch); } [Fact] public async Task WithNoBranch_TheStackIsCreatedAndTheCurrentBranchIsNotChanged() { // Arrange - var gitOperations = Substitute.For(); + var sourceBranch = Some.BranchName(); + var existingBranch = Some.BranchName(); + using var repo = new TestGitRepositoryBuilder() + .WithBranch(sourceBranch) + .WithBranch(existingBranch) + .Build(); + var stackConfig = Substitute.For(); var inputProvider = Substitute.For(); var outputProvider = Substitute.For(); + var gitOperations = new GitOperations(outputProvider, repo.GitOperationSettings); + var gitHubOperations = Substitute.For(); var handler = new NewStackCommandHandler(inputProvider, outputProvider, gitOperations, stackConfig); - var remoteUri = Some.HttpsUri().ToString(); - - gitOperations.GetRemoteUri().Returns(remoteUri); - gitOperations.GetLocalBranchesOrderedByMostRecentCommitterDate().Returns(["branch-1", "branch-2"]); + gitOperations.ChangeBranch(existingBranch); var stacks = new List(); stackConfig.Load().Returns(stacks); @@ -116,36 +126,40 @@ public async Task WithNoBranch_TheStackIsCreatedAndTheCurrentBranchIsNotChanged( inputProvider.Text(Questions.StackName).Returns("Stack1"); - inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns("branch-1"); + inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns(sourceBranch); inputProvider.Confirm(Questions.ConfirmAddOrCreateBranch).Returns(false); // Act var response = await handler.Handle(NewStackCommandInputs.Empty); // Assert - response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", "branch-1", null, null)); + response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", sourceBranch, null, null)); stacks.Should().BeEquivalentTo(new List { - new("Stack1", remoteUri, "branch-1", []) + new("Stack1", repo.RemoteUri, sourceBranch, []) }); - gitOperations.DidNotReceive().ChangeBranch(Arg.Any()); + gitOperations.GetCurrentBranch().Should().Be(existingBranch); } [Fact] public async Task WithANewBranch_AndNotSwitchingToTheBranch_TheStackIsCreatedAndTheCurrentBranchIsNotChanged() { // Arrange - var gitOperations = Substitute.For(); + var sourceBranch = Some.BranchName(); + var newBranch = Some.BranchName(); + using var repo = new TestGitRepositoryBuilder() + .WithBranch(sourceBranch) + .Build(); + var stackConfig = Substitute.For(); var inputProvider = Substitute.For(); var outputProvider = Substitute.For(); + var gitOperations = new GitOperations(outputProvider, repo.GitOperationSettings); + var gitHubOperations = Substitute.For(); var handler = new NewStackCommandHandler(inputProvider, outputProvider, gitOperations, stackConfig); - var remoteUri = Some.HttpsUri().ToString(); - - gitOperations.GetRemoteUri().Returns(remoteUri); - gitOperations.GetLocalBranchesOrderedByMostRecentCommitterDate().Returns(["branch-1", "branch-2"]); + gitOperations.ChangeBranch(sourceBranch); var stacks = new List(); stackConfig.Load().Returns(stacks); @@ -155,39 +169,44 @@ public async Task WithANewBranch_AndNotSwitchingToTheBranch_TheStackIsCreatedAnd inputProvider.Text(Questions.StackName).Returns("Stack1"); - inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns("branch-1"); + inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns(sourceBranch); inputProvider.Confirm(Questions.ConfirmAddOrCreateBranch).Returns(true); inputProvider.Select(Questions.AddOrCreateBranch, Arg.Any(), Arg.Any>()).Returns(BranchAction.Create); - inputProvider.Text(Questions.BranchName, Arg.Any()).Returns("new-branch-1"); + inputProvider.Text(Questions.BranchName, Arg.Any()).Returns(newBranch); inputProvider.Confirm(Questions.ConfirmSwitchToBranch).Returns(false); // Act var response = await handler.Handle(NewStackCommandInputs.Empty); // Assert - response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", "branch-1", BranchAction.Create, "new-branch-1")); + response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", sourceBranch, BranchAction.Create, newBranch)); stacks.Should().BeEquivalentTo(new List { - new("Stack1", remoteUri, "branch-1", ["new-branch-1"]) + new("Stack1", repo.RemoteUri, sourceBranch, [newBranch]) }); - gitOperations.DidNotReceive().ChangeBranch("new-branch-1"); + gitOperations.GetCurrentBranch().Should().Be(sourceBranch); } [Fact] public async Task WithAnExistingBranch_AndNotSwitchingToTheBranch_TheStackIsCreatedAndTheCurrentBranchIsNotChanged() { // Arrange - var gitOperations = Substitute.For(); + var sourceBranch = Some.BranchName(); + var existingBranch = Some.BranchName(); + using var repo = new TestGitRepositoryBuilder() + .WithBranch(sourceBranch) + .WithBranch(existingBranch) + .Build(); + var stackConfig = Substitute.For(); var inputProvider = Substitute.For(); var outputProvider = Substitute.For(); + var gitOperations = new GitOperations(outputProvider, repo.GitOperationSettings); + var gitHubOperations = Substitute.For(); var handler = new NewStackCommandHandler(inputProvider, outputProvider, gitOperations, stackConfig); - var remoteUri = Some.HttpsUri().ToString(); - - gitOperations.GetRemoteUri().Returns(remoteUri); - gitOperations.GetLocalBranchesOrderedByMostRecentCommitterDate().Returns(["branch-1", "branch-2"]); + gitOperations.ChangeBranch(sourceBranch); var stacks = new List(); stackConfig.Load().Returns(stacks); @@ -196,47 +215,48 @@ public async Task WithAnExistingBranch_AndNotSwitchingToTheBranch_TheStackIsCrea .Do(ci => stacks = ci.ArgAt>(0)); inputProvider.Text(Questions.StackName).Returns("Stack1"); - inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns("branch-1"); + inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns(sourceBranch); inputProvider.Confirm(Questions.ConfirmAddOrCreateBranch).Returns(true); inputProvider.Select(Questions.AddOrCreateBranch, Arg.Any(), Arg.Any>()).Returns(BranchAction.Add); - inputProvider.Select(Questions.SelectBranch, Arg.Any()).Returns("branch-2"); + inputProvider.Select(Questions.SelectBranch, Arg.Any()).Returns(existingBranch); inputProvider.Confirm(Questions.ConfirmSwitchToBranch).Returns(false); // Act var response = await handler.Handle(NewStackCommandInputs.Empty); // Assert - response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", "branch-1", BranchAction.Add, "branch-2")); + response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", sourceBranch, BranchAction.Add, existingBranch)); stacks.Should().BeEquivalentTo(new List { - new("Stack1", remoteUri, "branch-1", ["branch-2"]) + new("Stack1", repo.RemoteUri, sourceBranch, [existingBranch]) }); - gitOperations.DidNotReceive().ChangeBranch("branch-2"); + gitOperations.GetCurrentBranch().Should().Be(sourceBranch); } [Fact] public async Task WhenStackNameIsProvidedInInputs_TheProviderIsNotAskedForAName_AndTheStackIsCreatedWithTheName() { // Arrange - var gitOperations = Substitute.For(); + var sourceBranch = Some.BranchName(); + using var repo = new TestGitRepositoryBuilder() + .WithBranch(sourceBranch) + .Build(); + var stackConfig = Substitute.For(); var inputProvider = Substitute.For(); var outputProvider = Substitute.For(); + var gitOperations = new GitOperations(outputProvider, repo.GitOperationSettings); + var gitHubOperations = Substitute.For(); var handler = new NewStackCommandHandler(inputProvider, outputProvider, gitOperations, stackConfig); - var remoteUri = Some.HttpsUri().ToString(); - - gitOperations.GetRemoteUri().Returns(remoteUri); - gitOperations.GetLocalBranchesOrderedByMostRecentCommitterDate().Returns(["branch-1", "branch-2"]); - var stacks = new List(); stackConfig.Load().Returns(stacks); stackConfig .WhenForAnyArgs(s => s.Save(Arg.Any>())) .Do(ci => stacks = ci.ArgAt>(0)); - inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns("branch-1"); + inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns(sourceBranch); inputProvider.Confirm(Questions.ConfirmAddOrCreateBranch).Returns(false); var inputs = new NewStackCommandInputs("Stack1", null, null); @@ -245,10 +265,10 @@ public async Task WhenStackNameIsProvidedInInputs_TheProviderIsNotAskedForAName_ var response = await handler.Handle(inputs); // Assert - response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", "branch-1", null, null)); + response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", sourceBranch, null, null)); stacks.Should().BeEquivalentTo(new List { - new("Stack1", remoteUri, "branch-1", []) + new("Stack1", repo.RemoteUri, sourceBranch, []) }); inputProvider.DidNotReceive().Text(Questions.StackName); @@ -258,17 +278,18 @@ public async Task WhenStackNameIsProvidedInInputs_TheProviderIsNotAskedForAName_ public async Task WhenSourceBranchIsProvidedInInputs_TheProviderIsNotAskedForTheBranch_AndTheStackIsCreatedWithTheSourceBranch() { // Arrange - var gitOperations = Substitute.For(); + var sourceBranch = Some.BranchName(); + using var repo = new TestGitRepositoryBuilder() + .WithBranch(sourceBranch) + .Build(); + var stackConfig = Substitute.For(); var inputProvider = Substitute.For(); var outputProvider = Substitute.For(); + var gitOperations = new GitOperations(outputProvider, repo.GitOperationSettings); + var gitHubOperations = Substitute.For(); var handler = new NewStackCommandHandler(inputProvider, outputProvider, gitOperations, stackConfig); - var remoteUri = Some.HttpsUri().ToString(); - - gitOperations.GetRemoteUri().Returns(remoteUri); - gitOperations.GetLocalBranchesOrderedByMostRecentCommitterDate().Returns(["branch-1", "branch-2"]); - var stacks = new List(); stackConfig.Load().Returns(stacks); stackConfig @@ -278,16 +299,16 @@ public async Task WhenSourceBranchIsProvidedInInputs_TheProviderIsNotAskedForThe inputProvider.Text(Questions.StackName).Returns("Stack1"); inputProvider.Confirm(Questions.ConfirmAddOrCreateBranch).Returns(false); - var inputs = new NewStackCommandInputs(null, "branch-1", null); + var inputs = new NewStackCommandInputs(null, sourceBranch, null); // Act var response = await handler.Handle(inputs); // Assert - response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", "branch-1", null, null)); + response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", sourceBranch, null, null)); stacks.Should().BeEquivalentTo(new List { - new("Stack1", remoteUri, "branch-1", []) + new("Stack1", repo.RemoteUri, sourceBranch, []) }); inputProvider.DidNotReceive().Select(Questions.SelectBranch, Arg.Any()); @@ -297,17 +318,19 @@ public async Task WhenSourceBranchIsProvidedInInputs_TheProviderIsNotAskedForThe public async Task WhenBranchNameIsProvidedInInputs_TheProviderIsNotAskedForTheBranchName_AndTheStackIsCreatedWithTheBranchName() { // Arrange - var gitOperations = Substitute.For(); + var sourceBranch = Some.BranchName(); + var newBranch = Some.BranchName(); + using var repo = new TestGitRepositoryBuilder() + .WithBranch(sourceBranch) + .Build(); + var stackConfig = Substitute.For(); var inputProvider = Substitute.For(); var outputProvider = Substitute.For(); + var gitOperations = new GitOperations(outputProvider, repo.GitOperationSettings); + var gitHubOperations = Substitute.For(); var handler = new NewStackCommandHandler(inputProvider, outputProvider, gitOperations, stackConfig); - var remoteUri = Some.HttpsUri().ToString(); - - gitOperations.GetRemoteUri().Returns(remoteUri); - gitOperations.GetLocalBranchesOrderedByMostRecentCommitterDate().Returns(["branch-1", "branch-2"]); - var stacks = new List(); stackConfig.Load().Returns(stacks); stackConfig @@ -315,19 +338,19 @@ public async Task WhenBranchNameIsProvidedInInputs_TheProviderIsNotAskedForTheBr .Do(ci => stacks = ci.ArgAt>(0)); inputProvider.Text(Questions.StackName).Returns("Stack1"); - inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns("branch-1"); + inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns(sourceBranch); // Note there shouldn't be any more inputs required at all - var inputs = new NewStackCommandInputs(null, null, "new-branch"); + var inputs = new NewStackCommandInputs(null, null, newBranch); // Act var response = await handler.Handle(inputs); // Assert - response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", "branch-1", BranchAction.Create, "new-branch")); + response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", sourceBranch, BranchAction.Create, newBranch)); stacks.Should().BeEquivalentTo(new List { - new("Stack1", remoteUri, "branch-1", ["new-branch"]) + new("Stack1", repo.RemoteUri, sourceBranch, [newBranch]) }); inputProvider.Received().Text(Questions.StackName); @@ -340,33 +363,35 @@ public async Task WhenBranchNameIsProvidedInInputs_TheProviderIsNotAskedForTheBr public async Task WhenAllInputsAreProvided_TheProviderIsNotAskedForAnything_AndTheStackIsCreatedCorrectly() { // Arrange - var gitOperations = Substitute.For(); + var sourceBranch = Some.BranchName(); + var newBranch = Some.BranchName(); + using var repo = new TestGitRepositoryBuilder() + .WithBranch(sourceBranch) + .Build(); + var stackConfig = Substitute.For(); var inputProvider = Substitute.For(); var outputProvider = Substitute.For(); + var gitOperations = new GitOperations(outputProvider, repo.GitOperationSettings); + var gitHubOperations = Substitute.For(); var handler = new NewStackCommandHandler(inputProvider, outputProvider, gitOperations, stackConfig); - var remoteUri = Some.HttpsUri().ToString(); - - gitOperations.GetRemoteUri().Returns(remoteUri); - gitOperations.GetLocalBranchesOrderedByMostRecentCommitterDate().Returns(["branch-1", "branch-2"]); - var stacks = new List(); stackConfig.Load().Returns(stacks); stackConfig .WhenForAnyArgs(s => s.Save(Arg.Any>())) .Do(ci => stacks = ci.ArgAt>(0)); - var inputs = new NewStackCommandInputs("Stack1", "branch-1", "new-branch"); + var inputs = new NewStackCommandInputs("Stack1", sourceBranch, newBranch); // Act var response = await handler.Handle(inputs); // Assert - response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", "branch-1", BranchAction.Create, "new-branch")); + response.Should().BeEquivalentTo(new NewStackCommandResponse("Stack1", sourceBranch, BranchAction.Create, newBranch)); stacks.Should().BeEquivalentTo(new List { - new("Stack1", remoteUri, "branch-1", ["new-branch"]) + new("Stack1", repo.RemoteUri, sourceBranch, [newBranch]) }); inputProvider.ReceivedCalls().Should().BeEmpty(); @@ -376,17 +401,19 @@ public async Task WhenAllInputsAreProvided_TheProviderIsNotAskedForAnything_AndT public async Task WhenAStackHasANameWithMultipleWords_SuggestsAGoodDefaultNewBranchName() { // Arrange - var gitOperations = Substitute.For(); + var sourceBranch = Some.BranchName(); + var newBranch = Some.BranchName(); + using var repo = new TestGitRepositoryBuilder() + .WithBranch(sourceBranch) + .Build(); + var stackConfig = Substitute.For(); var inputProvider = Substitute.For(); var outputProvider = Substitute.For(); + var gitOperations = new GitOperations(outputProvider, repo.GitOperationSettings); + var gitHubOperations = Substitute.For(); var handler = new NewStackCommandHandler(inputProvider, outputProvider, gitOperations, stackConfig); - var remoteUri = Some.HttpsUri().ToString(); - - gitOperations.GetRemoteUri().Returns(remoteUri); - gitOperations.GetLocalBranchesOrderedByMostRecentCommitterDate().Returns(["branch-1", "branch-2"]); - var stacks = new List(); stackConfig.Load().Returns(stacks); stackConfig @@ -394,22 +421,22 @@ public async Task WhenAStackHasANameWithMultipleWords_SuggestsAGoodDefaultNewBra .Do(ci => stacks = ci.ArgAt>(0)); inputProvider.Text(Questions.StackName).Returns("A stack with multiple words"); - inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns("branch-1"); + inputProvider.Select(Questions.SelectSourceBranch, Arg.Any()).Returns(sourceBranch); inputProvider.Confirm(Questions.ConfirmAddOrCreateBranch).Returns(true); inputProvider.Select(Questions.AddOrCreateBranch, Arg.Any(), Arg.Any>()).Returns(BranchAction.Create); - inputProvider.Text(Questions.BranchName, "a-stack-with-multiple-words-1").Returns("new-branch"); + inputProvider.Text(Questions.BranchName, "a-stack-with-multiple-words-1").Returns(newBranch); inputProvider.Confirm(Questions.ConfirmSwitchToBranch).Returns(true); // Act var response = await handler.Handle(NewStackCommandInputs.Empty); // Assert - response.Should().BeEquivalentTo(new NewStackCommandResponse("A stack with multiple words", "branch-1", BranchAction.Create, "new-branch")); + response.Should().BeEquivalentTo(new NewStackCommandResponse("A stack with multiple words", sourceBranch, BranchAction.Create, newBranch)); stacks.Should().BeEquivalentTo(new List { - new("A stack with multiple words", remoteUri, "branch-1", ["new-branch"]) + new("A stack with multiple words", repo.RemoteUri, sourceBranch, [newBranch]) }); - gitOperations.Received().ChangeBranch("new-branch"); + gitOperations.GetCurrentBranch().Should().Be(newBranch); } }