Example #1
0
        static void SetActiveRepository(IVSGitExt gitExt, LocalRepositoryModel repo)
        {
            var repos = repo != null ? new[] { repo } : Array.Empty <LocalRepositoryModel>();

            gitExt.ActiveRepositories.Returns(repos);
            gitExt.ActiveRepositoriesChanged += Raise.Event <Action>();
        }
Example #2
0
    static PullRequestService CreateTarget(
        IGitClient gitClient                 = null,
        IGitService gitService               = null,
        IVSGitExt gitExt                     = null,
        IApiClientFactory apiClientFactory   = null,
        IGraphQLClientFactory graphqlFactory = null,
        IOperatingSystem os                  = null,
        IUsageTracker usageTracker           = null)
    {
        gitClient        = gitClient ?? Substitute.For <IGitClient>();
        gitService       = gitService ?? Substitute.For <IGitService>();
        gitExt           = gitExt ?? Substitute.For <IVSGitExt>();
        apiClientFactory = apiClientFactory ?? Substitute.For <IApiClientFactory>();
        graphqlFactory   = graphqlFactory ?? Substitute.For <IGraphQLClientFactory>();
        os           = os ?? Substitute.For <IOperatingSystem>();
        usageTracker = usageTracker ?? Substitute.For <IUsageTracker>();

        return(new PullRequestService(
                   gitClient,
                   gitService,
                   gitExt,
                   apiClientFactory,
                   graphqlFactory,
                   os,
                   usageTracker));
    }
Example #3
0
 public RepositoryForkService(IGitClient gitClient, IVSGitServices vsGitServices, IVSGitExt vsGitExt, IUsageTracker usageTracker)
 {
     this.gitClient     = gitClient;
     this.vsGitServices = vsGitServices;
     this.vsGitExt      = vsGitExt;
     this.usageTracker  = usageTracker;
 }
        public TeamExplorerServiceHolder(IVSGitExt gitService)
        {
            this.gitService = gitService;
            syncContext     = SynchronizationContext.Current;

            UpdateActiveRepo();
            gitService.ActiveRepositoriesChanged += UpdateActiveRepo;
        }
Example #5
0
        static TeamExplorerContext CreateTeamExplorerContext(IVSGitExt gitExt, DTE dte = null)
        {
            dte = dte ?? Substitute.For <DTE>();
            var sp = Substitute.For <IGitHubServiceProvider>();

            sp.GetService <DTE>().Returns(dte);
            return(new TeamExplorerContext(gitExt, sp));
        }
        public TeamExplorerContext(IVSGitExt gitExt, IGitHubServiceProvider serviceProvider)
        {
            this.gitExt = gitExt;

            // This is a standard service which should always be available.
            dte = serviceProvider.GetService <DTE>();

            Refresh();
            gitExt.ActiveRepositoriesChanged += Refresh;
        }
Example #7
0
 static TeamExplorerContext CreateTeamExplorerContext(
     IVSGitExt gitExt,
     DTE dte = null,
     IPullRequestService pullRequestService  = null,
     JoinableTaskContext joinableTaskContext = null)
 {
     dte = dte ?? Substitute.For <DTE>();
     pullRequestService  = pullRequestService ?? Substitute.For <IPullRequestService>();
     joinableTaskContext = joinableTaskContext ?? new JoinableTaskContext();
     return(new TeamExplorerContext(gitExt, new AsyncLazy <DTE>(() => Task.FromResult(dte)), pullRequestService, joinableTaskContext));
 }
        static TeamExplorerContext CreateTeamExplorerContext(
            IVSGitExt gitExt,
            DTE dte = null,
            IPullRequestService pullRequestService = null)
        {
            dte = dte ?? Substitute.For <DTE>();
            pullRequestService = pullRequestService ?? Substitute.For <IPullRequestService>();
            var sp = Substitute.For <IGitHubServiceProvider>();

            sp.GetService <DTE>().Returns(dte);
            return(new TeamExplorerContext(sp, gitExt, pullRequestService));
        }
 public PullRequestService(
     IGitClient gitClient,
     IGitService gitService,
     IVSGitExt gitExt,
     IOperatingSystem os,
     IUsageTracker usageTracker)
 {
     this.gitClient    = gitClient;
     this.gitService   = gitService;
     this.gitExt       = gitExt;
     this.os           = os;
     this.usageTracker = usageTracker;
 }
        /// <summary>
        /// This constructor can be used for unit testing.
        /// </summary>
        /// <param name="gitService">Used for monitoring the active repository.</param>
        /// <param name="joinableTaskFactory">Used for switching to the Main thread.</param>
        public TeamExplorerServiceHolder(IVSGitExt gitService, JoinableTaskContext joinableTaskContext)
        {
            JoinableTaskCollection             = joinableTaskContext.CreateCollection();
            JoinableTaskCollection.DisplayName = nameof(TeamExplorerServiceHolder);
            JoinableTaskFactory = joinableTaskContext.CreateFactory(JoinableTaskCollection);

            // This might be null in Blend or SafeMode
            if (gitService != null)
            {
                this.gitService = gitService;
                UpdateActiveRepo();
                gitService.ActiveRepositoriesChanged += UpdateActiveRepo;
            }
        }
 TeamExplorerContext(
     IVSGitExt gitExt,
     [Import(typeof(SVsServiceProvider))] IServiceProvider sp,
     IPullRequestService pullRequestService) : this(
         gitExt,
         new AsyncLazy <DTE>(async() =>
 {
     await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
     return((DTE)sp.GetService(typeof(DTE)));
 }),
         pullRequestService,
         ThreadHelper.JoinableTaskContext)
 {
 }
        public PullRequestDetailViewModel(
            IPullRequestService pullRequestsService,
            IPullRequestSessionManager sessionManager,
            IModelServiceFactory modelServiceFactory,
            IUsageTracker usageTracker,
            IVSGitExt vsGitExt)
        {
            Guard.ArgumentNotNull(pullRequestsService, nameof(pullRequestsService));
            Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
            Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
            Guard.ArgumentNotNull(usageTracker, nameof(usageTracker));

            this.pullRequestsService = pullRequestsService;
            this.sessionManager      = sessionManager;
            this.modelServiceFactory = modelServiceFactory;
            this.usageTracker        = usageTracker;
            this.vsGitExt            = vsGitExt;

            Checkout = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.CheckoutState)
                .Cast <CheckoutCommandState>()
                .Select(x => x != null && x.IsEnabled),
                DoCheckout);
            Checkout.IsExecuting.Subscribe(x => isInCheckout = x);
            SubscribeOperationError(Checkout);

            Pull = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.PullEnabled),
                DoPull);
            SubscribeOperationError(Pull);

            Push = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.PushEnabled),
                DoPush);
            SubscribeOperationError(Push);

            OpenOnGitHub = ReactiveCommand.Create();
            DiffFile     = ReactiveCommand.Create();
            DiffFileWithWorkingDirectory = ReactiveCommand.Create(this.WhenAnyValue(x => x.IsCheckedOut));
            OpenFileInWorkingDirectory   = ReactiveCommand.Create(this.WhenAnyValue(x => x.IsCheckedOut));
            ViewFile = ReactiveCommand.Create();
        }
        public TeamExplorerContext(
            IVSGitExt gitExt,
            AsyncLazy <DTE> dteAsync,
            IPullRequestService pullRequestService,
            JoinableTaskContext joinableTaskContext)
        {
            JoinableTaskCollection             = joinableTaskContext.CreateCollection();
            JoinableTaskCollection.DisplayName = nameof(TeamExplorerContext);
            JoinableTaskFactory = joinableTaskContext.CreateFactory(JoinableTaskCollection);

            this.gitExt             = gitExt;
            this.dteAsync           = dteAsync;
            this.pullRequestService = pullRequestService;

            StartRefresh();
            gitExt.ActiveRepositoriesChanged += Refresh;
        }
    static PullRequestService CreateTarget(
        IGitClient gitClient       = null,
        IGitService gitService     = null,
        IVSGitExt gitExt           = null,
        IOperatingSystem os        = null,
        IUsageTracker usageTracker = null)
    {
        gitClient    = gitClient ?? Substitute.For <IGitClient>();
        gitService   = gitService ?? Substitute.For <IGitService>();
        gitExt       = gitExt ?? Substitute.For <IVSGitExt>();
        os           = os ?? Substitute.For <IOperatingSystem>();
        usageTracker = usageTracker ?? Substitute.For <IUsageTracker>();

        return(new PullRequestService(
                   gitClient,
                   gitService,
                   gitExt,
                   os,
                   usageTracker));
    }
Example #15
0
 static void RefreshContext(UIContext context, IVSGitExt gitExt)
 {
     context.IsActive = gitExt.ActiveRepositories.Count > 0;
 }
 TeamExplorerServiceHolder(IVSGitExt gitService) : this(gitService, ThreadHelper.JoinableTaskContext)
 {
 }
 public TeamExplorerContext(IGitHubServiceProvider serviceProvider, IVSGitExt gitExt)
     : this(gitExt, serviceProvider)
 {
 }
 public TeamExplorerServiceHolder(IVSGitExt gitService)
 {
     this.GitService = gitService;
     syncContext     = SynchronizationContext.Current;
 }