Skip to content

Commit facdcb7

Browse files
committed
[GH Usage] Fixed tests
1 parent 09dc4b3 commit facdcb7

2 files changed

Lines changed: 15 additions & 69 deletions

File tree

tests/NuGetGallery.Core.Facts/GitHub/GitHubUsageConfigurationFacts.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void MultiReposSameDependency()
7474

7575
// Make sure they're alphabetically ordered since they have the same star count!
7676
Assert.Equal(expectedRepo2, nupkgInformation.Repos.First());
77-
Assert.Equal(expectedRepo1, nupkgInformation.Repos[1]);
77+
Assert.Equal(expectedRepo1, nupkgInformation.Repos.ToList()[1]);
7878
}
7979

8080
[Fact]

tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs

Lines changed: 14 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ private static PackagesController CreateController(
158158
contentObjectService
159159
.Setup(x => x.SymbolsConfiguration.IsSymbolsUploadEnabledForUser(It.IsAny<User>()))
160160
.Returns(false);
161+
contentObjectService
162+
.SetupGet(c => c.GitHubUsageConfiguration)
163+
.Returns(new GitHubUsageConfiguration(Array.Empty<RepositoryInformation>()));
161164
}
162165

163166
if (symbolPackageUploadService == null)
@@ -504,17 +507,12 @@ private async Task<ActionResult> GetActionResultForPackageStatusAsync(
504507
var deprecationService = new Mock<IPackageDeprecationService>();
505508
var httpContext = new Mock<HttpContextBase>();
506509
var httpCachePolicy = new Mock<HttpCachePolicyBase>();
507-
var contentObjectService = new Mock<IContentObjectService>();
508-
contentObjectService
509-
.SetupGet(c => c.GitHubUsageConfiguration)
510-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
511510

512511
var controller = CreateController(
513512
GetConfigurationService(),
514513
packageService: packageService,
515514
httpContext: httpContext,
516-
deprecationService: deprecationService,
517-
contentObjectService: contentObjectService);
515+
deprecationService: deprecationService);
518516
controller.SetCurrentUser(currentUser);
519517

520518
httpContext.Setup(c => c.Response.Cache).Returns(httpCachePolicy.Object);
@@ -637,18 +635,13 @@ private async Task CheckValidPackage(User currentUser, User owner)
637635
var indexingService = new Mock<IIndexingService>();
638636
var httpContext = new Mock<HttpContextBase>();
639637
var httpCachePolicy = new Mock<HttpCachePolicyBase>();
640-
var contentObjectService = new Mock<IContentObjectService>();
641-
contentObjectService
642-
.SetupGet(c => c.GitHubUsageConfiguration)
643-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
644638

645639
var controller = CreateController(
646640
GetConfigurationService(),
647641
packageService: packageService,
648642
indexingService: indexingService,
649643
httpContext: httpContext,
650-
deprecationService: deprecationService,
651-
contentObjectService: contentObjectService);
644+
deprecationService: deprecationService);
652645
controller.SetCurrentUser(currentUser);
653646
httpContext.Setup(c => c.Response.Cache).Returns(httpCachePolicy.Object);
654647
var title = "A test package!";
@@ -700,17 +693,12 @@ public async Task GivenAnAbsoluteLatestVersionItReturnsTheFirstLatestSemVer2()
700693
var packageService = new Mock<IPackageService>();
701694
var indexingService = new Mock<IIndexingService>();
702695
var deprecationService = new Mock<IPackageDeprecationService>();
703-
var contentObjectService = new Mock<IContentObjectService>();
704-
contentObjectService
705-
.SetupGet(c => c.GitHubUsageConfiguration)
706-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
707696

708697
var controller = CreateController(
709698
GetConfigurationService(),
710699
packageService: packageService,
711700
indexingService: indexingService,
712-
deprecationService: deprecationService,
713-
contentObjectService: contentObjectService);
701+
deprecationService: deprecationService);
714702
controller.SetCurrentUser(TestUtility.FakeUser);
715703

716704
var id = "Foo";
@@ -785,17 +773,12 @@ public async Task GivenAnAbsoluteLatestVersionAndNoLatestSemVer2ItFiltersTheList
785773
var packageService = new Mock<IPackageService>();
786774
var indexingService = new Mock<IIndexingService>();
787775
var deprecationService = new Mock<IPackageDeprecationService>();
788-
var contentObjectService = new Mock<IContentObjectService>();
789-
contentObjectService
790-
.SetupGet(c => c.GitHubUsageConfiguration)
791-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
792776

793777
var controller = CreateController(
794778
GetConfigurationService(),
795779
packageService: packageService,
796780
indexingService: indexingService,
797-
deprecationService: deprecationService,
798-
contentObjectService: contentObjectService);
781+
deprecationService: deprecationService);
799782
controller.SetCurrentUser(TestUtility.FakeUser);
800783

801784
var id = "Foo";
@@ -847,20 +830,14 @@ public async Task GivenAValidPackageWithNoVersionThatTheCurrentUserDoesNotOwnItD
847830
var packageService = new Mock<IPackageService>();
848831
var indexingService = new Mock<IIndexingService>();
849832
var deprecationService = new Mock<IPackageDeprecationService>();
850-
var contentObjectService = new Mock<IContentObjectService>();
851-
contentObjectService
852-
.SetupGet(c => c.GitHubUsageConfiguration)
853-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
854833

855834
var controller = CreateController(
856835
GetConfigurationService(),
857836
packageService: packageService,
858837
indexingService: indexingService,
859-
deprecationService: deprecationService,
860-
contentObjectService: contentObjectService);
838+
deprecationService: deprecationService);
861839
controller.SetCurrentUser(TestUtility.FakeUser);
862840

863-
864841
var package = new Package()
865842
{
866843
PackageRegistration = new PackageRegistration()
@@ -959,18 +936,13 @@ private async Task<ActionResult> GetResultWithReadMe(string readMeHtml, bool has
959936
var indexingService = new Mock<IIndexingService>();
960937
var deprecationService = new Mock<IPackageDeprecationService>();
961938
var fileService = new Mock<IPackageFileService>();
962-
var contentObjectService = new Mock<IContentObjectService>();
963-
contentObjectService
964-
.SetupGet(c => c.GitHubUsageConfiguration)
965-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
966939

967940
var controller = CreateController(
968941
GetConfigurationService(),
969942
packageService: packageService,
970943
indexingService: indexingService,
971944
packageFileService: fileService,
972-
deprecationService: deprecationService,
973-
contentObjectService: contentObjectService);
945+
deprecationService: deprecationService);
974946
controller.SetCurrentUser(TestUtility.FakeUser);
975947

976948
var id = "Foo";
@@ -1023,19 +995,14 @@ public async Task GetsValidationIssues()
1023995
var indexingService = new Mock<IIndexingService>();
1024996
var fileService = new Mock<IPackageFileService>();
1025997
var validationService = new Mock<IValidationService>();
1026-
var contentObjectService = new Mock<IContentObjectService>();
1027-
contentObjectService
1028-
.SetupGet(c => c.GitHubUsageConfiguration)
1029-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
1030998

1031999
var controller = CreateController(
10321000
GetConfigurationService(),
10331001
packageService: packageService,
10341002
indexingService: indexingService,
10351003
packageFileService: fileService,
10361004
validationService: validationService,
1037-
deprecationService: deprecationService,
1038-
contentObjectService: contentObjectService);
1005+
deprecationService: deprecationService);
10391006
controller.SetCurrentUser(TestUtility.FakeUser);
10401007

10411008
var package = new Package()
@@ -1091,17 +1058,12 @@ public async Task ShowsAtomFeedIfEnabled(bool isAtomFeedEnabled)
10911058
var featureFlagService = new Mock<IFeatureFlagService>();
10921059
var packageService = new Mock<IPackageService>();
10931060
var deprecationService = new Mock<IPackageDeprecationService>();
1094-
var contentObjectService = new Mock<IContentObjectService>();
1095-
contentObjectService
1096-
.SetupGet(c => c.GitHubUsageConfiguration)
1097-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
10981061

10991062
var controller = CreateController(
11001063
GetConfigurationService(),
11011064
packageService: packageService,
11021065
featureFlagService: featureFlagService,
1103-
deprecationService: deprecationService,
1104-
contentObjectService: contentObjectService);
1066+
deprecationService: deprecationService);
11051067
controller.SetCurrentUser(TestUtility.FakeUser);
11061068

11071069
var id = "Foo";
@@ -1152,17 +1114,12 @@ public async Task DoesNotShowDeprecationToLoggedOutUsers(bool isDeprecationEnabl
11521114
var featureFlagService = new Mock<IFeatureFlagService>();
11531115
var packageService = new Mock<IPackageService>();
11541116
var deprecationService = new Mock<IPackageDeprecationService>();
1155-
var contentObjectService = new Mock<IContentObjectService>();
1156-
contentObjectService
1157-
.SetupGet(c => c.GitHubUsageConfiguration)
1158-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
11591117

11601118
var controller = CreateController(
11611119
GetConfigurationService(),
11621120
packageService: packageService,
11631121
featureFlagService: featureFlagService,
1164-
deprecationService: deprecationService,
1165-
contentObjectService: contentObjectService);
1122+
deprecationService: deprecationService);
11661123

11671124
var id = "Foo";
11681125
var package = new Package()
@@ -1212,17 +1169,12 @@ public async Task ShowsDeprecationIfEnabled(bool isDeprecationEnabled)
12121169
var featureFlagService = new Mock<IFeatureFlagService>();
12131170
var packageService = new Mock<IPackageService>();
12141171
var deprecationService = new Mock<IPackageDeprecationService>();
1215-
var contentObjectService = new Mock<IContentObjectService>();
1216-
contentObjectService
1217-
.SetupGet(c => c.GitHubUsageConfiguration)
1218-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
12191172

12201173
var controller = CreateController(
12211174
GetConfigurationService(),
12221175
packageService: packageService,
12231176
featureFlagService: featureFlagService,
1224-
deprecationService: deprecationService,
1225-
contentObjectService: contentObjectService);
1177+
deprecationService: deprecationService);
12261178
controller.SetCurrentUser(TestUtility.FakeUser);
12271179

12281180
var id = "Foo";
@@ -1308,18 +1260,12 @@ public async Task SplitsLicenseExpressionWhenProvided()
13081260

13091261
indexingService.Setup(i => i.GetLastWriteTime()).Returns(Task.FromResult((DateTime?)DateTime.UtcNow));
13101262

1311-
var contentObjectService = new Mock<IContentObjectService>();
1312-
contentObjectService
1313-
.SetupGet(c => c.GitHubUsageConfiguration)
1314-
.Returns(new GitHub.GitHubUsageConfiguration(Array.Empty<GitHub.RepositoryInformation>().ToList()));
1315-
13161263
var controller = CreateController(
13171264
GetConfigurationService(),
13181265
packageService: packageService,
13191266
indexingService: indexingService,
13201267
licenseExpressionSplitter: splitterMock,
1321-
deprecationService: deprecationService,
1322-
contentObjectService: contentObjectService);
1268+
deprecationService: deprecationService);
13231269

13241270
var result = await controller.DisplayPackage(id, version: null);
13251271

0 commit comments

Comments
 (0)