public void WhenGettingExportedServices_ThenSuccceedsForAll() { var devEnv = DevEnv.Get(GlobalServiceProvider.Instance); Assert.NotNull(devEnv.ServiceLocator.GetInstance <DTE>()); Assert.NotNull(devEnv.ServiceLocator.GetInstance <IVsShell>()); }
public void WhenCloning_ThenTargetPatternIsCloned() { new PatternModelCloner(this.sourcePatternModel, new Version("1.0.0.0"), this.targetPatternModel).Clone(); Assert.NotNull(this.targetPatternModel.Pattern); Assert.Equal(this.sourcePatternModel.Pattern.Name, this.targetPatternModel.Pattern.Name); Assert.Equal(this.sourcePatternModel.Pattern.Views.Count, this.targetPatternModel.Pattern.Views.Count); Assert.NotNull(this.targetPatternModel.Pattern.Views[0]); Assert.Equal(this.sourcePatternModel.Pattern.Views[0].Name, this.targetPatternModel.Pattern.Views[0].Name); Assert.Equal(this.sourcePatternModel.Pattern.Views[0].Elements.Count, this.targetPatternModel.Pattern.Views[0].Elements.Count); Assert.NotNull(this.targetPatternModel.Pattern.Views[0].Elements[0]); Assert.Equal(this.sourcePatternModel.Pattern.Views[0].Elements[0].Name, this.targetPatternModel.Pattern.Views[0].Elements[0].Name); Assert.NotNull(this.targetPatternModel.Pattern.Views[0].Elements[0].ExtensionPoints[0]); Assert.Equal(this.sourcePatternModel.Pattern.Views[0].Elements[0].ExtensionPoints[0].Name, this.targetPatternModel.Pattern.Views[0].Elements[0].ExtensionPoints[0].Name); Assert.Equal( ((CollectionSchema)this.sourcePatternModel.Pattern.Views[0].Elements[0]).Elements.Count, ((CollectionSchema)this.targetPatternModel.Pattern.Views[0].Elements[0]).Elements.Count); Assert.NotNull(((CollectionSchema)this.targetPatternModel.Pattern.Views[0].Elements[0]).Elements[0]); Assert.Equal( ((CollectionSchema)this.sourcePatternModel.Pattern.Views[0].Elements[0]).Elements[0].Name, ((CollectionSchema)this.targetPatternModel.Pattern.Views[0].Elements[0]).Elements[0].Name); }
public void WhenGettingServiceProviderFromPackage_ThenSucceeds() { var components = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel)); var service = (IServiceProvider)components.GetService <SVsServiceProvider>(); Assert.NotNull(service); }
public void WhenConvertingFromValue_ThenReturnsConvertedValue() { var convertedValue = this.converter.ConvertFrom(this.context, CultureInfo.InvariantCulture, "Foo"); Assert.NotNull(convertedValue); Assert.NotNull(convertedValue as List <IExtensionPointSchema>); Assert.Equal(1, ((List <IExtensionPointSchema>)convertedValue).Count); }
public void WhenGettingStandardValues_ThenReturnsValues() { var values = this.converter.GetStandardValues(this.context); Assert.NotNull(values); Assert.Equal(1, values.Count); Assert.Equal("Foo", ((IExtensionPointSchema)values.Cast <StandardValue>().ElementAt(0).Value).RequiredExtensionPointId); }
public void WhenFindingExistingProduct_ThenFindsIt() { var product = Mocks.Of <IProduct>().First(x => x.InstanceName == "Foo"); var manager = Mocks.Of <IPatternManager>().First(x => x.Products == new[] { product } && x.IsOpen == true); var found = PatternManagerExtensions.Find(manager, "Foo"); Assert.NotNull(found); }
public void WhenCloning_ThenTargetPatternIsCloned() { new PatternModelCloner(this.sourcePatternModel, new Version("1.0.0.0"), this.targetPatternModel).Clone(); Assert.NotNull(this.targetPatternModel.Pattern); Assert.Equal(this.sourcePatternModel.Pattern.Name, this.targetPatternModel.Pattern.Name); Assert.Equal(this.sourcePatternModel.Pattern.Views.Count, this.targetPatternModel.Pattern.Views.Count); Assert.NotNull(this.targetPatternModel.Pattern.Views[0]); Assert.Equal(this.sourcePatternModel.Pattern.Views[0].Name, this.targetPatternModel.Pattern.Views[0].Name); }
public void WhenRetrievingShellPackage_ThenSucceeds() { var components = ServiceProvider.GetService <SComponentModel, IComponentModel>(); var package = components.GetService <IShellComponent>(); Assert.NotNull(package); package = ServiceLocator.GetInstance <IShellComponent>(); Assert.NotNull(package); }
public void WhenSolutionIsOpened_ThenCanGetProjectConfigurations() { base.OpenSolution("SampleSolution\\SampleSolution.sln"); var explorer = base.ServiceLocator.GetInstance <ISolutionExplorer>(); var lib = new ITreeNode[] { explorer.Solution }.Traverse(TraverseKind.BreadthFirst, node => node.Nodes) .OfType <IProjectNode>() .FirstOrDefault(node => node.DisplayName == "ClassLibrary"); Assert.NotNull(lib); }
public void WhenResolvingUri_ThenNotFeatureRuntimeVsix() { var service = VsIdeTestHostContext.ServiceProvider.GetService <IUriReferenceService>(); Assert.NotNull(service); var uri = new Uri("vsix://FeatureExtensionRuntime"); var installed = service.ResolveUri <IInstalledExtension>(uri); var extension = service.ResolveUri <IExtension>(uri); Assert.Null(installed); Assert.Null(extension); }
public void WhenRetrievingVsService_ThenCanGetFromCompositionContainer() { var servicesExports = new ServicesExportProvider(GlobalServiceProvider.Instance); var container = new CompositionContainer(servicesExports); var shell = container.GetExportedValue <IVsUIShell>(); Assert.NotNull(shell); var shell2 = GlobalServiceProvider.Instance.GetService <SVsUIShell, IVsUIShell>(); Assert.Same(shell, shell2); }
internal static void VerifyDocuments(IEnumerable <string> documents, string directoryPath, string[] filenames) { if (filenames == null) { Assert.True(Directory.GetFiles(directoryPath).GetLength(0) == 0); } else { //Ensure correct number of files var filesOnDiskCount = Directory.GetFiles(directoryPath).GetLength(0); var fileNameCount = filenames.GetLength(0); Assert.True(filesOnDiskCount == fileNameCount, "Number of files found on disk ({0}) does not equal the number of expected files on disk ({1})", filesOnDiskCount, fileNameCount); foreach (var filename in filenames) { // Ensure it exists in collection Assert.NotNull(documents.FirstOrDefault(d => d.Equals(filename, StringComparison.OrdinalIgnoreCase)), "Expected file ({0}) not found in collection.", filename); //Ensure it exists on disk var filePath = Path.Combine(directoryPath, filename); Assert.True(File.Exists(filePath), "Expected file ({0}) not found on disk", filePath); } } }
public void ThenGuidanceExtensionIsInstalled() { var registrations = this.guidanceManager.InstalledGuidanceExtensions; var extension = registrations.FirstOrDefault(registration => registration.ExtensionId == Runtime.Shell.Constants.VsixIdentifier); Assert.NotNull(extension); }
public void WhenGettingInstalledToolkitInfos_ThenCanRetrieveThem() { var componentModel = VsIdeTestHostContext.ServiceProvider.GetService <SComponentModel, IComponentModel>(); var installed = componentModel.GetService <IEnumerable <IInstalledToolkitInfo> >(); Assert.NotNull(installed); }
public void ThenGuidanceExtensionIsInstalled() { var registrations = this.guidanceManager.InstalledGuidanceExtensions; var feature = registrations.FirstOrDefault(registration => registration.ExtensionId == AuthoringToolkitInfo.VsixIdentifier); Assert.NotNull(feature); }
public void WhenSolutionIsOpened_ThenCanGetProjectOutputAssembly() { base.OpenSolution("SampleSolution\\SampleSolution.sln"); var explorer = base.ServiceLocator.GetInstance <ISolutionExplorer>(); var lib = new ITreeNode[] { explorer.Solution }.Traverse(TraverseKind.BreadthFirst, node => node.Nodes) .OfType <IProjectNode>() .FirstOrDefault(node => node.DisplayName == "ClassLibrary"); Assert.NotNull(lib); var asm = lib.GetOutputAssembly(); Assert.NotNull(asm, "Failed to retrieve output assembly from class library project."); }
public void WhenCreated_ThenCreateDynamicContextSucceeds() { var value = new object(); var binding = FixedBinding.Create(value); Assert.NotNull(binding.CreateDynamicContext()); }
public void WhenResolvingValidUri_ThenResolvesProject() { var resolvedElement = this.provider.ResolveUri(new Uri(string.Format("solution://{0}", this.id.ToString()))); Assert.NotNull(resolvedElement); Assert.Equal(resolvedElement.Id, this.id); }
public void WhenGettingMainWindow_ThenSucceeds() { var shell = ServiceProvider.GetService <SVsUIShell, IVsUIShell>(); var window = shell.GetMainWindow(); Assert.NotNull(window); }
public void WhenAddingError_ThenItemIsNotNull() { var manager = ServiceLocator.GetInstance <IErrorsManager>(); manager.ClearErrors(); var item = manager.AddError("Error1", null); Assert.NotNull(item); }
public void WhenInitializing_TheTemplatesEmpty() { var extension = new Mock <IInstalledExtension>(); extension.Setup(ext => ext.InstallPath).Returns(@"Z:\InstallDir"); var target = new InstalledToolkitInfo(extension.Object, this.reader, this.resource); Assert.NotNull(target.Templates); Assert.Equal(0, target.Templates.Count()); }
public void WhenCreatingAProduct_ThenSetsArtifactLinks() { IProduct product = null; UIThreadInvoker.Invoke((Action)(() => { DoActionWithWait(4000, () => product = this.manager.CreateProduct(toolkit, "Foo")); })); Assert.NotNull(product); Assert.NotNull(product.TryGetReference(ReferenceKindConstants.SolutionItem)); Assert.True(product.Views.Count() > 0); var view = product.Views.ElementAt(0); Assert.True(view.Elements.Count() > 0); var element = view.Elements.ElementAt(0); Assert.NotNull(element.TryGetReference(ReferenceKindConstants.SolutionItem)); }
public void WhenCloning_ThenTargetPatternIsCloned() { new PatternModelCloner(this.sourcePatternModel, new Version("1.0.0.0"), this.targetPatternModel).Clone(); Assert.NotNull(this.targetPatternModel.Pattern); Assert.Equal(this.sourcePatternModel.Pattern.Name, this.targetPatternModel.Pattern.Name); Assert.Equal(this.sourcePatternModel.Pattern.Properties.Count, this.targetPatternModel.Pattern.Properties.Count); Assert.Equal(this.sourcePatternModel.Pattern.Properties[0].Name, this.targetPatternModel.Pattern.Properties[0].Name); Assert.Equal(this.sourcePatternModel.Pattern.Properties[0].Type, this.targetPatternModel.Pattern.Properties[0].Type); Assert.Equal(this.sourcePatternModel.Pattern.Properties[0].RawDefaultValue, this.targetPatternModel.Pattern.Properties[0].RawDefaultValue); }
public void WhenTypeAttributeIsFound_ThenElementPropertyIsGenerated() { var processor = new ModelElementDirectiveProcessor(); processor.StartProcessingRun(provider, null, new CompilerErrorCollection()); processor.ProcessDirective("ModelElement", directiveAttributes); var result = processor.GetClassCodeForProcessingRun(); Assert.NotNull(result); Assert.True(result.Contains("public new Foo.Bar Element")); Assert.True(result.Contains("return ((Foo.Bar)(base.Element));")); }
public void WhenLoadingAModel_ThenPatternModelIsReturned() { var stream = new MemoryStream( UTF8Encoding.UTF8.GetBytes( "<?xml version=\"1.0\" encoding=\"utf-8\"?><patternModel xmlns:dm0=\"http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core\" dslVersion=\"1.0.0.0\" Id=\"fe155518-e417-4f08-94d2-c2678c28fdd8\" xmlns=\"http://schemas.microsoft.com/dsltools/ComponentModel\"></patternModel>")); PatternModelSchema patternModel = null; this.store.TransactionManager.DoWithinTransaction(() => patternModel = PatternModelSerializationHelper.Instance.LoadModel(this.store, stream, null, null)); Assert.NotNull(patternModel); }
public void WhenProductInstantiated_ThenRaisesInstantiatedEvent() { var store = new DslTestStore <ProductStateStoreDomainModel>(); IProductState productState = null; store.TransactionManager.DoWithinTransaction(() => { productState = store.ElementFactory.CreateElement <ProductState>(); }); IInstanceBase instantiated = null; IProduct product = null; productState.ElementInstantiated += (sender, args) => instantiated = args.Value; store.TransactionManager.DoWithinTransaction(() => { product = productState.CreateProduct(); }); Assert.NotNull(instantiated); Assert.Same(product, instantiated); }
public void WhenSolutionIsOpened_ThenCanGetMsBuildProjectProperties() { base.OpenSolution("SampleSolution\\SampleSolution.sln"); var explorer = base.ServiceLocator.GetInstance <ISolutionExplorer>(); var lib = new ITreeNode[] { explorer.Solution }.Traverse(TraverseKind.BreadthFirst, node => node.Nodes) .OfType <IProjectNode>() .FirstOrDefault(node => node.DisplayName == "ClassLibrary"); var msb = lib.As <MsBuild.Project>(); Assert.NotNull(msb); //Console.WriteLine("IntermediateOutputPath : {0}", lib.Properties.IntermediateOutputPath); //Console.WriteLine("DesignTimeIntermediateOutputPath : {0}", lib.Properties.DesignTimeIntermediateOutputPath); //Console.WriteLine("BaseIntermediateOutputPath : {0}", lib.Properties.BaseIntermediateOutputPath); //Console.WriteLine("MSBuildProjectDirectory : {0}", lib.Properties.MSBuildProjectDirectory); //Console.WriteLine("OutputFileName: {0}", lib.Properties.OutputFileName); //Console.WriteLine("OutputPath: {0}", lib.Properties.OutputPath); //Console.WriteLine("TargetDir : {0}", lib.Properties.TargetDir); //Console.WriteLine("TargetedFrameworkDir : {0}", lib.Properties.TargetedFrameworkDir); //Console.WriteLine("TargetedRuntimeVersion : {0}", lib.Properties.TargetedRuntimeVersion); //Console.WriteLine("TargetedSDKArchitecture : {0}", lib.Properties.TargetedSDKArchitecture); //Console.WriteLine("TargetedSDKConfiguration : {0}", lib.Properties.TargetedSDKConfiguration); //Console.WriteLine("TargetExt : {0}", lib.Properties.TargetExt); //Console.WriteLine("TargetFileName : {0}", lib.Properties.TargetFileName); //Console.WriteLine("TargetFramework : {0}", lib.Properties.TargetFramework); //Console.WriteLine("TargetFrameworkAsMSBuildRuntime : {0}", lib.Properties.TargetFrameworkAsMSBuildRuntime); //Console.WriteLine("TargetFrameworkIdentifier : {0}", lib.Properties.TargetFrameworkIdentifier); //Console.WriteLine("TargetFrameworkMoniker : {0}", lib.Properties.TargetFrameworkMoniker); //Console.WriteLine("TargetFrameworkMonikerAssemblyAttributesPath : {0}", lib.Properties.TargetFrameworkMonikerAssemblyAttributesPath); //Console.WriteLine("TargetFrameworkMonikerDisplayName : {0}", lib.Properties.TargetFrameworkMonikerDisplayName); //Console.WriteLine("TargetFrameworkSDKToolsDirectory : {0}", lib.Properties.TargetFrameworkSDKToolsDirectory); //Console.WriteLine("TargetFrameworkVersion : {0}", lib.Properties.TargetFrameworkVersion); //Console.WriteLine("TargetName : {0}", lib.Properties.TargetName); //Console.WriteLine("TargetPath : {0}", lib.Properties.TargetPath); //Console.WriteLine("TargetPlatformIdentifier : {0}", lib.Properties.TargetPlatformIdentifier); //Console.WriteLine("TargetPlatformMoniker : {0}", lib.Properties.TargetPlatformMoniker); //Console.WriteLine("TargetPlatformRegistryBase : {0}", lib.Properties.TargetPlatformRegistryBase); //Console.WriteLine("TargetPlatformSdkPath : {0}", lib.Properties.TargetPlatformSdkPath); //Console.WriteLine("TargetPlatformVersion : {0}", lib.Properties.TargetPlatformVersion); //Console.WriteLine("TargetRuntime : {0}", lib.Properties.TargetRuntime); //((DynamicObject)lib.Properties).GetDynamicMemberNames() // .ToList() // .ForEach(prop => Console.WriteLine(prop)); }
public void WhenCreatingReference_ThenUsesAdapter() { var stateFile = this.solution.Find <IItem>(item => item.Name.EndsWith(StoreConstants.RuntimeStoreExtension)).First(); var manager = this.modelBus.FindAdapterManagers(new object[] { stateFile.PhysicalPath }).FirstOrDefault(); Assert.NotNull(manager); Assert.True(manager.CanCreateReference(new object[] { stateFile.PhysicalPath })); var mar = new ModelingAdapterReference(null, null, stateFile.PhysicalPath); var mbr = new ModelBusReference(this.modelBus, Adapter.AdapterId, Path.GetFileNameWithoutExtension(stateFile.Name), mar); using (var adapter = this.modelBus.CreateAdapter(mbr, VsIdeTestHostContext.ServiceProvider)) { var withRoot = adapter as IModelingAdapterWithRootedModel; var state = ((IProductState)withRoot.ModelRoot).Products.First(); var elementRef = adapter.GetElementReference(state); Assert.NotNull(elementRef); } }
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"))); }
public void WhenSourceEventRaisedAndWeakSubscriberDisposed_ThenRemovesSubscriber() { EventHandler raiseHandler = null; var removed = 0; var observer = new Mock <IObserver <IEvent <EventArgs> > >(); var weakSubscriber = new WeakObserverEvent <EventArgs>(observer.Object.OnNext, observer.Object.OnError, observer.Object.OnCompleted); var observable = new WeakObservableEvent <EventHandler, EventArgs>( handler => new EventHandler(handler.Invoke), handler => raiseHandler = handler, handler => removed++); observable.Subscribe(weakSubscriber); Assert.NotNull(raiseHandler); Assert.Equal(0, removed); observer = null; GC.Collect(); raiseHandler(this, EventArgs.Empty); Assert.Equal(1, removed); }