public void op_Execute_IEnumerable() { using (var file = new TempFile()) { using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Cavity.Build.MSBuildCompliance.xml")) { if (null != resource) { using (var reader = new StreamReader(resource)) { file.Info.Append(reader.ReadToEnd()); } } } var obj = new MSBuildCompliance { BuildEngine = new Mock<IBuildEngine>().Object, Projects = new ITaskItem[] { new TaskItem(file.Info.FullName) }, XPath = "0=count(/b:Project/b:PropertyGroup[@Condition][not(b:WarningLevel[text()='4'])])" }; Assert.True(obj.Execute()); } }
public void op_Execute_IEnumerable_containingNullItem() { using (var file = new TempFile()) { using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Cavity.Build.MSBuildCompliance.xml")) { if (null != resource) { using (var reader = new StreamReader(resource)) { file.Info.Append(reader.ReadToEnd()); } } } var obj = new MSBuildCompliance { BuildEngine = new Mock <IBuildEngine>().Object, Projects = new ITaskItem[] { new TaskItem(file.Info.FullName), null }, XPath = "0=count(/b:Project/b:PropertyGroup[@Condition][not(b:WarningLevel[text()='4'])])" }; Assert.True(obj.Execute()); } }
public void op_Execute_IEnumerableNull() { var obj = new MSBuildCompliance { BuildEngine = new Mock<IBuildEngine>().Object }; Assert.False(obj.Execute()); }
public void op_Execute_IEnumerableNull() { var obj = new MSBuildCompliance { BuildEngine = new Mock <IBuildEngine>().Object }; Assert.False(obj.Execute()); }
public void op_Execute_IEnumerableEmpty() { var obj = new MSBuildCompliance { BuildEngine = new Mock<IBuildEngine>().Object, Projects = new ITaskItem[] { } }; Assert.True(obj.Execute()); }
public void op_Execute_IEnumerableEmpty() { var obj = new MSBuildCompliance { BuildEngine = new Mock <IBuildEngine>().Object, Projects = new ITaskItem[] { } }; Assert.True(obj.Execute()); }
public void op_Execute_IEnumerable_whenWarningLevelMissing() { using (var file = new TempFile()) { using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Cavity.Build.MSBuildCompliance.xml")) { if (null != resource) { using (var reader = new StreamReader(resource)) { var xml = new XmlDocument(); xml.LoadXml(reader.ReadToEnd()); var namespaces = new XmlNamespaceManager(xml.NameTable); namespaces.AddNamespace("b", "http://schemas.microsoft.com/developer/msbuild/2003"); var node = xml.SelectSingleNode("/b:Project/b:PropertyGroup[@Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \"]/b:WarningLevel", namespaces); if (null != node && null != node.ParentNode) { node.ParentNode.RemoveChild(node); } file.Info.Append(xml.OuterXml); } } } var obj = new MSBuildCompliance { BuildEngine = new Mock <IBuildEngine>().Object, Projects = new ITaskItem[] { new TaskItem(file.Info.FullName) }, Explanation = "This is a test", XPath = "0=count(/b:Project/b:PropertyGroup[@Condition][not(b:WarningLevel[text()='4'])])" }; Assert.False(obj.Execute()); } }
public void op_Execute_IEnumerable_whenWarningLevelMissing() { using (var file = new TempFile()) { using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Cavity.Build.MSBuildCompliance.xml")) { if (null != resource) { using (var reader = new StreamReader(resource)) { var xml = new XmlDocument(); xml.LoadXml(reader.ReadToEnd()); var namespaces = new XmlNamespaceManager(xml.NameTable); namespaces.AddNamespace("b", "http://schemas.microsoft.com/developer/msbuild/2003"); var node = xml.SelectSingleNode("/b:Project/b:PropertyGroup[@Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \"]/b:WarningLevel", namespaces); if (null != node && null != node.ParentNode) { node.ParentNode.RemoveChild(node); } file.Info.Append(xml.OuterXml); } } } var obj = new MSBuildCompliance { BuildEngine = new Mock<IBuildEngine>().Object, Projects = new ITaskItem[] { new TaskItem(file.Info.FullName) }, Explanation = "This is a test", XPath = "0=count(/b:Project/b:PropertyGroup[@Condition][not(b:WarningLevel[text()='4'])])" }; Assert.False(obj.Execute()); } }