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? - (VB.Net) 

A Dim myLog As New EventLog("Application", ".")
For Each entry As EventLogEntry In myLog.Entries
If entry.Source = "MySource" 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] And 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] OrElse entry.EntryType = EventLogEntryType.
Warning Then
PersistToDB(entry)
End If
End If
Next 

D Dim myLog As New EventLog("Application", ".")
myLog.Source = "MySource"
For Each entry As EventLogEntry In myLog.Entries
If entry.EntryType = EventLogEntryType.[Error] OrElse entry.EntryType = EventLogEntryType.
Warning Then
PersistToDB(entry)
End If
Next 

+ Answer
+ Report
Total Preview: 920

Copyright © 2024. Powered by Intellect Software Ltd