コード例 #1
0
        public async Task OptOut_WhenMoreThanThreeFailures_ReturnsFalse()
        {
            // Arrange
            var httpHandler = new FakeHttpMessageHandler(_ => throw new Exception());
            var client      = new TelemetryClient(httpHandler, 3, TimeSpan.FromMilliseconds(1));

            // Act
            var result = await client.OptOutAsync(new TelemetryPayload());

            // Assert
            result.Should().BeFalse();
        }
コード例 #2
0
        public async Task OptOut_WhenSuccess_ReturnsTrue()
        {
            // Arrange
            var response    = new HttpResponseMessage(System.Net.HttpStatusCode.Created);
            var httpHandler = new FakeHttpMessageHandler(_ => response);
            var client      = new TelemetryClient(httpHandler);

            // Act
            var result = await client.OptOutAsync(new TelemetryPayload());

            // Assert
            result.Should().BeTrue();
        }