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

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

            Assert.False(EventLog.SourceExists(null));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
            }
        }