예제 #1
0
 public MofFixture()
 {
     if (AdminHelpers.IsProcessElevated())
     {
         ExtractAndCompileMof("WmiEBvt.mof");
     }
 }
예제 #2
0
 public void Dispose()
 {
     if (AdminHelpers.IsProcessElevated())
     {
         ExtractAndCompileMof("CleanUp.mof");
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
        public void DeleteUnregisteredSource()
        {
            if (!AdminHelpers.IsProcessElevated())
            {
                return;
            }

            Assert.Throws <System.ArgumentException>(() => EventLog.DeleteEventSource(Guid.NewGuid().ToString("N")));
        }
예제 #5
0
        public void CheckSourceExistsArgumentNull()
        {
            if (!AdminHelpers.IsProcessElevated())
            {
                return;
            }

            Assert.False(EventLog.SourceExists(null));
        }
예제 #6
0
        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));
        }
예제 #7
0
        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));
            }
        }