Example #1
0
        public void AddItemPreviousSiblingNotVisible(PythonVisualStudioApp app)
        {
            var project = app.OpenProject(@"TestData\AddItemPreviousSiblingNotVisible.sln");

            app.OpenSolutionExplorer();
            var window = app.SolutionExplorerTreeView;

            var projectNode = window.WaitForItem("Solution 'AddItemPreviousSiblingNotVisible' (1 of 1 project)", "HelloWorld");

            Assert.IsNotNull(projectNode);
            AutomationWrapper.Select(projectNode);

            var solutionService = app.GetService <IVsSolution>(typeof(SVsSolution));

            Assert.IsNotNull(solutionService);

            IVsHierarchy selectedHierarchy;

            ErrorHandler.ThrowOnFailure(solutionService.GetProjectOfUniqueName(project.UniqueName, out selectedHierarchy));
            Assert.IsNotNull(selectedHierarchy);
            HierarchyEvents events = new HierarchyEvents();
            uint            cookie;

            selectedHierarchy.AdviseHierarchyEvents(events, out cookie);

            using (var newItem = NewItemDialog.FromDte(app)) {
                var pythonFile = newItem.ProjectTypes.FindItem("Empty Python File");
                pythonFile.Select();
                newItem.FileName = "zmodule1.py";
                newItem.OK();
            }

            var test2 = window.WaitForItem("Solution 'AddItemPreviousSiblingNotVisible' (1 of 1 project)", "HelloWorld", "zmodule1.py");

            Assert.IsNotNull(test2);

            selectedHierarchy.UnadviseHierarchyEvents(cookie);

            object caption;

            ErrorHandler.ThrowOnFailure(
                selectedHierarchy.GetProperty(
                    events.SiblingPrev,
                    (int)__VSHPROPID.VSHPROPID_Caption,
                    out caption
                    )
                );

            Assert.AreEqual("Program.py", caption);
        }
Example #2
0
        public ProjectService(SolutionService solutionService, ObservableCollection <ProjectViewModel> projects)
        {
            _projectHierarchyData = new Dictionary <string, HierarchyData>();
            _solutionService      = solutionService;
            _projects             = projects;
            var subject = new Subject <EventArgs>();

            _updateRequestSource     = subject;
            _updateRequestConnection = subject.AsObservable()
                                       .Throttle(TimeSpan.FromMilliseconds(100))
                                       .ObserveOn(SynchronizationContext.Current)
                                       .Subscribe(_ => {
                ThreadHelper.ThrowIfNotOnUIThread();
                UpdateState();
            });

            _hierarchyEvents = new HierarchyEvents(this);

            WireEvents();
        }
Example #3
0
        public void AddItemPreviousSiblingNotVisible() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\AddItemPreviousSiblingNotVisible.sln");

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                var projectNode = window.WaitForItem("Solution 'AddItemPreviousSiblingNotVisible' (1 project)", "HelloWorld");
                Assert.IsNotNull(projectNode);
                AutomationWrapper.Select(projectNode);

                var solutionService = app.GetService<IVsSolution>(typeof(SVsSolution));
                Assert.IsNotNull(solutionService);

                IVsHierarchy selectedHierarchy;
                ErrorHandler.ThrowOnFailure(solutionService.GetProjectOfUniqueName(project.UniqueName, out selectedHierarchy));
                Assert.IsNotNull(selectedHierarchy);
                HierarchyEvents events = new HierarchyEvents();
                uint cookie;
                selectedHierarchy.AdviseHierarchyEvents(events, out cookie);

                using (var newItem = NewItemDialog.FromDte(app)) {
                    AutomationWrapper.Select(newItem.ProjectTypes.FindItem("Empty Python File"));
                    newItem.FileName = "zmodule1.py";
                    newItem.OK();
                }

                var test2 = window.WaitForItem("Solution 'AddItemPreviousSiblingNotVisible' (1 project)", "HelloWorld", "zmodule1.py");
                Assert.IsNotNull(test2);

                selectedHierarchy.UnadviseHierarchyEvents(cookie);

                object caption;
                ErrorHandler.ThrowOnFailure(
                    selectedHierarchy.GetProperty(
                        events.SiblingPrev,
                        (int)__VSHPROPID.VSHPROPID_Caption,
                        out caption
                    )
                );

                Assert.AreEqual("Program.py", caption);
            }
        }