﻿using System;
using System.Threading.Tasks;
using FluentAssertions;
using Xunit;
using Auth0.Tests.Shared;

namespace Auth0.ManagementApi.IntegrationTests
{
    public class StatsTests : TestBase
    {
        [Fact(Skip = "Inactivity causes these to fail")]
        public async Task Test_stats_sequence()
        {
            string token = await GenerateManagementApiToken();

            using (var apiClient = new ManagementApiClient(token, GetVariable("AUTH0_MANAGEMENT_API_URL")))
            {
                // Get stats for the past 10 days
                var dailyStats = await apiClient.Stats.GetDailyStatsAsync(DateTime.Now.AddDays(-100), DateTime.Now);
                dailyStats.Should().NotBeNull();
                dailyStats.Count.Should().BeGreaterOrEqualTo(1);

                // Get the active users
                var activeUsers = await apiClient.Stats.GetActiveUsersAsync();
                activeUsers.Should().BeGreaterOrEqualTo(1); // These integration tests themselves trigger non-zero values
            }
        }
    }
}
﻿using System;
using System.Threading.Tasks;
using FluentAssertions;
using Xunit;
using Auth0.Tests.Shared;
using System.Linq;

namespace Auth0.ManagementApi.IntegrationTests
{
    public class StatsTests : TestBase
    {
        [Fact]
        public async Task Daily_Stats_Returns_Values()
        {
            string token = await GenerateManagementApiToken();

            using (var apiClient = new ManagementApiClient(token, GetVariable("AUTH0_MANAGEMENT_API_URL")))
            {
                var dailyStats = await apiClient.Stats.GetDailyStatsAsync(DateTime.Now.AddDays(-100), DateTime.Now);
                dailyStats.Should().NotBeNull();
                dailyStats.Count.Should().BeGreaterOrEqualTo(1);
                dailyStats.Max(d => d.Logins).Should().BeGreaterThan(0);
            }
        }

        [Fact(Skip = "Inactivity causes these to fail")]
        public async Task Active_Users_Returns_Values()
        {
            string token = await GenerateManagementApiToken();

            using (var apiClient = new ManagementApiClient(token, GetVariable("AUTH0_MANAGEMENT_API_URL")))
            {
                var activeUsers = await apiClient.Stats.GetActiveUsersAsync();
                activeUsers.Should().BeGreaterThan(0);
            }
        }
    }
}
Break failing test into working & non-working parts
Break failing test into working & non-working parts
