public void QuickPulseTelemetryModuleInitializesServiceClientFromConfiguration() { // ARRANGE var module = new QuickPulseTelemetryModule(null, null, null, null, null, null); module.QuickPulseServiceEndpoint = "https://test.com/api"; // ACT module.Initialize(new TelemetryConfiguration()); // ASSERT Assert.IsInstanceOfType(QuickPulseTestHelper.GetPrivateField(module, "serviceClient"), typeof(QuickPulseServiceClient)); }
public void QuickPulseTelemetryModuleInitializesServiceClientFromDefault() { // ARRANGE var module = new QuickPulseTelemetryModule(null, null, null, null, null, null); // ACT // do not provide module configuration, force default service client module.Initialize(new TelemetryConfiguration()); // ASSERT IQuickPulseServiceClient serviceClient = (IQuickPulseServiceClient)QuickPulseTestHelper.GetPrivateField(module, "serviceClient"); Assert.IsInstanceOfType(serviceClient, typeof(QuickPulseServiceClient)); Assert.AreEqual(QuickPulseDefaults.ServiceEndpoint, serviceClient.ServiceUri); }
public void QuickPulseTopCpuCollectorCleansUpStateWhenProcessesGoAway() { // ARRANGE var processProvider = new QuickPulseProcessProviderMock(); var baseProcessorTime = TimeSpan.FromSeconds(100); processProvider.Processes = new List <QuickPulseProcess>() { new QuickPulseProcess("Process1", baseProcessorTime), new QuickPulseProcess("Process2", baseProcessorTime), new QuickPulseProcess("Process3", baseProcessorTime), new QuickPulseProcess("Process4", baseProcessorTime), new QuickPulseProcess("Process5", baseProcessorTime), }; var timeProvider = new ClockMock(); var collector = new QuickPulseTopCpuCollector(timeProvider, processProvider); var processDictionary = QuickPulseTestHelper.GetPrivateField(collector, "processObservations") as Dictionary <string, TimeSpan>; // ACT collector.GetTopProcessesByCpu(3); int itemCount1 = processDictionary.Count; timeProvider.FastForward(TimeSpan.FromSeconds(1)); processProvider.Processes = new List <QuickPulseProcess>() { new QuickPulseProcess("Process1", baseProcessorTime) }; collector.GetTopProcessesByCpu(3); int itemCount3 = processDictionary.Count; // ASSERT Assert.AreEqual(5, itemCount1); Assert.AreEqual(1, itemCount3); }