public void WhenRetrievingExportedMultipleComponents_ThenSucceeds() { var devEnv = DevEnv.Get(this.ServiceProvider); var result = devEnv.ServiceLocator.GetAllInstances <ICompletionSourceProvider>().ToList(); Assert.True(result.Any()); }
public void WhenGettingExportedServices_ThenSuccceedsForAll() { var devEnv = DevEnv.Get(GlobalServiceProvider.Instance); Assert.NotNull(devEnv.ServiceLocator.GetInstance <DTE>()); Assert.NotNull(devEnv.ServiceLocator.GetInstance <IVsShell>()); }
public void WhenRetrievingAPackageExport_ThenReturnsSingleExport() { var devEnv = DevEnv.Get(new Guid(Constants.PackageGuid)); var models = devEnv.ServiceLocator.GetAllInstances <ViewModel>().ToList(); Assert.Equal(1, models.Count); }
public void WhenCreatingDialog_ThenSucceeds() { var devEnv = DevEnv.Get(this.ServiceProvider); var window = devEnv.DialogWindowFactory.CreateDialog <FooWindow>(); devEnv.UIThread.Invoke(() => { Assert.NotNull(window); }); }
public void WhenRetrievingSettings_ThenSavesDefaultTracingLevelValue() { var devEnv = DevEnv.Get(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider); var settings = devEnv.ServiceLocator.GetInstance <ClideSettings>(); Assert.NotNull(settings); var defaultValue = Reflect <ClideSettings> .GetProperty(x => x.TracingLevel) .GetCustomAttributes(typeof(DefaultValueAttribute), true) .OfType <DefaultValueAttribute>() .Select(d => (SourceLevels)d.Value) .First(); var collection = SettingsManager.GetSettingsCollectionName(typeof(ClideSettings)); Assert.True(settingsStore.CollectionExists(collection)); Assert.Equal(defaultValue, (SourceLevels)Enum.Parse(typeof(SourceLevels), settingsStore.GetString(collection, Reflect <ClideSettings> .GetPropertyName(x => x.TracingLevel), "-1"))); }
/// <summary> /// Registers the package components such as commands, filter, options, etc. /// with the development environment. This call should always be made from /// the package Initialize method, which is guaranteed to run on the UI /// thread. /// </summary> /// <param name="hostingPackage">The package owning this deploy /// of Clide.</param> public static IDevEnv Initialize(IServiceProvider hostingPackage) { try { // This call should always be made from a package Initialize method, // which is guaranteed to be called from the UI thread. UIThread.Initialize(Dispatcher.CurrentDispatcher); var devEnv = DevEnv.Get(hostingPackage); using (tracer.StartActivity("Initializing package")) { // TODO // Brings in imports that the package itself might need. //devEnv.ServiceLocator.SatisfyImportsOnce(hostingPackage); // Initialize the host package components. var host = devEnv.ServiceLocator.GetInstance <HostImpl>(); host.Initialize(); // This call causes the static initialization on Adapters to run, which // is then overriden on the next line. Debug.Assert(Adapters.ServiceInstance != null); // Re-initialize the adapter service so that extended adapter implementations // are available. AdaptersInitializer.SetService(devEnv.ServiceLocator.GetInstance <IAdapterService>()); // Force initialization of the global service locator so that the component model // is requested from the UI thread. // This call also forces initialization of the global service locator singleton. Debug.Assert(ServiceLocator.GlobalLocator != null); tracer.Info("Package initialization finished successfully"); return(devEnv); } } catch (Exception ex) { tracer.Error(ex, Strings.Host.FailedToInitialize); throw; } }
public void when_getting_global_devenv_then_succeeds() { var dev = DevEnv.Get(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider); Assert.NotNull(dev); }
public void WhenRetrievingSingleComponent_ThenSucceeds() { var devEnv = DevEnv.Get(GlobalServiceProvider.Instance); Assert.NotNull(devEnv.ServiceLocator.GetInstance <ISmartTagBroker>()); }