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]; } }
public void TestReferenceWithNoMetadataNoBuildInProjectAttribute() { // Test the case where the metadata is missing and we are not supposed to build the reference ITaskItem referenceItem = new TaskItem("TestItem"); XmlDocument doc = new XmlDocument(); XmlElement element = doc.CreateElement("TestElement"); AssignProjectConfiguration.SetBuildInProjectAndReferenceOutputAssemblyMetadata(true, referenceItem, element); Assert.Empty(referenceItem.GetMetadata("BuildReference")); Assert.Empty(referenceItem.GetMetadata("ReferenceOutputAssembly")); }
public void TestReferenceWithNoMetadataBuildInProjectAttributeFalse() { // Test the case where the metadata is missing and we are not supposed to build the reference ITaskItem referenceItem = new TaskItem("TestItem"); XmlDocument doc = new XmlDocument(); XmlElement element = doc.CreateElement("TestElement"); element.SetAttribute("BuildProjectInSolution", "false"); AssignProjectConfiguration.SetBuildInProjectAndReferenceOutputAssemblyMetadata(true, referenceItem, element); Assert.IsTrue(referenceItem.GetMetadata("BuildReference").Equals("false", StringComparison.OrdinalIgnoreCase)); Assert.IsTrue(referenceItem.GetMetadata("ReferenceOutputAssembly").Equals("false", StringComparison.OrdinalIgnoreCase)); }
public void TestReferenceWithNoMetadataBuildInProjectAttributeFalseReferenceAndBuildProjectsDisabledInProjectConfiguration() { // Test the case where the metadata is missing and we are not supposed to build the reference ITaskItem referenceItem = new TaskItem("TestItem"); XmlDocument doc = new XmlDocument(); XmlElement element = doc.CreateElement("TestElement"); element.SetAttribute("BuildProjectInSolution", "false"); AssignProjectConfiguration.SetBuildInProjectAndReferenceOutputAssemblyMetadata(false, referenceItem, element); Assert.IsTrue(referenceItem.GetMetadata("BuildReference").Length == 0); Assert.IsTrue(referenceItem.GetMetadata("ReferenceOutputAssembly").Length == 0); }
public void TestReferenceWithNoMetadataBadBuildInProjectAttribute() { // Test the case where the metadata is missing and we are not supposed to build the reference ITaskItem referenceItem = new TaskItem("TestItem"); XmlDocument doc = new XmlDocument(); XmlElement element = doc.CreateElement("TestElement"); element.SetAttribute("BuildProjectInSolution", "IAmReallyABadOne"); AssignProjectConfiguration.SetBuildInProjectAndReferenceOutputAssemblyMetadata(true, referenceItem, element); Assert.Equal(0, referenceItem.GetMetadata("BuildReference").Length); Assert.Equal(0, referenceItem.GetMetadata("ReferenceOutputAssembly").Length); }
public void VerifyDefaultValuesVcxToDefaultPlatformMappingNoOutput() { string expectedVcxToDefaultPlatformMappingNoOutput = "Win32=X86;X64=X64;Itanium=Itanium"; AssignProjectConfiguration assignProjectConfiguration = new AssignProjectConfiguration(); // Test the case for VcxToDefaultPlatformMapping when the outputType is not library string actualVcxToDefaultPlatformMappingNoOutput = assignProjectConfiguration.VcxToDefaultPlatformMapping; Assert.Equal(actualVcxToDefaultPlatformMappingNoOutput, expectedVcxToDefaultPlatformMappingNoOutput); assignProjectConfiguration.VcxToDefaultPlatformMapping = String.Empty; actualVcxToDefaultPlatformMappingNoOutput = assignProjectConfiguration.VcxToDefaultPlatformMapping; Assert.Equal(actualVcxToDefaultPlatformMappingNoOutput, expectedVcxToDefaultPlatformMappingNoOutput); assignProjectConfiguration.VcxToDefaultPlatformMapping = null; actualVcxToDefaultPlatformMappingNoOutput = assignProjectConfiguration.VcxToDefaultPlatformMapping; Assert.Equal(actualVcxToDefaultPlatformMappingNoOutput, expectedVcxToDefaultPlatformMappingNoOutput); }
public void VerifyDefaultValuesVcxToDefaultPlatformMappingNoOutput() { string expectedVcxToDefaultPlatformMappingNoOutput = "Win32=X86;X64=X64;Itanium=Itanium"; AssignProjectConfiguration assignProjectConfiguration = new AssignProjectConfiguration(); // Test the case for VcxToDefaultPlatformMapping when the outputType is not library string actualVcxToDefaultPlatformMappingNoOutput = assignProjectConfiguration.VcxToDefaultPlatformMapping; Assert.IsTrue(expectedVcxToDefaultPlatformMappingNoOutput.Equals(actualVcxToDefaultPlatformMappingNoOutput, StringComparison.OrdinalIgnoreCase), String.Format("Expected '{0}' but found '{1}'", expectedVcxToDefaultPlatformMappingNoOutput, actualVcxToDefaultPlatformMappingNoOutput)); assignProjectConfiguration.VcxToDefaultPlatformMapping = String.Empty; actualVcxToDefaultPlatformMappingNoOutput = assignProjectConfiguration.VcxToDefaultPlatformMapping; Assert.IsTrue(expectedVcxToDefaultPlatformMappingNoOutput.Equals(actualVcxToDefaultPlatformMappingNoOutput, StringComparison.OrdinalIgnoreCase), String.Format("Expected '{0}' but found '{1}'", expectedVcxToDefaultPlatformMappingNoOutput, actualVcxToDefaultPlatformMappingNoOutput)); assignProjectConfiguration.VcxToDefaultPlatformMapping = null; actualVcxToDefaultPlatformMappingNoOutput = assignProjectConfiguration.VcxToDefaultPlatformMapping; Assert.IsTrue(expectedVcxToDefaultPlatformMappingNoOutput.Equals(actualVcxToDefaultPlatformMappingNoOutput, StringComparison.OrdinalIgnoreCase), String.Format("Expected '{0}' but found '{1}'", expectedVcxToDefaultPlatformMappingNoOutput, actualVcxToDefaultPlatformMappingNoOutput)); }
public void VerifyDefaultValueDefaultToVcxPlatformMappings() { string expectedDefaultToVcxPlatformMapping = "AnyCPU=Win32;X86=Win32;X64=X64;Itanium=Itanium"; AssignProjectConfiguration assignProjectConfiguration = new AssignProjectConfiguration(); /// Test defaults with nothing set string actualDefaultToVcxPlatformMapping = assignProjectConfiguration.DefaultToVcxPlatformMapping; Assert.Equal(actualDefaultToVcxPlatformMapping, expectedDefaultToVcxPlatformMapping); assignProjectConfiguration.DefaultToVcxPlatformMapping = String.Empty; actualDefaultToVcxPlatformMapping = assignProjectConfiguration.DefaultToVcxPlatformMapping; Assert.Equal(actualDefaultToVcxPlatformMapping, expectedDefaultToVcxPlatformMapping); assignProjectConfiguration.DefaultToVcxPlatformMapping = null; actualDefaultToVcxPlatformMapping = assignProjectConfiguration.DefaultToVcxPlatformMapping; Assert.Equal(actualDefaultToVcxPlatformMapping, expectedDefaultToVcxPlatformMapping); }
public void VerifyDefaultValueDefaultToVcxPlatformMappings() { string expectedDefaultToVcxPlatformMapping = "AnyCPU=Win32;X86=Win32;X64=X64;Itanium=Itanium"; AssignProjectConfiguration assignProjectConfiguration = new AssignProjectConfiguration(); /// Test defaults with nothign set string actualDefaultToVcxPlatformMapping = assignProjectConfiguration.DefaultToVcxPlatformMapping; Assert.IsTrue(expectedDefaultToVcxPlatformMapping.Equals(actualDefaultToVcxPlatformMapping, StringComparison.OrdinalIgnoreCase), String.Format("Expected '{0}' but found '{1}'", expectedDefaultToVcxPlatformMapping, actualDefaultToVcxPlatformMapping)); assignProjectConfiguration.DefaultToVcxPlatformMapping = String.Empty; actualDefaultToVcxPlatformMapping = assignProjectConfiguration.DefaultToVcxPlatformMapping; Assert.IsTrue(expectedDefaultToVcxPlatformMapping.Equals(actualDefaultToVcxPlatformMapping, StringComparison.OrdinalIgnoreCase), String.Format("Expected '{0}' but found '{1}'", expectedDefaultToVcxPlatformMapping, actualDefaultToVcxPlatformMapping)); assignProjectConfiguration.DefaultToVcxPlatformMapping = null; actualDefaultToVcxPlatformMapping = assignProjectConfiguration.DefaultToVcxPlatformMapping; Assert.IsTrue(expectedDefaultToVcxPlatformMapping.Equals(actualDefaultToVcxPlatformMapping, StringComparison.OrdinalIgnoreCase), String.Format("Expected '{0}' but found '{1}'", expectedDefaultToVcxPlatformMapping, actualDefaultToVcxPlatformMapping)); }
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); } }
public void TestReferenceWithMetadataAlreadySetBuildInProjectAttributeFalse() { // Test the case where the metadata is missing and we are not supposed to build the reference ITaskItem referenceItem = new TaskItem("TestItem"); referenceItem.SetMetadata("BuildReference", "true"); referenceItem.SetMetadata("ReferenceOutputAssembly", "true"); XmlDocument doc = new XmlDocument(); XmlElement element = doc.CreateElement("TestElement"); element.SetAttribute("BuildProjectInSolution", "false"); AssignProjectConfiguration.SetBuildInProjectAndReferenceOutputAssemblyMetadata(true, referenceItem, element); Assert.Equal("true", referenceItem.GetMetadata("BuildReference")); Assert.Equal("true", referenceItem.GetMetadata("ReferenceOutputAssembly")); // Test the case where only ReferenceOutputAssembly is not set referenceItem = new TaskItem("TestItem"); referenceItem.SetMetadata("BuildReference", "true"); doc = new XmlDocument(); element = doc.CreateElement("TestElement"); element.SetAttribute("BuildProjectInSolution", "false"); AssignProjectConfiguration.SetBuildInProjectAndReferenceOutputAssemblyMetadata(true, referenceItem, element); Assert.Equal("true", referenceItem.GetMetadata("BuildReference")); Assert.Equal("false", referenceItem.GetMetadata("ReferenceOutputAssembly")); // Test the case where only BuildReference is not set referenceItem = new TaskItem("TestItem"); referenceItem.SetMetadata("ReferenceOutputAssembly", "true"); doc = new XmlDocument(); element = doc.CreateElement("TestElement"); element.SetAttribute("BuildProjectInSolution", "false"); AssignProjectConfiguration.SetBuildInProjectAndReferenceOutputAssemblyMetadata(true, referenceItem, element); Assert.Equal("false", referenceItem.GetMetadata("BuildReference")); Assert.Equal("true", referenceItem.GetMetadata("ReferenceOutputAssembly")); }