本文整理汇总了C#中MockLogger类的典型用法代码示例。如果您正苦于以下问题:C# MockLogger类的具体用法?C# MockLogger怎么用?C# MockLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockLogger类属于命名空间,在下文中一共展示了MockLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: SetUp
public void SetUp()
{
_nodeRequestId = 1;
_host = new MockHost();
_mockLogger = new MockLogger();
_host.OnLoggingThreadException += this.LoggingException;
}
示例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");
}
示例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;
}
示例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);
}
}
}
示例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");
}
示例7: Setup
public void Setup()
{
Logger = new LoggingExtensions.Moq.MockLogger();
LoggingExtensions.Logging.Log.InitializeWith(Logger);
Context();
Because();
}
示例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");
}
示例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;
}
示例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");
}
示例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");
}
示例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);
}
示例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");
}
示例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: 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");
}