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 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.NotNull(this.targetPatternModel.Pattern.Views[0].ExtensionPoints[0]); Assert.Equal(this.sourcePatternModel.Pattern.Views[0].ExtensionPoints[0].Name, this.targetPatternModel.Pattern.Views[0].ExtensionPoints[0].Name); }
public void WhenInitializing_ThenIdIsExposed() { var extension = new Mock <IInstalledExtension>(); extension.Setup(ext => ext.Header.Identifier).Returns("Foo"); var target = new InstalledToolkitInfo(extension.Object, this.reader, this.resource); Assert.Equal("Foo", target.Id); }
public void WhenComparingItemsInProject_ThenCanCheckForEquality() { base.OpenSolution("SampleSolution\\SampleSolution.sln"); var explorer = base.ServiceLocator.GetInstance <ISolutionExplorer>(); var node1 = explorer.Solution.Traverse().OfType <IItemNode>().First(i => i.DisplayName == "Class1.cs"); var node2 = explorer.Solution.Traverse().OfType <IItemNode>().First(i => i.DisplayName == "Class1.cs"); Assert.Equal(node1.OwningProject, node2.OwningProject, "Owning projects aren't equal."); Assert.Equal(node1.As <VsHierarchyItem>().ItemId, node2.As <VsHierarchyItem>().ItemId, "ItemIds aren't equal."); Assert.Equal(node1, node2, "Items aren't equal."); }
public void WhenProjectItemIsLocal_ThenUriCreated() { var item = this.project.Find <IItem>(i => i.Name == "Bitmap1.bmp").First(); var createdUri = this.service.CreateUri <ResourcePack>(new ResourcePack(item)); Assert.Equal("pack://application:,,,/TestProviders;component/Resources/Bitmap1.bmp", createdUri.AbsoluteUri); }
public void WhenSolutionIsOpened_ThenCanGetProjectReferencedAssemblies() { var slnFile = base.OpenSolution("SampleSolution\\SampleSolution.sln"); var proj = XDocument.Load(GetFullPath(Path.GetDirectoryName(slnFile), "ClassLibrary\\ClassLibrary.csproj")); var refs = proj.Descendants(XName.Get("{http://schemas.microsoft.com/developer/msbuild/2003}Reference")) .Select(e => e.Attribute("Include").Value) .ToList(); 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.GetReferencedAssemblies().ToList(); //asm.ForEach(a => Console.WriteLine(a.FullName)); // 7 actual references + mscorlib which is always added automatically. Assert.Equal(1 + refs.Count, asm.Count); Assert.True(refs.All(r => asm.Any(a => a.GetName().Name == r))); }
public void WhenComparingNodes_ThenCheckForEquality() { base.OpenSolution("SampleSolution\\SampleSolution.sln"); var explorer = base.ServiceLocator.GetInstance <ISolutionExplorer>(); var lib1 = new ITreeNode[] { explorer.Solution }.Traverse(TraverseKind.BreadthFirst, node => node.Nodes) .OfType <IProjectNode>() .FirstOrDefault(node => node.DisplayName == "ClassLibrary"); var lib2 = new ITreeNode[] { explorer.Solution }.Traverse(TraverseKind.BreadthFirst, node => node.Nodes) .OfType <IProjectNode>() .FirstOrDefault(node => node.DisplayName == "ClassLibrary"); Assert.Equal(lib1, lib2); }
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); }
public void WhenGettingIdFromExtension_ThenAlwaysReturnsSameValue() { var solution = ServiceProvider.GetService <IVsSolution>(); var hierarchy = solution as IVsHierarchy; var solutionFolder1 = new VsSolutionHierarchyNode(hierarchy, VSConstants.VSITEMID_ROOT).Children.FirstOrDefault(n => n.VsHierarchy.Properties(n.ItemId).DisplayName == "SolutionFolder1"); Assert.Equal(solutionFolder1.ItemId, solutionFolder1.VsHierarchy.Properties(solutionFolder1.ItemId).ItemId); var solutionFolder2 = solutionFolder1.Children.FirstOrDefault(n => n.VsHierarchy.Properties(n.ItemId).DisplayName == "SolutionFolder2"); var project = solutionFolder2.Children.FirstOrDefault(n => n.VsHierarchy.Properties(n.ItemId).DisplayName == "ClassLibrary"); Assert.Equal(solutionFolder2.ItemId, solutionFolder2.VsHierarchy.Properties(solutionFolder2.ItemId).ItemId); Assert.Equal(project.ItemId, project.VsHierarchy.Properties(project.ItemId).ItemId); }
public void WhenAdaptingProjectReferencesToNonAdaptedType_ThenReturnsEmptyList() { base.OpenSolution("SampleSolution\\SampleSolution.sln"); var references = base.ServiceLocator.GetInstance <ISolutionExplorer>().Solution .FindProjects() .First() .Nodes .OfType <IReferencesNode> () .SelectMany(r => r.Nodes.OfType <IReferenceNode> ()) .Select(r => r.As <IFormattable> ()) .Where(r => r != null) .ToList(); Assert.Equal(0, references.Count); }
public void SyncNamesWorks() { var newName = "a" + Guid.NewGuid().ToString().Replace("-", ""); var handle = UIThreadInvoker.Invoke(new Action(() => pattern.InstanceName = newName)); Assert.Equal(newName, solution.Items.OfType <IProject>().First().Name); }
public void WhenForEachInvoked_ThenCallsActionWithSourceItems() { string arg = null; EnumerableExtensions.ForEach(new[] { "foo" }, s => arg = s); Assert.Equal("foo", arg); }
public void WhenUnfolding_ThenParameterIsReplaced() { var project = (IProject)this.toolkitTemplate.Unfold("Foo", this.solution); var item = project.Find(@"source.vsixmanifest").First(); var itemContent = XElement.Load(item.PhysicalPath); Assert.Equal("$guid3$", (string)itemContent.Elements().First().Attribute("Id")); }
public void WhenSelectingProjects_ThenSelectionReturnsOnlyProjectNodes() { var projects = explorer.Solution.Nodes.Traverse(TraverseKind.DepthFirst, node => node.Nodes) .OfType <IProjectNode>() .ToList(); projects.First().Select(false); projects.Skip(1).ToList().ForEach(project => project.Select(true)); Assert.True(projects.TrueForAll(project => project.IsSelected)); var selection = explorer.SelectedNodes.ToList(); Assert.Equal(projects.Count, selection.Count); Assert.True(selection.TrueForAll(node => node is IProjectNode)); Assert.True(projects.TrueForAll(project => selection.OfType <IProjectNode>().Any(sel => sel.PhysicalPath == project.PhysicalPath))); }
public void WhenRetrievingAPackageExport_ThenReturnsSingleExport() { var devEnv = DevEnv.Get(new Guid(Constants.PackageGuid)); var models = devEnv.ServiceLocator.GetAllInstances <ViewModel>().ToList(); Assert.Equal(1, models.Count); }
private static void AssertDictionaryValue(IDictionary <string, string> dictionary, string propertyName, string propertyValue) { Assert.True(dictionary.Keys.Contains(propertyName), string.Format(CultureInfo.CurrentCulture, "{0} key not found in dictionary.", propertyName)); Assert.Equal(propertyValue, dictionary[propertyName]); //Remove item from dictionary dictionary.Remove(propertyName); }
public void WhenSolutionIsOpened_ThenCanGetAllProjects() { base.OpenSolution("SampleSolution\\SampleSolution.sln"); var explorer = base.ServiceLocator.GetInstance <ISolutionExplorer>(); var projects = explorer.Solution.FindProjects().ToList(); Assert.Equal(2, projects.Count); }
public void WhenCreatingUri_ThenCanRoundTrip() { var service = VsIdeTestHostContext.ServiceProvider.GetService <IUriReferenceService>(); Assert.NotNull(service); var installed = VsIdeTestHostContext.ServiceProvider.GetService <IExtensionManager>() .GetInstalledExtensions().First(e => e.Header.Name.Contains("NuPattern")); Assert.True(service.CanCreateUri(installed)); Assert.True(service.CanCreateUri <IExtension>(installed)); var uri = service.CreateUri(installed); var resolved = service.ResolveUri <IExtension>(uri); var resolved2 = service.ResolveUri <IInstalledExtension>(uri); Assert.Equal(installed.Header.Identifier, resolved.Header.Identifier); Assert.Equal(installed.Header.Identifier, resolved2.Header.Identifier); }
public void WhenCreated_ThenUserMessageCanBeSet() { var value = new object(); var binding = FixedBinding.Create(value); binding.UserMessage = "foo"; Assert.Equal("foo", binding.UserMessage); }
public void WhenComparingSharedProjects_ThenCanCheckForEquality() { using (AutoCloseDialog("Developer License")) { base.OpenSolution("SampleShared\\SampleShared.sln"); } var explorer = base.ServiceLocator.GetInstance <ISolutionExplorer>(); var prj1 = new ITreeNode[] { explorer.Solution }.Traverse(TraverseKind.BreadthFirst, node => node.Nodes) .OfType <IProjectNode>() .FirstOrDefault(node => node.DisplayName == "Shared"); var prj2 = new ITreeNode[] { explorer.Solution }.Traverse(TraverseKind.BreadthFirst, node => node.Nodes) .OfType <IProjectNode>() .FirstOrDefault(node => node.DisplayName == "Shared"); Assert.Equal(prj1, prj2); }
public void WhenDisposedTwice_ThenInvokesActionOnce() { var called = 0; using (var disposable = new AnonymousDisposable(() => called++)) { disposable.Dispose(); disposable.Dispose(); } Assert.Equal(1, called); }
public void WhenSettingDteProperty_ThenCanRetrieveIt() { var explorer = base.ServiceLocator.GetInstance <ISolutionExplorer>(); var slnFile = this.OpenSolution("SampleSolution\\SampleSolution.sln"); var project = explorer.Solution.Nodes.Traverse(TraverseKind.DepthFirst, node => node.Nodes) .OfType <ProjectNode>() .First(node => node.DisplayName == "ClassLibrary"); project.Properties.StartupObject = "ClassLibrary.Program"; project.Save(); this.CloseSolution(); this.OpenSolution(slnFile); project = explorer.Solution.Nodes.Traverse(TraverseKind.DepthFirst, node => node.Nodes) .OfType <ProjectNode>() .First(node => node.DisplayName == "ClassLibrary"); Assert.Equal("ClassLibrary.Program", (string)project.Properties.StartupObject); }
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 WhenRetrievingExportedValueOrDefaultForMany_ThenThrowsImportCardinalityException() { var components = GlobalServiceProvider.Instance.GetService <SComponentModel, IComponentModel>(); // ICompletionSourceProvider has many exports. // On VS2010 this throws, but on VS2012+ it succeeds and returns null :S #if Vs10 Assert.Throws <ImportCardinalityMismatchException>(() => components.DefaultExportProvider.GetExportedValueOrDefault <ICompletionSourceProvider>()); #endif #if Vs11 || Vs12 Assert.Equal <ICompletionSourceProvider>(null, components.DefaultExportProvider.GetExportedValueOrDefault <ICompletionSourceProvider>()); #endif }
public void WhenFirstSubscriberAdded_ThenAttachesToSource() { var added = 0; var removed = 0; var observable = new WeakObservableEvent <EventHandler, EventArgs>( handler => new EventHandler(handler.Invoke), handler => added++, handler => removed++); observable.Subscribe(new Mock <IObserver <IEvent <EventArgs> > >().Object); Assert.Equal(1, added); Assert.Equal(0, removed); observable.Subscribe(new Mock <IObserver <IEvent <EventArgs> > >().Object); Assert.Equal(1, added); Assert.Equal(0, removed); }
public void WhenAddingError_ThenItemIsAddedToTheErrorList() { var manager = ServiceLocator.GetInstance <IErrorsManager>(); manager.ClearErrors(); var item = manager.AddError("Error1", null); var dte = this.ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2; Assert.Equal(1, dte.ToolWindows.ErrorList.ErrorItems.Count); Assert.Equal("Error1", dte.ToolWindows.ErrorList.ErrorItems.Item(1).Description); }
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 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.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 WhenTemplateTypeIsItem_ThenReturnsBaseUri() { Assert.Equal("template://item", VsTemplateUri.GetUriBase(VsTemplateType.Item)); }
public void WhenCreatingNewPropertyWithDefinitionId_ThenSetsSchemaInfo() { var target = this.CreateProperty(); Assert.Equal(this.propertyInfo.Object, target.Info); }