public void Given_no_previously_selected_revision_When_single_revision_selected_Then_AuthorEmailToHighlight_should_change()
        {
            var sut           = new AuthorRevisionHighlighting();
            var currentModule = NewModule();

            sut.ProcessRevisionSelectionChange(currentModule, new[] { NewRevisionWithAuthorEmail(ExpectedAuthorEmail1) });

            sut.AuthorEmailToHighlight.Should().Be(ExpectedAuthorEmail1);
        }
        public void IsHighlighted_should_return_false_if_revision_AuthorEmail_is_null_or_whitespace(string authorEmail)
        {
            var sut = new AuthorRevisionHighlighting();

            sut.IsHighlighted(new GitRevision(ObjectId.Random())
            {
                AuthorEmail = authorEmail
            }).Should().BeFalse();
        }
        public void Given_no_previously_selected_revision_When_single_revision_selected_Then_ProcessSelectionChange_should_return_RefreshUserInterface()
        {
            var sut           = new AuthorRevisionHighlighting();
            var currentModule = NewModule();

            var action = sut.ProcessRevisionSelectionChange(currentModule, new[] { NewRevisionWithAuthorEmail(ExpectedAuthorEmail1) });

            action.Should().Be(true);
        }
        public void Given_previously_selected_revision_When_single_revision_with_same_author_email_selected_Then_ProcessSelectionChange_should_return_NoAction()
        {
            var sut           = new AuthorRevisionHighlighting();
            var currentModule = NewModule();

            sut.ProcessRevisionSelectionChange(currentModule, new[] { NewRevisionWithAuthorEmail(ExpectedAuthorEmail1) });

            var action = sut.ProcessRevisionSelectionChange(currentModule, new[] { NewRevisionWithAuthorEmail(ExpectedAuthorEmail1) });

            action.Should().Be(false);
        }
        public void Given_previously_selected_revision_When_no_revision_selected_Then_AuthorEmailToHighlight_should_be_value_of_current_user_email_setting()
        {
            var sut           = new AuthorRevisionHighlighting();
            var currentModule = NewModule();

            currentModule.SetSetting(SettingKeyString.UserEmail, ExpectedAuthorEmail2);
            sut.ProcessRevisionSelectionChange(currentModule, new[] { NewRevisionWithAuthorEmail(ExpectedAuthorEmail1) });

            sut.ProcessRevisionSelectionChange(currentModule, Array.Empty <GitRevision>());

            sut.AuthorEmailToHighlight.Should().Be(ExpectedAuthorEmail2);
        }
        public void Given_previously_selected_revision_When_no_revision_selected_Then_ProcessSelectionChange_should_return_RefreshUserInterface()
        {
            var sut           = new AuthorRevisionHighlighting();
            var currentModule = NewModule();

            currentModule.SetSetting(SettingKeyString.UserEmail, ExpectedAuthorEmail2);
            sut.ProcessRevisionSelectionChange(currentModule, new[] { NewRevisionWithAuthorEmail(ExpectedAuthorEmail1) });

            var action = sut.ProcessRevisionSelectionChange(currentModule, Array.Empty <GitRevision>());

            action.Should().Be(true);
        }
        public void IsHighlighted_should_return_true_if_revision_AuthorEmail_matches_AuthorEmailToHighlight(string authorEmail, string highlightEmail, bool expected)
        {
            var currentModule = NewModule();
            var sut           = new AuthorRevisionHighlighting();

            sut.ProcessRevisionSelectionChange(currentModule, new[] { NewRevisionWithAuthorEmail(highlightEmail) });
            sut.AuthorEmailToHighlight.Should().Be(highlightEmail);

            sut.IsHighlighted(new GitRevision(ObjectId.Random())
            {
                AuthorEmail = authorEmail
            }).Should().Be(expected);
        }
        public void When_multiple_revisions_selected_Then_ProcessSelectionChange_should_return_NoAction()
        {
            var sut           = new AuthorRevisionHighlighting();
            var currentModule = NewModule();

            var action = sut.ProcessRevisionSelectionChange(currentModule,
                                                            new[]
            {
                NewRevisionWithAuthorEmail(ExpectedAuthorEmail1),
                NewRevisionWithAuthorEmail(ExpectedAuthorEmail1)
            });

            action.Should().Be(false);
        }
        public AuthorNameColumnProvider(RevisionGridControl grid, AuthorRevisionHighlighting authorHighlighting)
            : base("Author Name")
        {
            _grid = grid;
            _authorHighlighting = authorHighlighting;

            Column = new DataGridViewTextBoxColumn
            {
                AutoSizeMode = DataGridViewAutoSizeColumnMode.None,
                HeaderText   = "Author Name",
                ReadOnly     = true,
                SortMode     = DataGridViewColumnSortMode.NotSortable,
                Width        = DpiUtil.Scale(130)
            };
        }
        public void Given_previously_selected_revision_When_multiple_revisions_selected_Then_AuthorEmailToHighlight_should_not_change()
        {
            var sut           = new AuthorRevisionHighlighting();
            var currentModule = NewModule();

            Assert.True(sut.ProcessRevisionSelectionChange(currentModule,
                                                           new[] { NewRevisionWithAuthorEmail(ExpectedAuthorEmail1) }));

            Assert.False(sut.ProcessRevisionSelectionChange(currentModule,
                                                            new[]
            {
                NewRevisionWithAuthorEmail(ExpectedAuthorEmail2),
                NewRevisionWithAuthorEmail(ExpectedAuthorEmail1)
            }));

            sut.AuthorEmailToHighlight.Should().Be(ExpectedAuthorEmail1);
        }
        public void AuthorEmailToHighlight_should_be_null_when_no_revision_change_processed_yet()
        {
            var sut = new AuthorRevisionHighlighting();

            sut.AuthorEmailToHighlight.Should().BeNull();
        }
        public void IsHighlighted_should_return_false_if_revision_is_null()
        {
            var sut = new AuthorRevisionHighlighting();

            sut.IsHighlighted(null).Should().BeFalse();
        }