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]; } }
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); } }