public PackageDownloadsByVersion ( string id, string groupby ) : Task |
||
id | string | |
groupby | string | |
리턴 | Task |
public async void StatisticsHomePage_Per_Package_ValidateModel() { string PackageId = "A"; var fakeReportService = new Mock <IReportService>(); var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object)); TestUtility.SetupUrlHelperForUrlGeneration(controller); var model = (StatisticsPackagesViewModel)((ViewResult)await controller.PackageDownloadsByVersion(PackageId, new[] { GalleryConstants.StatisticsDimensions.Version })).Model; Assert.Equal(PackageId, model.PackageId); }
public async void StatisticsHomePage_Per_Package_ValidateReportStructureAndAvailability() { string PackageId = "A"; var fakeReport = "[{\"PackageVersion\":\"1.0\",\"Downloads\":101},{\"PackageVersion\":\"2.1\",\"Downloads\":202}]"; var fakeReportService = new Mock<IReportService>(); fakeReportService.Setup(x => x.Load("RecentPopularity_" + PackageId + ".json")).Returns(Task.FromResult(fakeReport)); var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object)); var model = (StatisticsPackagesViewModel)((ViewResult) await controller.PackageDownloadsByVersion(PackageId)).Model; int sum = 0; foreach (var item in model.PackageDownloadsByVersion) { sum += item.Downloads; } Assert.Equal<int>(303, sum); Assert.Equal<int>(303, model.TotalPackageDownloads); }
public async void StatisticsHomePage_Per_Package_ValidateReportStructureAndAvailability() { string PackageId = "A"; 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.PackageDownloadsByVersion(PackageId, new string[] { "Version" })).Model; int sum = 0; foreach (var row in model.Report.Table) { sum += int.Parse(row[row.GetLength(0) - 1].Data); } Assert.Equal(603, sum); Assert.Equal("603", model.Report.Total); Assert.True(model.LastUpdatedUtc.HasValue); Assert.Equal(updatedUtc, model.LastUpdatedUtc.Value); }
public async void StatisticsHomePage_Per_Package_ValidateReportStructureAndAvailability() { string PackageId = "A"; 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.PackageDownloadsByVersion(PackageId, new string[] { "Version" })).Model; int sum = 0; foreach (var row in model.Report.Table) { sum += int.Parse(row[row.GetLength(0) - 1].Data); } Assert.Equal(603, sum); Assert.Equal("603", model.Report.Total); Assert.True(model.LastUpdatedUtc.HasValue); Assert.Equal(updatedUtc, model.LastUpdatedUtc.Value); }