Пример #1
0
        public async Task QueryResult()
        {
            var querier = new AppInsightClient(appId, apiKey);



            var result = await querier.QueryAppInsights(eventType, null, null);

            Assert.IsNotNull(result);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        public void PublishingAnEventWorksCorrectly()
        {
            // arrange
            using (var httpDummy = new HttpMockFixture())
            {
                httpDummy.SetupServer();

                // act
                AppInsightClient.TrackEvent("Test");
                AppInsightClient.Flush();

                // assert
                httpDummy.PathWasCalled.Should().BeTrue();
            }
        }
Пример #5
0
        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();
            }
        }
Пример #6
0
        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();
            }
        }
Пример #7
0
        public void TrackingPageViewWorksCorrectly()
        {
            // arrange
            using (var httpDummy = new HttpMockFixture())
            {
                httpDummy.SetupServer();

                // act
                AppInsightClient.TrackPageView("Test Page");
                AppInsightClient.Flush();

                // assert
                httpDummy.PathWasCalled.Should().BeTrue();
            }
        }
Пример #8
0
        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();
            }
        }
Пример #9
0
        public void TackingATaceWithSeverityLevelWorksCorrectly()
        {
            // arrange
            using (var httpDummy = new HttpMockFixture())
            {
                httpDummy.SetupServer();

                // act
                AppInsightClient.TrackTrace("Test", SeverityLevel.Critical);
                AppInsightClient.Flush();

                // assert
                httpDummy.PathWasCalled.Should().BeTrue();
            }
        }
Пример #10
0
        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);
            }
        }
Пример #11
0
        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;
            }
        }