public static void TextViewCreatedDoesNotCreateTemplateCompletionHandlerWhenCompletionListsAreDisabled() { ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(false); var adapterFactory = Substitute.For <IVsEditorAdaptersFactoryService>(); var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For <SVsServiceProvider>(), Substitute.For <ICompletionBroker>()); var viewAdapter = Substitute.For <IVsTextView>(); provider.VsTextViewCreated(viewAdapter); adapterFactory.DidNotReceive().GetWpfTextView(viewAdapter); }
public static void TextViewCreatedDoesNotCreateTemplateCompletionHandlerWhenViewAdapterDoesNotHaveTextView() { ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(true); var adapterFactory = Substitute.For <IVsEditorAdaptersFactoryService>(); adapterFactory.GetWpfTextView(Arg.Any <IVsTextView>()).Returns((IWpfTextView)null); var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For <SVsServiceProvider>(), Substitute.For <ICompletionBroker>()); provider.VsTextViewCreated(Substitute.For <IVsTextView>()); // No exception expected }
public static void TextViewCreatedCreatesTemplateCompletionHandlerWhenViewAdapterHasTextView() { var viewProperties = new PropertyCollection(); var view = Substitute.For <IWpfTextView>(); view.Properties.Returns(viewProperties); var viewAdapter = Substitute.For <IVsTextView>(); var adapterFactory = Substitute.For <IVsEditorAdaptersFactoryService>(); adapterFactory.GetWpfTextView(viewAdapter).Returns(view); ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(true); var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For <SVsServiceProvider>(), Substitute.For <ICompletionBroker>()); provider.VsTextViewCreated(viewAdapter); Assert.True(viewProperties.ContainsProperty(typeof(TemplateCompletionHandler))); }
public static void TestViewCreatedSetsNextHandlerOfTemplateCompletionHandler() { var viewProperties = new PropertyCollection(); var view = Substitute.For <IWpfTextView>(); view.Properties.Returns(viewProperties); var viewAdapter = Substitute.For <IVsTextView>(); var adapterFactory = Substitute.For <IVsEditorAdaptersFactoryService>(); adapterFactory.GetWpfTextView(viewAdapter).Returns(view); ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(true); var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For <SVsServiceProvider>(), Substitute.For <ICompletionBroker>()); provider.VsTextViewCreated(viewAdapter); var handler = (TemplateCompletionHandler)viewProperties.GetProperty(typeof(TemplateCompletionHandler)); viewAdapter.Received().AddCommandFilter(handler, out handler.NextHandler); }
public static void TextViewCreatedAddsTemplateCompletionHandlerToTextViewCommandFilters() { var viewProperties = new PropertyCollection(); var view = Substitute.For <IWpfTextView>(); view.Properties.Returns(viewProperties); var viewAdapter = Substitute.For <IVsTextView>(); var adapterFactory = Substitute.For <IVsEditorAdaptersFactoryService>(); adapterFactory.GetWpfTextView(viewAdapter).Returns(view); ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(true); var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For <SVsServiceProvider>(), Substitute.For <ICompletionBroker>()); provider.VsTextViewCreated(viewAdapter); IOleCommandTarget nextTarget; viewAdapter.Received().AddCommandFilter(Arg.Any <TemplateCompletionHandler>(), out nextTarget); }
public static void TextViewCreatedDoesNotCreateTemplateCompletionHandlerWhenViewAdapterDoesNotHaveTextView() { ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(true); var adapterFactory = Substitute.For<IVsEditorAdaptersFactoryService>(); adapterFactory.GetWpfTextView(Arg.Any<IVsTextView>()).Returns((IWpfTextView)null); var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For<SVsServiceProvider>(), Substitute.For<ICompletionBroker>()); provider.VsTextViewCreated(Substitute.For<IVsTextView>()); // No exception expected }
public static void TextViewCreatedDoesNotCreateTemplateCompletionHandlerWhenCompletionListsAreDisabled() { ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(false); var adapterFactory = Substitute.For<IVsEditorAdaptersFactoryService>(); var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For<SVsServiceProvider>(), Substitute.For<ICompletionBroker>()); var viewAdapter = Substitute.For<IVsTextView>(); provider.VsTextViewCreated(viewAdapter); adapterFactory.DidNotReceive().GetWpfTextView(viewAdapter); }
public static void TestViewCreatedSetsNextHandlerOfTemplateCompletionHandler() { var viewProperties = new PropertyCollection(); var view = Substitute.For<IWpfTextView>(); view.Properties.Returns(viewProperties); var viewAdapter = Substitute.For<IVsTextView>(); var adapterFactory = Substitute.For<IVsEditorAdaptersFactoryService>(); adapterFactory.GetWpfTextView(viewAdapter).Returns(view); ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(true); var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For<SVsServiceProvider>(), Substitute.For<ICompletionBroker>()); provider.VsTextViewCreated(viewAdapter); var handler = (TemplateCompletionHandler)viewProperties.GetProperty(typeof(TemplateCompletionHandler)); viewAdapter.Received().AddCommandFilter(handler, out handler.NextHandler); }
public static void TextViewCreatedAddsTemplateCompletionHandlerToTextViewCommandFilters() { var viewProperties = new PropertyCollection(); var view = Substitute.For<IWpfTextView>(); view.Properties.Returns(viewProperties); var viewAdapter = Substitute.For<IVsTextView>(); var adapterFactory = Substitute.For<IVsEditorAdaptersFactoryService>(); adapterFactory.GetWpfTextView(viewAdapter).Returns(view); ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(true); var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For<SVsServiceProvider>(), Substitute.For<ICompletionBroker>()); provider.VsTextViewCreated(viewAdapter); IOleCommandTarget nextTarget; viewAdapter.Received().AddCommandFilter(Arg.Any<TemplateCompletionHandler>(), out nextTarget); }
public static void TextViewCreatedCreatesTemplateCompletionHandlerWhenViewAdapterHasTextView() { var viewProperties = new PropertyCollection(); var view = Substitute.For<IWpfTextView>(); view.Properties.Returns(viewProperties); var viewAdapter = Substitute.For<IVsTextView>(); var adapterFactory = Substitute.For<IVsEditorAdaptersFactoryService>(); adapterFactory.GetWpfTextView(viewAdapter).Returns(view); ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(true); var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For<SVsServiceProvider>(), Substitute.For<ICompletionBroker>()); provider.VsTextViewCreated(viewAdapter); Assert.True(viewProperties.ContainsProperty(typeof(TemplateCompletionHandler))); }