本文整理汇总了C#中MockLogger.AssertLogDoesntContain方法的典型用法代码示例。如果您正苦于以下问题:C# MockLogger.AssertLogDoesntContain方法的具体用法?C# MockLogger.AssertLogDoesntContain怎么用?C# MockLogger.AssertLogDoesntContain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockLogger
的用法示例。
在下文中一共展示了MockLogger.AssertLogDoesntContain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmptyItemSpecInTargetInputs
public void EmptyItemSpecInTargetInputs()
{
MockLogger ml = new MockLogger();
Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<ItemGroup>
<MyFile Include='a.cs; b.cs; c.cs'/>
</ItemGroup>
<Target Name='Build'
Inputs=""@(MyFile->'%(NonExistentMetadata)')""
Outputs='foo.exe'>
<Message Text='Running Build target' Importance='High'/>
</Target>
</Project>"))));
bool success = p.Build(new string[] { "Build" }, new ILogger[] { ml });
Assert.True(success);
// It should have actually skipped the "Build" target since there were no inputs.
ml.AssertLogDoesntContain("Running Build target");
}
示例2: OverridePropertiesInInferredCreateProperty
public void OverridePropertiesInInferredCreateProperty()
{
string[] files = null;
try
{
files = ObjectModelHelpers.GetTempFiles(2, new DateTime(2005, 1, 1));
MockLogger logger = new MockLogger();
string projectFileContents = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<ItemGroup>
<i Include='" + files[0] + "'><output>" + files[1] + @"</output></i>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include='a.resx'>
<LogicalName>foo</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include='b.resx'>
<LogicalName>bar</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include='c.resx'>
<LogicalName>barz</LogicalName>
</EmbeddedResource>
</ItemGroup>
<Target Name='t2' DependsOnTargets='t'>
<Message Text='final:[$(LinkSwitches)]'/>
</Target>
<Target Name='t' Inputs='%(i.Identity)' Outputs='%(i.Output)'>
<Message Text='start:[Hello]'/>
<CreateProperty Value=""@(EmbeddedResource->'/assemblyresource:%(Identity),%(LogicalName)', ' ')""
Condition=""'%(LogicalName)' != '' "">
<Output TaskParameter=""Value"" PropertyName=""LinkSwitches""/>
</CreateProperty>
<Message Text='end:[hello]'/>
</Target>
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
List<ILogger> loggers = new List<ILogger>();
loggers.Add(logger);
project.Build("t2", loggers);
// We should only see messages from the second target, as the first is only inferred
logger.AssertLogDoesntContain("start:");
logger.AssertLogDoesntContain("end:");
logger.AssertLogContains(new string[] { "final:[/assemblyresource:c.resx,barz]" });
logger.AssertLogDoesntContain(ResourceUtilities.FormatResourceString("TaskStarted", "CreateProperty"));
logger.AssertLogContains(new string[] { ResourceUtilities.FormatResourceString("PropertyOutputOverridden", "LinkSwitches", "/assemblyresource:a.resx,foo", "/assemblyresource:b.resx,bar") });
logger.AssertLogContains(new string[] { ResourceUtilities.FormatResourceString("PropertyOutputOverridden", "LinkSwitches", "/assemblyresource:b.resx,bar", "/assemblyresource:c.resx,barz") });
}
finally
{
ObjectModelHelpers.DeleteTempFiles(files);
}
}
示例3: TasksAreDiscoveredWhenTaskConditionTrue
public void TasksAreDiscoveredWhenTaskConditionTrue()
{
MockLogger logger = new MockLogger();
string projectFileContents = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
<NonExistantTask Condition=""'1'=='1'""/>
<Message Text='Made it'/>
</Target>
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
List<ILogger> loggers = new List<ILogger>();
loggers.Add(logger);
project.Build("t", loggers);
logger.AssertLogContains("MSB4036");
logger.AssertLogDoesntContain("Made it");
}
示例4: LogWithLoggersOnProjectCollectionCustomOneUsed
public void LogWithLoggersOnProjectCollectionCustomOneUsed()
{
MockLogger mockLogger = new MockLogger();
MockLogger mockLogger2 = new MockLogger();
string projectFileContent = ObjectModelHelpers.CleanupFileContents(@"
<Project xmlns='msbuildnamespace'>
<Target Name=""BUild"">
<Message Text=""IHaveBeenLogged"" Importance=""High""/>
</Target>
</Project>");
ProjectRootElement xml = ProjectRootElement.Create(XmlReader.Create(new StringReader(projectFileContent)));
ProjectCollection collection = new ProjectCollection();
collection.RegisterLogger(mockLogger2);
Project project = new Project(xml, null, null, collection);
bool result = project.Build(mockLogger);
Assert.Equal(true, result);
mockLogger.AssertLogContains("IHaveBeenLogged");
mockLogger2.AssertLogDoesntContain("IHaveBeenLogged");
}
示例5: TwoSubmissionsWithSeparateLoggers
public void TwoSubmissionsWithSeparateLoggers()
{
string projectBody1 = ObjectModelHelpers.CleanupFileContents(@"
<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='Test'>
<Message Text='Foo'/>
<Error Text='Error'/>
</Target>
</Project>
");
string projectBody2 = ObjectModelHelpers.CleanupFileContents(@"
<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='Test'>
<Message Text='Bar'/>
<Warning Text='Warning'/>
</Target>
</Project>
");
ProjectInstance project1 = (new Project(XmlReader.Create(new StringReader(projectBody1)))).CreateProjectInstance();
ProjectInstance project2 = (new Project(XmlReader.Create(new StringReader(projectBody2)))).CreateProjectInstance();
BuildManager buildManager = BuildManager.DefaultBuildManager;
MuxLogger muxLogger = new MuxLogger();
BuildParameters parameters = new BuildParameters(ProjectCollection.GlobalProjectCollection);
parameters.Loggers = new ILogger[] { muxLogger };
MockLogger mockLogger1 = new MockLogger();
MockLogger mockLogger2 = new MockLogger();
buildManager.BeginBuild(parameters);
try
{
BuildSubmission submission1 = buildManager.PendBuildRequest(new BuildRequestData(project1, new string[0], null));
muxLogger.RegisterLogger(submission1.SubmissionId, mockLogger1);
submission1.Execute();
BuildSubmission submission2 = buildManager.PendBuildRequest(new BuildRequestData(project2, new string[0], null));
muxLogger.RegisterLogger(submission2.SubmissionId, mockLogger2);
submission2.Execute();
}
finally
{
buildManager.EndBuild();
}
mockLogger1.AssertLogContains("Foo");
mockLogger1.AssertLogContains("Error");
mockLogger1.AssertLogDoesntContain("Bar");
mockLogger1.AssertLogDoesntContain("Warning");
Assert.Equal(1, mockLogger1.ErrorCount);
Assert.Equal(0, mockLogger1.WarningCount);
mockLogger2.AssertLogDoesntContain("Foo");
mockLogger2.AssertLogDoesntContain("Error");
mockLogger2.AssertLogContains("Bar");
mockLogger2.AssertLogContains("Warning");
Assert.Equal(0, mockLogger2.ErrorCount);
Assert.Equal(1, mockLogger2.WarningCount);
}
示例6: ToolsVersionFallbackIfCurrentToolsVersionDoesNotExist_ProjectInstance
public void ToolsVersionFallbackIfCurrentToolsVersionDoesNotExist_ProjectInstance()
{
ProjectCollection p = new ProjectCollection();
p.RemoveToolset(ObjectModelHelpers.MSBuildDefaultToolsVersion);
MockLogger mockLogger = new MockLogger();
LoggingService service = (LoggingService)LoggingService.CreateLoggingService(LoggerMode.Synchronous, 1);
service.RegisterLogger(mockLogger);
bool success = false;
Project project = new Project(XmlReader.Create(new StringReader(@"<Project ToolsVersion='4.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='Foo'>
</Target>
</Project>")), null /* no global properties */, null /* don't explicitly set the toolsversion */, p);
ProjectInstance pi = new ProjectInstance(project.Xml, null /* no global properties */, null /* don't explicitly set the toolsversion */, p);
Assert.AreEqual("4.0", pi.ToolsVersion);
success = pi.Build(new ILogger[] { mockLogger });
Assert.IsTrue(success);
mockLogger.AssertLogContains("\"4.0\"");
mockLogger.AssertLogDoesntContain(ObjectModelHelpers.CleanupFileContents("\"msbuilddefaulttoolsversion\""));
}
示例7: CommandLineErrorsReportFullCommandline
public void CommandLineErrorsReportFullCommandline()
{
string projectFile = @"
<Project ToolsVersion=`msbuilddefaulttoolsversion` DefaultTargets=`XamlTaskFactory` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
<UsingTask TaskName=`TestTask` TaskFactory=`XamlTaskFactory` AssemblyName=`Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a`>
<Task>
<![CDATA[
<ProjectSchemaDefinitions xmlns=`clr-namespace:Microsoft.Build.Framework.XamlTypes;assembly=Microsoft.Build.Framework` xmlns:x=`http://schemas.microsoft.com/winfx/2006/xaml` xmlns:sys=`clr-namespace:System;assembly=mscorlib` xmlns:impl=`clr-namespace:Microsoft.VisualStudio.Project.Contracts.Implementation;assembly=Microsoft.VisualStudio.Project.Contracts.Implementation`>
<Rule Name=`TestTask` ToolName=`echoparameters.exe`>
<StringProperty Name=`test` />
</Rule>
</ProjectSchemaDefinitions>
]]>
</Task>
</UsingTask>
<Target Name=`XamlTaskFactory`>
<TestTask CommandLineTemplate=`where /x` />
</Target>
</Project>";
Project p = ObjectModelHelpers.CreateInMemoryProject(projectFile);
MockLogger logger = new MockLogger();
bool success = p.Build(logger);
Assert.IsFalse(success, "Build should have failed");
// Should not be logging ToolTask.ToolCommandFailed, should be logging Xaml.CommandFailed
logger.AssertLogDoesntContain("MSB6006");
logger.AssertLogContains("MSB3721");
}
示例8: MultiInputItemsThatCorrelatesWithMultipleTransformOutputItems2
public void MultiInputItemsThatCorrelatesWithMultipleTransformOutputItems2()
{
Console.WriteLine("MultiInputItemsThatCorrelatesWithMultipleTransformOutputItems2");
MockLogger logger = new MockLogger();
Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(@"
<Project InitialTargets='Setup' xmlns='msbuildnamespace'>
<ItemGroup>
<A Include='A' />
<B Include='B' />
</ItemGroup>
<Target Name='Build' DependsOnTargets='GAFT'>
<Message Text='Build: @(Outs)' />
<Message Text='Build: GAFTOutsA @(GAFTOutsA)' />
<Message Text='Build: GAFTOutsB @(GAFTOutsB)' />
</Target>
<Target Name='Setup'>
<WriteLinesToFile
File='A'
Lines='A'
Overwrite='true'/>
<WriteLinesToFile
File='B.out'
Lines='B.out'
Overwrite='true'/>
<Exec Command='sleep.exe 1' />
<WriteLinesToFile
File='B'
Lines='B'
Overwrite='true'/>
<WriteLinesToFile
File='A.out'
Lines='A.out'
Overwrite='true'/>
</Target>
<Target Name='GAFT' Inputs='@(A);@(B)' Outputs=""@(A->'%(Filename).out');@(B->'%(Filename).out')"">
<CreateItem Include=""@(A->'%(Filename).out')"">
<Output TaskParameter='Include' ItemName='GAFTOutsA' />
</CreateItem>
<Message Text='GAFT A:@(A)' />
<CreateItem Include=""@(B->'%(Filename).out')"">
<Output TaskParameter='Include' ItemName='GAFTOutsB' />
</CreateItem>
<Message Text='GAFT B:@(B)' />
</Target>
</Project>
"))));
p.Build(new string[] { "Build" }, new ILogger[] { logger });
// If the log contains B.out twice, then there is leakage from the parent lookup
logger.AssertLogDoesntContain("B.out;B.out");
}
示例9: MockLogger
public void ItemsEmittedByIntrinsicTaskConsumingItemExpression_DestinationDefaultMetadataOverriddenBySourceDefaultMetadata()
{
MockLogger logger = new MockLogger();
Project p = new Project(XmlReader.Create(new StringReader(@"
<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemDefinitionGroup>
<i>
<m>m1</m>
</i>
<j>
<m>m2</m>
</j>
</ItemDefinitionGroup>
<ItemGroup>
<i Include=""n1""/>
<j Include=""@(i)""/>
</ItemGroup>
<Target Name=""t"">
<ItemGroup>
<i Include=""n2""/>
<j Include=""@(i)""/>
</ItemGroup>
<Message Text=""[%(j.m)]""/>
</Target>
</Project>
")));
Assert.AreEqual("m1", p.GetItems("j").First().GetMetadataValue("m"));
p.Build("t", new ILogger[] { logger });
logger.AssertLogContains("[m1]");
logger.AssertLogDoesntContain("[m2]");
}
示例10: ItemGroupWithConditionOnGroup
public void ItemGroupWithConditionOnGroup()
{
MockLogger logger = new MockLogger();
Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
<ItemGroup Condition='false'>
<i1 Include='a1'/>
<i2 Include='b1'/>
</ItemGroup>
<Message Text='[@(i1)][@(i2)]'/>
</Target>
</Project>"))));
p.Build(new string[] { "t" }, new ILogger[] { logger });
logger.AssertLogDoesntContain("[a1][b1]");
logger.ClearLog();
p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
<ItemGroup Condition='true'>
<i1 Include='a1'/>
<i2 Include='b1'/>
</ItemGroup>
<Message Text='[@(i1)][@(i2)]'/>
</Target>
</Project>"))));
p.Build(new string[] { "t" }, new ILogger[] { logger });
logger.AssertLogContains("[a1][b1]");
}
示例11: FilterItemPreviouslyModified2
public void FilterItemPreviouslyModified2()
{
MockLogger logger = new MockLogger();
Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(@"
<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<ItemGroup>
<x Include='a'/>
</ItemGroup>
<Target Name='t'>
<ItemGroup>
<x>
<m1>1</m1>
</x>
<x>
<m1 Condition=""'%(x.m1)'=='1'"">2</m1>
</x>
</ItemGroup>
<Message Text='[%(x.m1)]'/>
</Target>
</Project>
"))));
p.Build(new string[] { "t" }, new ILogger[] { logger });
logger.AssertLogDoesntContain("[1]");
logger.AssertLogContains("[2]");
}
示例12: PropertiesInInferredBuildCreateProperty
public void PropertiesInInferredBuildCreateProperty()
{
string[] files = null;
try
{
files = ObjectModelHelpers.GetTempFiles(2, new DateTime(2005, 1, 1));
MockLogger logger = new MockLogger();
Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(@"
<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<ItemGroup>
<i Include='" + files.First() + "'><output>" + files.ElementAt(1) + @"</output></i>
</ItemGroup>
<Target Name='t2' DependsOnTargets='t'>
<Message Text='final:[$(p)]'/>
</Target>
<Target Name='t' Inputs='%(i.Identity)' Outputs='%(i.Output)'>
<Message Text='start:[$(p)]'/>
<CreateProperty Value='@(i)'>
<Output TaskParameter='Value' PropertyName='p'/>
</CreateProperty>
<Message Text='end:[$(p)]'/>
</Target>
</Project>
"))));
p.Build(new string[] { "t2" }, new ILogger[] { logger });
// We should only see messages from the second target, as the first is only inferred
logger.AssertLogDoesntContain("start:");
logger.AssertLogDoesntContain("end:");
logger.AssertLogContains(new string[] { "final:[" + files.First() + "]" });
}
finally
{
ObjectModelHelpers.DeleteTempFiles(files);
}
}
示例13: PropertyGroupWithConditionOnGroup
public void PropertyGroupWithConditionOnGroup()
{
MockLogger logger = new MockLogger();
Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
<PropertyGroup Condition='false'>
<p1>v1</p1>
<p2>v2</p2>
</PropertyGroup>
<Message Text='[$(P1)][$(P2)]'/>
</Target>
</Project>"))));
p.Build(new string[] { "t" }, new ILogger[] { logger });
logger.AssertLogDoesntContain("[v1][v2]");
logger.ClearLog();
p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
<PropertyGroup Condition='true'>
<p1>v1</p1>
<p2>v2</p2>
</PropertyGroup>
<Message Text='[$(P1)][$(P2)]'/>
</Target>
</Project>"))));
p.Build(new string[] { "t" }, new ILogger[] { logger });
logger.AssertLogContains("[v1][v2]");
}
示例14: EmptyItemSpecInTargetOutputs
public void EmptyItemSpecInTargetOutputs()
{
MockLogger ml = new MockLogger();
Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='Build'
Inputs='@(TASKXML)'
Outputs=""@(TASKXML->'%(OutputFile)');@(TASKXML->'%(PasFile)');"">
<Message Text='Running Build target' Importance='High'/>
</Target>
<ItemGroup>
<TASKXML Include='bcc32task.xml'>
<OutputFile>bcc32task.cs</OutputFile>
</TASKXML>
<TASKXML Include='ccc32task.xml'>
<PasFile>ccc32task.pas</PasFile>
</TASKXML>
</ItemGroup>
</Project>"))));
bool success = p.Build("Build", new ILogger[] { ml });
Assert.True(success);
// It should not have skipped the "Build" target since some output metadata was missing
ml.AssertLogContains("Running Build target");
ml = new MockLogger();
p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='Build'
Inputs='@(TASKXML)'
Outputs=""@(TASKXML->'%(OutputFile)');@(TASKXML->'%(PasFile)');"">
<Message Text='Running Build target' Importance='High'/>
</Target>
<ItemGroup>
<TASKXML Include='bcc32task.xml'>
</TASKXML>
<TASKXML Include='ccc32task.xml'>
</TASKXML>
</ItemGroup>
</Project>"))));
success = p.Build("Build", new ILogger[] { ml });
Assert.True(success);
// It should have actually skipped the "Build" target since some output metadata was missing
ml.AssertLogDoesntContain("Running Build target");
}
示例15: TasksCanAddRecursiveDirBuiltInMetadata
public void TasksCanAddRecursiveDirBuiltInMetadata()
{
MockLogger logger = new MockLogger();
string projectFileContents = ObjectModelHelpers.CleanupFileContents(@"
<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
<CreateItem Include='$(programfiles)\reference assemblies\**\*.dll;'>
<Output TaskParameter='Include' ItemName='x' />
</CreateItem>
<Message Text='@(x)'/>
<Message Text='[%(x.RecursiveDir)]'/>
</Target>
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
List<ILogger> loggers = new List<ILogger>();
loggers.Add(logger);
bool result = project.Build("t", loggers);
Assert.AreEqual(true, result);
logger.AssertLogDoesntContain("[]");
logger.AssertLogDoesntContain("MSB4118");
logger.AssertLogDoesntContain("MSB3031");
}