コード例 #1
0
        public void getEventsfromLast5Minutes_ExceptionInConnection_ExpectedNull()
        {
            var mockWindowsEvents = new Mock <IEvents>();
            var eventLogViewer    = new EventLogViewer(mockWindowsEvents.Object);

            mockWindowsEvents.Setup(win => win.getEventLogs(It.IsAny <DateTime>()))
            .Returns <ManagementObjectCollection>(null);

            var logs = eventLogViewer.getEventsfromLast5Minutes();

            Assert.IsNull(logs);
        }
コード例 #2
0
        public void getEventsfromLast5Minutes_NoEvents_ExpectedEmptyList()
        {
            var mockWindowsEvents = new Mock <IEvents>();
            var eventLogViewer    = new EventLogViewer(mockWindowsEvents.Object);

            mockWindowsEvents.Setup(win => win.getEventLogs(It.IsAny <DateTime>()))
            .Returns <ManagementObjectCollection>(null);

            var logs = eventLogViewer.getEventsfromLast5Minutes();

            Assert.That(logs.Count, Is.EqualTo(0));
        }
コード例 #3
0
        public void getEventsfromLast5Minutes_ValidEvents_ExpectedEventList()
        {
            var windowsEvents = new WindowsEvents(@"ROOT\CIMV2", new ConnectionOptions()
            {
                Impersonation    = ImpersonationLevel.Impersonate,
                EnablePrivileges = true,
                Authentication   = AuthenticationLevel.Packet
            });

            var eventlogViewer = new EventLogViewer(windowsEvents);
            var eventlogs      = eventlogViewer.getEventsfromLast5Minutes();

            Assert.That(eventlogs.Count, Is.GreaterThan(0));
        }