public async Task ReturnsLeaderboardEntries()
            {
                // Arrange
                var handler                  = new MockHttpMessageHandler();
                var telemetryClient          = new TelemetryClient();
                var steamCommunityDataClient = new SteamCommunityDataClient(handler, telemetryClient);

                handler
                .When("http://steamcommunity.com/stats/247080/leaderboards/2047387/?xml=1")
                .Respond(new StringContent(Resources.LeaderboardEntries, Encoding.UTF8, "text/xml"));
                var appId         = 247080U;
                var leaderboardId = 2047387;

                // Act
                var leaderboardEntriesEnvelope = await steamCommunityDataClient.GetLeaderboardEntriesAsync(appId, leaderboardId);

                // Assert
                var entries = leaderboardEntriesEnvelope.Entries;

                Assert.Equal(317, entries.Count);
                var entry = entries.First();

                Assert.Equal(76561197998799529, entry.SteamId);
                Assert.Equal(134377, entry.Score);
                Assert.Equal(1, entry.Rank);
                Assert.Equal(849347241492683863UL, entry.UgcId);
                Assert.Equal("0b00000001000000", entry.Details);
            }
            public async Task ReturnsLeaderboards()
            {
                // Arrange
                var handler                  = new MockHttpMessageHandler();
                var telemetryClient          = new TelemetryClient();
                var steamCommunityDataClient = new SteamCommunityDataClient(handler, telemetryClient);

                handler
                .When("http://steamcommunity.com/stats/247080/leaderboards/?xml=1")
                .Respond(new StringContent(Resources.Leaderboards, Encoding.UTF8, "text/xml"));
                var appId = 247080U;

                // Act
                var leaderboardsEnvelope = await steamCommunityDataClient.GetLeaderboardsAsync(appId);

                // Assert
                Assert.Equal(411, leaderboardsEnvelope.Leaderboards.Count);
                var leaderboard = leaderboardsEnvelope.Leaderboards.First();

                Assert.Equal("http://steamcommunity.com/stats/247080/leaderboards/2047387/?xml=1", leaderboard.Url);
                Assert.Equal(2047387, leaderboard.LeaderboardId);
                Assert.Equal("DLC HARDCORE All Chars DLC_PROD", leaderboard.Name);
                Assert.Equal("All Characters (DLC) Score (Amplified)", leaderboard.DisplayName);
                Assert.Equal(317, leaderboard.EntryCount);
                Assert.Equal(2, leaderboard.SortMethod);
                Assert.Equal(1, leaderboard.DisplayType);
            }
            public void ExIsIOExceptionAndInnerExceptionIsNotSocketException_ReturnsFalse()
            {
                // Arrange
                var ex = new IOException(null);

                // Act
                var isTransient = SteamCommunityDataClient.IsTransient(ex);

                // Assert
                Assert.False(isTransient);
            }
            public void ExIsHttpRequestStatusExceptionAndStatusCodeIsTransient_ReturnsTrue(HttpStatusCode statusCode)
            {
                // Arrange
                var ex = new HttpRequestStatusException(statusCode, new Uri("http://example.org"));

                // Act
                var isTransient = SteamCommunityDataClient.IsTransient(ex);

                // Assert
                Assert.True(isTransient);
            }
            public void ReturnsFalse()
            {
                // Arrange
                var ex = new Exception();

                // Act
                var isTransient = SteamCommunityDataClient.IsTransient(ex);

                // Assert
                Assert.False(isTransient);
            }
            public void DisposesHttpClient()
            {
                // Arrange
                var client = new SteamCommunityDataClient(handler, true, telemetryClient);

                // Act
                client.Dispose();

                // Assert
                Assert.Equal(1, handler.DisposeCount);
            }
            public void ExIsIOExceptionAndInnerExceptionIsSocketExceptionAndSocketErrorCodeIsNotTransient_ReturnsFalse()
            {
                // Arrange
                var innerException = new SocketException((int)SocketError.SocketNotSupported);
                var ex             = new IOException(null, innerException);

                // Act
                var isTransient = SteamCommunityDataClient.IsTransient(ex);

                // Assert
                Assert.False(isTransient);
            }
            public void ExIsIOExceptionAndInnerExceptionIsSocketExceptionAndSocketErrorCodeIsTransient_ReturnsTrue(int errorCode)
            {
                // Arrange
                var innerException = new SocketException(errorCode);
                var ex             = new IOException(null, innerException);

                // Act
                var isTransient = SteamCommunityDataClient.IsTransient(ex);

                // Assert
                Assert.True(isTransient);
            }
            public void ExIsHttpRequestStatusExceptionAndStatusCodeIsNotTransient_ReturnsFalse()
            {
                // Arrange
                var statusCode = HttpStatusCode.Forbidden;
                var ex         = new HttpRequestStatusException(statusCode, new Uri("http://example.org"));

                // Act
                var isTransient = SteamCommunityDataClient.IsTransient(ex);

                // Assert
                Assert.False(isTransient);
            }
            public void ReturnsSteamCommunityDataClient()
            {
                // Arrange
                var handler         = new MockHttpMessageHandler();
                var telemetryClient = new TelemetryClient();

                // Act
                var client = new SteamCommunityDataClient(handler, telemetryClient);

                // Assert
                Assert.IsAssignableFrom <SteamCommunityDataClient>(client);
            }
            public void ExIsHttpRequestExceptionAndInnerExceptionIsNotWebException_ReturnsFalse()
            {
                // Arrange
                var inner = new Exception();
                var ex    = new HttpRequestException(null, inner);

                // Act
                var isTransient = SteamCommunityDataClient.IsTransient(ex);

                // Assert
                Assert.False(isTransient);
            }
            public void ExIsHttpRequestExceptionAndInnerExceptionIsWebExceptionAndStatusIsTransient_ReturnsTrue(WebExceptionStatus status)
            {
                // Arrange
                var inner = new WebException(null, status);
                var ex    = new HttpRequestException(null, inner);

                // Act
                var isTransient = SteamCommunityDataClient.IsTransient(ex);

                // Assert
                Assert.True(isTransient);
            }
            public void ExIsHttpRequestExceptionAndInnerExceptionIsWebExceptionAndStatusIsNotTransient_ReturnsFalse()
            {
                // Arrange
                var status = WebExceptionStatus.NameResolutionFailure;
                var inner  = new WebException(null, status);
                var ex     = new HttpRequestException(null, inner);

                // Act
                var isTransient = SteamCommunityDataClient.IsTransient(ex);

                // Assert
                Assert.False(isTransient);
            }
 public SteamCommunityDataClientTests()
 {
     steamCommunityDataClient = new SteamCommunityDataClient(handler, telemetryClient);
 }