public async Task ShouldAddAndCommitAllFiles() { Logger.Trace("Starting ShouldAddAndCommitAllFiles"); try { var repositoryManagerListener = Substitute.For <IRepositoryManagerListener>(); await Initialize(TestRepoMasterCleanSynchronized, initializeRepository : false, onRepositoryManagerCreated : manager => { repositoryManagerListener.AttachListener(manager, repositoryManagerEvents); }); repositoryManagerEvents.CurrentBranchUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.LocalBranchesUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.RemoteBranchesUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.GitLogUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.GitAheadBehindStatusUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.IsBusy.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.IsNotBusy.WaitOne(Timeout).Should().BeTrue(); repositoryManagerListener.ClearReceivedCalls(); repositoryManagerEvents.Reset(); var foobarTxt = TestRepoMasterCleanSynchronized.Combine("foobar.txt"); foobarTxt.WriteAllText("foobar"); var testDocumentTxt = TestRepoMasterCleanSynchronized.Combine("Assets", "TestDocument.txt"); testDocumentTxt.WriteAllText("foobar"); await TaskManager.Wait(); RepositoryManager.WaitForEvents(); repositoryManagerEvents.WaitForNotBusy(); repositoryManagerEvents.GitStatusUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerListener.Received().OnIsBusyChanged(Args.Bool); repositoryManagerListener.DidNotReceive().CurrentBranchUpdated(Args.NullableConfigBranch, Args.NullableConfigRemote); repositoryManagerListener.DidNotReceive().GitAheadBehindStatusUpdated(Args.GitAheadBehindStatus); repositoryManagerListener.Received().GitStatusUpdated(Args.GitStatus); repositoryManagerListener.DidNotReceive().GitLocksUpdated(Args.GitLocks); repositoryManagerListener.DidNotReceive().GitLogUpdated(Args.GitLogs); repositoryManagerListener.DidNotReceive().LocalBranchesUpdated(Args.LocalBranchDictionary); repositoryManagerListener.DidNotReceive().RemoteBranchesUpdated(Args.RemoteDictionary, Args.RemoteBranchDictionary); repositoryManagerListener.ClearReceivedCalls(); repositoryManagerEvents.Reset(); await RepositoryManager .CommitAllFiles("IntegrationTest Commit", string.Empty) .StartAsAsync(); await TaskManager.Wait(); RepositoryManager.WaitForEvents(); repositoryManagerEvents.WaitForNotBusy(); repositoryManagerEvents.GitStatusUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.GitStatusUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.LocalBranchesUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.GitLogUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerListener.Received().OnIsBusyChanged(Args.Bool); repositoryManagerListener.DidNotReceive().CurrentBranchUpdated(Args.NullableConfigBranch, Args.NullableConfigRemote); repositoryManagerListener.DidNotReceive().GitAheadBehindStatusUpdated(Args.GitAheadBehindStatus); repositoryManagerListener.Received().GitStatusUpdated(Args.GitStatus); repositoryManagerListener.DidNotReceive().GitLocksUpdated(Args.GitLocks); repositoryManagerListener.Received().GitLogUpdated(Args.GitLogs); repositoryManagerListener.Received().LocalBranchesUpdated(Args.LocalBranchDictionary); repositoryManagerListener.DidNotReceive().RemoteBranchesUpdated(Args.RemoteDictionary, Args.RemoteBranchDictionary); } finally { Logger.Trace("Ending ShouldAddAndCommitAllFiles"); } }
public async Task ShouldAddAndCommitAllFiles() { await Initialize(TestRepoMasterCleanSynchronized); var repositoryManagerListener = Substitute.For <IRepositoryManagerListener>(); repositoryManagerListener.AttachListener(RepositoryManager, repositoryManagerEvents); var expectedAfterChanges = new GitStatus { Behind = 1, LocalBranch = "master", RemoteBranch = "origin/master", Entries = new List <GitStatusEntry> { new GitStatusEntry("Assets\\TestDocument.txt", TestRepoMasterCleanSynchronized.Combine("Assets", "TestDocument.txt"), "Assets\\TestDocument.txt", GitFileStatus.Modified), new GitStatusEntry("foobar.txt", TestRepoMasterCleanSynchronized.Combine("foobar.txt"), "foobar.txt", GitFileStatus.Untracked) } }; var result = new GitStatus(); RepositoryManager.OnStatusUpdated += status => { result = status; }; var foobarTxt = TestRepoMasterCleanSynchronized.Combine("foobar.txt"); foobarTxt.WriteAllText("foobar"); var testDocumentTxt = TestRepoMasterCleanSynchronized.Combine("Assets", "TestDocument.txt"); testDocumentTxt.WriteAllText("foobar"); await TaskManager.Wait(); WaitForNotBusy(repositoryManagerEvents, 1); RepositoryManager.WaitForEvents(); WaitForNotBusy(repositoryManagerEvents, 1); repositoryManagerListener.Received().OnStatusUpdate(Args.GitStatus); repositoryManagerListener.DidNotReceive().OnActiveBranchChanged(Arg.Any <ConfigBranch?>()); repositoryManagerListener.DidNotReceive().OnActiveRemoteChanged(Arg.Any <ConfigRemote?>()); repositoryManagerListener.DidNotReceive().OnHeadChanged(); repositoryManagerListener.DidNotReceive().OnLocalBranchListChanged(); repositoryManagerListener.DidNotReceive().OnRemoteBranchListChanged(); repositoryManagerListener.ReceivedWithAnyArgs().OnIsBusyChanged(Args.Bool); repositoryManagerListener.DidNotReceive().OnLocksUpdated(Args.EnumerableGitLock); result.AssertEqual(expectedAfterChanges); repositoryManagerListener.ClearReceivedCalls(); repositoryManagerEvents.Reset(); await RepositoryManager .CommitAllFiles("IntegrationTest Commit", string.Empty) .StartAsAsync(); await TaskManager.Wait(); RepositoryManager.WaitForEvents(); WaitForNotBusy(repositoryManagerEvents, 1); repositoryManagerListener.DidNotReceive().OnStatusUpdate(Args.GitStatus); repositoryManagerListener.DidNotReceive().OnActiveBranchChanged(Arg.Any <ConfigBranch?>()); repositoryManagerListener.DidNotReceive().OnActiveRemoteChanged(Arg.Any <ConfigRemote?>()); repositoryManagerListener.DidNotReceive().OnHeadChanged(); repositoryManagerListener.DidNotReceive().OnLocalBranchListChanged(); repositoryManagerListener.DidNotReceive().OnRemoteBranchListChanged(); repositoryManagerListener.Received(2).OnIsBusyChanged(Args.Bool); repositoryManagerListener.DidNotReceive().OnLocksUpdated(Args.EnumerableGitLock); }
public async Task ShouldAddAndCommitAllFiles() { Stopwatch watch = null; ILogging logger = null; StartTest(out watch, out logger); try { var repositoryManagerListener = Substitute.For <IRepositoryManagerListener>(); InitializePlatformAndEnvironment(TestRepoMasterCleanSynchronized, onRepositoryManagerCreated: manager => { repositoryManagerListener.AttachListener(manager, repositoryManagerEvents); }); repositoryManagerListener.AssertDidNotReceiveAnyCalls(); logger.Trace("Add files"); var foobarTxt = TestRepoMasterCleanSynchronized.Combine("foobar.txt"); foobarTxt.WriteAllText("foobar"); await TaskManager.Wait(); StartTrackTime(watch, logger, "RepositoryManager.WaitForEvents()"); RepositoryManager.WaitForEvents(); StopTrackTimeAndLog(watch, logger); StartTrackTime(watch, logger, "repositoryManagerEvents.WaitForNotBusy()"); await repositoryManagerEvents.WaitForNotBusy(); StopTrackTimeAndLog(watch, logger); // we expect these events await AssertReceivedEvent(nameof(repositoryManagerEvents.GitStatusUpdated), repositoryManagerEvents.GitStatusUpdated); // we don't expect these events await AssertDidNotReceiveEvent(nameof(repositoryManagerEvents.LocalBranchesUpdated), repositoryManagerEvents.LocalBranchesUpdated); await AssertDidNotReceiveEvent(nameof(repositoryManagerEvents.RemoteBranchesUpdated), repositoryManagerEvents.RemoteBranchesUpdated); await AssertDidNotReceiveEvent(nameof(repositoryManagerEvents.GitAheadBehindStatusUpdated), repositoryManagerEvents.GitAheadBehindStatusUpdated); await AssertDidNotReceiveEvent(nameof(repositoryManagerEvents.GitLogUpdated), repositoryManagerEvents.GitLogUpdated); await AssertDidNotReceiveEvent(nameof(repositoryManagerEvents.GitLocksUpdated), repositoryManagerEvents.GitLocksUpdated); await AssertDidNotReceiveEvent(nameof(repositoryManagerEvents.CurrentBranchUpdated), repositoryManagerEvents.CurrentBranchUpdated); repositoryManagerListener.ClearReceivedCalls(); repositoryManagerEvents.Reset(); StartTrackTime(watch, logger, "CommitAllFiles"); await RepositoryManager.CommitAllFiles("IntegrationTest Commit", string.Empty).StartAsAsync(); StopTrackTimeAndLog(watch, logger); await TaskManager.Wait(); StartTrackTime(watch, logger, "RepositoryManager.WaitForEvents()"); RepositoryManager.WaitForEvents(); StopTrackTimeAndLog(watch, logger); StartTrackTime(watch, logger, "repositoryManagerEvents.WaitForNotBusy()"); await repositoryManagerEvents.WaitForNotBusy(); StopTrackTimeAndLog(watch, logger); // we expect these events await AssertReceivedEvent(nameof(repositoryManagerEvents.GitStatusUpdated), repositoryManagerEvents.GitStatusUpdated); await AssertReceivedEvent(nameof(repositoryManagerEvents.LocalBranchesUpdated), repositoryManagerEvents.LocalBranchesUpdated); await AssertReceivedEvent(nameof(repositoryManagerEvents.RemoteBranchesUpdated), repositoryManagerEvents.RemoteBranchesUpdated); await AssertReceivedEvent(nameof(repositoryManagerEvents.GitAheadBehindStatusUpdated), repositoryManagerEvents.GitAheadBehindStatusUpdated); await AssertReceivedEvent(nameof(repositoryManagerEvents.GitLogUpdated), repositoryManagerEvents.GitLogUpdated); await AssertReceivedEvent(nameof(repositoryManagerEvents.CurrentBranchUpdated), repositoryManagerEvents.CurrentBranchUpdated); // we don't expect these events await AssertDidNotReceiveEvent(nameof(repositoryManagerEvents.GitLocksUpdated), repositoryManagerEvents.GitLocksUpdated); } finally { EndTest(logger); } }
public async Task ShouldAddAndCommitAllFiles() { Stopwatch watch = null; ILogging logger = null; StartTest(out watch, out logger); try { var repositoryManagerListener = Substitute.For <IRepositoryManagerListener>(); InitializePlatformAndEnvironment(TestRepoMasterCleanSynchronized, onRepositoryManagerCreated: manager => { repositoryManagerListener.AttachListener(manager, repositoryManagerEvents); }); repositoryManagerListener.AssertDidNotReceiveAnyCalls(); var foobarTxt = TestRepoMasterCleanSynchronized.Combine("foobar.txt"); foobarTxt.WriteAllText("foobar"); var testDocumentTxt = TestRepoMasterCleanSynchronized.Combine("Assets", "TestDocument.txt"); testDocumentTxt.WriteAllText("foobar"); await TaskManager.Wait(); StartTrackTime(watch, logger, "RepositoryManager.WaitForEvents()"); RepositoryManager.WaitForEvents(); StopTrackTimeAndLog(watch, logger); StartTrackTime(watch, logger, "repositoryManagerEvents.WaitForNotBusy()"); repositoryManagerEvents.WaitForNotBusy(); StopTrackTimeAndLog(watch, logger); repositoryManagerEvents.GitStatusUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerListener.Received().OnIsBusyChanged(Args.Bool); repositoryManagerListener.DidNotReceive().CurrentBranchUpdated(Args.NullableConfigBranch, Args.NullableConfigRemote); repositoryManagerListener.DidNotReceive().GitAheadBehindStatusUpdated(Args.GitAheadBehindStatus); repositoryManagerListener.Received().GitStatusUpdated(Args.GitStatus); repositoryManagerListener.DidNotReceive().GitLocksUpdated(Args.GitLocks); repositoryManagerListener.DidNotReceive().GitLogUpdated(Args.GitLogs); repositoryManagerListener.DidNotReceive().LocalBranchesUpdated(Args.LocalBranchDictionary); repositoryManagerListener.DidNotReceive().RemoteBranchesUpdated(Args.RemoteDictionary, Args.RemoteBranchDictionary); repositoryManagerListener.ClearReceivedCalls(); repositoryManagerEvents.Reset(); StartTrackTime(watch, logger, "CommitAllFiles"); await RepositoryManager .CommitAllFiles("IntegrationTest Commit", string.Empty) .StartAsAsync(); StopTrackTimeAndLog(watch, logger); await TaskManager.Wait(); StartTrackTime(watch, logger, "RepositoryManager.WaitForEvents()"); RepositoryManager.WaitForEvents(); StopTrackTimeAndLog(watch, logger); StartTrackTime(watch, logger, "repositoryManagerEvents.WaitForNotBusy()"); repositoryManagerEvents.WaitForNotBusy(); StopTrackTimeAndLog(watch, logger); repositoryManagerEvents.GitStatusUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.LocalBranchesUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerEvents.GitLogUpdated.WaitOne(Timeout).Should().BeTrue(); repositoryManagerListener.Received().OnIsBusyChanged(Args.Bool); repositoryManagerListener.Received().CurrentBranchUpdated(Args.NullableConfigBranch, Args.NullableConfigRemote); repositoryManagerListener.Received().GitAheadBehindStatusUpdated(Args.GitAheadBehindStatus); repositoryManagerListener.Received().GitStatusUpdated(Args.GitStatus); repositoryManagerListener.DidNotReceive().GitLocksUpdated(Args.GitLocks); repositoryManagerListener.Received().GitLogUpdated(Args.GitLogs); repositoryManagerListener.Received().LocalBranchesUpdated(Args.LocalBranchDictionary); repositoryManagerListener.Received().RemoteBranchesUpdated(Args.RemoteDictionary, Args.RemoteBranchDictionary); } finally { EndTest(logger); } }