Ejemplo n.º 1
0
        public void Constructor_ValueAsCommonServices_SetsProjectAccessorToCommonServicesProjectAccessor()
        {
            var projectAccessor = IProjectAccessorFactory.Create();
            var commonServices  = IUnconfiguredProjectCommonServicesFactory.Create(projectAccessor: projectAccessor);

            var vsServices = CreateInstance(commonServices);

            Assert.Same(projectAccessor, vsServices.ProjectAccessor);
        }
Ejemplo n.º 2
0
        public void Constructor_ValueAsCommonServices_SetsThreadingServiceToCommonServicesThreadingService()
        {
            var threadingService = IProjectThreadingServiceFactory.Create();
            var commonServices   = IUnconfiguredProjectCommonServicesFactory.Create(threadingService: threadingService);

            var vsServices = CreateInstance(commonServices);

            Assert.Same(threadingService, vsServices.ThreadingService);
        }
        public void Constructor_ValueAsCommonServices_SetsProjectTreeToCommonServicesProjectTree()
        {
            var projectTree    = IPhysicalProjectTreeFactory.Create();
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(projectTree: projectTree);

            var vsServices = CreateInstance(commonServices);

            Assert.Same(projectTree, vsServices.ProjectTree);
        }
Ejemplo n.º 4
0
        public void Constructor_ValueAsCommonServices_SetsProjectToCommonServicesProject()
        {
            var project        = UnconfiguredProjectFactory.Create();
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var vsServices = CreateInstance(commonServices);

            Assert.Same(project, vsServices.Project);
        }
        public void Constructor_ValueAsUnconfiguedProject_SetsVsProjectToHostObject()
        {
            var hierarchy      = IVsHierarchyFactory.Create();
            var project        = IUnconfiguredProjectFactory.Create(hostObject: hierarchy);
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var vsServices = CreateInstance(commonServices);

            Assert.Same(hierarchy, vsServices.VsProject);
        }
        public void Constructor_ValueAsCommonServices_SetsActiveConfiguredProjectPropertiesToCommonServicesActiveConfiguredProjectProperties()
        {
            var project           = IUnconfiguredProjectFactory.Create();
            var projectProperties = ProjectPropertiesFactory.Create(project);
            var commonServices    = IUnconfiguredProjectCommonServicesFactory.Create(projectProperties: projectProperties);

            var vsServices = CreateInstance(commonServices);

            Assert.Same(projectProperties, vsServices.ActiveConfiguredProjectProperties);
        }
        public async Task DebugTokenReplacer_ReplaceTokensInStringTests(string input, string expected, bool expandEnvVars)
        {
            IUnconfiguredProjectCommonServices services = IUnconfiguredProjectCommonServicesFactory.Create();

            var replacer = new DebugTokenReplacerUnderTest(IUnconfiguredProjectCommonServicesFactory.Create(), _envHelper.Object);

            // Test msbuild vars
            string result = await replacer.ReplaceTokensInStringAsync(input, expandEnvVars);

            Assert.Equal(expected, result);
        }
        public async Task GetActiveDebuggingFrameworkPropertyAsync_ReturnsFrameworkValue(string framework)
        {
            var project = UnconfiguredProjectFactory.Create();
            var data    = new PropertyPageData(ProjectDebugger.SchemaName, ProjectDebugger.ActiveDebugFrameworkProperty, framework);

            var projectProperties = ProjectPropertiesFactory.Create(project, data);

            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(projectProperties: projectProperties);

            var debugFrameworkSvcs = new ActiveDebugFrameworkServices(null !, commonServices);
            var result             = await debugFrameworkSvcs.GetActiveDebuggingFrameworkPropertyAsync();

            Assert.Equal(framework, result);
        }
        private static DependenciesTreeViewProvider CreateProvider(
            IEnumerable <IDependencyModel>?rootModels   = null,
            IEnumerable <IDependencyModel>?targetModels = null)
        {
            var treeServices = new MockIDependenciesTreeServices();

            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement(
                getDependenciesRootIcon: s_rootImage,
                createRootViewModel: rootModels,
                createTargetViewModel: targetModels);

            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create();

            return(new DependenciesTreeViewProvider(treeServices, treeViewModelFactory, commonServices));
        }
        public async Task SetActiveDebuggingFrameworkPropertyAsync_SetsValue()
        {
            var project = UnconfiguredProjectFactory.Create();
            var data    = new PropertyPageData(ProjectDebugger.SchemaName, ProjectDebugger.ActiveDebugFrameworkProperty, "FrameworkOne");

            var projectProperties = ProjectPropertiesFactory.Create(project, data);

            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(projectProperties: projectProperties);

            var debugFrameworkSvcs = new ActiveDebugFrameworkServices(null !, commonServices);
            await debugFrameworkSvcs.SetActiveDebuggingFrameworkPropertyAsync("netcoreapp1.0");

            // Just verifies it doesn't throw. In other words, the function is trying to set the correct property. The way the property mocks
            // are set up there is no easy way to capture the value being set without rewriting how they work.
        }
        internal static LaunchSettingsUnderTest GetLaunchSettingsProvider(IFileSystem?fileSystem, string?appDesignerFolder = @"c:\test\Project1\Properties", string activeProfile = "")
        {
            var activeProfileValue = new Mock <IEnumValue>();

            activeProfileValue.Setup(s => s.Name).Returns(activeProfile);
            var debuggerData = new PropertyPageData(ProjectDebugger.SchemaName, ProjectDebugger.ActiveDebugProfileProperty, activeProfileValue.Object);

            var specialFilesManager = ActiveConfiguredProjectFactory.ImplementValue(() => IAppDesignerFolderSpecialFileProviderFactory.ImplementGetFile(appDesignerFolder));
            var project             = UnconfiguredProjectFactory.Create(filePath: @"c:\test\Project1\Project1.csproj");
            var properties          = ProjectPropertiesFactory.Create(project, new[] { debuggerData });
            var commonServices      = IUnconfiguredProjectCommonServicesFactory.Create(project, IProjectThreadingServiceFactory.Create(), null, properties);
            var projectServices     = IUnconfiguredProjectServicesFactory.Create(IProjectAsynchronousTasksServiceFactory.Create());
            var provider            = new LaunchSettingsUnderTest(project, projectServices, fileSystem ?? new IFileSystemMock(), commonServices, null, specialFilesManager);

            return(provider);
        }
Ejemplo n.º 12
0
            public TestTempPEBuildManager(IFileSystem fileSystem)
                : base(IProjectThreadingServiceFactory.Create(),
                       IUnconfiguredProjectCommonServicesFactory.Create(threadingService: IProjectThreadingServiceFactory.Create()),
                       IActiveWorkspaceProjectContextHostFactory.Create(),
                       IActiveConfiguredProjectSubscriptionServiceFactory.Create(),
                       null,
                       fileSystem,
                       IProjectFaultHandlerServiceFactory.Create(),
                       null)
            {
                BuildManager = new TestBuildManager(this);

                AppliedValue = new ProjectVersionedValue <DesignTimeInputsItem>(new DesignTimeInputsItem()
                {
                    OutputPath = "TempPE"
                }, ImmutableDictionary <NamedIdentity, IComparable> .Empty);
            }
        public void WhenFindByPathAndNullNode_ShouldDoNothing()
        {
            // Arrange
            const string projectPath   = @"c:\myfolder\mysubfolder\myproject.csproj";
            var          projectFolder = Path.GetDirectoryName(projectPath);

            var treeServices         = new MockIDependenciesTreeServices();
            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement();
            var project        = UnconfiguredProjectFactory.Create();
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            // Act
            var provider   = new GroupedByTargetTreeViewProvider(treeServices, treeViewModelFactory, commonServices);
            var resultTree = provider.FindByPath(null, Path.Combine(projectFolder, @"somenode"));

            // Assert
            Assert.Null(resultTree);
        }
Ejemplo n.º 14
0
        private DebugTokenReplacer CreateInstance()
        {
            var projectCommonServices = IUnconfiguredProjectCommonServicesFactory.Create();
            var environmentHelper     = _envHelper.Object;
            var activeDebugFramework  = Mock.Of <IActiveDebugFrameworkServices>();

            string projectFile = @"<Project>
                <PropertyGroup>
                    <msbuildProperty1>Property1</msbuildProperty1>
                    <msbuildProperty2>Property2</msbuildProperty2>
                    <msbuildProperty3>Property3</msbuildProperty3>
                    <msbuildProperty4>Property4</msbuildProperty4>
                    <msbuildProperty5>Property5</msbuildProperty5>
                    <msbuildProperty6>Property6</msbuildProperty6>
                </PropertyGroup>
                </Project>";

            return(new DebugTokenReplacer(projectCommonServices, environmentHelper, activeDebugFramework, IProjectAccessorFactory.Create(projectFile)));
        }
        public async Task GetProjectFrameworksAsync_ReturnsFrameworksInCorrectOrder(string frameworks, string[] expectedOrder)
        {
            var project = UnconfiguredProjectFactory.Create();
            var data    = new PropertyPageData(ConfigurationGeneral.SchemaName, ConfigurationGeneral.TargetFrameworksProperty, frameworks);

            var projectProperties = ProjectPropertiesFactory.Create(project, data);

            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(projectProperties: projectProperties);

            var debugFrameworkSvcs = new ActiveDebugFrameworkServices(null !, commonServices);
            var result             = await debugFrameworkSvcs.GetProjectFrameworksAsync();

            Assert.NotNull(result);
            Assert.Equal(expectedOrder.Length, result.Count);
            for (int i = 0; i < result.Count; i++)
            {
                Assert.Equal(expectedOrder[i], result[i]);
            }
        }
        public async Task GetConfiguredProjectForActiveFrameworkAsync_ReturnsCorrectProject(string framework, string selectedConfigFramework)
        {
            var project = UnconfiguredProjectFactory.Create();
            var data    = new PropertyPageData()
            {
                Category     = ProjectDebugger.SchemaName,
                PropertyName = ProjectDebugger.ActiveDebugFrameworkProperty,
                Value        = framework
            };
            var data2 = new PropertyPageData()
            {
                Category     = ConfigurationGeneral.SchemaName,
                PropertyName = ConfigurationGeneral.TargetFrameworksProperty,
                Value        = "net462;net461;netcoreapp1.0"
            };

            var projects = ImmutableDictionary <string, ConfiguredProject> .Empty
                           .Add("net461", ConfiguredProjectFactory.Create(null, new StandardProjectConfiguration("Debug|AnyCPU|net461", Empty.PropertiesMap
                                                                                                                 .Add("Configuration", "Debug")
                                                                                                                 .Add("Platform", "AnyCPU")
                                                                                                                 .Add("TargetFramework", "net461"))))
                           .Add("netcoreapp1.0", ConfiguredProjectFactory.Create(null, new StandardProjectConfiguration("Debug|AnyCPU|netcoreapp1.0", Empty.PropertiesMap
                                                                                                                        .Add("Configuration", "Debug")
                                                                                                                        .Add("Platform", "AnyCPU")
                                                                                                                        .Add("TargetFramework", "netcoreapp1.0"))))
                           .Add("net462", ConfiguredProjectFactory.Create(null, new StandardProjectConfiguration("Debug|AnyCPU|net462", Empty.PropertiesMap
                                                                                                                 .Add("Configuration", "Debug")
                                                                                                                 .Add("Platform", "AnyCPU")
                                                                                                                 .Add("TargetFramework", "net462"))));

            var projectProperties    = ProjectPropertiesFactory.Create(project, data, data2);
            var projectConfgProvider = new IActiveConfiguredProjectsProviderFactory(MockBehavior.Strict)
                                       .ImplementGetActiveConfiguredProjectsMapAsync(projects);

            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(projectProperties: projectProperties);

            var debugFrameworkSvcs      = new ActiveDebugFrameworkServices(projectConfgProvider.Object, commonServices);
            var activeConfiguredProject = await debugFrameworkSvcs.GetConfiguredProjectForActiveFrameworkAsync();

            Assert.Equal(selectedConfigFramework, activeConfiguredProject.ProjectConfiguration.Dimensions.GetValueOrDefault("TargetFramework"));
        }
Ejemplo n.º 17
0
        internal LaunchSettingsUnderTest GetLaunchSettingsProvider(IFileSystem fileSystem, string appDesignerFolder = @"c:\test\Project1\Properties", string activeProfile = "")
        {
            Mock <IEnumValue> activeProfileValue = new Mock <IEnumValue>();

            activeProfileValue.Setup(s => s.Name).Returns(activeProfile);
            var debuggerData = new PropertyPageData()
            {
                Category     = ProjectDebugger.SchemaName,
                PropertyName = ProjectDebugger.ActiveDebugProfileProperty,
                Value        = activeProfileValue.Object
            };

            var specialFilesManager = ISpecialFilesManagerFactory.ImplementGetFile(appDesignerFolder);
            var unconfiguredProject = UnconfiguredProjectFactory.Create(null, null, @"c:\test\Project1\Project1.csproj");
            var properties          = ProjectPropertiesFactory.Create(unconfiguredProject, new[] { debuggerData });
            var commonServices      = IUnconfiguredProjectCommonServicesFactory.Create(unconfiguredProject, null, new IProjectThreadingServiceMock(), null, properties);
            var projectServices     = IUnconfiguredProjectServicesFactory.Create(IProjectAsynchronousTasksServiceFactory.Create(CancellationToken.None));
            var provider            = new LaunchSettingsUnderTest(unconfiguredProject, projectServices, fileSystem ?? new IFileSystemMock(), commonServices, null, specialFilesManager);

            return(provider);
        }
        public void VerifyFileWatcherRegistration(string inputTree, string fileToWatch)
        {
            var  spMock            = new IServiceProviderMoq();
            uint adviseCookie      = 100;
            var  fileChangeService = IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(adviseCookie);

            spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), fileChangeService);

            var watcher = new ProjectLockFileWatcher(spMock,
                                                     IProjectTreeProviderFactory.Create(),
                                                     IUnconfiguredProjectCommonServicesFactory.Create(IUnconfiguredProjectFactory.Create(filePath: @"C:\Foo\foo.proj")),
                                                     IProjectLockServiceFactory.Create());

            var tree = ProjectTreeParser.Parse(inputTree);

            watcher.ProjectTree_ChangedAsync(IProjectVersionedValueFactory <IProjectTreeSnapshot> .Create(IProjectTreeSnapshotFactory.Create(tree)));

            // If fileToWatch is null then we expect to not register any filewatcher.
            var times = fileToWatch == null?Times.Never() : Times.Once();

            Mock.Get <IVsFileChangeEx>(fileChangeService).Verify(s => s.AdviseFileChange(fileToWatch ?? It.IsAny <string>(), It.IsAny <uint>(), watcher, out adviseCookie), times);
        }
Ejemplo n.º 19
0
        public void VerifyFileWatcherRegistrationOnTreeChange(string inputTree, string changedTree, int numRegisterCalls, int numUnregisterCalls)
        {
            var  spMock            = new IServiceProviderMoq();
            uint adviseCookie      = 100;
            var  fileChangeService = IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(adviseCookie);

            spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), fileChangeService);

            var propertyData = new PropertyPageData
            {
                Category     = ConfigurationGeneral.SchemaName,
                PropertyName = ConfigurationGeneral.BaseIntermediateOutputPathProperty,
                Value        = "obj\\"
            };
            var unconfiguredProject = IUnconfiguredProjectFactory.Create(filePath: @"C:\Foo\foo.proj");
            var watcher             = new ProjectLockFileWatcher(spMock,
                                                                 IProjectTreeProviderFactory.Create(),
                                                                 IUnconfiguredProjectCommonServicesFactory.Create(unconfiguredProject,
                                                                                                                  projectProperties: ProjectPropertiesFactory.Create(unconfiguredProject, new[] { propertyData })),
                                                                 IProjectLockServiceFactory.Create());

            watcher.Load();

            var firstTree = ProjectTreeParser.Parse(inputTree);

            watcher.ProjectTree_ChangedAsync(IProjectVersionedValueFactory <IProjectTreeSnapshot> .Create(IProjectTreeSnapshotFactory.Create(firstTree)));

            var secondTree = ProjectTreeParser.Parse(changedTree);

            watcher.ProjectTree_ChangedAsync(IProjectVersionedValueFactory <IProjectTreeSnapshot> .Create(IProjectTreeSnapshotFactory.Create(secondTree)));

            // If fileToWatch is null then we expect to not register any filewatcher.
            Mock <IVsFileChangeEx> fileChangeServiceMock = Mock.Get <IVsFileChangeEx>(fileChangeService);

            fileChangeServiceMock.Verify(s => s.AdviseFileChange(It.IsAny <string>(), It.IsAny <uint>(), watcher, out adviseCookie),
                                         Times.Exactly(numRegisterCalls));
            fileChangeServiceMock.Verify(s => s.UnadviseFileChange(adviseCookie), Times.Exactly(numUnregisterCalls));
        }
Ejemplo n.º 20
0
        public async Task ReplaceTokensInProfileTests()
        {
            IUnconfiguredProjectCommonServices services = IUnconfiguredProjectCommonServicesFactory.Create();

            IActiveDebugFrameworkServices activeDebugFramework = Mock.Of <IActiveDebugFrameworkServices>();

            var replacer = new DebugTokenReplacerUnderTest(IUnconfiguredProjectCommonServicesFactory.Create(), _envHelper.Object, activeDebugFramework);

            // Tests all the possible replacements. env3 tests that enviroment vars are resolved before msbuild tokens
            var launchProfile = new LaunchProfile()
            {
                Name                 = "$(msbuildProperty1)",
                CommandLineArgs      = "%env1%",
                CommandName          = "$(msbuildProperty2)",
                ExecutablePath       = "$(test this string", // Not a valid token
                WorkingDirectory     = "c:\\test\\%env3%",
                LaunchBrowser        = false,
                LaunchUrl            = "http://localhost:8080/$(unknownproperty)",
                EnvironmentVariables = ImmutableDictionary <string, string> .Empty.Add("var1", "%env1%").Add("var2", "$(msbuildProperty3)"),
                OtherSettings        = ImmutableDictionary <string, object> .Empty.Add("setting1", "%env1%").Add("setting2", true),
            };

            var resolvedProfile = await replacer.ReplaceTokensInProfileAsync(launchProfile);

            // Name and Command name should never be touched
            Assert.Equal("$(msbuildProperty1)", resolvedProfile.Name);
            Assert.Equal("$(msbuildProperty2)", resolvedProfile.CommandName);
            Assert.Equal("envVariable1", resolvedProfile.CommandLineArgs);
            Assert.Equal("$(test this string", resolvedProfile.ExecutablePath);
            Assert.False(resolvedProfile.LaunchBrowser);
            Assert.Equal("http://localhost:8080/", resolvedProfile.LaunchUrl);
            Assert.Equal("c:\\test\\Property6", resolvedProfile.WorkingDirectory);
            Assert.Equal("envVariable1", resolvedProfile.EnvironmentVariables["var1"]);
            Assert.Equal("Property3", resolvedProfile.EnvironmentVariables["var2"]);
            Assert.Equal("envVariable1", resolvedProfile.OtherSettings["setting1"]);
            Assert.True((bool)resolvedProfile.OtherSettings["setting2"]);
        }
        public async Task VerifyFileWatcherRegistration(string inputTree, string fileToWatch)
        {
            uint adviseCookie      = 100;
            var  fileChangeService = IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(adviseCookie);

            var tasksService = IUnconfiguredProjectTasksServiceFactory.ImplementLoadedProjectAsync <ConfiguredProject>(t => t());

            var watcher = new ProjectAssetFileWatcher(IVsServiceFactory.Create <SVsFileChangeEx, IVsFileChangeEx>(fileChangeService),
                                                      IProjectTreeProviderFactory.Create(),
                                                      IUnconfiguredProjectCommonServicesFactory.Create(threadingService: IProjectThreadingServiceFactory.Create()),
                                                      tasksService,
                                                      IActiveConfiguredProjectSubscriptionServiceFactory.Create());

            var tree          = ProjectTreeParser.Parse(inputTree);
            var projectUpdate = IProjectSubscriptionUpdateFactory.FromJson(ProjectCurrentStateJson);

            watcher.Load();
            await watcher.DataFlow_ChangedAsync(IProjectVersionedValueFactory <Tuple <IProjectTreeSnapshot, IProjectSubscriptionUpdate> > .Create((Tuple.Create(IProjectTreeSnapshotFactory.Create(tree), projectUpdate))));

            // If fileToWatch is null then we expect to not register any filewatcher.
            var times = fileToWatch == null?Times.Never() : Times.Once();

            Mock.Get(fileChangeService).Verify(s => s.AdviseFileChange(fileToWatch ?? It.IsAny <string>(), It.IsAny <uint>(), watcher, out adviseCookie), times);
        }
        public void WhenFindByPathAndAbsoluteNodePath_ShouldFind()
        {
            // Arrange
            var treeServices         = new MockIDependenciesTreeServices();
            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement();
            var project        = UnconfiguredProjectFactory.Create();
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = "",
                Flags    = DependencyTreeFlags.DependenciesRootNodeFlags
            };

            var level1Child1 = new TestProjectTree
            {
                Caption  = "level1Child1",
                FilePath = @"c:\folder\level1Child1",
                Flags    = ProjectTreeFlags.Empty
            };

            var level1Child2 = new TestProjectTree
            {
                Caption  = "level1Child2",
                FilePath = @"c:\folder\level1Child2",
                Flags    = ProjectTreeFlags.Empty
            };

            var level2Child21 = new TestProjectTree
            {
                Caption  = "level2Child21",
                FilePath = @"c:\folder\level2Child21",
                Flags    = ProjectTreeFlags.Empty
            };

            var level2Child22 = new TestProjectTree
            {
                Caption  = "level1Child22",
                FilePath = @"c:\folder\level2Child22",
                Flags    = ProjectTreeFlags.Empty
            };

            var level3Child31 = new TestProjectTree
            {
                Caption  = "level3Child31",
                FilePath = @"c:\folder\level3Child31",
                Flags    = ProjectTreeFlags.Empty
            };

            var level3Child32 = new TestProjectTree
            {
                Caption  = "level3Child32",
                FilePath = @"c:\folder\level3Child32",
                Flags    = ProjectTreeFlags.Empty
            };

            dependenciesRoot.Add(level1Child1);
            dependenciesRoot.Add(level1Child2);

            level1Child2.Add(level2Child21);
            level1Child2.Add(level2Child22);

            level2Child22.Add(level3Child31);
            level2Child22.Add(level3Child32);

            // Act
            var provider   = new GroupedByTargetTreeViewProvider(treeServices, treeViewModelFactory, commonServices);
            var resultTree = provider.FindByPath(dependenciesRoot, @"c:\folder\level3Child32");

            // Assert
            Assert.NotNull(resultTree);
            Assert.Equal("level3Child32", resultTree.Caption);
        }
Ejemplo n.º 23
0
        public void GrouppedByTargetTreeViewProvider_WhenFindByPathAndNeedToFindDependenciesRoot_ShouldFind()
        {
            // Arrange
            const string projectPath   = @"c:\myfolder\mysubfolder\myproject.csproj";
            var          projectFolder = Path.GetDirectoryName(projectPath);

            var treeServices         = new MockIDependenciesTreeServices();
            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement();
            var project        = UnconfiguredProjectFactory.Create(filePath: projectPath);
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var projectRoot = new TestProjectTree
            {
                Caption  = "myproject",
                FilePath = "",
                Flags    = ProjectTreeFlags.Empty
            };

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = "",
                Flags    = DependencyTreeFlags.DependenciesRootNodeFlags
            };

            var level1Child1 = new TestProjectTree
            {
                Caption  = "level1Child1",
                FilePath = @"c:\folder\level1Child1",
                Flags    = ProjectTreeFlags.Empty
            };

            var level1Child2 = new TestProjectTree
            {
                Caption  = "level1Child2",
                FilePath = @"c:\folder\level1Child2",
                Flags    = ProjectTreeFlags.Empty
            };

            var level2Child21 = new TestProjectTree
            {
                Caption  = "level2Child21",
                FilePath = @"c:\folder\level2Child21",
                Flags    = ProjectTreeFlags.Empty
            };

            var level2Child22 = new TestProjectTree
            {
                Caption  = "level1Child22",
                FilePath = @"c:\folder\level2Child22",
                Flags    = ProjectTreeFlags.Empty
            };

            var level3Child31 = new TestProjectTree
            {
                Caption  = "level3Child31",
                FilePath = @"c:\folder\level3Child31",
                Flags    = ProjectTreeFlags.Empty
            };

            var level3Child32 = new TestProjectTree
            {
                Caption  = "level3Child32",
                FilePath = @"level3Child32",
                Flags    = ProjectTreeFlags.Empty
            };

            projectRoot.Add(dependenciesRoot);

            dependenciesRoot.Add(level1Child1);
            dependenciesRoot.Add(level1Child2);

            level1Child2.Add(level2Child21);
            level1Child2.Add(level2Child22);

            level2Child22.Add(level3Child31);
            level2Child22.Add(level3Child32);

            // Act
            var provider   = new GroupedByTargetTreeViewProvider(treeServices, treeViewModelFactory, commonServices);
            var resultTree = provider.FindByPath(projectRoot, Path.Combine(projectFolder, @"level3Child32"));

            // Assert
            Assert.NotNull(resultTree);
            Assert.Equal("level3Child32", resultTree.Caption);
        }
 internal TestBuildManager()
     : base(IProjectThreadingServiceFactory.Create(),
            IUnconfiguredProjectCommonServicesFactory.Create(UnconfiguredProjectFactory.Create()))
 {
 }
Ejemplo n.º 25
0
 internal TestBuildManager(TestTempPEBuildManager mgr)
     : base(IProjectThreadingServiceFactory.Create(), IUnconfiguredProjectCommonServicesFactory.Create(UnconfiguredProjectFactory.Create()))
 {
     _mgr = mgr;
 }
Ejemplo n.º 26
0
        public void GrouppedByTargetTreeViewProvider_WhenOneTargetSnapshotAndDependencySupportsRule_ShouldCreateRule()
        {
            var dependencyRootYyy     = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""YyyDependencyRoot"",
    ""Name"":""YyyDependencyRoot"",
    ""Caption"":""YyyDependencyRoot"",
    ""Resolved"":""true""
}");
            var dependencyYyyExisting = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""tfm1\\yyy\\dependencyExisting"",
    ""Name"":""dependencyExisting"",
    ""Caption"":""DependencyExisting"",
    ""SchemaItemType"":""Yyy"",
    ""Resolved"":""true""
}", icon: KnownMonikers.Uninstall,
                                                                    expandedIcon: KnownMonikers.Uninstall,
                                                                    flags: DependencyTreeFlags.SupportsRuleProperties);

            var dependencies = new List <IDependency>
            {
                dependencyYyyExisting
            };

            var dependencyYyyExistingTree = new TestProjectTree
            {
                Caption  = "DependencyExisting",
                FilePath = "tfm1\\yyy\\dependencyExisting",
                Flags    = DependencyTreeFlags.ResolvedFlags
            };

            var dependencyRootYyyTree = new TestProjectTree
            {
                Caption  = "YyyDependencyRoot",
                FilePath = "YyyDependencyRoot"
            };

            dependencyRootYyyTree.Add(dependencyYyyExistingTree);

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = ""
            };

            dependenciesRoot.Add(dependencyRootYyyTree);

            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement(
                getDependenciesRootIcon: KnownMonikers.AboutBox,
                createRootViewModel: new[] { dependencyRootYyy });

            var testData = new Dictionary <ITargetFramework, List <IDependency> >
            {
                { ITargetFrameworkFactory.Implement(moniker: "tfm1"), dependencies }
            };

            var project        = UnconfiguredProjectFactory.Create(filePath: @"c:\somefodler\someproject.csproj");
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var provider = new GroupedByTargetTreeViewProvider(
                new MockIDependenciesTreeServices(),
                treeViewModelFactory,
                commonServices);

            // Act
            var resultTree = provider.BuildTree(dependenciesRoot, GetSnapshot(testData));

            // Assert
            var expectedFlatHierarchy =
                @"Caption=MyDependencies, FilePath=, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag=
Caption=YyyDependencyRoot, FilePath=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=DependencyExisting, FilePath=tfm1\yyy\dependencyExisting, IconHash=325249260, ExpandedIconHash=325249260, Rule=Yyy, IsProjectItem=False, CustomTag=
";

            Assert.Equal(expectedFlatHierarchy, ((TestProjectTree)resultTree).FlatHierarchy);
        }
Ejemplo n.º 27
0
        public void GrouppedByTargetTreeViewProvider_WheEmptySnapshotAndVisibilityMarkerNotProvided_ShouldHideSubTreeRoot()
        {
            var dependencyRootYyy          = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""YyyDependencyRoot"",
    ""Name"":""YyyDependencyRoot"",
    ""Caption"":""YyyDependencyRoot"",
    ""Resolved"":""true""
}");
            var dependencyVisibilityMarker = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""someid"",
    ""Name"":""someid"",
    ""Caption"":""someid"",
    ""Resolved"":""false"",
    ""Visible"":""false""
}");

            var dependencies = new List <IDependency>
            {
                dependencyVisibilityMarker
            };

            var dependencyRootYyyTree = new TestProjectTree
            {
                Caption  = "YyyDependencyRoot",
                FilePath = "YyyDependencyRoot"
            };

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = ""
            };

            dependenciesRoot.Add(dependencyRootYyyTree);

            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement(
                getDependenciesRootIcon: KnownMonikers.AboutBox,
                createRootViewModel: new[] { dependencyRootYyy });

            var testData = new Dictionary <ITargetFramework, List <IDependency> >
            {
                { ITargetFrameworkFactory.Implement(moniker: "tfm1"), dependencies }
            };

            var project        = UnconfiguredProjectFactory.Create(filePath: @"c:\somefodler\someproject.csproj");
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var provider = new GroupedByTargetTreeViewProvider(
                new MockIDependenciesTreeServices(),
                treeViewModelFactory,
                commonServices);

            // Act
            var resultTree = provider.BuildTree(dependenciesRoot, GetSnapshot(testData));

            // Assert
            var expectedFlatHierarchy =
                @"Caption=MyDependencies, FilePath=, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag=
";

            Assert.Equal(expectedFlatHierarchy, ((TestProjectTree)resultTree).FlatHierarchy);
        }
Ejemplo n.º 28
0
        public void GrouppedByTargetTreeViewProvider_WhenMultipleTargetSnapshotsWithExistingDependencies_ShouldApplyChanges()
        {
            var tfm1   = ITargetFrameworkFactory.Implement(moniker: "tfm1");
            var tfm2   = ITargetFrameworkFactory.Implement(moniker: "tfm2");
            var tfmAny = ITargetFrameworkFactory.Implement(moniker: "any");

            var dependencyRootXxx = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Xxx"",
    ""Id"": ""XxxDependencyRoot"",
    ""Name"":""XxxDependencyRoot"",
    ""Caption"":""XxxDependencyRoot"",
    ""Resolved"":""true""
}");

            var dependencyXxx1 = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Xxx"",
    ""Id"": ""xxx\\dependency1"",
    ""Path"": ""dependencyxxxpath"",
    ""Name"":""dependency1"",
    ""Caption"":""Dependency1"",
    ""SchemaItemType"":""Xxx"",
    ""Resolved"":""true""
}", icon: KnownMonikers.Uninstall, expandedIcon: KnownMonikers.Uninstall, targetFramework: tfm1);

            var dependencyRootYyy = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""YyyDependencyRoot"",
    ""Name"":""YyyDependencyRoot"",
    ""Caption"":""YyyDependencyRoot""
}");

            var dependencyYyy1 = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""yyy\\dependency1"",
    ""Path"": ""dependencyyyypath"",
    ""Name"":""dependency1"",
    ""Caption"":""Dependency1"",
    ""SchemaItemType"":""Yyy"",
    ""Resolved"":""true""
}", icon: KnownMonikers.Uninstall, expandedIcon: KnownMonikers.Uninstall, targetFramework: tfm1);

            var dependencyYyyExisting = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""yyy\\dependencyExisting"",
    ""Path"": ""dependencyyyyExistingpath"",
    ""Name"":""dependencyExisting"",
    ""Caption"":""DependencyExisting"",
    ""SchemaItemType"":""Yyy"",
    ""Resolved"":""true""
}", icon: KnownMonikers.Uninstall, expandedIcon: KnownMonikers.Uninstall, targetFramework: tfm1);

            var dependencyRootZzz = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Zzz"",
    ""Id"": ""ZzzDependencyRoot"",
    ""Name"":""ZzzDependencyRoot"",
    ""Caption"":""ZzzDependencyRoot"",
    ""Resolved"":""true""
}", flags: ProjectTreeFlags.Create(ProjectTreeFlags.Common.BubbleUp));
            var dependencyAny1    = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Zzz"",
    ""Id"": ""ZzzDependencyAny1"",
    ""Path"": ""ZzzDependencyAny1path"",
    ""Name"":""ZzzDependencyAny1"",
    ""Caption"":""ZzzDependencyAny1""
}", targetFramework: tfmAny);

            var dependencies = new List <IDependency>
            {
                dependencyXxx1,
                dependencyYyy1,
                dependencyYyyExisting
            };

            var dependenciesAny = new List <IDependency>
            {
                dependencyAny1
            };

            var oldRootChildToBeRemoved = new TestProjectTree
            {
                Caption  = "OldRootChildToBeRemoved",
                FilePath = ""
            };

            var dependencyYyyExistingTree = new TestProjectTree
            {
                Caption  = "DependencyExisting",
                FilePath = "yyy\\dependencyExisting"
            };

            var dependencyRootYyyTree = new TestProjectTree
            {
                Caption  = "YyyDependencyRoot",
                FilePath = "YyyDependencyRoot"
            };

            dependencyRootYyyTree.Add(dependencyYyyExistingTree);

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = ""
            };

            dependenciesRoot.Add(oldRootChildToBeRemoved);
            dependenciesRoot.Add(dependencyRootYyyTree);

            var target1   = IDependencyFactory.FromJson(@"
{
    ""Id"": ""tfm1"",
    ""Name"":""tfm1"",
    ""Caption"":""tfm1""
}");
            var target2   = IDependencyFactory.FromJson(@"
{
    ""Id"": ""tfm2"",
    ""Name"":""tfm2"",
    ""Caption"":""tfm2""
}");
            var targetAny = IDependencyFactory.FromJson(@"
{
    ""Id"": ""any"",
    ""Name"":""any"",
    ""Caption"":""any""
}");

            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement(
                getDependenciesRootIcon: KnownMonikers.AboutBox,
                createRootViewModel: new[] { dependencyRootXxx, dependencyRootYyy, dependencyRootZzz },
                createTargetViewModel: new[] { target1, target2 });

            var testData = new Dictionary <ITargetFramework, List <IDependency> >
            {
                { tfm1, dependencies },
                { tfm2, dependencies },
                { tfmAny, dependenciesAny }
            };

            var project        = UnconfiguredProjectFactory.Create(filePath: @"c:\somefodler\someproject.csproj");
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var provider = new GroupedByTargetTreeViewProvider(
                new MockIDependenciesTreeServices(),
                treeViewModelFactory,
                commonServices);

            // Act
            var resultTree = provider.BuildTree(dependenciesRoot, GetSnapshot(testData));

            // Assert
            var expectedFlatHierarchy =
                @"Caption=MyDependencies, FilePath=, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag=
Caption=tfm2, FilePath=tfm2, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=, BubbleUpFlag=True
Caption=YyyDependencyRoot, FilePath=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=Dependency1, FilePath=tfm1\Yyy\dependencyyyypath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=False, CustomTag=
Caption=DependencyExisting, FilePath=tfm1\Yyy\dependencyyyyExistingpath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=False, CustomTag=
Caption=XxxDependencyRoot, FilePath=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=Dependency1, FilePath=tfm1\Xxx\dependencyxxxpath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=False, CustomTag=
Caption=ZzzDependencyRoot, FilePath=ZzzDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=ZzzDependencyAny1, FilePath=ZzzDependencyAny1, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=tfm1, FilePath=tfm1, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=, BubbleUpFlag=True
Caption=YyyDependencyRoot, FilePath=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=Dependency1, FilePath=tfm1\Yyy\dependencyyyypath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=True, CustomTag=
Caption=DependencyExisting, FilePath=tfm1\Yyy\dependencyyyyExistingpath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=True, CustomTag=
Caption=XxxDependencyRoot, FilePath=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=Dependency1, FilePath=tfm1\Xxx\dependencyxxxpath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=True, CustomTag=
";

            Assert.Equal(expectedFlatHierarchy, ((TestProjectTree)resultTree).FlatHierarchy);
        }