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


C# LogEntry.Clone方法代码示例

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


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

示例1: LogEntryCloneMethodTest

        public void LogEntryCloneMethodTest()
        {
            LogEntry entry = new LogEntry();
            entry.ActivityId = new Guid("AAAABBBBCCCCDDDDAAAABBBBCCCCDDDD");
            entry.AddErrorMessage("LogEntryCloneMethodTest exception");
            entry.Categories.Add("Error");
            entry.EventId = 1;
            entry.ExtendedProperties.Add("key1", "value1");
            entry.Message = "To test the cloning method";
            entry.Priority = 10;
            entry.Severity = TraceEventType.Critical;
            entry.Title = "LogEntryCloneMethodTest";

            LogEntry clonedEntry = (LogEntry)entry.Clone();

            Assert.AreEqual(entry.ActivityIdString, clonedEntry.ActivityIdString);
            Assert.AreEqual(entry.Categories.Count, clonedEntry.Categories.Count);
            Assert.AreEqual(entry.EventId, clonedEntry.EventId);
            Assert.AreEqual(entry.ExtendedProperties.Count, clonedEntry.ExtendedProperties.Count);
            Assert.AreEqual(entry.Message, clonedEntry.Message);
            Assert.AreEqual(entry.Priority, clonedEntry.Priority);
            Assert.AreEqual(entry.ProcessId, clonedEntry.ProcessId);
            Assert.AreEqual(entry.ProcessName, clonedEntry.ProcessName);
            Assert.AreEqual(entry.Severity, clonedEntry.Severity);
            Assert.AreEqual(entry.TimeStamp, clonedEntry.TimeStamp);
            Assert.AreEqual(entry.TimeStampString, clonedEntry.TimeStampString);
            Assert.AreEqual(entry.Title, clonedEntry.Title);
            Assert.AreEqual(entry.Win32ThreadId, clonedEntry.Win32ThreadId);
            Assert.AreEqual(entry.ManagedThreadName, clonedEntry.ManagedThreadName);
            Assert.AreEqual(entry.MachineName, clonedEntry.MachineName);
            Assert.AreEqual(entry.ErrorMessages, clonedEntry.ErrorMessages);
            Assert.AreEqual(entry.AppDomainName, clonedEntry.AppDomainName);

            clonedEntry.Categories.Add("Debug");
            clonedEntry.ExtendedProperties.Add("key2", "value2");
            clonedEntry.ActivityId = new Guid("EEEEFFFFEEEEFFFFEEEEFFFFEEEEFFFF");

            Assert.IsTrue(entry.Categories.Count == 1);
            Assert.IsTrue(clonedEntry.Categories.Count == 2);
            Assert.IsTrue(entry.ExtendedProperties.Count == 1);
            Assert.IsTrue(clonedEntry.ExtendedProperties.Count == 2);
            Assert.IsFalse(entry.ActivityIdString == clonedEntry.ActivityIdString);
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:43,代码来源:LogEntryFixture.cs


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