Пример #1
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)
            {
                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);
            }
        }