PackageDownloadsDetail() public method

public PackageDownloadsDetail ( string id, string version, string groupby ) : Task
id string
version string
groupby string
return Task
        public async void Statistics_By_Client_Operation_ValidateModel()
        {
            string PackageId      = "A";
            string PackageVersion = "2.0";

            var fakeReportService = new Mock <IReportService>();

            var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));

            TestUtility.SetupUrlHelperForUrlGeneration(controller);

            var model = (StatisticsPackagesViewModel)((ViewResult)await controller.PackageDownloadsDetail(PackageId, PackageVersion, new string[] { "ClientName" })).Model;

            Assert.Equal(PackageId, model.PackageId);
            Assert.Equal(PackageVersion, model.PackageVersion);
        }
        public async void Statistics_By_Client_Operation_ValidateReportStructureAndAvailability()
        {
            string PackageId      = "A";
            string PackageVersion = "2.0";

            JObject report = new JObject
            {
                { "Downloads", 603 },
                { "Items", new JArray
                  {
                      new JObject
                      {
                          { "Version", "1.0" },
                          { "Downloads", 101 },
                          { "Items", new JArray
                            {
                                new JObject
                                {
                                    { "ClientName", "NuGet" },
                                    { "ClientVersion", "2.1" },
                                    { "Operation", "Install" },
                                    { "Downloads", 101 }
                                },
                            } }
                      },
                      new JObject
                      {
                          { "Version", "2.0" },
                          { "Downloads", 502 },
                          { "Items", new JArray
                            {
                                new JObject
                                {
                                    { "ClientName", "NuGet" },
                                    { "ClientVersion", "2.1" },
                                    { "Operation", "Install" },
                                    { "Downloads", 201 }
                                },
                                new JObject
                                {
                                    { "ClientName", "NuGet" },
                                    { "ClientVersion", "2.1" },
                                    { "Operation", "unknow" },
                                    { "Downloads", 301 }
                                }
                            } }
                      },
                  } }
            };

            var fakeReport = report.ToString();

            var fakeReportService = new Mock <IReportService>();

            string reportName = "recentpopularity/RecentPopularityDetail_" + PackageId + ".json";

            reportName = reportName.ToLowerInvariant();

            var updatedUtc = new DateTime(2001, 01, 01, 10, 20, 30);

            fakeReportService.Setup(x => x.Load(reportName)).Returns(Task.FromResult(new StatisticsReport(fakeReport, updatedUtc)));

            var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));

            TestUtility.SetupUrlHelperForUrlGeneration(controller, new Uri("http://nuget.org"));

            var model = (StatisticsPackagesViewModel)((ViewResult)await controller.PackageDownloadsDetail(PackageId, PackageVersion, new string[] { "ClientName" })).Model;

            int sum = 0;

            foreach (var row in model.Report.Table)
            {
                sum += int.Parse(row[row.GetLength(0) - 1].Data);
            }

            Assert.Equal(502, sum);
            Assert.Equal("502", model.Report.Total);
            Assert.True(model.LastUpdatedUtc.HasValue);
            Assert.Equal(updatedUtc, model.LastUpdatedUtc.Value);
        }
        public async void Statistics_By_Client_Operation_ValidateReportStructureAndAvailability()
        {
            string PackageId = "A";
            string PackageVersion = "2.0";

            JObject report = new JObject
            {
                { "Downloads", 603 },
                { "Items", new JArray
                    {
                        new JObject
                        {
                            { "Version", "1.0" },
                            { "Downloads", 101 },
                            { "Items", new JArray 
                                {
                                    new JObject
                                    {
                                        { "ClientName", "NuGet" },
                                        { "ClientVersion", "2.1" },
                                        { "Operation", "Install" },
                                        { "Downloads", 101 }
                                    },
                                }
                            }
                        },
                        new JObject
                        {
                            { "Version", "2.0" },
                            { "Downloads", 502 },
                            { "Items", new JArray
                                {
                                    new JObject
                                    {
                                        { "ClientName", "NuGet" },
                                        { "ClientVersion", "2.1" },
                                        { "Operation", "Install" },
                                        { "Downloads", 201 }
                                    },
                                    new JObject
                                    {
                                        { "ClientName", "NuGet" },
                                        { "ClientVersion", "2.1" },
                                        { "Operation", "unknow" },
                                        { "Downloads", 301 }
                                    }
                                }
                            }
                        },
                    }
                }
            };

            var fakeReport = report.ToString();

            var fakeReportService = new Mock<IReportService>();

            string reportName = "RecentPopularityDetail_" + PackageId + ".json";
            reportName = reportName.ToLowerInvariant();

            var updatedUtc = new DateTime(2001, 01, 01, 10, 20, 30);
            fakeReportService.Setup(x => x.Load(reportName)).Returns(Task.FromResult(new StatisticsReport(fakeReport, updatedUtc)));

            var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));

            TestUtility.SetupUrlHelperForUrlGeneration(controller, new Uri("http://nuget.org"));

            var model = (StatisticsPackagesViewModel)((ViewResult)await controller.PackageDownloadsDetail(PackageId, PackageVersion, new string[] { "ClientName" })).Model;

            int sum = 0;

            foreach (var row in model.Report.Table)
            {
                sum += int.Parse(row[row.GetLength(0) - 1].Data);
            }

            Assert.Equal(502, sum);
            Assert.Equal("502", model.Report.Total);
            Assert.True(model.LastUpdatedUtc.HasValue);
            Assert.Equal(updatedUtc, model.LastUpdatedUtc.Value);
        }