public void cpu_value_is_formatted_when_diagnostics_service_pumps_cpu()
        {
            // ARRANGE
            var viewModel = new DiagnosticsViewModel(_diagnosticService.Object, SchedulerService);

            // ACT
            _cpuSubject.OnNext(42);

            TestScheduler.AdvanceBy(TimeSpan.FromSeconds(1));

            // ASSERT
            Assert.That(viewModel.Cpu, Is.EqualTo("CPU: 42 %"));
        }
示例#2
0
        public async Task <IActionResult> Index()
        {
            var localAddresses = new string[] { "127.0.0.1", "::1", HttpContext.Connection.LocalIpAddress.ToString() };

            if (!localAddresses.Contains(HttpContext.Connection.RemoteIpAddress.ToString()))
            {
                return(NotFound());
            }

            var model = new DiagnosticsViewModel(await HttpContext.AuthenticateAsync());

            return(View(model));
        }
        public void managed_memory_value_is_default_value_when_diagnostics_service_memory_errors()
        {
            // ARRANGE
            var viewModel = new DiagnosticsViewModel(_diagnosticService.Object, SchedulerService);

            // ACT
            _memorySubject.OnError(new Exception("blah!"));

            TestScheduler.AdvanceBy(TimeSpan.FromSeconds(1));

            // ASSERT
            Assert.That(viewModel.ManagedMemory, Is.EqualTo(Constants.UI.Diagnostics.DefaultManagedMemoryString));
        }
示例#4
0
        public void log_is_empty_when_diagnostics_service_log_errors()
        {
            // ARRANGE
            var viewModel = new DiagnosticsViewModel(_diagnosticService.Object, _schedulerService);

            // ACT
            _logSubject.OnError(new Exception("blah!"));

            _testScheduler.AdvanceBy(TimeSpan.FromSeconds(1));

            // ASSERT
            Assert.That(viewModel.Log, Is.Empty);
        }
示例#5
0
        public void cpu_value_is_default_value_when_diagnostics_service_cpu_errors()
        {
            // ARRANGE
            var viewModel = new DiagnosticsViewModel(_diagnosticService.Object, _schedulerService);

            // ACT
            _cpuSubject.OnError(new Exception("blah!"));

            _testScheduler.AdvanceBy(TimeSpan.FromSeconds(1));

            // ASSERT
            Assert.That(viewModel.Cpu, Is.EqualTo(Constants.DefaultCpuString));
        }
示例#6
0
        public void rps_value_is_formatted_when_diagnostics_service_pumps_rps()
        {
            // ARRANGE
            var viewModel = new DiagnosticsViewModel(_diagnosticService.Object, _schedulerService);

            // ACT
            _rpsSubject.OnNext(66);

            _testScheduler.AdvanceBy(TimeSpan.FromSeconds(2));

            // ASSERT
            Assert.That(viewModel.Rps, Is.EqualTo("Render: 66 RPS"));
        }
        public void managed_memory_value_is_formatted_when_diagnostics_service_pumps_memory()
        {
            // ARRANGE
            const decimal managedMemory = 1024 * 1000 * 4;
            const decimal totalMemory   = 1024 * 1000 * 42;

            var viewModel = new DiagnosticsViewModel(_diagnosticService.Object, SchedulerService);

            // ACT
            _memorySubject.OnNext(new Memory(totalMemory, managedMemory));

            TestScheduler.AdvanceBy(TimeSpan.FromSeconds(1));

            // ASSERT
            Assert.That(viewModel.ManagedMemory, Is.EqualTo("Managed Memory: 4.00 Mb"));
        }
        public void disposing_unsubscribes_diagnostics_service_stream()
        {
            // ARRANGE
            const decimal managedMemory = 1024 * 1000 * 4;
            const decimal totalMemory   = 1024 * 1000 * 42;

            var viewModel = new DiagnosticsViewModel(_diagnosticService.Object, SchedulerService);

            // ACT
            viewModel.Dispose();

            _memorySubject.OnNext(new Memory(totalMemory, managedMemory));
            _cpuSubject.OnNext(42);

            // ASSERT
            Assert.That(viewModel.Cpu, Is.EqualTo(Constants.UI.Diagnostics.DefaultCpuString));
            Assert.That(viewModel.TotalMemory, Is.EqualTo(Constants.UI.Diagnostics.DefaultTotalMemoryString));
            Assert.That(viewModel.ManagedMemory, Is.EqualTo(Constants.UI.Diagnostics.DefaultManagedMemoryString));
        }
示例#9
0
        public ActionResult Index()
        {
            var model = new DiagnosticsViewModel();

            var envVarsBuilder = new StringBuilder();

            foreach (var nameValue in Environment.GetEnvironmentVariables().Cast <DictionaryEntry>().OrderBy(nv => nv.Key))
            {
                envVarsBuilder.AppendLine($"{nameValue.Key}={nameValue.Value}");
            }
            model.EnvironmentVariables = envVarsBuilder.ToString();

            model.LogFilePath = Environment.GetEnvironmentVariable(LoggingConfig.LogFileEnvVarName);

            if (model.LogFilePath != null)
            {
                try
                {
                    model.LogFileContent = System.IO.File.ReadAllText(model.LogFilePath);
                }
                catch (Exception ex)
                {
                    model.LogFileReadException = ex;
                }
            }

            var inMemoryLogContentBuilder = new StringBuilder();

            foreach (var line in LoggingConfig.LogMemoryTarget.Logs)
            {
                inMemoryLogContentBuilder.AppendLine(line);
            }
            model.InMemoryLogContent = inMemoryLogContentBuilder.ToString();

            model.LoggingSubsystemInternalLogContent = InternalLogger.LogWriter?.ToString();

            return(View(model));
        }
示例#10
0
        public void exposes_log_messages()
        {
            // ARRANGE
            LogHelper.ReconfigureLoggerToLevel(LogLevel.Error);
            var logger = LogManager.GetCurrentClassLogger();

            var message1 = string.Format("Message 1 - {0}", Guid.NewGuid());
            var message2 = string.Format("Message 2 - {0}", Guid.NewGuid());

            var viewModel = new DiagnosticsViewModel(_diagnosticService.Object, _schedulerService);

            _logSubject.OnNext(message1);
            _logSubject.OnNext(message2);

            _testScheduler.AdvanceBy(Constants.DiagnosticsLogInterval + Constants.DiagnosticsLogInterval);

            //ACT
            var log = viewModel.Log.ToArray();

            //ASSERT
            Assert.That(log.Count(x => x.Contains(message1)) == 1, Is.True);
            Assert.That(log.Count(x => x.Contains(message2)) == 1, Is.True);
        }
示例#11
0
 public static DiagnosticsWindow GetDiagnosticsWindow(DiagnosticsViewModel viewModel)
 {
     return(new DiagnosticsWindow(viewModel));
 }
        public async Task <IActionResult> Index()
        {
            var model = new DiagnosticsViewModel(await HttpContext.AuthenticateAsync());

            return(View(model));
        }
示例#13
0
 public MainViewModel(Child1ViewModel child1, Child2ViewModel child2, DiagnosticsViewModel diagnosticsViewModel)
 {
     Diagnostics = diagnosticsViewModel;
     Child1      = child1;
     Child2      = child2;
 }