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


C# TestMessageLogger.CheckLoggedMessageHead方法代码示例

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


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

示例1: CheckMessage2

		void CheckMessage2 (TestMessageLogger logger, string culture, string resx_files, string nonresx_files, string id)
		{
			logger.CheckLoggedMessageHead (String.Format ("Culture: {0} -- ResXFiles: {1} NonResXFiles: {2}", culture, resx_files, nonresx_files), id);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:4,代码来源:TaskBatchingTest.cs

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

示例3: TestTargetInvocationFromBatchedTask

		public void TestTargetInvocationFromBatchedTask () {
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
	<ItemGroup>
		<Item1 Include=""One""/>
		<Item1 Include=""Two""/>

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

				testLogger.CheckLoggedMessageHead ("Item1: One;Two Item1Ref: One;Two", "A3");
				testLogger.CheckLoggedMessageHead ("Prop1: One;Two Prop2: One;Two", "A4");

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

示例4: TestTargetOutputsIncludingMetadata

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

			string documentString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
			<ItemGroup>
				<fruit Include=""apple""><md>a</md></fruit>
				<fruit Include=""rhubarb""><md>b</md></fruit>
				<fruit Include=""apricot""><md>c</md></fruit>
			</ItemGroup>

			<Target Name=""Main"">
				<CallTarget Targets=""foo"">
					<Output TaskParameter=""TargetOutputs"" ItemName=""AllOut""/>
				</CallTarget>

				<CallTarget Targets=""foo"">
					<Output TaskParameter=""TargetOutputs"" ItemName=""AllOut""/>
				</CallTarget>
				<Message Text=""AllOut: @(AllOut) metadata: %(AllOut.md)""/>
			</Target>

			<Target Name=""foo"" Outputs=""@(FooItem)"">
				<Message Text=""foo called""/>
				<CreateItem Include=""@(fruit)"">
					<Output TaskParameter=""Include"" ItemName=""FooItem""/>
				</CreateItem>
				<Message Text=""FooItem: @(FooItem) metadata: %(FooItem.md)""/>
			</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 ("Main");
			if (!result) {
				logger.DumpMessages ();
				Assert.Fail ("Build failed");
			}

			try {
				logger.CheckLoggedMessageHead ("foo called", "A1");
				logger.CheckLoggedMessageHead ("FooItem: apple metadata: a", "A2");
				logger.CheckLoggedMessageHead ("FooItem: rhubarb metadata: b", "A3");
				logger.CheckLoggedMessageHead ("FooItem: apricot metadata: c", "A4");

				logger.CheckLoggedMessageHead ("AllOut: apple;apple metadata: a", "A5");
				logger.CheckLoggedMessageHead ("AllOut: rhubarb;rhubarb metadata: b", "A6");
				logger.CheckLoggedMessageHead ("AllOut: apricot;apricot metadata: c", "A7");

				Assert.AreEqual (0, logger.NormalMessageCount, "Extra messages found");

				Assert.AreEqual (2, logger.TargetStarted, "TargetStarted count");
				Assert.AreEqual (2, logger.TargetFinished, "TargetFinished count");
				Assert.AreEqual (10, logger.TaskStarted, "TaskStarted count");
				Assert.AreEqual (10, logger.TaskFinished, "TaskFinished count");

			} catch (AssertionException) {
				logger.DumpMessages ();
				throw;
			}
		}
开发者ID:ancailliau,项目名称:mono,代码行数:68,代码来源:TargetTest.cs

示例5: TestBeforeAndAfterTargets

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

			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
			  <Target Name=""DefaultBeforeTarget1"" BeforeTargets=""Default"">
			    <Message Text=""Hello from DefaultBeforeTarget1""/>
			  </Target>

			  <Target Name=""DefaultBeforeTarget2"" BeforeTargets=""Default;Default;NonExistant"">
			    <Message Text=""Hello from DefaultBeforeTarget2""/>
			  </Target>


			  <Target Name=""DefaultAfterTarget"" AfterTargets=""Default  ; Foo"">
			    <Message Text=""Hello from DefaultAfterTarget""/>
			  </Target>

			  <Target Name=""Default"" DependsOnTargets=""DefaultDependsOn"">
			    <Message Text=""Hello from Default""/>
			  </Target>

			  <Target Name=""DefaultDependsOn"">
			    <Message Text=""Hello from DefaultDependsOn""/>
			  </Target>
			</Project>";

			engine = new Engine ();
			project = engine.CreateNewProject ();
			project.LoadXml (projectString);

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

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

			logger.CheckLoggedMessageHead ("Hello from DefaultDependsOn", "A1");
			logger.CheckLoggedMessageHead ("Hello from DefaultBeforeTarget1", "A1");
			logger.CheckLoggedMessageHead ("Hello from DefaultBeforeTarget2", "A1");
			logger.CheckLoggedMessageHead ("Hello from Default", "A1");
			logger.CheckLoggedMessageHead ("Hello from DefaultAfterTarget", "A1");

			Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected messages found");

			//warnings for referencing unknown targets: NonExistant and Foo
			Assert.AreEqual (2, logger.WarningsCount, "Expected warnings not raised");
		}
开发者ID:ancailliau,项目名称:mono,代码行数:52,代码来源:TargetTest.cs

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

示例7: TestPropertiesWithDynamicItems

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

		<Item2 Include=""Z""/>
		<Item2Ref Include=""@(Item2)"" />
	</ItemGroup>
	<PropertyGroup>
		<Prop1>@(Item2)</Prop1>
		<Prop2>@(Item2Ref)</Prop2>
	</PropertyGroup>
	<Target Name='1'>
		<Message Text=""Item1: %(Item1.Identity) | Prop1: $(Prop1) | Prop2: $(Prop2)""/>
		<Message Text=""Item2: @(Item2) | Item2Ref: @(Item2Ref)""/>
		<CreateItem Include=""A;B"">
			<Output TaskParameter=""Include"" ItemName=""Item2""/>
		</CreateItem>
		<Message Text=""Item1: %(Item1.Identity) | Prop1: $(Prop1) | Prop2: $(Prop2)""/>
		<Message Text=""Item2: @(Item2) | Item2Ref: @(Item2Ref)""/>
	</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: Z | Prop2: Z", "A1");
				testLogger.CheckLoggedMessageHead ("Item1: Two | Prop1: Z | Prop2: Z", "A2");
				testLogger.CheckLoggedMessageHead ("Item2: Z | Item2Ref: Z", "A3");

				testLogger.CheckLoggedMessageHead ("Item1: One | Prop1: Z;A;B | Prop2: Z", "A4");
				testLogger.CheckLoggedMessageHead ("Item1: Two | Prop1: Z;A;B | Prop2: Z", "A5");
				testLogger.CheckLoggedMessageHead ("Item2: Z;A;B | Item2Ref: Z", "A3");

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

示例8: TestNoDefaultTargets

		public void TestNoDefaultTargets () {
			Engine engine = new Engine (Consts.BinPath);
			Project project = engine.CreateNewProject ();

			project.LoadXml (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" >
				<Target Name=""boo"">
					<Message Text=""Executing boo target""/>
				</Target>
				<Target Name=""pre"">
					<Message Text=""Executing pre target""/>
				</Target>
			</Project>");

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

			try {
				Assert.IsTrue (project.Build (), "Build failed");

				logger.CheckLoggedMessageHead ("Executing boo target", "A1");
				Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found");

				Assert.AreEqual ("", project.DefaultTargets, "Default targets");
			} catch {
				logger.DumpMessages ();
				throw;
			}
		}
开发者ID:salloo,项目名称:mono,代码行数:29,代码来源:ProjectTest.cs

示例9: TestPropertiesFromImportedProjects

		public void TestPropertiesFromImportedProjects ()
		{
			Engine engine = new Engine (Consts.BinPath);
			Project project = engine.CreateNewProject ();

			string second = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
	<PropertyGroup>
	  <Prop1>InitialVal</Prop1>
	</PropertyGroup>
	<ItemGroup>
		<Second Include=""$(ThirdProp):Third""/>
	</ItemGroup>

	<Target Name=""Main"">
		<Message Text=""Prop1: $(Prop1) FooItem: @(FooItem)""/>
		<Message Text=""Second: @(Second) ThirdProp: $(ThirdProp)""/>
	</Target>
	<Import Project=""third.proj""/>
</Project>";
			using (StreamWriter sw = new StreamWriter (Path.Combine ("Test", Path.Combine ("resources", "second.proj")))) {
				sw.Write (second);
			}

			string third = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
	<PropertyGroup>
	  <ThirdProp>Third Value</ThirdProp>
	</PropertyGroup>
</Project>";
			using (StreamWriter sw = new StreamWriter (Path.Combine ("Test", Path.Combine ("resources", "third.proj")))) {
				sw.Write (third);
			}

			project.LoadXml (@"<Project InitialTargets=""Main"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
	<ItemGroup>
		<FooItem Include=""$(Prop1):Something""/>
	</ItemGroup>

	<Import Project=""Test/resources/second.proj""/>
</Project>");

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

			try {
				Assert.IsTrue (project.Build (), "Build failed");

				logger.CheckLoggedMessageHead ("Prop1: InitialVal FooItem: InitialVal:Something", "A1");
				logger.CheckLoggedMessageHead ("Second: Third Value:Third ThirdProp: Third Value", "A2");

				Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found");
			} catch {
				logger.DumpMessages ();
				throw;
			}
		}
开发者ID:salloo,项目名称:mono,代码行数:56,代码来源:ProjectTest.cs

示例10: TestBatchedMetadataRefInOutput

		public void TestBatchedMetadataRefInOutput () {
			string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
			<UsingTask TaskName=""BatchingTestTask"" AssemblyFile=""Test/resources/TestTasks.dll"" />
			<ItemGroup>
				<Coll1 Include=""A1""><Name>Abc</Name></Coll1>
				<Coll1 Include=""A2""><Name>Def</Name></Coll1>
				<Coll1 Include=""A3""><Name>Abc</Name></Coll1>
				<Coll1 Include=""B1""><Name>Bar</Name></Coll1>
			</ItemGroup>
				<Target Name=""ShowMessage"">
					<BatchingTestTask Sources=""@(Coll1)"" >
						<Output TaskParameter=""Output"" ItemName=""AbcItems"" Condition=""'%(Coll1.Name)' == 'Abc'""/>
						<Output TaskParameter=""Output"" ItemName=""NonAbcItems"" Condition=""'%(Coll1.Name)' != 'Abc'""/>
					</BatchingTestTask>
					<Message Text='AbcItems: @(AbcItems)' />
					<Message Text='NonAbcItems: @(NonAbcItems)' />
				</Target>
		 </Project>";

			Engine engine = new Engine (Consts.BinPath);
			Project project = engine.CreateNewProject ();
			MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
				new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
			engine.RegisterLogger (logger);

			project.LoadXml (projectString);
			bool result = project.Build ("ShowMessage");
			if (!result) {
				logger.DumpMessages ();
				Assert.Fail ("A1: Build failed");
			}

			logger.CheckLoggedMessageHead ("AbcItems: A1;A3", "A2");
			logger.CheckLoggedMessageHead ("NonAbcItems: A2;B1", "A2");

			if (logger.NormalMessageCount != 0) {
				logger.DumpMessages ();
				Assert.Fail ("Unexpected extra messages found");
			}
		}
开发者ID:salloo,项目名称:mono,代码行数:40,代码来源:ProjectTest.cs

示例11: TestNoDefaultTargetsWithImports

		public void TestNoDefaultTargetsWithImports () {
			Engine engine = new Engine (Consts.BinPath);
			Project project = engine.CreateNewProject ();


			string second = @"<Project DefaultTargets='; One  ; Two' xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<Target Name=""One"">
					<Message Text='Executing Second::One target'/>
				</Target>
				<Target Name=""Two"">
					<Message Text='Executing Second::Two target'/>
				</Target>

			</Project>";
			using (StreamWriter sw = new StreamWriter (Path.Combine ("Test", Path.Combine ("resources", "second.proj")))) {
				sw.Write (second);
			}

			project.LoadXml (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" >
				<Target Name=""boo"">
					<Message Text=""Executing boo target""/>
				</Target>
				<Target Name=""pre"">
					<Message Text=""Executing pre target""/>
				</Target>
				<Import Project='Test/resources/second.proj'/>
			</Project>");

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

			try {
				Assert.IsTrue (project.Build (), "Build failed");

				logger.CheckLoggedMessageHead ("Executing Second::One target", "A1");
				logger.CheckLoggedMessageHead ("Executing Second::Two target", "A2");
				Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found");

				Assert.AreEqual ("One; Two", project.DefaultTargets, "Default targets");
			} catch {
				logger.DumpMessages ();
				throw;
			}
		}
开发者ID:salloo,项目名称:mono,代码行数:45,代码来源:ProjectTest.cs

示例12: TestVariableExpansion

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

			string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
				<PropertyGroup>
					<P1>FooP1</P1>
					<P2>FooP2</P2>
					<C>@(IG)</C>
					<P3>@(Nine->'%(Identity)')</P3>
				</PropertyGroup>
				<ItemGroup>
					<Nine Include=""Nine""/>
					<Eight Include=""Eight""/>
					<Seven Include=""@(Eight)""/>
					<Six Include=""@(Seven);$(P3)""/>
					<Third Include=""Abc""/>
					<Fourth Include=""$(P2)""/>
					<Second Include=""@(Third);$(P1);@(Fourth);@(Six)""/>
					<IG Include=""@(Second)""/>
				</ItemGroup>

					<Target Name='1'>
						<CreateItem Include='$(C)' >
							<Output
								TaskParameter='Include'
								ItemName='Items'
							/>
						</CreateItem>

						<Message Text=""C: $(C)""/>
						<Message Text=""items: @(items)""/>
					</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");
			}

			BuildItemGroup include = project.GetEvaluatedItemsByName ("Items");
			Assert.AreEqual (5, include.Count, "A2");

			Assert.AreEqual ("Abc", include [0].FinalItemSpec, "A#3");
			Assert.AreEqual ("FooP1", include[1].FinalItemSpec, "A#4");
			Assert.AreEqual ("FooP2", include[2].FinalItemSpec, "A#5");
			Assert.AreEqual ("Eight", include[3].FinalItemSpec, "A#6");
			Assert.AreEqual ("Nine", include[4].FinalItemSpec, "A#7");

			testLogger.CheckLoggedMessageHead ("C: Abc;FooP1;FooP2;Eight;Nine", "A#9");
			testLogger.CheckLoggedMessageHead ("items: Abc;FooP1;FooP2;Eight;Nine", "A#10");

		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:63,代码来源:CreateItemTest.cs

示例13: TestRunTargetTwice

		public void TestRunTargetTwice ()
		{
			string documentString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
			<Target Name=""Foo"">
				<Message Text=""Foo ran""/>
			</Target>
			<Target Name=""Main"">
				<MSBuild Projects=""$(MSBuildProjectFile)"" Targets=""Foo;Foo"" />
			</Target>

		</Project>";

			var filepath = Path.GetTempFileName ();
			try {
				File.WriteAllText (filepath, documentString);

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

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

				var result = project.Build ("Main");
				if (!result) {
					logger.DumpMessages ();
					Assert.Fail ("Build failed, see the logs");
				}

				Assert.AreEqual(1, logger.NormalMessageCount, "Expected number of messages");
				logger.CheckLoggedMessageHead ("Foo ran", "A1");

				Assert.AreEqual(0, logger.NormalMessageCount, "Extra messages found");
				Assert.AreEqual(0, logger.WarningMessageCount, "Extra warning messages found");

				Assert.AreEqual(2, logger.TargetStarted, "TargetStarted count");
				Assert.AreEqual(2, logger.TargetFinished, "TargetFinished count");

				Assert.IsTrue (result);
			} finally {
				File.Delete (filepath);
			}
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:43,代码来源:TargetTest.cs

示例14: Test1

		public void Test1 ()
		{
			string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion='3.5'>
				
				<ItemGroup>
					<Items Include='A'>
						<MD>Value1</MD>
					</Items>
					<Items Include='A'>
						<MD>Value1</MD>
					</Items>

					<Items Include='A'>
						<MD>Value2</MD>
						<MD2>Value2</MD2>
					</Items>

					<Items Include='B'>
						<MD>Value1</MD>
					</Items>
					<Items Include='B'>
						<MD>Value1</MD>
					</Items>
					<Items Include='C'>
						<MD>Value1</MD>
					</Items>
					<Items Include='A'>
						<MD>Value3</MD>
						<MD3>Value3</MD3>
					</Items>
				</ItemGroup>

					<Target Name='Main'>
						<RemoveDuplicates Inputs='@(Items)'>
							<Output TaskParameter='Filtered' ItemName='Filtered'/>
						</RemoveDuplicates>
						<Message Text=""Filtered items: %(Filtered.Identity) MD: %(Filtered.MD) MD2: %(Filtered.MD2) MD3: %(Filtered.MD3)""/>
					</Target>
				</Project>
			";

			Engine engine = new Engine (Consts.BinPath);

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

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

			testLogger.CheckLoggedMessageHead ("Filtered items: A MD: Value1 MD2:  MD3: ", "A1");
			testLogger.CheckLoggedMessageHead ("Filtered items: B MD: Value1 MD2:  MD3: ", "A2");
			testLogger.CheckLoggedMessageHead ("Filtered items: C MD: Value1 MD2:  MD3: ", "A3");
			Assert.AreEqual (0, testLogger.NormalMessageCount, "Unexpected extra messages found");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:59,代码来源:RemoveDuplicatesTest.cs

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


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