public void Can_Retrieve_SysInfo_For_OS()
        {
            var sysInfoResult = _retriever.Retrieve(SysInfoQueries.OperatingSystem);

            if (ExceptionReporter.IsRunningMono())
            {
                Assert.That(sysInfoResult, Is.Null);
                return;
            }
            ;
            Assert.That(sysInfoResult.Nodes[0], Does.Contain("Windows"));
        }
Пример #2
0
        internal IList <SysInfoResult> GetOrFetchSysInfoResults()
        {
            if (ExceptionReporter.IsRunningMono())
            {
                return(new List <SysInfoResult>());
            }
            if (_sysInfoResults.Count == 0)
            {
                _sysInfoResults.AddRange(CreateSysInfoResults());
            }

            return(_sysInfoResults.AsReadOnly());
        }
        public void Can_Create_Report_With_A_Couple_Of_Minimal_Bits_That_Should_Exist()
        {
            if (ExceptionReporter.IsRunningMono())
            {
                return;
            }
            var report       = _reportGenerator.CreateExceptionReport();
            var reportString = report.ToString();

            Assert.That(reportString, Does.StartWith("-"));
            Assert.That(reportString, Does.Contain("Application:"));
            Assert.That(reportString, Does.Contain("TotalPhysicalMemory ="));
        }
        public void Can_Take_Screenshot()
        {
            var screenshot = ScreenshotTaker.TakeScreenShot();

            if (ExceptionReporter.IsRunningMono())
            {
                Assert.That(screenshot, Is.Null);
            }
            else
            {
                Assert.IsNotNull(screenshot);
            }
        }
        public void Can_Retrieve_SysInfo_For_CPU()
        {
            var sysInfoResult = _retriever.Retrieve(SysInfoQueries.Machine);

            if (ExceptionReporter.IsRunningMono())
            {
                Assert.That(sysInfoResult, Is.Null);
                return;
            }
            ;

            Assert.That(sysInfoResult.Nodes.Count, Is.EqualTo(1));                  // at least 1 machine name
            Assert.That(sysInfoResult.ChildResults[0].Nodes.Count, Is.GreaterThan(0));
            Assert.That(sysInfoResult.ChildResults[0].Nodes.Count(r => r.Contains("CurrentTimeZone")), Is.GreaterThan(0));
        }
Пример #6
0
        /// <summary>
        /// Retrieve system information, using the given SysInfoQuery to determine what information to retrieve
        /// </summary>
        /// <param name="sysInfoQuery">the query to determine what information to retrieve</param>
        /// <returns>a SysInfoResult ie containing the results of the query</returns>
        public SysInfoResult Retrieve(SysInfoQuery sysInfoQuery)
        {
            if (ExceptionReporter.IsRunningMono())
            {
                return(null);
            }
            _sysInfoQuery    = sysInfoQuery;
            _sysInfoSearcher = new ManagementObjectSearcher(string.Format("SELECT * FROM {0}", _sysInfoQuery.QueryText));
            _sysInfoResult   = new SysInfoResult(_sysInfoQuery.Name);

            foreach (ManagementObject managementObject in _sysInfoSearcher.Get())
            {
                _sysInfoResult.AddNode(managementObject.GetPropertyValue(_sysInfoQuery.DisplayField).ToString().Trim());
                _sysInfoResult.AddChildren(GetChildren(managementObject));
            }
            return(_sysInfoResult);
        }
        public void Can_Build_SysInfo_Section()
        {
            var sysInfoResults          = CreateSysInfoResult();
            var expectedExceptionReport = CreateExpectedReport();

            using (var reportInfo = CreateReportInfo())
            {
                reportInfo.ShowSysInfoTab = true;

                var builder         = new ExceptionReportBuilder(reportInfo, sysInfoResults);
                var exceptionReport = builder.Build();

                if (!ExceptionReporter.IsRunningMono())
                {
                    Assert.That(exceptionReport.ToString(), Is.EqualTo(expectedExceptionReport.ToString()));
                }
            }
        }
Пример #8
0
        /// <summary>
        /// The main entry point, populates the report with everything it needs
        /// </summary>
        public void PopulateReport()
        {
            try
            {
                _view.SetInProgressState();

                _view.PopulateExceptionTab(ReportInfo.Exceptions);
                _view.PopulateAssembliesTab();
                if (!ExceptionReporter.IsRunningMono())
                {
                    _view.PopulateSysInfoTab();
                }
            }
            finally
            {
                _view.SetProgressCompleteState();
            }
        }
        public void Can_Build_Referenced_Assemblies_Section()
        {
            using (var reportInfo = CreateReportInfo())
            {
                reportInfo.ShowAssembliesTab = true;
                reportInfo.AppAssembly       = Assembly.GetExecutingAssembly();

                var builder = new ExceptionReportBuilder(reportInfo, new List <SysInfoResult>());

                var exceptionReport = builder.Build();

                Assert.That(exceptionReport, Is.Not.Null);

                var exceptionReportString = exceptionReport.ToString();
                Assert.That(exceptionReportString.Length, Is.GreaterThan(0));
                if (!ExceptionReporter.IsRunningMono())
                {
                    Assert.That(exceptionReportString, Does.Contain("System.Core, Version="));
                }
                Assert.That(exceptionReportString, Does.Contain(Environment.NewLine));
            }
        }
        /// <summary> Take a screenshot (supports multiple monitors) </summary>
        /// <returns>Bitmap of the screen, as at the time called</returns>
        public Bitmap TakeScreenShot()
        {
            if (ExceptionReporter.IsRunningMono())
            {
                return(null);
            }

            var rectangle = Rectangle.Empty;

            foreach (var screen in Screen.AllScreens)
            {
                rectangle = Rectangle.Union(rectangle, screen.Bounds);
            }

            var bitmap = new Bitmap(rectangle.Width, rectangle.Height, PixelFormat.Format32bppArgb);

            using (var graphics = Graphics.FromImage(bitmap))
            {
                graphics.CopyFromScreen(rectangle.X, rectangle.Y, 0, 0, rectangle.Size, CopyPixelOperation.SourceCopy);
            }

            return(bitmap);
        }