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


C# TestMessageLogger.CheckLoggedAny方法代码示例

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


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

示例1: TestCopy_Retries

		public void TestCopy_Retries ()
		{
			Engine engine;
			Project project;
			string file_path = Path.Combine (source_path, "copyretries.txt");
			string target_file = Path.Combine (target_path, "copyretries.txt");			

			using (File.CreateText (file_path)) { }
			using (File.CreateText (target_file)) { }

			File.SetAttributes (target_file, FileAttributes.ReadOnly);
			Assert.AreEqual (FileAttributes.ReadOnly, File.GetAttributes (target_file), "A1");

			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<PropertyGroup><DestFile>" + target_file + @"</DestFile></PropertyGroup>
					<ItemGroup>
						<SFiles Include='" + file_path + @"'><Md>1</Md></SFiles>
						<DFiles Include='$(DestFile)'><Mde>2</Mde></DFiles>
					</ItemGroup>
					<Target Name='1'>
						<Copy SourceFiles='@(SFiles)' DestinationFiles='@(DFiles)' Retries='3' RetryDelayMilliseconds='2000'>
							<Output TaskParameter='CopiedFiles' ItemName='I0'/>
							<Output TaskParameter='DestinationFiles' ItemName='I1'/>
						</Copy>
						<Message Text=""I0 : @(I0), I1: @(I1)""/>
					</Target>
				</Project>
			";

			engine = new Engine (Consts.BinPath);
			project = engine.CreateNewProject ();

			TestMessageLogger testLogger = new TestMessageLogger ();
			engine.RegisterLogger (testLogger);

			project.LoadXml (documentString);

			// remove the read-only flag from the file after a few secs,
			// so copying works after retries
			new Thread ( () => {
				Thread.Sleep (3000);
				File.SetAttributes (target_file, FileAttributes.Normal);
			}).Start ();

			if (!project.Build ("1")) {
				var sb = new StringBuilder ();
				testLogger.DumpMessages (sb);
				Assert.Fail ("Build failed " + sb.ToString ());
			}

			testLogger.CheckLoggedAny ("Copying failed. Retries left: 3.", MessageImportance.Normal, "A2");
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:53,代码来源:CopyTest.cs

示例2: TestItemsWithWildcards

		public void TestItemsWithWildcards () {
			Engine engine = new Engine (Consts.BinPath);
			Project proj = engine.CreateNewProject ();
			TestMessageLogger logger = new TestMessageLogger ();
			engine.RegisterLogger (logger);

			// Setup

			string basedir = PathCombine ("Test", "resources", "dir");
			string aaa = PathCombine ("a", "aa", "aaa");
			string bb = Path.Combine ("b", "bb");

			string[] dirs = { aaa, bb, "c" };
			string[] files = {
								PathCombine (basedir, aaa, "foo.dll"),
								PathCombine (basedir, bb, "bar.dll"),
								PathCombine (basedir, bb, "sample.txt"),
								Path.Combine (basedir, "xyz.dll")
							  };

			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
					<PropertyGroup>
						<WC>dir\**\*.dll</WC>
						<ExWC>*\x*.dll</ExWC>
					</PropertyGroup>

					<Target Name='Main'>
						<Copy SourceFiles='dir\xyz.dll' DestinationFiles='dir\abc.dll'/>
						<CreateItem Include='dir\**\*.dll' Exclude='*\x*.dll'>
							<Output TaskParameter='Include' ItemName='CI1' />
						</CreateItem>
						<Message Text=""CI1: %(CI1.FullPath)""/>

						<CreateItem Include='$(WC)' Exclude='$(ExWC)'>
							<Output TaskParameter='Include' ItemName='CI2' />
						</CreateItem>
						<Message Text=""CI2: %(CI2.FullPath)""/>
					</Target>
				</Project>";

			try {
				CreateDirectoriesAndFiles (basedir, dirs, files);
				string projectdir = Path.Combine ("Test", "resources");
				File.WriteAllText (Path.Combine (projectdir, "wild1.proj"), documentString);
				proj.Load (Path.Combine (projectdir, "wild1.proj"));
				if (!proj.Build ("Main"))
					Assert.Fail ("Build failed");

				string full_base_dir = Path.GetFullPath (basedir);
				foreach (string prefix in new string[] { "CI1: ", "CI2: " }) {
					logger.CheckLoggedAny (prefix + PathCombine (full_base_dir, aaa, "foo.dll"),
										MessageImportance.Normal, "A1");
					logger.CheckLoggedAny (prefix + PathCombine (full_base_dir, bb, "bar.dll"), MessageImportance.Normal, "A2");
					logger.CheckLoggedAny (prefix + PathCombine (full_base_dir, "abc.dll"),
										MessageImportance.Normal, "A3");

				}
			} catch (AssertionException) {
				logger.DumpMessages ();
				throw;
			} finally {
				Directory.Delete (basedir, true);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:65,代码来源:CreateItemTest.cs

示例3: TestBatchingWithUnqualifiedMetadataReference

		public void TestBatchingWithUnqualifiedMetadataReference () {
			string projectString = projectHeader + @"
	<ItemGroup>
		<Item1 Include=""One""><Md>1</Md></Item1>
		<Item1 Include=""Two""><Md>2</Md></Item1>
		<Item1Ref Include=""@(Item1)"" />

		<Item2 Include=""Three""><Md>3</Md></Item2>
		<Item2 Include=""Four""><Md>4</Md></Item2>
		<Item2Ref Include=""@(Item2)"" />
	</ItemGroup>
	<PropertyGroup>
		<Prop1>@(Item1)</Prop1>
		<Prop1Ref>@(Item1Ref)</Prop1Ref>

		<Prop2>@(Item2)</Prop2>
		<Prop2Ref>@(Item2Ref)</Prop2Ref>
	</PropertyGroup>
	<Target Name='1'>
		<Message Text=""For md: %(Md) Item1: @(Item1) Item1Ref: @(Item1Ref) Item2: @(Item2) Item2Ref: @(Item2Ref) " +
					  @" Prop1: $(Prop1) Prop1Ref: $(Prop1Ref) Prop2: $(Prop2) Prop2Ref: $(Prop2Ref)""/>
	</Target>
</Project>";

			Engine engine = new Engine (Consts.BinPath);
			Project project = engine.CreateNewProject ();

			TestMessageLogger testLogger = new TestMessageLogger ();
			engine.RegisterLogger (testLogger);

			project.LoadXml (projectString);
			if (!project.Build ("1")) {

				testLogger.DumpMessages ();
				Assert.Fail ("Build failed");
			}

			try {
				testLogger.CheckLoggedAny ("For md: 3 Item1:  Item1Ref:  Item2: Three Item2Ref: Three  Prop1:  Prop1Ref:  Prop2: Three Prop2Ref: Three", MessageImportance.Normal, "A1");
				testLogger.CheckLoggedAny ("For md: 4 Item1:  Item1Ref:  Item2: Four Item2Ref: Four  Prop1:  Prop1Ref:  Prop2: Four Prop2Ref: Four", MessageImportance.Normal, "A2");
				testLogger.CheckLoggedAny ("For md: 1 Item1: One Item1Ref: One Item2:  Item2Ref:   Prop1: One Prop1Ref: One Prop2:  Prop2Ref: ", MessageImportance.Normal, "A3");
				testLogger.CheckLoggedAny ("For md: 2 Item1: Two Item1Ref: Two Item2:  Item2Ref:   Prop1: Two Prop1Ref: Two Prop2:  Prop2Ref: ", MessageImportance.Normal, "A4");

				Assert.AreEqual (0, testLogger.NormalMessageCount, "Unexpected extra messages found");
			} catch (AssertionException) {
				testLogger.DumpMessages ();
				throw;
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:49,代码来源:TaskBatchingTest.cs

示例4: TestItemsWithWildcards

		public void TestItemsWithWildcards () {
			Engine engine = new Engine (Consts.BinPath);
			Project proj = engine.CreateNewProject ();
			TestMessageLogger logger = new TestMessageLogger ();
			engine.RegisterLogger (logger);

			// Setup

			string projectdir = Path.Combine ("Test", "resources");
			string basedir = "dir";
			string aaa = PathCombine (basedir, "a", "aa", "aaa");
			string bb = Path.Combine (basedir, "b", "bb");
			string c = Path.Combine (basedir, "c");

			string[] dirs = { aaa, bb, c };
			string[] files = {
								PathCombine (aaa, "foo.dll"),
								PathCombine (bb, "bar.dll"),
								PathCombine (bb, "sample.txt"),
								Path.Combine (basedir, "xyz.dll")
							  };

			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
					<Target Name='Main'>
						<CreateItem Include='dir\**'>
							<Output TaskParameter='Include' ItemName='CI1' />
						</CreateItem>
						<Message Text=""CI1: @(CI1)""/>
					</Target>
				</Project>";

			try {
				CreateDirectoriesAndFiles (projectdir, dirs, files);
				File.WriteAllText (Path.Combine (projectdir, "wild1.proj"), documentString);
				proj.Load (Path.Combine (projectdir, "wild1.proj"));
				if (!proj.Build ("Main"))
					Assert.Fail ("Build failed");

				string full_base_dir = Path.GetFullPath (basedir);
				logger.CheckLoggedAny ("CI1: " + String.Join (";", files), MessageImportance.Normal, "A1");
			} catch (AssertionException) {
				logger.DumpMessages ();
				throw;
			} finally {
				Directory.Delete (Path.Combine (projectdir, basedir), true);
			}
		}
开发者ID:nicolas-raoul,项目名称:mono,代码行数:48,代码来源:CreateItemTest.cs


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