You are testing a newly developed method named PersistToDB. This method accepts a parameter of type EventLogEntry.

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. EventLog^ myLog = gcnew EventLog(“Application”, “.”);for each (EventLogEntry^
    entry in myLog->Entries) {
    if (entry->Source == "MySource") {
    PersistToDB(entry);
    }}
B. EventLog^ myLog = gcnew EventLog(“Application”, “.”);myLog->Source = “MySource”;for each     
    (EventLogEntry^ entry in myLog->Entries) {
    if (entry->EntryType == (EventLogEntryType::Error &
    EventLogEntryType::Warning)) {
    PersistToDB(entry);}}
C. EventLog^ myLog = gcnew EventLog(“Application”, “.”);for each (EventLogEntry^
    entry in myLog->Entries) {
    if (entry->Source == "MySource") {
    if (entry->EntryType == EventLogEntryType::Error ||
    entry->EntryType == EventLogEntryType::Warning) {
    PersistToDB(entry);
    }
    }
D. EventLog^ myLog = gcnew EventLog(“Application”, “.”);myLog->Source = “MySource”;for       each     
    (EventLogEntry^ entry in myLog->Entries) {
    if (entry->EntryType == EventLogEntryType::Error ||
    entry->EntryType == EventLogEntryType::Warning) {
    PersistToDB(entry);
    }}
    

Answer: C

No comments:

Post a Comment