Ejemplo n.º 1
0
        public void Performance_counter_with_instance_name()
        {
            var performanceCounter = new PerformanceCounter("Process", "Private Bytes", Process.GetCurrentProcess().ProcessName);

            var monitor = new PerformanceCounterMonitor(MonitorConfig.Build("Test"),
                                                        PerformanceCounterConfig.Build("Process", "Private Bytes", Process.GetCurrentProcess().ProcessName));

            monitor.GetValue()
            .Should()
            .BeGreaterThan(0)
            .And.BeApproximately(performanceCounter.NextValue(), 1000000,
                                 "Because memory usage can change between the two values");
        }
Ejemplo n.º 2
0
        public void Performance_counter_without_instance_name()
        {
            var performanceCounter = new PerformanceCounter("Memory", "Available Bytes");

            var monitor = new PerformanceCounterMonitor(MonitorConfig.Build("Test"),
                                                        PerformanceCounterConfig.Build("Memory", "Available Bytes"));

            monitor.GetValue()
            .Should()
            .BeGreaterThan(0)
            .And.BeApproximately(performanceCounter.NextValue(), 1000000,
                                 "Because memory usage can change between the two values");
        }