• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Tasks.TestMessageLogger类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



TestMessageLogger类属于MonoTests.Microsoft.Build.Tasks命名空间,在下文中一共展示了TestMessageLogger类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Test1

		public void Test1 ()
		{
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<ItemGroup>
					<ResXFile Include=""Item1"">
						<Culture>fr</Culture>
					</ResXFile>
					<ResXFile Include=""Item2"">
						<Culture>fr</Culture>
					</ResXFile>
					<ResXFile Include=""Item3"">
						<Culture>en</Culture>
					</ResXFile>
					<ResXFile Include=""Item4"">
						<Culture>gb</Culture>
					</ResXFile>
					<ResXFile Include=""Item5"">
						<Culture>fr</Culture>
					</ResXFile>
					<ResXFile Include=""Item6"">
						<Culture>it</Culture>
					</ResXFile>
				</ItemGroup>

				<Target Name=""ShowMessage"">
					<Message
						Text = ""Culture: %(ResXFile.Culture) -- ResXFile: @(ResXFile)"" />
				</Target>
			  </Project>";

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

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

			project.LoadXml (projectString);
			Assert.IsTrue (project.Build ("ShowMessage"), "A1: Build failed");

			CheckMessage (testLogger, "fr", "Item1;Item2;Item5", "A2");
			CheckMessage (testLogger, "en", "Item3", "A3");
			CheckMessage (testLogger, "gb", "Item4", "A4");
			CheckMessage (testLogger, "it", "Item6", "A5");

			CheckEngineEventCounts (testLogger, 1, 1, 4, 4);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:46,代码来源:TaskBatchingTest.cs


示例2: TestUnqualifiedMetadataReference

		public void TestUnqualifiedMetadataReference ()
		{
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<ItemGroup>
					<ResXFile Include=""Item1"">
						<Culture>fr</Culture>
					</ResXFile>
					<ResXFile Include=""Item5"" />
					<ResXFile Include=""Item6"">
						<Culture>it</Culture>
					</ResXFile>
				</ItemGroup>

				<Target Name=""ShowMessage"">
					<Message
						Text = ""Culture: %(Culture) -- ResXFile: @(ResXFile)"" />
				</Target>
			  </Project>";

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

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

			project.LoadXml (projectString);

			//Fails as Culture is being referenced unqualified, and no Culture is
			//specified for "Item5"
			bool result = project.Build ("ShowMessage");
			if (result)
				Assert.Fail ("A1: Build should have failed");

			CheckEngineEventCounts (testLogger, 1, 1, 0, 0);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:35,代码来源:TaskBatchingTest.cs


示例3: TestEmptyPropertyValue

		public void TestEmptyPropertyValue ()
		{
			Engine engine;
			Project project;

			string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<PropertyGroup>
						<A>1</A>
					</PropertyGroup>
					<Target Name='1'>
						<Message Text='Before: $(A)'/>
						<CreateProperty Value=''>
							<Output
								TaskParameter='Value'
								PropertyName='A'
							/>
						</CreateProperty>
						<Message Text='After: $(A)'/>
					</Target>
				</Project>
			";

			engine = new Engine (Consts.BinPath);

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

			project = engine.CreateNewProject ();
			project.LoadXml (documentString);
			if (!project.Build ("1")) {
				testLogger.DumpMessages ();
				Assert.Fail ("Build failed");
			}

			testLogger.CheckLoggedMessageHead ("Before: 1", "A1");
			testLogger.CheckLoggedMessageHead ("After: ", "A2");
			Assert.AreEqual (0, testLogger.NormalMessageCount, "Unexpected messages found");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:39,代码来源:CreatePropertyTest.cs


示例4: TestTargetReturns

		public void TestTargetReturns ()
		{
			engine = new Engine (Consts.BinPath);
			project = engine.CreateNewProject ();
			project.Load (Path.Combine ("Test", Path.Combine ("resources", "TestReturns.csproj")));

			var logger = new TestMessageLogger ();
			engine.RegisterLogger (logger);

			bool result = project.Build ("Main");
			if (!result) {
				logger.DumpMessages ();
				Assert.Fail ("Build failed");
			}

			logger.CheckLoggedMessageHead ("Result: Bar", "A1");

			Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found");
		}
开发者ID:ancailliau,项目名称:mono,代码行数:19,代码来源:TargetTest.cs


示例5: TestOverridingTargets

		public void TestOverridingTargets ()
		{
			Engine engine;
			Project project;

			string second = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<Target Name='BeforeBuild'/>
				<Target Name='AfterBuild'/>
				<Target Name='Build' DependsOnTargets='BeforeBuild'>
					<Message Text='Build executing'/>
					<CallTarget Targets='AfterBuild'/>
				</Target>
		</Project>";
			using (StreamWriter sw = new StreamWriter (Path.Combine ("Test", Path.Combine ("resources", "second.proj")))) {
				sw.Write (second);
			}

			string documentString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<Target Name='AfterBuild'>
					<Message Text='Overriding AfterBuild'/>
				</Target>

				<Import Project='Test/resources/second.proj'/>
				<Target Name='BeforeBuild'>
					<Message Text='Overriding BeforeBuild'/>
				</Target>
		</Project>";

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

			MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
				new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
			engine.RegisterLogger (logger);

			bool result = project.Build ("Build");
			if (!result) {
				logger.DumpMessages ();
				Assert.Fail ("Build failed");
			}

			logger.CheckLoggedMessageHead ("Overriding BeforeBuild", "A1");
			logger.CheckLoggedMessageHead ("Build executing", "A1");

			Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found");
		}
开发者ID:ancailliau,项目名称:mono,代码行数:47,代码来源:TargetTest.cs


示例6: CreateLogger

		TestMessageLogger CreateLogger (string projectXml)
		{
			var logger = new TestMessageLogger ();
			var result = Build (projectXml, logger);

			if (!result) {
				logger.DumpMessages ();
				Assert.Fail ("Build failed");
			}

			return logger;
		}
开发者ID:ancailliau,项目名称:mono,代码行数:12,代码来源:TargetTest.cs


示例7: 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


示例8: TestCopy_OverwriteReadOnlyTrue

		public void TestCopy_OverwriteReadOnlyTrue ()
		{
			Engine engine;
			Project project;
			string file_path = Path.Combine (source_path, "copyro1.txt");
			string target_file = Path.Combine (target_path, "copyro1.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"" ToolsVersion=""4.0"">
					<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)' OverwriteReadOnlyFiles='true'>
							<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);

			if (!project.Build ("1")) {
				var sb = new StringBuilder ();
				testLogger.DumpMessages (sb);
				Assert.Fail ("Build failed " + sb.ToString ());
			}
			Assert.IsTrue (File.Exists (target_file), "A2");
			var target_file_attrs = File.GetAttributes (target_file);
			if (Environment.OSVersion.Platform == PlatformID.Unix)
				Assert.AreEqual (FileAttributes.Normal, File.GetAttributes (target_file), "A3");
			else
				// On Windows the Archive attribute will be set, not the Normal attribute.
				Assert.AreEqual (FileAttributes.Archive, File.GetAttributes (target_file), "A3");
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:51,代码来源:CopyTest.cs


示例9: TestFilter

		public void TestFilter ()
		{
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				 <ItemGroup>
					 <fruit Include=""apple"">
						 <consistency>firm</consistency>
					 </fruit>
					 <fruit Include=""orange"">
						 <consistency>pulpy</consistency>
					 </fruit>
					 <fruit Include=""banana"">
						 <consistency>softish</consistency>
					 </fruit>
					 <fruit Include=""pear"">
						 <consistency>unsound</consistency>
					 </fruit>
					 <fruit Include=""apricot"">
						 <consistency>unsound</consistency>
					 </fruit>
				 </ItemGroup>
				 <Target Name=""Compost"">
					 <CreateItem Include=""@(fruit)"" Condition=""'%(consistency)' == 'pulpy' or '%(consistency)' == 'unsound' "">
						<Output TaskParameter=""Include"" ItemName=""Final""/>
					 </CreateItem>
				 </Target>
			 </Project>";

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

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

			project.LoadXml (projectString);
			Assert.IsTrue (project.Build ("Compost"), "A1: Build failed");

			BuildItemGroup include = project.GetEvaluatedItemsByName ("Final");
			Assert.AreEqual (3, include.Count, "A2");

			string [,] additional_metadata = new string [,] { { "Identity", "orange" } };
			CreateItemTest.CheckBuildItem (include [0], "Final", additional_metadata, "orange", "A3");

			additional_metadata = new string [,] { { "Identity", "pear" } };
			CreateItemTest.CheckBuildItem (include [1], "Final", additional_metadata, "pear", "A4");

			additional_metadata = new string [,] { { "Identity", "apricot" } };
			CreateItemTest.CheckBuildItem (include [2], "Final", additional_metadata, "apricot", "A5");
			CheckEngineEventCounts (testLogger, 1, 1, 2, 2);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:49,代码来源:TaskBatchingTest.cs


示例10: TestMultipleMetadataReference2

		public void TestMultipleMetadataReference2 ()
		{
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<ItemGroup>
					<GroupA Include=""file1.txt""/>
					<GroupA Include=""file2.txt""/>
					<GroupA Include=""file3.txt""/>
					<GroupA Include=""file3.txt""/>
					<GroupA Include=""file4.txt""/>
				</ItemGroup>

				<ItemGroup>
					<GroupB Include=""file1.txt""/>
					<GroupB Include=""file3.txt""/>
					<GroupB Include=""file5.txt""/>

					<GroupC Include=""PreExistingValue""/>
				</ItemGroup>

				<Target Name=""Build"">
					<CreateItem Include=""@(GroupA)"" Condition=""'%(Identity)' != '' and '@(GroupA)' != '' and '@(GroupB)' != ''"" >
						<Output TaskParameter=""Include"" ItemName=""GroupC""/>
					</CreateItem>
					<Message Text=""%(GroupC.Identity)""/>
				</Target>
			</Project>";

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

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

			project.LoadXml (projectString);
			Assert.IsTrue (project.Build ("Build"), "A1: Build failed");

			BuildItemGroup include = project.GetEvaluatedItemsByName ("GroupC");
			Assert.AreEqual (4, include.Count, "A2");

			string [,] additional_metadata = new string [,] { { "Identity", "PreExistingValue" } };
			CreateItemTest.CheckBuildItem (include [0], "GroupC", additional_metadata, "PreExistingValue", "A3");

			additional_metadata = new string [,] { { "Identity", "file1.txt" } };
			CreateItemTest.CheckBuildItem (include [1], "GroupC", additional_metadata, "file1.txt", "A4");

			additional_metadata = new string [,] { { "Identity", "file3.txt" } };
			CreateItemTest.CheckBuildItem (include [2], "GroupC", additional_metadata, "file3.txt", "A5");
			CreateItemTest.CheckBuildItem (include [3], "GroupC", additional_metadata, "file3.txt", "A6");

			CheckEngineEventCounts (testLogger, 1, 1, 5, 5);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:51,代码来源:TaskBatchingTest.cs


示例11: TestIdentity

		public void TestIdentity ()
		{
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<ItemGroup>
					<ExampColl Include=""Item1""/>
					<ExampColl Include=""Item2""/>
					<ExampColl Include=""Item3""/>
					<ExampColl Include=""Item4""/>
					<ExampColl Include=""Item4""/>
					<ExampColl Include=""Item5""/>
					<ExampColl Include=""Item6""/>
				</ItemGroup>
				<Target Name=""ShowMessage"">
					<Message Text = ""Identity: %(IdenTIty) -- Items in ExampColl: @(ExampColl)""/>
				</Target>
			</Project>";

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

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

			project.LoadXml (projectString);
			Assert.IsTrue (project.Build ("ShowMessage"), "A1: Build failed");

			CheckLoggedMessageAny (testLogger, "Identity: Item1 -- Items in ExampColl: Item1", "A2");
			CheckLoggedMessageAny (testLogger, "Identity: Item2 -- Items in ExampColl: Item2", "A3");
			CheckLoggedMessageAny (testLogger, "Identity: Item3 -- Items in ExampColl: Item3", "A4");
			CheckLoggedMessageAny (testLogger, "Identity: Item4 -- Items in ExampColl: Item4;Item4", "A5");
			CheckLoggedMessageAny (testLogger, "Identity: Item5 -- Items in ExampColl: Item5", "A6");
			CheckLoggedMessageAny (testLogger, "Identity: Item6 -- Items in ExampColl: Item6", "A7");
			Assert.AreEqual (0, testLogger.NormalMessageCount, "A8");
			Assert.AreEqual (0, testLogger.WarningMessageCount, "A7");
			CheckEngineEventCounts (testLogger, 1, 1, 6, 6);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:36,代码来源:TaskBatchingTest.cs


示例12: TestMultipleMetadataReference

		public void TestMultipleMetadataReference ()
		{
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<ItemGroup>
					<ExampColl Include=""Item1"">
						<Number>1</Number>
					</ExampColl>
					<ExampColl Include=""Item2"">
						<Number>2</Number>
					</ExampColl>
					<ExampColl Include=""Item3"">
					<Number>1</Number>
					</ExampColl>

					<ExampColl2 Include=""Item4"">
						<Number>1</Number>
					</ExampColl2>
					<ExampColl2 Include=""Item5"">
						<Number>2</Number>
					<Color>Red</Color>
					</ExampColl2>
					<ExampColl2 Include=""Item6"">
						<Number>3</Number>
					<Color>Green</Color>
					</ExampColl2>
				</ItemGroup>
				<Target Name=""ShowMessage"">
					<Message Text = ""Number: %(Number) Color: %(ExampColl2.Color)-- Items in ExampColl: @(ExampColl) ExampColl2: @(ExampColl2)""/>
				</Target>
			</Project>";

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

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

			project.LoadXml (projectString);
			Assert.IsTrue (project.Build ("ShowMessage"), "A1: Build failed");

			CheckLoggedMessageAny (testLogger, "Number: 1 Color: -- Items in ExampColl: Item1;Item3 ExampColl2: Item4", "A2");
			CheckLoggedMessageAny (testLogger, "Number: 2 Color: Red-- Items in ExampColl:  ExampColl2: Item5", "A3");
			CheckLoggedMessageAny (testLogger, "Number: 3 Color: Green-- Items in ExampColl:  ExampColl2: Item6", "A4");
			CheckLoggedMessageAny (testLogger, "Number: 2 Color: -- Items in ExampColl: Item2 ExampColl2: ", "A5");
			Assert.AreEqual (0, testLogger.NormalMessageCount, "A6");
			Assert.AreEqual (0, testLogger.WarningMessageCount, "A7");
			CheckEngineEventCounts (testLogger, 1, 1, 4, 4);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:48,代码来源:TaskBatchingTest.cs


示例13: TestConditionalBatching

		public void TestConditionalBatching ()
		{
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<ItemGroup>
					<ResXFile Include=""Item1"">
						<Culture>fr</Culture>
					</ResXFile>
					<ResXFile Include=""Item2"">
						<Culture>fr</Culture>
					</ResXFile>
					<ResXFile Include=""Item3"">
						<Culture>en</Culture>
					</ResXFile>
					<ResXFile Include=""Item4"">
						<Culture>gb</Culture>
					</ResXFile>
					<ResXFile Include=""Item6"">
						<Culture>it</Culture>
					</ResXFile>

					<NonResXFile Include=""Item7"">
						<Culture>it</Culture>
					</NonResXFile>
					<NonResXFile Include=""Item8"">
						<Culture>en</Culture>
					</NonResXFile>
					<NonResXFile Include=""Item9"">
						<Culture>en</Culture>
					</NonResXFile>
				</ItemGroup>

				<Target Name=""ShowMessage"">
					<Message
						Text = ""ResXFiles: @(ResXFile) NonResXFiles: @(NonResXFile)""
						Condition = ""'%(Culture)' == 'fr'""/>
				</Target>
			  </Project>";

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

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

			project.LoadXml (projectString);
			Assert.IsTrue (project.Build ("ShowMessage"), "A1: Build failed");

			testLogger.CheckLoggedMessageHead ("ResXFiles: Item1;Item2 NonResXFiles: ", "A2");
			CheckEngineEventCounts (testLogger, 1, 1, 1, 1);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:50,代码来源:TaskBatchingTest.cs


示例14: Test4

		public void Test4 ()
		{
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<ItemGroup>
					<ResXFile Include=""Item1"">
						<Culture>fr</Culture>
					</ResXFile>
					<ResXFile Include=""Item5"" />
					<ResXFile Include=""Item6"">
						<Culture>it</Culture>
					</ResXFile>
				</ItemGroup>

				<Target Name=""ShowMessage"">
					<Message
						Text = ""Culture: %(ResXFile.Culture) -- ResXFile: @(ResXFile)"" />
				</Target>
			  </Project>";

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

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

			project.LoadXml (projectString);

			//no Culture is specified for "Item5", but
			//Culture is being referenced __qualified__, so works
			Assert.IsTrue (project.Build ("ShowMessage"), "A1: Build failed");

			CheckMessage (testLogger, "fr", "Item1", "A2");
			CheckMessage (testLogger, "", "Item5", "A3");
			CheckMessage (testLogger, "it", "Item6", "A3");
			CheckEngineEventCounts (testLogger, 1, 1, 3, 3);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:36,代码来源:TaskBatchingTest.cs


示例15: TestCopy2

		public void TestCopy2 ()
		{
			Engine engine;
			Project project;
			string [] file_paths = new string [] {
				Path.Combine (source_path, "copy1.txt"),
				Path.Combine (source_path, "copy2.txt")
			};

			using (File.CreateText (file_paths[0])) { }
			using (File.CreateText (file_paths[1])) { }

			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<PropertyGroup><TargetPath>" + target_path + @"</TargetPath></PropertyGroup>
					<ItemGroup>
						<SFiles Include='" + file_paths [0] + @"'><Md>1</Md></SFiles>
						<SFiles Include='" + file_paths [1] + @"'><Md>2</Md></SFiles>
					</ItemGroup>
					<Target Name='1'>
						<Copy SourceFiles='@(SFiles)' DestinationFolder='$(TargetPath)' SkipUnchangedFiles='true' >
							<Output TaskParameter='CopiedFiles' ItemName='I0'/>
							<Output TaskParameter='DestinationFiles' ItemName='I1'/>
						</Copy>
					</Target>
				</Project>
			";
			engine = new Engine (Consts.BinPath);
			project = engine.CreateNewProject ();

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

			project.LoadXml (documentString);

			if (!project.Build ("1")) {
				testLogger.DumpMessages ();
				Assert.Fail ("Build failed");
			}

			CheckCopyBuildItems (project, file_paths, target_path, "A1");

			// build again, this time files won't get copied because
			// of SkipUnchangedFiles=true
			if (!project.Build ("1")) {
				testLogger.DumpMessages ();
				Assert.Fail ("Build failed #2");
			}
			CheckCopyBuildItems (project, file_paths, target_path, "A2");
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:50,代码来源:CopyTest.cs


示例16: TestNoBatching

		// test for metadata refs in properties or items
		public void TestNoBatching () {
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
	<ItemGroup>
		<item3 Include=""foo""/>
		<item2 Include=""%(item3.Identity)""/>
		<item0 Include=""@(item3)""/>
	</ItemGroup>
	<PropertyGroup>
		<Prop1>%(item0.Identity)</Prop1>
	</PropertyGroup>
	<Target Name='1'>
		<Message Text=""Prop1: $(Prop1)""/>
		<Message Text=""Item2: @(item2)""/>
	</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");
			}

			testLogger.CheckLoggedMessageHead ("Prop1: %(item0.Identity)", "A1");
			testLogger.CheckLoggedMessageHead ("Item2: %(item3.Identity)", "A2");
			Assert.AreEqual (0, testLogger.NormalMessageCount, "Unexpected extra messages found");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:33,代码来源:TaskBatchingTest.cs


示例17: TestCopy_EmptyDestFolder

		public void TestCopy_EmptyDestFolder () {
			Engine engine;
			Project project;

			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<ItemGroup>
						<SFiles Include='foo.txt'><Md>1</Md></SFiles>
					</ItemGroup>
					<Target Name='1'>
						<Copy SourceFiles='@(SFiles)' DestinationFolder='@(NonExistant)' DestinationFiles='@(NonExistant)' SkipUnchangedFiles='true' >
							<Output TaskParameter='CopiedFiles' ItemName='I0'/>
							<Output TaskParameter='DestinationFiles' ItemName='I1'/>
						</Copy>
					</Target>
				</Project>
			";
			engine = new Engine (Consts.BinPath);
			project = engine.CreateNewProject ();

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

			project.LoadXml (documentString);
			if (project.Build ("1")) {
				testLogger.DumpMessages ();
				Assert.Fail ("Build should have failed");
			}
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:29,代码来源:CopyTest.cs


示例18: TestConditionalBatching2

		// test for metadata refs via metadata refs
		// batching should happen only on basis of the task attributes,
		// and not the resolved expression values
		public void TestConditionalBatching2 () {
			string projectString = projectHeader + @"
	<ItemGroup>
		<item2 Include=""%(item3.Identity)""/>
		<item4 Include=""%(item2.Identity);@(item3)""/>
	</ItemGroup>
	<Target Name='1'>
		<Message Text=""Item3: %(item2.Identity)"" Condition="" '%(item5.Identity)' == '' ""/>
		<Message Text=""Item4: %(item4.Identity)""/>
	</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");
			}

			testLogger.CheckLoggedMessageHead ("Item3: %(item3.Identity)", "A1");
			testLogger.CheckLoggedMessageHead ("Item4: %(item2.Identity)", "A2");
			Assert.AreEqual (0, testLogger.NormalMessageCount, "Unexpected extra messages found");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:31,代码来源:TaskBatchingTest.cs


示例19: TestCopy_OverwriteReadOnlyFalse

		public void TestCopy_OverwriteReadOnlyFalse ()
		{
			Engine engine;
			Project project;
			string file_path = Path.Combine (source_path, "copyro2.txt");
			string target_file = Path.Combine (target_path, "copyro2.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)'>
							<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);

			// build should fail because of the readonly target file
			Assert.IsFalse (project.Build ("1"));
			
			File.SetAttributes (target_file, FileAttributes.Normal);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:43,代码来源:CopyTest.cs


示例20: TestPropertiesWithBatchedReferences

		public void TestPropertiesWithBatchedReferences () {
			string projectString = projectHeader + @"
	<ItemGroup>
		<Item1 Include=""One""/>
		<Item1 Include=""Two""/>

		<Item1Ref Include=""@(Item1)""/>
	</ItemGroup>
	<PropertyGroup>
		<Prop1>@(Item1)</Prop1>
		<Prop2>@(Item1Ref)</Prop2>
	</PropertyGroup>
	<Target Name='1'>
		<Message Text=""Item1: %(Item1.Identity) | Prop1: $(Prop1) | Prop2: $(Prop2)""/>
	</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.CheckLoggedMessageHead ("Item1: One | Prop1: One | Prop2: One;Two", "A1");
				testLogger.CheckLoggedMessageHead ("Item1: Two | Prop1: Two | Prop2: One;Two", "A2");

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# System.UnitTestUriParser类代码示例发布时间:2022-05-26
下一篇:
C# Common.PokerMemoryCache类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap