public void Create_CreatesTooltipWithHyperlink()
        {
            var issue = new Mock <IAnalysisIssueBase>();

            issue.Setup(x => x.RuleKey).Returns("some rule");
            issue.Setup(x => x.Message).Returns("some message");

            var navigateCommand = Mock.Of <INavigateToRuleDescriptionCommand>();

            var testSubject = new ErrorTagTooltipProvider(Mock.Of <IVsThemeColorProvider>(), navigateCommand);
            var result      = testSubject.Create(issue.Object);

            result.Should().NotBeNull();
            result.Should().BeOfType <TextBlock>();

            var inlines = ((TextBlock)result).Inlines.ToList();

            inlines[0].Should().BeOfType <Hyperlink>();
            inlines[1].Should().BeOfType <Run>();
            inlines[2].Should().BeOfType <Run>();

            (inlines[1] as Run).Text.Should().Be(": ");
            (inlines[2] as Run).Text.Should().Be("some message");

            var hyperlink = (Hyperlink)inlines[0];

            hyperlink.Command.Should().Be(navigateCommand);
            hyperlink.CommandParameter.Should().Be("some rule");
        }
Пример #2
0
        public void Create_CreatesTooltipWithHyperlink()
        {
            var issue = new Mock <IAnalysisIssueBase>();

            issue.Setup(x => x.RuleKey).Returns("some rule");
            issue.Setup(x => x.Message).Returns("some message");

            var ruleHelpLinkProvider = new Mock <IRuleHelpLinkProvider>();

            ruleHelpLinkProvider.Setup(x => x.GetHelpLink("some rule")).Returns("some url");

            var browserService = new Mock <IVsBrowserService>();

            var testSubject = new ErrorTagTooltipProvider(browserService.Object, Mock.Of <IVsThemeColorProvider>(), ruleHelpLinkProvider.Object);
            var result      = testSubject.Create(issue.Object);

            result.Should().NotBeNull();
            result.Should().BeOfType <TextBlock>();

            var inlines = ((TextBlock)result).Inlines.ToList();

            inlines[0].Should().BeOfType <Hyperlink>();
            inlines[1].Should().BeOfType <Run>();
            inlines[2].Should().BeOfType <Run>();

            (inlines[1] as Run).Text.Should().Be(": ");
            (inlines[2] as Run).Text.Should().Be("some message");

            var hyperlink = (Hyperlink)inlines[0];

            hyperlink.Command.Should().NotBeNull();
            hyperlink.Command.CanExecute(null).Should().BeTrue();

            browserService.Invocations.Count.Should().Be(0);
            hyperlink.Command.Execute(null);
            browserService.Verify(x => x.Navigate("some url"), Times.Once);
            browserService.VerifyNoOtherCalls();
        }