Beispiel #1
0
        private void TestUnresolvedReferencesHelper(ArrayList projectRefs, Hashtable pregenConfigurations,
                                                    out Hashtable unresolvedProjects, out Hashtable resolvedProjects)
        {
            // Use the XML string generation method from our sister class - XML element names will be different,
            // but they are ignored anyway, and the rest is identical
            string xmlString = ResolveNonMSBuildProjectOutput_Tests.CreatePregeneratedPathDoc(pregenConfigurations);

            MockEngine engine = new MockEngine(_output);
            AssignProjectConfiguration rpc = new AssignProjectConfiguration();

            rpc.BuildEngine = engine;
            rpc.SolutionConfigurationContents = xmlString;
            rpc.ProjectReferences             = (ITaskItem[])projectRefs.ToArray(typeof(ITaskItem));

            bool result = rpc.Execute();

            unresolvedProjects = new Hashtable();

            for (int i = 0; i < rpc.UnassignedProjects.Length; i++)
            {
                unresolvedProjects[rpc.UnassignedProjects[i].ItemSpec] = rpc.UnassignedProjects[i];
            }

            resolvedProjects = new Hashtable();
            for (int i = 0; i < rpc.AssignedProjects.Length; i++)
            {
                resolvedProjects[rpc.AssignedProjects[i].GetMetadata("FullConfiguration")] = rpc.AssignedProjects[i];
            }
        }
Beispiel #2
0
        public void TestUnresolvedReferences()
        {
            Hashtable unresolvedProjects    = null;
            Hashtable resolvedProjects      = null;
            Hashtable projectConfigurations = null;
            ArrayList projectRefs           = null;

            projectRefs = new ArrayList();
            projectRefs.Add(ResolveNonMSBuildProjectOutput_Tests.CreateReferenceItem("MCDep1.vcproj", "{2F6BBCC3-7111-4116-A68B-000000000000}",
                                                                                     "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}", "MCDep1"));
            projectRefs.Add(ResolveNonMSBuildProjectOutput_Tests.CreateReferenceItem("MCDep2.vcproj", "{2F6BBCC3-7111-4116-A68B-34CFC76F37C5}",
                                                                                     "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}", "MCDep2"));

            // 1. multiple projects, none resolvable
            projectConfigurations = new Hashtable();
            projectConfigurations.Add("{11111111-1111-1111-1111-111111111111}", @"Config1|Win32");
            projectConfigurations.Add("{11111111-1111-1111-1111-111111111112}", @"Config2|AnyCPU");
            projectConfigurations.Add("{11111111-1111-1111-1111-111111111113}", @"Config3|AnyCPU");

            TestUnresolvedReferencesHelper(projectRefs, projectConfigurations, out unresolvedProjects, out resolvedProjects);

            Assert.Empty(resolvedProjects);            // "No resolved refs expected for case 1"
            Assert.Equal(2, unresolvedProjects.Count); // "Two unresolved refs expected for case 1"
            Assert.Equal(unresolvedProjects["MCDep1.vcproj"], projectRefs[0]);
            Assert.Equal(unresolvedProjects["MCDep2.vcproj"], projectRefs[1]);

            // 2. multiple projects, one resolvable
            projectConfigurations = new Hashtable();
            projectConfigurations.Add("{11111111-1111-1111-1111-111111111111}", @"Config1|Win32");
            projectConfigurations.Add("{11111111-1111-1111-1111-111111111112}", @"Config2|AnyCPU");
            projectConfigurations.Add("{11111111-1111-1111-1111-111111111113}", @"Config3|AnyCPU");
            projectConfigurations.Add("{2F6BBCC3-7111-4116-A68B-34CFC76F37C5}", @"CorrectProjectConfig|Platform");

            TestUnresolvedReferencesHelper(projectRefs, projectConfigurations, out unresolvedProjects, out resolvedProjects);

            Assert.Single(resolvedProjects);   // "One resolved ref expected for case 2"
            Assert.True(resolvedProjects.ContainsKey(@"CorrectProjectConfig|Platform"));
            Assert.Single(unresolvedProjects); // "One unresolved ref expected for case 2"
            Assert.Equal(unresolvedProjects["MCDep1.vcproj"], projectRefs[0]);

            // 3. multiple projects, all resolvable
            projectConfigurations = new Hashtable();
            projectConfigurations.Add("{11111111-1111-1111-1111-111111111111}", @"Config1|Win32");
            projectConfigurations.Add("{11111111-1111-1111-1111-111111111112}", @"Config2|AnyCPU");
            projectConfigurations.Add("{11111111-1111-1111-1111-111111111113}", @"Config3|AnyCPU");
            projectConfigurations.Add("{2F6BBCC3-7111-4116-A68B-34CFC76F37C5}", @"CorrectProjectConfig|Platform");
            projectConfigurations.Add("{2F6BBCC3-7111-4116-A68B-000000000000}", @"CorrectProjectConfig2|Platform");

            TestUnresolvedReferencesHelper(projectRefs, projectConfigurations, out unresolvedProjects, out resolvedProjects);

            Assert.Equal(2, resolvedProjects.Count); // "Two resolved refs expected for case 3"
            Assert.True(resolvedProjects.ContainsKey(@"CorrectProjectConfig|Platform"));
            Assert.True(resolvedProjects.ContainsKey(@"CorrectProjectConfig2|Platform"));
            Assert.Empty(unresolvedProjects); // "No unresolved refs expected for case 3"
        }
Beispiel #3
0
        private void TestResolveHelper(string itemSpec, string projectGuid, string package, string name,
                                       Hashtable pregenConfigurations, bool expectedResult,
                                       string expectedFullConfiguration, string expectedConfiguration, string expectedPlatform)
        {
            ITaskItem reference = ResolveNonMSBuildProjectOutput_Tests.CreateReferenceItem(itemSpec, projectGuid, package, name);
            // Use the XML string generation method from our sister class - XML element names will be different,
            // but they are ignored anyway, and the rest is identical
            string    xmlString = ResolveNonMSBuildProjectOutput_Tests.CreatePregeneratedPathDoc(pregenConfigurations);
            ITaskItem resolvedProjectWithConfiguration;

            AssignProjectConfiguration rpc = new AssignProjectConfiguration();

            rpc.SolutionConfigurationContents = xmlString;
            rpc.CacheProjectElementsFromXml(xmlString);
            bool result = rpc.ResolveProject(reference, out resolvedProjectWithConfiguration);

            string message = string.Format("Reference \"{0}\" [project \"{1}\", package \"{2}\", name \"{3}\"] Pregen Xml string : \"{4}\"" +
                                           "expected result \"{5}\", actual result \"{6}\", expected configuration \"{7}\", actual configuration \"{8}\".",
                                           itemSpec, projectGuid, package, name, xmlString, expectedResult, result, expectedFullConfiguration,
                                           (resolvedProjectWithConfiguration == null) ? string.Empty : resolvedProjectWithConfiguration.GetMetadata("FullConfiguration"));

            Assert.Equal(expectedResult, result);
            if (result == true)
            {
                Assert.Equal(expectedFullConfiguration, resolvedProjectWithConfiguration.GetMetadata("FullConfiguration"));
                Assert.Equal(expectedConfiguration, resolvedProjectWithConfiguration.GetMetadata("Configuration"));
                Assert.Equal(expectedPlatform, resolvedProjectWithConfiguration.GetMetadata("Platform"));
                Assert.Equal("Configuration=" + expectedConfiguration, resolvedProjectWithConfiguration.GetMetadata("SetConfiguration"));
                Assert.Equal("Platform=" + expectedPlatform, resolvedProjectWithConfiguration.GetMetadata("SetPlatform"));
                Assert.Equal(reference.ItemSpec, resolvedProjectWithConfiguration.ItemSpec);
            }
            else
            {
                Assert.Null(resolvedProjectWithConfiguration);
            }
        }