示例#1
0
        public async Task R_LibrarySuggestedActions()
        {
            using (var script = await _editorHost.StartScript(_services, " library(base)", RContentTypeDefinition.ContentType)) {
                IEnumerable <SuggestedActionSet> sets = null;
                ILightBulbSession session             = null;

                var svc = _services.GetService <ISuggestedActionCategoryRegistryService>();

                script.Invoke(() => {
                    var broker = _services.GetService <ILightBulbBroker2>();
                    broker.CreateSession(svc.AllCodeFixes, script.View, svc.AllCodeFixes);
                    session = script.GetLightBulbSession();
                    session.Should().NotBeNull();
                    session.Expand();
                    session.TryGetSuggestedActionSets(out sets);
                });

                sets.Should().NotBeNull();
                sets.Should().BeEmpty();

                script.Invoke(() => session.Dismiss());
                script.DoIdle(200);

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

                sets = null;
                script.Invoke(() => {
                    var broker = _services.GetService <ILightBulbBroker2>();
                    broker.DismissSession(script.View);
                    broker.CreateSession(svc.Any, script.View, svc.AllCodeFixes);
                    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));
            }
        }
示例#2
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.DismissSession(EditorWindow.CoreEditor.View);
                    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));
            }
        }