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


C# MockLogger类代码示例

本文整理汇总了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);
 }
开发者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


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