public MofFixture() { if (AdminHelpers.IsProcessElevated()) { ExtractAndCompileMof("WmiEBvt.mof"); } }
public void Dispose() { if (AdminHelpers.IsProcessElevated()) { ExtractAndCompileMof("CleanUp.mof"); } }
public void ClearLogTest() { if (!AdminHelpers.IsProcessElevated()) { return; } string source = Guid.NewGuid().ToString("N"); string logName = Guid.NewGuid().ToString("N"); try { EventLog.CreateEventSource(source, logName); using (EventLog myLog = new EventLog()) { myLog.Source = source; myLog.WriteEntry("Writing to event log."); Assert.True(myLog.Entries.Count != 0); myLog.Clear(); Assert.Equal(0, myLog.Entries.Count); } } finally { EventLog.DeleteEventSource(source); } }
public void DeleteUnregisteredSource() { if (!AdminHelpers.IsProcessElevated()) { return; } Assert.Throws <System.ArgumentException>(() => EventLog.DeleteEventSource(Guid.NewGuid().ToString("N"))); }
public void CheckSourceExistsArgumentNull() { if (!AdminHelpers.IsProcessElevated()) { return; } Assert.False(EventLog.SourceExists(null)); }
public void CheckSourceExistenceAndDeletion() { if (!AdminHelpers.IsProcessElevated()) { return; } string source = Guid.NewGuid().ToString("N"); try { EventLog.CreateEventSource(source, "MyNewLog"); Assert.True(EventLog.SourceExists(source)); } finally { EventLog.DeleteEventSource(source); } Assert.False(EventLog.SourceExists(source)); }
public void DeleteLogTest() { if (!AdminHelpers.IsProcessElevated()) { return; } string source = Guid.NewGuid().ToString("N"); string logName = Guid.NewGuid().ToString("N"); try { EventLog.CreateEventSource(source, logName); Assert.True(EventLog.Exists(logName)); } finally { EventLog.Delete(logName); Assert.False(EventLog.Exists(logName)); } }