public async Task ShouldDetectBranchCreate() { await Initialize(TestRepoMasterCleanSynchronized); using (var repositoryWatcher = CreateRepositoryWatcher(TestRepoMasterCleanSynchronized)) { var watcherAutoResetEvent = new RepositoryWatcherAutoResetEvent(); var repositoryWatcherListener = Substitute.For <IRepositoryWatcherListener>(); repositoryWatcherListener.AttachListener(repositoryWatcher, watcherAutoResetEvent); repositoryWatcher.Initialize(); repositoryWatcher.Start(); try { Logger.Trace("Issuing Command"); await GitClient.CreateBranch("feature/document2", "feature/document").StartAsAsync(); await TaskManager.Wait(); watcherAutoResetEvent.LocalBranchCreated.WaitOne(TimeSpan.FromSeconds(2)).Should().BeTrue(); Logger.Trace("Continue test"); repositoryWatcherListener.DidNotReceive().ConfigChanged(); repositoryWatcherListener.DidNotReceive().HeadChanged(); repositoryWatcherListener.DidNotReceive().IndexChanged(); repositoryWatcherListener.Received(1).LocalBranchCreated("feature/document2"); repositoryWatcherListener.DidNotReceive().LocalBranchDeleted(Args.String); repositoryWatcherListener.DidNotReceive().LocalBranchChanged("feature/document2"); repositoryWatcherListener.DidNotReceive().RemoteBranchChanged(Args.String, Args.String); repositoryWatcherListener.DidNotReceive().RemoteBranchCreated(Args.String, Args.String); repositoryWatcherListener.DidNotReceive().RemoteBranchDeleted(Args.String, Args.String); repositoryWatcherListener.DidNotReceive().RepositoryChanged(); repositoryWatcherListener.ClearReceivedCalls(); Logger.Trace("Issuing Command"); await GitClient.CreateBranch("feature2/document2", "feature/document").StartAsAsync(); await TaskManager.Wait(); watcherAutoResetEvent.LocalBranchCreated.WaitOne(TimeSpan.FromSeconds(2)).Should().BeTrue(); Logger.Trace("Continue test"); repositoryWatcherListener.DidNotReceive().ConfigChanged(); repositoryWatcherListener.DidNotReceive().HeadChanged(); repositoryWatcherListener.DidNotReceive().IndexChanged(); repositoryWatcherListener.Received(1).LocalBranchCreated("feature2/document2"); repositoryWatcherListener.DidNotReceive().LocalBranchDeleted(Args.String); repositoryWatcherListener.DidNotReceive().LocalBranchChanged(Args.String); repositoryWatcherListener.DidNotReceive().RemoteBranchChanged(Args.String, Args.String); repositoryWatcherListener.DidNotReceive().RemoteBranchCreated(Args.String, Args.String); repositoryWatcherListener.DidNotReceive().RemoteBranchDeleted(Args.String, Args.String); repositoryWatcherListener.DidNotReceive().RepositoryChanged(); repositoryWatcherListener.ClearReceivedCalls(); } finally { repositoryWatcher.Stop(); } } }
public async void CreateBranch() { var client = new GitClient(TeamProjectName, CollectionUri, AccessToken); await client.CreateBranch("refs/heads/test/123", "heads/develop", Guid.Parse("6e3239e6-e054-464a-81f5-6e95d72ba79a")); }