コード例 #1
0
        public IssueVisualizationToolWindow(IServiceProvider serviceProvider) : base(null)
        {
            Caption = Resources.IssueVisualizationToolWindowCaption;

            var componentModel    = serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel;
            var selectionService  = componentModel.GetService <IAnalysisIssueSelectionService>();
            var locationNavigator = componentModel.GetService <ILocationNavigator>();

            var imageService = serviceProvider.GetService(typeof(SVsImageService)) as IVsImageService2;
            var logger       = componentModel.GetService <ILogger>();
            var fileNameLocationListItemCreator = new FileNameLocationListItemCreator(imageService, logger);

            var navigateToCodeLocationCommand    = componentModel.GetService <INavigateToCodeLocationCommand>();
            var navigateToRuleDescriptionCommand = componentModel.GetService <INavigateToRuleDescriptionCommand>();
            var navigateToDocumentationCommand   = componentModel.GetService <INavigateToDocumentationCommand>();

            var viewModel = new IssueVisualizationViewModel(
                selectionService,
                locationNavigator,
                fileNameLocationListItemCreator,
                navigateToCodeLocationCommand,
                navigateToRuleDescriptionCommand,
                navigateToDocumentationCommand);

            Content = new IssueVisualizationControl(viewModel);
        }
        public void TestInitialize()
        {
            selectionServiceMock  = new Mock <IAnalysisIssueSelectionService>();
            locationNavigatorMock = new Mock <ILocationNavigator>();
            fileNameLocationListItemCreatorMock = new Mock <IFileNameLocationListItemCreator>();
            propertyChangedEventHandler         = new Mock <PropertyChangedEventHandler>();

            testSubject = CreateTestSubject();

            selectionServiceMock.Invocations.Clear();
        }
        private IssueVisualizationViewModel CreateTestSubject()
        {
            var viewModel = new IssueVisualizationViewModel(selectionServiceMock.Object,
                                                            locationNavigatorMock.Object,
                                                            fileNameLocationListItemCreatorMock.Object,
                                                            Mock.Of <INavigateToCodeLocationCommand>(),
                                                            Mock.Of <INavigateToRuleDescriptionCommand>(),
                                                            Mock.Of <INavigateToDocumentationCommand>());

            viewModel.PropertyChanged += propertyChangedEventHandler.Object;

            return(viewModel);
        }
        public void Ctor_InitializeWithExistingSelection()
        {
            var newLocation = CreateLocation();
            var newFlow     = CreateFlow(newLocation);
            var newIssue    = CreateIssue(flows: new[] { newFlow });

            selectionServiceMock.Setup(x => x.SelectedIssue).Returns(newIssue);
            selectionServiceMock.Setup(x => x.SelectedFlow).Returns(newFlow);
            selectionServiceMock.Setup(x => x.SelectedLocation).Returns(newLocation);

            testSubject = CreateTestSubject();

            testSubject.CurrentIssue.Should().Be(newIssue);
            testSubject.CurrentFlow.Should().Be(newFlow);
            testSubject.CurrentLocationListItem.Should().NotBeNull();
            testSubject.CurrentLocationListItem.Location.Should().Be(newLocation);
        }