public async Task QueryResult() { var querier = new AppInsightClient(appId, apiKey); var result = await querier.QueryAppInsights(eventType, null, null); Assert.IsNotNull(result); }
public async Task InitializationCanOccurOnlyOnce() { // arrange // act await AppInsightClient.InitializeAsync(TestKey, TestUserKey); // assert AppInsightClient.IsInitialized.Should().BeTrue(); _logMock.Verify(t => t.Warning("Client can only be initialized once"), Times.Once); }
public async Task SetupWithCheckThatPostCannotOccurPriorToInitialization() { // arrange _logMock = LoggerFixture.SetupLogCatcher(); // act AppInsightClient.TrackEvent("BeforeStart"); // assert _logMock.Verify(t => t.Warning("Cannot track telemetry - Client has not been initialized"), Times.Once); await AppInsightClient.InitializeAsync(TestKey, TestUserKey); }
public void PublishingAnEventWorksCorrectly() { // arrange using (var httpDummy = new HttpMockFixture()) { httpDummy.SetupServer(); // act AppInsightClient.TrackEvent("Test"); AppInsightClient.Flush(); // assert httpDummy.PathWasCalled.Should().BeTrue(); } }
public void ExternalDependencyCallEventIsPublishedCorrectly() { // arrange using (var httpDummy = new HttpMockFixture()) { httpDummy.SetupServer(); // act AppInsightClient.TrackDependency("Test", "testCommand", DateTimeOffset.Now, TimeSpan.Zero, true); AppInsightClient.Flush(); // assert httpDummy.PathWasCalled.Should().BeTrue(); } }
public void TrackingRequestWorksCorrectly() { // arrange using (var httpDummy = new HttpMockFixture()) { httpDummy.SetupServer(); // act AppInsightClient.TrackRequest("Test", DateTimeOffset.Now, TimeSpan.Zero, "202", true); AppInsightClient.Flush(); // assert httpDummy.PathWasCalled.Should().BeTrue(); } }
public void TrackingPageViewWorksCorrectly() { // arrange using (var httpDummy = new HttpMockFixture()) { httpDummy.SetupServer(); // act AppInsightClient.TrackPageView("Test Page"); AppInsightClient.Flush(); // assert httpDummy.PathWasCalled.Should().BeTrue(); } }
public void TrackingExceptionWorksCorrectly() { // arrange using (var httpDummy = new HttpMockFixture()) { httpDummy.SetupServer(); // act AppInsightClient.TrackException(new Exception("Oh no!")); AppInsightClient.Flush(); // assert httpDummy.PathWasCalled.Should().BeTrue(); } }
public void TackingATaceWithSeverityLevelWorksCorrectly() { // arrange using (var httpDummy = new HttpMockFixture()) { httpDummy.SetupServer(); // act AppInsightClient.TrackTrace("Test", SeverityLevel.Critical); AppInsightClient.Flush(); // assert httpDummy.PathWasCalled.Should().BeTrue(); } }
public void PublishingMetricWorksCorrectly() { // arrange using (var httpDummy = new HttpMockFixture()) { httpDummy.SetupServer(); // act AppInsightClient.TrackMetric("Test", 12.2); AppInsightClient.Flush(); // assert httpDummy.CallCount.Should().Be(1); } }
public void MetricIsNotPublishedIfPublishingIsDisabled() { // arrange using (var httpDummy = new HttpMockFixture()) { httpDummy.SetupServer(); AppInsightClient.TrackTelemetry = false; // act AppInsightClient.TrackMetric("Test", 10.5); AppInsightClient.Flush(); // assert httpDummy.PathWasCalled.Should().BeFalse(); AppInsightClient.TrackTelemetry = true; } }