Question:You are testing a newly developed method named PersistToDB. This method accepts a parameter of type EventLogEntry. This method does not return a value.
You need to create a code segment that helps you to test the method. The code segment must read entries from the application log of local computers and then pass the entries on to the PersistToDB method. The code block must pass only events of type Error or Warning from the source MySource to the PersistToDB method. Which code segment should you use?

 

A Dim myLog as New EventLog("Application", ".")
myLog.Source = "MySource"
For Each entry As EventLogEntry In myLog.Entries
If entry.EntryType = (EventLogEntryType.Error And _
EventLogEntryType.Warning)
Then PersistToDB(entry)
End If
Next 

B Dim myLog as New EventLog("Application", ".")
myLog.Source = "MySource"
For Each entry As EventLogEntry In myLog.Entries
If (entry.EntryType = EventLogEntryType.Error) Or _
(entry.EntryType = EventLogEntryType.Warning)
Then PersistToDB(entry)
End If
Next 

C Dim myLog as New EventLog("Application", ".")
For Each entry As EventLogEntry In myLog.Entries
If entry.Source = "MySource" Then
If (entry.EntryType = EventLogEntryType.Error) Or _
(entry.EntryType = EventLogEntryType.Warning) Then
PersistToDB(entry)
End If
End If
Next 

D Dim myLog As New EventLog("Application", ".")
For Each entry As EventLogEntry In myLog.Entries
If entry.Source = "MySource"
Then PersistToDB(entry)
End If
Next 

+ Answer
+ Report
Total Preview: 762

Copyright © 2024. Powered by Intellect Software Ltd