本文整理汇总了C#中MockLogger类的典型用法代码示例。如果您正苦于以下问题:C# MockLogger类的具体用法?C# MockLogger怎么用?C# MockLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockLogger类属于命名空间,在下文中一共展示了MockLogger类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
_systemClock = MockRepository.GenerateStub<ISystemClock>();
_logger = new MockLogger();
_messagingService = new MessagingService(_logger);
_supportCase = new SupportCase("Looking at the logs", _systemClock);
}
开发者ID:scichelli,项目名称:Experiments,代码行数:7,代码来源:InteractionVsState.cs
示例2: SetUp
public void SetUp()
{
_nodeRequestId = 1;
_host = new MockHost();
_mockLogger = new MockLogger();
_host.OnLoggingThreadException += this.LoggingException;
}
开发者ID:JamesLinus,项目名称:msbuild,代码行数:7,代码来源:TargetBuilder_Tests.cs
示例3: VerifyNewLinesAndTabsEvaluateToEmpty
public void VerifyNewLinesAndTabsEvaluateToEmpty()
{
MockLogger mockLogger = new MockLogger();
string projectFileContent = ObjectModelHelpers.CleanupFileContents(@"
<Project xmlns='msbuildnamespace'>
<PropertyGroup><NewLine>" + Environment.NewLine + Environment.NewLine + "</NewLine></PropertyGroup>" +
"<PropertyGroup><Tab>\t\t\t\t</Tab></PropertyGroup>" +
"<PropertyGroup><CarriageReturn>\r\r\r\r</CarriageReturn></PropertyGroup>" +
@"<PropertyGroup><Message1 Condition =""'$(NewLine)' == ''"">NewLineEvalAsEmpty</Message1></PropertyGroup>
<PropertyGroup><Message2 Condition =""'$(Tab)' == ''"">TabEvalAsEmpty</Message2></PropertyGroup>
<PropertyGroup><Message3 Condition =""'$(CarriageReturn)' == ''"">CarriageReturnEvalAsEmpty</Message3></PropertyGroup>
<Target Name=""BUild"">
<Message Text=""$(Message1)"" Importance=""High""/>
<Message Text=""$(Message2)"" Importance=""High""/>
<Message Text=""$(Message3)"" Importance=""High""/>
</Target>
</Project>");
ProjectRootElement xml = ProjectRootElement.Create(XmlReader.Create(new StringReader(projectFileContent)));
Project project = new Project(xml);
bool result = project.Build(new ILogger[] { mockLogger });
Assert.Equal(true, result);
mockLogger.AssertLogContains("NewLineEvalAsEmpty");
mockLogger.AssertLogContains("TabEvalAsEmpty");
mockLogger.AssertLogContains("CarriageReturnEvalAsEmpty");
}
开发者ID:cameron314,项目名称:msbuild,代码行数:28,代码来源:Project_Tests.cs
示例4: TargetBuilder_Tests
/// <summary>
/// Sets up to run tests. Creates the host object.
/// </summary>
public TargetBuilder_Tests()
{
_nodeRequestId = 1;
_host = new MockHost();
_mockLogger = new MockLogger();
_host.OnLoggingThreadException += this.LoggingException;
}
开发者ID:cameron314,项目名称:msbuild,代码行数:10,代码来源:TargetBuilder_Tests.cs
示例5: 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:joperezr,项目名称:msbuild,代码行数:28,代码来源:ImportFromMSBuildExtensionsPath_Tests.cs
示例6: WhenCallingWarnCallCountShouldIncrease
public void WhenCallingWarnCallCountShouldIncrease()
{
ILogger sut = new MockLogger();
sut.Warn(TestString);
MockLogger mockLogger = (MockLogger)sut;
mockLogger.WarnCallCount.Should().Be(1, "because we only called the warn method once");
}
开发者ID:vnvizitiu,项目名称:AOP,代码行数:8,代码来源:LoggerImplementation.Tests.cs
示例7: Setup
public void Setup()
{
Logger = new LoggingExtensions.Moq.MockLogger();
LoggingExtensions.Logging.Log.InitializeWith(Logger);
Context();
Because();
}
开发者ID:xuanvu,项目名称:this.Log,代码行数:8,代码来源:TinySpec.cs
示例8: WhenCallingFatalCallCountShouldIncrease
public void WhenCallingFatalCallCountShouldIncrease()
{
ILogger sut = new MockLogger();
sut.Fatal(TestString, new Exception());
MockLogger mockLogger = (MockLogger)sut;
mockLogger.FatalCallCount.Should().Be(1, "because we only called the fatal method once");
}
开发者ID:vnvizitiu,项目名称:AOP,代码行数:8,代码来源:LoggerImplementation.Tests.cs
示例9: InitializeLoggerAndAspect
public void InitializeLoggerAndAspect()
{
_logger = new MockLogger();
LogAttribute.Logger = _logger;
Mock<IConfigurationProvider> mock = new Mock<IConfigurationProvider>();
mock.Setup(provider => provider.ShouldLog(It.IsAny<LogAttribute>())).Returns(true);
LogAttribute.ConfigurationProvider = mock.Object;
}
开发者ID:vnvizitiu,项目名称:AOP,代码行数:9,代码来源:ExcludeTests.cs
示例10: AddNewErrorWarningMessageElement
public void AddNewErrorWarningMessageElement()
{
MockLogger logger = new MockLogger();
/**
* <Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
* <Target Name=`Build`>
* </Target>
* </Project
*/
ProjectRootElement projectXml = ProjectRootElement.Create();
ProjectTargetElement target = projectXml.AddTarget("Build");
projectXml.DefaultTargets = "Build";
projectXml.ToolsVersion = ObjectModelHelpers.MSBuildDefaultToolsVersion;
SolutionProjectGenerator.AddErrorWarningMessageElement(target, XMakeElements.message, true, "SolutionVenusProjectNoClean");
SolutionProjectGenerator.AddErrorWarningMessageElement(target, XMakeElements.warning, true, "SolutionParseUnknownProjectType", "proj1.csproj");
SolutionProjectGenerator.AddErrorWarningMessageElement(target, XMakeElements.error, true, "SolutionInvalidSolutionConfiguration");
Project project = new Project(projectXml);
project.Build(logger);
string code = null;
string keyword = null;
string text = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionParseUnknownProjectType", "proj1.csproj");
// check the error event
Assert.AreEqual(1, logger.Warnings.Count);
BuildWarningEventArgs warning = logger.Warnings[0];
Assert.AreEqual(text, warning.Message);
Assert.AreEqual(code, warning.Code);
Assert.AreEqual(keyword, warning.HelpKeyword);
code = null;
keyword = null;
text = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionInvalidSolutionConfiguration");
// check the warning event
Assert.AreEqual(1, logger.Errors.Count);
BuildErrorEventArgs error = logger.Errors[0];
Assert.AreEqual(text, error.Message);
Assert.AreEqual(code, error.Code);
Assert.AreEqual(keyword, error.HelpKeyword);
code = null;
keyword = null;
text = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionVenusProjectNoClean");
// check the message event
Assert.IsTrue(logger.FullLog.Contains(text), "Log should contain the regular message");
}
开发者ID:ChronosWS,项目名称:msbuild,代码行数:55,代码来源:SolutionProjectGenerator_Tests.cs
示例11: WhenTestingAFullTestcaseClassWithDebugDisplayShouldLogEverythingAndTheObject
public void WhenTestingAFullTestcaseClassWithDebugDisplayShouldLogEverythingAndTheObject()
{
MockLogger logger = new MockLogger();
LogAttribute.Logger = logger;
FullTestClass testClass = CreateTestClass();
testClass.Value.Should().NotBeNullOrWhiteSpace();
FullTestClass.EmbeddedMethod();
logger.DebugCallCount.Should().Be(24, "because we call the Entry, Exit and Success methods for the constructor, property and methods, even private method");
}
开发者ID:vnvizitiu,项目名称:AOP,代码行数:12,代码来源:LoggingAspectFullLoggingTests.cs
示例12: ResolveAllReturnsRegisteredObjectsForBaseClass
public void ResolveAllReturnsRegisteredObjectsForBaseClass()
{
IUnityContainer container = new UnityContainer();
ILogger o1 = new MockLogger();
ILogger o2 = new SpecialLogger();
container
.RegisterInstance<ILogger>("o1", o1)
.RegisterInstance<ILogger>("o2", o2);
List<ILogger> results = new List<ILogger>(container.ResolveAll<ILogger>());
CollectionAssert.AreEqual(new ILogger[] {o1, o2}, results);
}
开发者ID:theoju,项目名称:CleanCode,代码行数:13,代码来源:ResolvingArraysFixture.cs
示例13: SetUp
public void SetUp()
{
// Ensure that any previous tests which may have been using the default BuildManager do not conflict with us.
BuildManager.DefaultBuildManager.Dispose();
_logger = new MockLogger();
_parameters = new BuildParameters();
_parameters.ShutdownInProcNodeOnBuildFinish = true;
_parameters.Loggers = new ILogger[] { _logger };
_parameters.EnableNodeReuse = false;
_buildManager = new BuildManager();
_projectCollection = new ProjectCollection();
Environment.SetEnvironmentVariable("MSBUILDINPROCENVCHECK", "1");
}
开发者ID:ravpacheco,项目名称:msbuild,代码行数:14,代码来源:BuildManager_Tests.cs
示例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");
}
开发者ID:nikson,项目名称:msbuild,代码行数:50,代码来源:TargetUpToDateChecker_Tests.cs
示例15: WhenTestingAFullTestcaseClassShouldLogEverything
public void WhenTestingAFullTestcaseClassShouldLogEverything()
{
MockLogger logger = new MockLogger();
LogAttribute.Logger = logger;
FullTestClass testClass = new FullTestClass
{
Value = Guid.NewGuid().ToString()
};
testClass.Value.Should().NotBeNullOrEmpty();
FullTestClass.EmbeddedMethod();
logger.DebugCallCount.Should().Be(15, "because we call the Entry, Exit and Success methods for the constructor, property and methods, even private method");
}
开发者ID:vnvizitiu,项目名称:AOP,代码行数:15,代码来源:LoggingAspectFullLoggingTests.cs
示例16: OverrideTaskPathIsRelative
public void OverrideTaskPathIsRelative()
{
//Note Engine's BinPath is distinct from the ToolsVersion's ToolsPath
ProjectCollection e = new ProjectCollection();
Toolset t = new Toolset("toolsversionname", "c:\\directory1\\directory2", new PropertyDictionary<ProjectPropertyInstance>(), new ProjectCollection(), new DirectoryGetFiles(this.getFiles), new LoadXmlFromPath(this.loadXmlFromPath), "msbuildoverridetasks", new DirectoryExists(this.directoryExists));
MockLogger mockLogger = new MockLogger();
LoggingService service = (LoggingService)LoggingService.CreateLoggingService(LoggerMode.Synchronous, 1);
service.RegisterLogger(mockLogger);
TaskRegistry taskoverrideRegistry = (TaskRegistry)t.GetOverrideTaskRegistry(service, new BuildEventContext(1, 2, BuildEventContext.InvalidProjectContextId, 4), e.ProjectRootElementCache);
Assert.IsNotNull(taskoverrideRegistry);
Assert.IsTrue(taskoverrideRegistry.TaskRegistrations.Count == 0);
string rootedPathMessage = ResourceUtilities.FormatResourceString("OverrideTaskNotRootedPath", "msbuildoverridetasks");
mockLogger.AssertLogContains(ResourceUtilities.FormatResourceString("OverrideTasksFileFailure", rootedPathMessage));
}
开发者ID:ravpacheco,项目名称:msbuild,代码行数:16,代码来源:ToolsVersion_Tests.cs
示例17: Basic
public void Basic()
{
MockLogger l = new MockLogger();
Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(@"
<Project DefaultTargets='Build' ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='CleanUp'>
<Message Text='CleanUp-was-called.'/>
</Target>
<Target Name='Build'>
<Error Text='This is an error.'/>
<OnError ExecuteTargets='CleanUp'/>
</Target>
</Project>"))));
p.Build(new string[] { "Build" }, new ILogger[] { l });
Assert.Equal(1, l.ErrorCount); // "Expected one error because 'Build' failed."
Assert.True((l.FullLog.IndexOf("CleanUp-was-called") != -1)); // "The CleanUp target should have been called."
}
开发者ID:cameron314,项目名称:msbuild,代码行数:20,代码来源:OnError_Tests.cs
示例18: 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");
}
开发者ID:nikson,项目名称:msbuild,代码行数:22,代码来源:TargetUpToDateChecker_Tests.cs
示例19: OtherBuiltInMetadataErrors2
public void OtherBuiltInMetadataErrors2()
{
MockLogger logger = new MockLogger();
string projectFileContents = ObjectModelHelpers.CleanupFileContents(@"
<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
<CreateItem Include='Foo' AdditionalMetadata='Extension=1'/>
</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(false, result);
logger.AssertLogContains("MSB3031");
}
开发者ID:JamesLinus,项目名称:msbuild,代码行数:18,代码来源:TaskBuilder_Tests.cs
示例20: 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");
}
开发者ID:JamesLinus,项目名称:msbuild,代码行数:25,代码来源:TaskBuilder_Tests.cs
注:本文中的MockLogger类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论