コード例 #1
0
        public void Load_FromExistentTestFileWithPropertyNamedAuthor_ShouldReturnObjectContainingAnPropertyNamedAuthor()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/Test.tcsproj");

            IList <IMsBuildProperty> properties = projectFile.GetChildren <IMsBuildProperty>();

            Assert.IsTrue(properties.Any(p => p.Name.Equals("Author")));
        }
コード例 #2
0
        public void Load_FromExistentTestFileWithTwoTargets_ShouldReturnObjectContainingNoNotExistentTarget()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/Test.tcsproj");

            IList <IMsBuildTarget> targets = projectFile.GetChildren <IMsBuildTarget>();

            Assert.IsFalse(targets.Any(t => t.Name.Equals("NotExistentTarget")));
        }
コード例 #3
0
        Load_FromExistentTestFileWithTargetExecutedBeforeOtherTarget_ShouldReturnObjectContainingTargetWithCorrectBeforeTargetValue()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/Test.tcsproj");

            IMsBuildTarget target =
                projectFile.GetChildren <IMsBuildTarget>().First(t => t.Name.Equals("BeforeCompile"));

            Assert.AreEqual("CoreCompile", target.BeforeTargets.First());
        }
コード例 #4
0
        Load_FromExistentTestFileWithPropertyNamedAuthor_ShouldReturnObjectContainingAnPropertyNamedAuthorWithCorrectValue()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/Test.tcsproj");

            IList <IMsBuildProperty> properties = projectFile.GetChildren <IMsBuildProperty>();

            Assert.IsTrue(properties.Any(p => p.Name.Equals("Author")));
            Assert.AreEqual("Viktor-Fabian Müller", properties.FirstOrDefault(p => p.Name.Equals("Author"))?.Value);
        }
コード例 #5
0
        Load_FromExistentTestFileWithTwoTargets_ShouldReturnObjectWithTwoContainingTargetsWithCorrectInitializedName()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/Test.tcsproj");

            IList <IMsBuildTarget> targets = projectFile.GetChildren <IMsBuildTarget>();

            Assert.IsTrue(targets.Any(t => t.Name.Equals("CheckFileNameSyntax")));
            Assert.IsTrue(targets.Any(t => t.Name.Equals("BeforeCompile")));
        }
コード例 #6
0
        Load_FromExistentTestFileWithOneTargetContainingOnErrorImplementation_ShouldContainTargetWithCorrectNamedOnErrorImplementation()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/TargetWithOnError.tcsproj");

            IMsBuildTarget target =
                projectFile.GetChildren <IMsBuildTarget>().First(t => t.Name.Equals("BeforeCompile"));

            Assert.AreEqual(1, target.OnErrorTargets.Count);
            Assert.AreEqual("CheckFileNameSyntax", target.OnErrorTargets.First());
        }
コード例 #7
0
        public void Load_FromExistentTestFileWithTargetContainingComment_ShouldInitializeTargetsOnErrorImplementation()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/TargetWithOnError.tcsproj");

            IMsBuildTarget target =
                projectFile.GetChildren <IMsBuildTarget>().First(t => t.Name.Equals("BeforeCompile"));

            Assert.IsNotNull(target.OnErrorTargets);
            Assert.AreNotEqual(0, target.OnErrorTargets.Count);
        }
コード例 #8
0
        Load_FromExistentTestFileWithTargetImplementingComplexConditionalOverwritableProperty_ShouldReturnProjectContainingTargetWithOverwritableProperty()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/TargetWithProperties.tcsproj");

            IMsBuildTarget target = projectFile.GetChildren <IMsBuildTarget>()
                                    .First(t => t.Name.Equals("WithComplexConditionalOverwritableProperty"));

            IMsBuildProperty overwritableProperty =
                target.GetChildren <IMsBuildPropertyGroup>().First().GetChildren <IMsBuildProperty>()
                .First(p => p.Name.Equals("OverwritableProperty"));

            Assert.AreEqual(true, overwritableProperty.HasPublicSetter);
        }
コード例 #9
0
        Load_FromExistentTestFileWithDocumentedTargetNamedCheckFileNameSyntax_ShouldContainTargetWithXmlHelp()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/Test.tcsproj");

            IMsBuildTarget target = projectFile.GetChildren <IMsBuildTarget>()
                                    .First(t => t.Name.Equals("CheckFileNameSyntax"));

            Assert.AreEqual("Checks the files from @(RelevantFiles) if it ends with '*.json'.",
                            target.Help.GetSectionContent("Synopsis", StringComparison.OrdinalIgnoreCase));
            Assert.AreEqual(
                "Prints an error with information about the item when it does not\nmatches the file extension 'json'. The printed error contains\ninformation about the affected item.",
                target.Help.GetSectionContent("DESCRIPTION", StringComparison.OrdinalIgnoreCase));
        }
コード例 #10
0
        Load_FromExistentTestFileWithOnePropertyGroupContainingThreeProperties_ShouldReturnObjectContainingThreeProperties()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/Test.tcsproj");

            Assert.AreEqual(3, projectFile.GetChildren <IMsBuildProperty>().Count);
        }
コード例 #11
0
        public void Load_FromExistentTestFileWithTwoTargets_ShouldReturnObjectWithTwoContainingTargets()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/Test.tcsproj");

            Assert.AreEqual(2, projectFile.GetChildren <IMsBuildTarget>().Count);
        }
コード例 #12
0
        public void Load_FromExistentTestFile_ShouldNotReturnNullObject()
        {
            IMsBuildProject projectFile = MsBuildProjectFile.Load("TestData/ProjectFiles/Test.tcsproj");

            Assert.IsNotNull(projectFile);
        }