public void ALocalRepoistoryCanBeCloned() { MockGitLocationForConfiguration(); Command command = MockCommandProperties(); Runner runner = MockRunner(); Mocks.ReplayAll(); runner.Output = string.Format("Cloning into {0}...", RepositoryDestination); var clone = new CloneCommand { ProjectLocation = GitEmptyTestProjectLocation, RepositoryToClone = GitEmptyTestProjectLocation, Destination = RepositoryDestination, Runner = runner, CommandArguments = command, EnvironmentVariable = StubEnvironmentVariable() }; IAsyncResult result = clone.Run(); result.AsyncWaitHandle.WaitOne(); Assert.That(clone.Output.Contains(string.Format("Cloning into {0}...", RepositoryDestination))); Assert.That(runner.Command, Is.EqualTo(command)); Assert.That(command.CommandFullLocation, Is.EqualTo(GitInstallLocation)); Assert.That(command.Arguments, Is.EqualTo("clone -v --verbose --progress \"C:\\Empty\\GitProject\" \"C:\\SomeFakeUnitTestDirectory\\MoreUnitTestFakey\"")); Assert.That(command.WorkingDirectory, Is.EqualTo(GitEmptyTestProjectLocation)); }
private EnvironmentVariable SetUpForEnvironmentVariableTest(out CloneCommand clone) { MockGitLocationForConfiguration(); var command = MockCommandProperties(); var runner = MockRunner(); var envVar = Mocks.StrictMock<EnvironmentVariable>(); envVar.SetPropertyAsBehavior(v => v.Home); envVar.SetPropertyAsBehavior(v => v.HomeDrive); envVar.SetPropertyAsBehavior(v => v.HomePath); envVar.SetPropertyAsBehavior(v => v.UserProfile); Mocks.ReplayAll(); clone = new CloneCommand { ProjectLocation = GitEmptyTestProjectLocation, RepositoryToClone = GitEmptyTestProjectLocation, Destination = RepositoryDestination, Runner = runner, CommandArguments = command, EnvironmentVariable = envVar }; return envVar; }
public void WhenCloningARepositoryTheProgressIsProvided() { MockGitLocationForConfiguration(); Command command = MockCommandProperties(); Runner runner = MockRunner(); Mocks.ReplayAll(); var clone = new CloneCommand { ProjectLocation = GitTestProjectLocation, RepositoryToClone = GitTestProjectLocation, Destination = RepositoryDestination, Runner = runner, CommandArguments = command, EnvironmentVariable = StubEnvironmentVariable() }; string progressMessage = string.Empty; bool messageRecieved = false; clone.Progress += (s, e) => { if (!messageRecieved) { progressMessage = e.Message; messageRecieved = true; } }; clone.Run(); var eventArgs = new OutputReceivedArgs { Data = "This is a progress message" }; runner.Raise(v => v.ErrorOutputReceived += null, eventArgs); Stopwatch watch = Stopwatch.StartNew(); while (!messageRecieved && watch.Elapsed < TimeSpan.FromMilliseconds(500)) { Thread.Sleep(1); } Assert.That(messageRecieved); Assert.That(progressMessage.StartsWith("This is a progress message")); }