コード例 #1
0
 private void StartServer()
 {
     if (HttpMock == null)
     {
         HttpMock = new HttpMockFixture();
         HttpMock.SetupServer(Authority);
     }
 }
コード例 #2
0
        public void PublishingAnEventWorksCorrectly()
        {
            // arrange
            using (var httpDummy = new HttpMockFixture())
            {
                httpDummy.SetupServer();

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

                // assert
                httpDummy.PathWasCalled.Should().BeTrue();
            }
        }
コード例 #3
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();
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
0
        public void TrackingPageViewWorksCorrectly()
        {
            // arrange
            using (var httpDummy = new HttpMockFixture())
            {
                httpDummy.SetupServer();

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

                // assert
                httpDummy.PathWasCalled.Should().BeTrue();
            }
        }
コード例 #6
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();
            }
        }
コード例 #7
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();
            }
        }
コード例 #8
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);
            }
        }
コード例 #9
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;
            }
        }