public async Task MovingToNoRepositoryShouldNullOutProperties()
            {
                var textView       = CreateTextView();
                var sessionService = CreateSessionService();
                var threads        = new List <IInlineCommentThreadModel>();
                var teHolder       = new FakeTeamExplorerServiceHolder(CreateRepositoryModel());

                var target = new PullRequestSessionManager(
                    CreatePullRequestService(),
                    CreateSessionService(),
                    CreateRepositoryHosts(),
                    teHolder);

                sessionService.BuildCommentThreads(
                    target.CurrentSession.PullRequest,
                    FilePath,
                    Arg.Any <IReadOnlyList <DiffChunk> >())
                .Returns(threads);

                var file = (PullRequestSessionLiveFile)await target.GetLiveFile(FilePath, textView, textView.TextBuffer);

                Assert.NotNull(file.BaseSha);
                Assert.NotNull(file.CommitSha);
                Assert.NotNull(file.Diff);
                Assert.NotNull(file.InlineCommentThreads);
                Assert.NotNull(file.TrackingPoints);

                teHolder.ActiveRepo = null;

                Assert.Null(file.BaseSha);
                Assert.Null(file.CommitSha);
                Assert.Null(file.Diff);
                Assert.Null(file.InlineCommentThreads);
                Assert.Null(file.TrackingPoints);
            }
            public void RepoChangedHandlesNullRepository()
            {
                var teService = new FakeTeamExplorerServiceHolder(CreateRepositoryModel());
                var target    = new PullRequestSessionManager(
                    CreatePullRequestService(),
                    Substitute.For <IPullRequestSessionService>(),
                    CreateRepositoryHosts(),
                    teService);

                teService.ActiveRepo = null;

                Assert.Null(target.CurrentSession);
            }
            public void RepoChangedDoesntCreateNewSessionIfNotNecessary()
            {
                var teService = new FakeTeamExplorerServiceHolder(CreateRepositoryModel());
                var target    = new PullRequestSessionManager(
                    CreatePullRequestService(),
                    Substitute.For <IPullRequestSessionService>(),
                    CreateRepositoryHosts(),
                    teService);

                var session = target.CurrentSession;

                teService.NotifyActiveRepoChanged();

                Assert.Same(session, target.CurrentSession);
            }
            public void CurrentSessionChangesWhenRepoChanged()
            {
                var teService = new FakeTeamExplorerServiceHolder(CreateRepositoryModel());
                var target    = new PullRequestSessionManager(
                    CreatePullRequestService(),
                    Substitute.For <IPullRequestSessionService>(),
                    CreateRepositoryHosts(),
                    teService);

                var session = target.CurrentSession;

                teService.ActiveRepo = CreateRepositoryModel("https://github.com/owner/other");

                Assert.NotSame(session, target.CurrentSession);
            }
            public void CurrentSessionChangesWhenBranchChanges()
            {
                var service   = CreatePullRequestService();
                var teService = new FakeTeamExplorerServiceHolder(CreateRepositoryModel());
                var target    = new PullRequestSessionManager(
                    service,
                    Substitute.For <IPullRequestSessionService>(),
                    CreateRepositoryHosts(),
                    teService);

                var session = target.CurrentSession;

                service.GetPullRequestForCurrentBranch(null).ReturnsForAnyArgs(Observable.Return(Tuple.Create("foo", 22)));
                teService.NotifyActiveRepoChanged();

                Assert.NotSame(session, target.CurrentSession);
            }