public void SentinelServiceMsgs_LogEventMsg_Clone() { LogEventMsg msgIn, msgOut; EventLog log = new EventLog("Application"); EventLogEntry entry; // Clear the log and then add an entry so we can retrieve it right // away (hopefully getting the same entry back). log.Source = "Application"; log.Clear(); log.WriteEntry("Test entry", EventLogEntryType.Information, 0, 0, new byte[] { 0, 1, 2, 3 }); entry = log.Entries[0]; msgOut = new LogEventMsg("Application", entry); msgIn = (LogEventMsg)msgOut.Clone(); Assert.AreEqual("Application", msgIn.LogName); Assert.AreEqual(entry.EntryType, msgIn.EntryType); Assert.AreEqual(entry.TimeGenerated.ToUniversalTime(), msgIn.Time); Assert.AreEqual(entry.MachineName, msgIn.MachineName); Assert.AreEqual(entry.Message, msgIn.Message); CollectionAssert.AreEqual(new byte[] { 0, 1, 2, 3 }, msgIn.Data); TestBaseCloning(msgOut); }
public void SentinelServiceMsgs_LogEventMsg_Serialize() { LogEventMsg msgIn, msgOut; EnhancedStream es = new EnhancedMemoryStream(); EventLog log = new EventLog("Application"); EventLogEntry entry; // Clear the log and then add an entry so we can retrieve it right // away (hopefully getting the same entry back). log.Source = "Application"; log.Clear(); log.WriteEntry("Test entry", EventLogEntryType.Information, 0, 0, new byte[] { 0, 1, 2, 3 }); entry = log.Entries[0]; msgOut = new LogEventMsg("Application", entry); Msg.Save(es, msgOut); es.Seek(0, SeekOrigin.Begin); msgIn = (LogEventMsg)Msg.Load(es); Assert.AreEqual("Application", msgIn.LogName); Assert.AreEqual(entry.EntryType, msgIn.EntryType); Assert.AreEqual(entry.TimeGenerated.ToUniversalTime(), msgIn.Time); Assert.AreEqual(entry.MachineName, msgIn.MachineName); Assert.AreEqual(entry.Message, msgIn.Message); CollectionAssert.AreEqual(new byte[] { 0, 1, 2, 3 }, msgIn.Data); }