当前位置: 首页>>代码示例>>C#>>正文


C# MockLogger.AssertLogContains方法代码示例

本文整理汇总了C#中Microsoft.Build.UnitTests.MockLogger.AssertLogContains方法的典型用法代码示例。如果您正苦于以下问题:C# MockLogger.AssertLogContains方法的具体用法?C# MockLogger.AssertLogContains怎么用?C# MockLogger.AssertLogContains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Build.UnitTests.MockLogger的用法示例。


在下文中一共展示了MockLogger.AssertLogContains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImportFromExtensionsPathNotFound

        public void ImportFromExtensionsPathNotFound()
        {
            string extnDir1 = null;
            string mainProjectPath = null;

            try {
                extnDir1 = GetNewExtensionsPathAndCreateFile("extensions1", Path.Combine("foo", "extn.proj"), GetExtensionTargetsFileContent1());
                mainProjectPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("main.proj", GetMainTargetFileContent());

                var projColln = new ProjectCollection();
                projColln.ResetToolsetsForTests(WriteConfigFileAndGetReader("MSBuildExtensionsPath", extnDir1, Path.Combine("tmp", "nonexistant")));
                var logger = new MockLogger();
                projColln.RegisterLogger(logger);

                Assert.Throws<InvalidProjectFileException>(() => projColln.LoadProject(mainProjectPath));

                logger.AssertLogContains("MSB4226");
            } finally {
                if (mainProjectPath != null)
                {
                    FileUtilities.DeleteNoThrow(mainProjectPath);
                }
                if (extnDir1 != null)
                {
                    FileUtilities.DeleteDirectoryNoThrow(extnDir1, recursive: true);
                }
            }
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:28,代码来源:ImportFromMSBuildExtensionsPath_Tests.cs

示例2: TargetARM

        public void TargetARM()
        {
            string file = null;
            string outputPath = Path.GetTempPath() + "\\" + Guid.NewGuid().ToString("N");

            try
            {
                file = Helpers.CreateFiles("class1.cs")[0];

                MockLogger logger = new MockLogger();

                Project project = ObjectModelHelpers.CreateInMemoryProject(
                    @"
                   <Project DefaultTargets=`Build` ToolsVersion=`4.0` xmlns=`msbuildnamespace`>
                      <PropertyGroup>
                        <OutputPath>" + outputPath + @"</OutputPath>
                        <AssemblyName>MyAssembly</AssemblyName>
                        <OutputType>Library</OutputType>
                        <Configuration>Debug</Configuration>
                        <PlatformTarget>arm</PlatformTarget>
                      </PropertyGroup>
                      <ItemGroup>
                        <Compile Include=`" + file + @"` />
                      </ItemGroup>
                      <Import Project=`$(MSBuildToolsPath)\Microsoft.CSharp.Targets` />
                    </Project>
                ",
                 logger
                 );

                project.Build();

                logger.AssertLogContains(" /platform:arm ");
            }
            finally
            {
                if (file != null)
                {
                    File.Delete(file);
                }

                ObjectModelHelpers.DeleteDirectory(outputPath);
            }
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:44,代码来源:TargetsFile_Test.cs

示例3: MetadataConditionOnItemDefinition

        public void MetadataConditionOnItemDefinition()
        {
            MockLogger logger = new MockLogger();
            Project p = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                  <ItemGroup>
                    <i Include='i1'/>
                    <j Include='j1'/>
                  </ItemGroup>
                  <ItemDefinitionGroup>
                    <i>
                      <m>m1</m>
                    </i>
                    <j>
                      <n>n1</n>
                    </j>
                  </ItemDefinitionGroup> 
                  <ItemDefinitionGroup>
                    <i Condition=`'%(m)'=='m1'`>
                      <m>m2</m>
                    </i>
                    <!-- verify j metadata is distinct -->
                    <j Condition=`'%(j.n)'=='n1' and '%(n)'=='n1'`>
                      <n>n2</n>   
                    </j>
                  </ItemDefinitionGroup> 
                  <Target Name=`t`>
                    <Message Text=`[%(i.m)]`/>
                    <Message Text=`[%(j.n)]`/>
                  </Target>
                </Project>
            ", logger);
            p.Build("t");

            logger.AssertLogContains("[m2]", "[n2]");
        }
开发者ID:nikson,项目名称:msbuild,代码行数:36,代码来源:BuildItemDefinitionGroupXml_Tests.cs

示例4: TargetNamesAlwaysUnescaped_Override

        public void TargetNamesAlwaysUnescaped_Override()
        {
            Project project = ObjectModelHelpers.CreateInMemoryProject(@"
            <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
                <Target Name=`%3B`>
                    <Message Text=`[WRONG]` />
                </Target>
                <Target Name=`;`>
                    <Message Text=`[OVERRIDE]` />
                </Target>
            </Project>
            ");
            MockLogger logger = new MockLogger();

            bool success = project.Build(logger);
            Assert.True(success); // "Build failed.  See Standard Out tab for details"
            logger.AssertLogContains("[OVERRIDE]");
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:18,代码来源:EscapingInProjects_Tests.cs

示例5: GlobalPropertyWithEscapedCharacters

        public void GlobalPropertyWithEscapedCharacters()
        {
            MockLogger logger = new MockLogger();
            Project project = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
                    <Target Name=`Build`>
                        <Message Text=`MyGlobalProperty = '$(MyGlobalProperty)'` />
                    </Target>
                </Project>
                ");

            project.SetGlobalProperty("MyGlobalProperty", "foo%253bbar");

            bool success = project.Build(logger);
            Assert.True(success); // "Build failed.  See Standard Out tab for details"

            logger.AssertLogContains("MyGlobalProperty = 'foo%3bbar'");
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:18,代码来源:EscapingInProjects_Tests.cs

示例6: NoLinkMetadataSynthesisWhenDefinedInProject

        public void NoLinkMetadataSynthesisWhenDefinedInProject()
        {
            string[] files = null;
            string outputPath = Path.GetTempPath() + "\\" + Guid.NewGuid().ToString("N");

            try
            {
                files = Helpers.CreateFiles("class1.cs", "File1.txt", "Content1.foo");

                MockLogger logger = new MockLogger();

                Project project = ObjectModelHelpers.CreateInMemoryProject(
                    @"
                   <Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                      <PropertyGroup>
                        <OutputPath>" + outputPath + @"</OutputPath>
                        <AssemblyName>MyAssembly</AssemblyName>
                        <OutputType>Library</OutputType>
                        <Configuration>Debug</Configuration>
                        <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
                        <SynthesizeLinkMetadata>true</SynthesizeLinkMetadata>
                      </PropertyGroup>
                      <ItemGroup>
                        <Compile Include=`" + files[0] + @"` />
                        <None Include=`" + files[1] + @"` />
                        <Content Include=`" + files[2] + @"` />
                      </ItemGroup>
                      <Import Project=`$(MSBuildToolsPath)\Microsoft.CSharp.Targets` />
                      <Target Name=`AfterBuild`>
                        <Message Text=`%(Compile.Identity): [%(Compile.Link)]` />
                        <Message Text=`%(None.Identity): [%(None.Link)]` />
                        <Message Text=`%(Content.Identity): [%(Content.Link)]` />
                      </Target>
                    </Project>
                ",
                 logger
                 );

                project.Build();

                logger.AssertLogContains(String.Format("{0}: []", files[0]));
                logger.AssertLogContains(String.Format("{0}: []", files[1]));
                logger.AssertLogContains(String.Format("{0}: []", files[2]));
            }
            finally
            {
                if (files != null)
                {
                    foreach (string file in files)
                    {
                        File.Delete(file);
                    }
                }

                ObjectModelHelpers.DeleteDirectory(outputPath);
            }
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:57,代码来源:TargetsFile_Test.cs

示例7: TestGetFrameworkPaths

        public void TestGetFrameworkPaths()
        {
            MockLogger logger = new MockLogger();

            Project project = ObjectModelHelpers.CreateInMemoryProject(
                @"
<Project ToolsVersion=`msbuilddefaulttoolsversion` DefaultTargets=`GetPaths` xmlns=`msbuildnamespace`>
  <Target Name=`GetPaths` DependsOnTargets=`GetFrameworkPaths`>
    <Message Text=`Framework 4.0 = @(_TargetFramework40DirectoryItem)` Importance=`High`/>
    <Message Text=`Framework 3.5 = @(_TargetFramework35DirectoryItem)` Importance=`High`/>
    <Message Text=`Framework 3.0 = @(_TargetFramework30DirectoryItem)` Importance=`High`/>
    <Message Text=`Framework 2.0 = @(_TargetFramework20DirectoryItem)` Importance=`High`/>
  </Target>
  <Import Project=`$(MSBuildToolsPath)\Microsoft.CSharp.targets` />
</Project>",
             logger
             );

            project.Build();

            logger.AssertLogContains(false/* not case sensitive */, "Framework 4.0 = " + FrameworkLocationHelper.PathToDotNetFrameworkV40);

            // Only check .NET 3.5 and below if they're actually on the box.
            if (FrameworkLocationHelper.PathToDotNetFrameworkV35 != null)
            {
                logger.AssertLogContains(false/* not case sensitive */, "Framework 3.5 = " + FrameworkLocationHelper.PathToDotNetFrameworkV35);
                logger.AssertLogContains(false/* not case sensitive */, "Framework 3.0 = " + FrameworkLocationHelper.PathToDotNetFrameworkV30);
                logger.AssertLogContains(false/* not case sensitive */, "Framework 2.0 = " + FrameworkLocationHelper.PathToDotNetFrameworkV20);
            }
        }
开发者ID:ravpacheco,项目名称:msbuild,代码行数:30,代码来源:TargetsFile_Test.cs

示例8: ProjectToolsVersionOverwriteIsTrue

        public void ProjectToolsVersionOverwriteIsTrue()
        {
            try
            {
                string projectContent =
                    @"
                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                    <Target Name=`a`>
                        <Message Text=`[a=$(MSBuildToolsVersion)]`/>
                        <MSBuild Projects=`p2.proj`/>
                        <MSBuild Projects=`p2.proj` ToolsVersion='3.5'/>
                        <MSBuild Projects=`p2.proj` ToolsVersion='2.0'/>
                    </Target>
                    </Project>
                    ";
                string projectContent2 =
                    @"
                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                    <Target Name=`a`>
                        <Message Text=`[b=$(MSBuildToolsVersion)]`/>
                    </Target>
                    </Project>
                    ";

                MockLogger logger = new MockLogger();
                Engine e = new Engine();
                e.RegisterLogger(logger);

                string p1Path = ObjectModelHelpers.CreateFileInTempProjectDirectory("p1.proj", projectContent);
                string p2Path = ObjectModelHelpers.CreateFileInTempProjectDirectory("p2.proj", projectContent2);

                Project p1 = new Project(e, "2.0");
                p1.Load(p1Path);
                p1.Build();

                logger.AssertLogContains("[a=2.0]");
                logger.AssertLogContains("[b=2.0]");

                Assertion.Assert("Cachescope should have an entry with 2.0", e.CacheManager.GetCacheScope(p1Path, new BuildPropertyGroup(), "2.0", CacheContentType.BuildResults) != null);
                Assertion.Assert("Cachescope should have an entry with 2.0", e.CacheManager.GetCacheScope(p2Path, new BuildPropertyGroup(), "2.0", CacheContentType.BuildResults) != null);
            }
            finally
            {
                ObjectModelHelpers.DeleteTempProjectDirectory();
            }
        }
开发者ID:nikson,项目名称:msbuild,代码行数:46,代码来源:Engine_Tests.cs

示例9: DefinitionInImportedFile

        public void DefinitionInImportedFile()
        {
            MockLogger logger = new MockLogger();
            string importedFile = null;

            try
            {
                importedFile = Path.GetTempFileName();
                File.WriteAllText(importedFile, @"
                <Project ToolsVersion='3.5' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
                  <ItemDefinitionGroup>
                    <CppCompile>
                      <Defines>DEBUG</Defines>
                    </CppCompile>
                  </ItemDefinitionGroup> 
                </Project>
            ");
                Project p = ObjectModelHelpers.CreateInMemoryProject(@"
                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                      <ItemGroup>
                        <CppCompile Include='a.cpp'/>                      
                      </ItemGroup>
                      <Import Project='" + importedFile + @"'/>
                      <Target Name=`t`>
                        <Message Text=`[%(CppCompile.Identity)==%(CppCompile.Defines)]`/>
                      </Target>
                    </Project>
                ", logger);
                p.Build("t");

                logger.AssertLogContains("[a.cpp==DEBUG]");
            }
            finally
            {
                ObjectModelHelpers.DeleteTempFiles(new string[] { importedFile });
            }
        }
开发者ID:nikson,项目名称:msbuild,代码行数:37,代码来源:BuildItemDefinitionGroupXml_Tests.cs

示例10: IntrinsicTaskConsumingDefaultMetadata

        public void IntrinsicTaskConsumingDefaultMetadata()
        {
            MockLogger logger = new MockLogger();
            Project p = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                  <ItemGroup>
                    <i Include='i1'/>
                  </ItemGroup>
                  <ItemDefinitionGroup>
                    <i>
                      <m>m1</m>
                    </i>
                  </ItemDefinitionGroup> 
                  <Target Name=`t`>
                    <ItemGroup>
                      <i Condition=`'%(i.m)'=='m1'`>
                        <n Condition=`'%(m)'=='m1'`>n2</n>
                      </i>
                    </ItemGroup>
                    <Message Text=`[%(i.n)]`/>
                  </Target>
                </Project>
            ", logger);
            p.Build("t");

            logger.AssertLogContains("[n2]");
        }
开发者ID:nikson,项目名称:msbuild,代码行数:27,代码来源:BuildItemDefinitionGroupXml_Tests.cs

示例11: IntrinsicTaskModifyingDefaultMetadata

        public void IntrinsicTaskModifyingDefaultMetadata()
        {
            MockLogger logger = new MockLogger();
            Project p = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                  <ItemGroup>
                    <i Include='i1'/>
                  </ItemGroup>
                  <ItemDefinitionGroup>
                    <i>
                      <m>m1</m>
                    </i>
                  </ItemDefinitionGroup> 
                  <Target Name=`t`>
                    <ItemGroup>
                      <i>
                        <m>m2</m>
                      </i>
                    </ItemGroup>
                    <Message Text=`[%(i.m)]`/>
                  </Target>
                </Project>
            ", logger);
            p.Build("t");

            logger.AssertLogContains("[m2]");

            BuildItemGroup group = p.GetEvaluatedItemsByName("i");
            BuildItem item = group[0];
            string metadataValue = item.GetMetadata("m");
            Assertion.AssertEquals("m2", metadataValue);

            p.ResetBuildStatus();

            // Should go back to definition
            group = p.GetEvaluatedItemsByName("i");
            item = group[0];
            metadataValue = item.GetMetadata("m");
            Assertion.AssertEquals("m1", metadataValue);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:40,代码来源:BuildItemDefinitionGroupXml_Tests.cs

示例12: MixtureOfItemAndDefaultMetadata

        public void MixtureOfItemAndDefaultMetadata()
        {
            MockLogger logger = new MockLogger();
            Project p = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                  <ItemGroup>
                    <CppCompile Include='a.cpp'>
                      <WarningLevel>4</WarningLevel>
                    </CppCompile>
                  </ItemGroup>
                  <ItemDefinitionGroup>
                    <CppCompile>
                      <Defines>DEBUG</Defines>
                    </CppCompile>
                  </ItemDefinitionGroup> 
                  <Target Name=`t`>
                    <Message Text=`[%(CppCompile.Identity)==%(CppCompile.Defines)]`/>
                    <Message Text=`[%(CppCompile.Identity)==%(CppCompile.WarningLevel)]`/>
                  </Target>
                </Project>
            ", logger);
            p.Build("t");

            logger.AssertLogContains("[a.cpp==DEBUG]", "[a.cpp==4]");
        }
开发者ID:nikson,项目名称:msbuild,代码行数:25,代码来源:BuildItemDefinitionGroupXml_Tests.cs

示例13: ItemDefinitionInTargetErrors

        public void ItemDefinitionInTargetErrors()
        {
            MockLogger logger = new MockLogger();
            Project p = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                  <Target Name=`t`>
                    <ItemDefinitionGroup/>
                  </Target>
                </Project>
            ", logger);
            bool result = p.Build("t");

            Assertion.AssertEquals(false, result);
            logger.AssertLogContains("MSB4163");
        }
开发者ID:nikson,项目名称:msbuild,代码行数:15,代码来源:BuildItemDefinitionGroupXml_Tests.cs

示例14: MetadataConditionOnItemDefinitionAndChildQualifiedWithUnrelatedItemType

        public void MetadataConditionOnItemDefinitionAndChildQualifiedWithUnrelatedItemType()
        {
            MockLogger logger = new MockLogger();
            Project p = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                  <ItemGroup>
                    <i Include='i1'/>
                  </ItemGroup>
                  <ItemDefinitionGroup>
                    <i>
                      <m>m1</m>
                    </i>
                  </ItemDefinitionGroup> 
                  <ItemDefinitionGroup>
                    <i Condition=`'%(j.m)'=='' and '%(j.m)'!='x'`>
                      <m Condition=`'%(j.m)'=='' and '%(j.m)'!='x'`>m2</m>
                    </i>
                  </ItemDefinitionGroup> 
                  <Target Name=`t`>
                    <Message Text=`[%(i.m)]`/>
                  </Target>
                </Project>
            ", logger);
            p.Build("t");

            logger.AssertLogContains("[m2]");
        }
开发者ID:nikson,项目名称:msbuild,代码行数:27,代码来源:BuildItemDefinitionGroupXml_Tests.cs

示例15: FalseMetadataConditionOnItemDefinitionChildBothQualifiedAndUnqualified

        public void FalseMetadataConditionOnItemDefinitionChildBothQualifiedAndUnqualified()
        {
            MockLogger logger = new MockLogger();
            Project p = ObjectModelHelpers.CreateInMemoryProject(@"
                <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                  <ItemGroup>
                    <i Include='i1'/>
                  </ItemGroup>
                  <ItemDefinitionGroup>
                    <i>
                      <m>m1</m>
                      <n>n1</n>
                    </i>
                  </ItemDefinitionGroup> 
                  <ItemDefinitionGroup>
                    <i>
                      <m Condition=`'%(m)'=='m2' or !('%(n)'=='n1') or '%(i.m)' != 'm1'`>m3</m>
                    </i>
                  </ItemDefinitionGroup> 
                  <Target Name=`t`>
                    <Message Text=`[%(i.m)]`/>
                  </Target>
                </Project>
            ", logger);
            p.Build("t");

            logger.AssertLogContains("[m1]");
        }
开发者ID:nikson,项目名称:msbuild,代码行数:28,代码来源:BuildItemDefinitionGroupXml_Tests.cs


注:本文中的Microsoft.Build.UnitTests.MockLogger.AssertLogContains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。