Ejemplo n.º 1
0
        public void R_LibrarySuggestedActions() {
            using (var script = new TestScript(" library(base)", RContentTypeDefinition.ContentType)) {
                IEnumerable<SuggestedActionSet> sets = null;
                ILightBulbSession session = null;

                var e = EditorShell.Current.ExportProvider;
                var svc = e.GetExportedValue<ISuggestedActionCategoryRegistryService>();

                script.Invoke(() => {
                    var broker = e.GetExportedValue<ILightBulbBroker>();
                    broker.CreateSession(svc.AllCodeFixes, EditorWindow.CoreEditor.View);
                    session = script.GetLightBulbSession();
                    session.Should().NotBeNull();
                    session.Expand();
                    session.TryGetSuggestedActionSets(out sets);
                });

                sets.Should().NotBeNull();
                sets.Should().HaveCount(0);
                session.Dismiss();
                script.DoIdle(200);

                script.MoveRight(2);
                script.DoIdle(200);

                sets = null;
                script.Invoke(() => {
                    var broker = e.GetExportedValue<ILightBulbBroker>();
                    broker.CreateSession(svc.Any, EditorWindow.CoreEditor.View);
                    session = script.GetLightBulbSession();
                    session.Should().NotBeNull();
                    session.Expand();
                    session.TryGetSuggestedActionSets(out sets);
                });
                script.DoIdle(3000);

                sets = null;
                script.Invoke(() => {
                    session.TryGetSuggestedActionSets(out sets);
                });

                sets.Should().NotBeNull();
                sets.Should().HaveCount(1);

                var set = sets.First();
                set.Actions.Should().HaveCount(2);
                var actions = set.Actions.ToArray();
                actions[0].Should().BeOfType(typeof(InstallPackageSuggestedAction));
                actions[1].Should().BeOfType(typeof(LoadLibrarySuggestedAction));
            }
        }