Permalink
Browse files

Reformat code to following NuGet coding standards and conventions.

  • Loading branch information...
1 parent 7b0bceb commit 53f6b87f8a693a9ddd6277164798385f3763bb28 @drakomeep drakomeep committed with jeffhandley Oct 21, 2012
Showing with 7,815 additions and 6,922 deletions.
  1. +26 −26 Facts/App_Start/ConfigurationFacts.cs
  2. +22 −21 Facts/Commands/AutomaticallyCuratePackageCommandFacts.cs
  3. +52 −48 Facts/Commands/CreatedCuratedPackageCommandFacts.cs
  4. +47 −43 Facts/Commands/DeleteCuratedPackageCommandFacts.cs
  5. +44 −40 Facts/Commands/ModifyCuratedPackageCommandFacts.cs
  6. +179 −173 Facts/Controllers/ApiControllerFacts.cs
  7. +90 −84 Facts/Controllers/AuthenticationControllerFacts.cs
  8. +81 −46 Facts/Controllers/CuratedFeedsControllerFacts.cs
  9. +208 −166 Facts/Controllers/CuratedPackagesControllerFacts.cs
  10. +27 −26 Facts/Controllers/JsonApiControllerFacts.cs
  11. +339 −298 Facts/Controllers/PackagesControllerFacts.cs
  12. +323 −311 Facts/Controllers/UsersControllerFacts.cs
  13. +1 −1 Facts/Entities/PackageFacts.cs
  14. +8 −2 Facts/Facts.csproj
  15. +42 −39 Facts/Infrastructure/CookieTempDataProviderFacts.cs
  16. +9 −10 Facts/Infrastructure/Jobs/UpdateStatisticsJobFacts.cs
  17. +6 −9 Facts/Infrastructure/LuceneIndexingServiceFacts.cs
  18. +134 −112 Facts/PackageCurators/WebMatrixPackageCuratorFacts.cs
  19. +97 −89 Facts/PackageCurators/Windows8PackageCuratorFacts.cs
  20. +5 −1 Facts/Properties/AssemblyInfo.cs
  21. +5 −5 Facts/RequireRemoteHttpsAttributeFacts.cs
  22. +1 −1 Facts/Routing/VersionRouteConstraintFacts.cs
  23. +168 −125 Facts/Services/CloudBlobFileStorageServiceFacts.cs
  24. +207 −104 Facts/Services/FeedServiceFacts.cs
  25. +68 −63 Facts/Services/FileSystemFileStorageServiceFacts.cs
  26. +67 −63 Facts/Services/MessageServiceFacts.cs
  27. +17 −17 Facts/Services/NuGetExeDownloaderServiceFacts.cs
  28. +26 −29 Facts/Services/ODataRemoveVersionSorterFacts.cs
  29. +614 −603 Facts/Services/PackageServiceFacts.cs
  30. +16 −29 Facts/Services/UploadFileServiceFacts.cs
  31. +390 −347 Facts/Services/UsersServiceFacts.cs
  32. +1 −1 Facts/TestUtility.cs
  33. +19 −19 Facts/ViewModels/DisplayPackageViewModelFacts.cs
  34. +5 −5 Facts/ViewModels/PreviousNextPagerViewModelFacts.cs
  35. +1 −0 Facts/packages.config
  36. +70 −47 Website/App_Code/ViewHelpers.cshtml
  37. +48 −38 Website/App_Start/AppActivator.cs
  38. +12 −10 Website/App_Start/AuthenticationModule.cs
  39. +49 −47 Website/App_Start/Configuration.cs
  40. +3 −6 Website/App_Start/Container.cs
  41. +52 −47 Website/App_Start/ContainerBindings.cs
  42. +1 −2 Website/App_Start/IConfiguration.cs
  43. +1 −2 Website/App_Start/PackageStoreType.cs
  44. +27 −27 Website/App_Start/Routes.cs
  45. +3 −1 Website/App_Start/VersionRouteConstraint.cs
  46. +1 −1 Website/Commands/AutomaticallyCuratePackageCommand.cs
  47. +12 −8 Website/Commands/CreateCuratedPackageCommand.cs
  48. +4 −0 Website/Commands/DeleteCuratedPackageCommand.cs
  49. +6 −2 Website/Commands/ModifyCuratedPackageCommand.cs
  50. +4 −5 Website/Constants.cs
  51. +919 −930 Website/Content/Site.css
  52. +118 −66 Website/Controllers/ApiController.cs
  53. +1 −1 Website/Controllers/AppController.cs
  54. +11 −8 Website/Controllers/AuthenticationController.cs
  55. +21 −13 Website/Controllers/CuratedFeedsController.cs
  56. +36 −10 Website/Controllers/CuratedPackagesController.cs
  57. +31 −27 Website/Controllers/JsonApiController.cs
  58. +135 −116 Website/Controllers/PackagesController.cs
  59. +12 −10 Website/Controllers/PagesController.cs
  60. +92 −75 Website/Controllers/UsersController.cs
  61. +5 −4 Website/DataServices/CountInterceptor.cs
  62. +4 −3 Website/DataServices/DisregardODataInterceptor.cs
  63. +2 −6 Website/DataServices/FeedContext.cs
  64. +47 −51 Website/DataServices/FeedServiceBase.cs
  65. +2 −3 Website/DataServices/ODataRemoveVersionSorter.cs
  66. +71 −67 Website/DataServices/PackageExtensions.cs
  67. +16 −18 Website/DataServices/V1Feed.svc.cs
  68. +20 −9 Website/DataServices/V1FeedPackage.cs
  69. +22 −20 Website/DataServices/V2CuratedFeed.svc.cs
  70. +49 −47 Website/DataServices/V2Feed.svc.cs
  71. +3 −4 Website/DynamicData/Content/GridViewPager.ascx.cs
  72. +1 −1 Website/DynamicData/Default.aspx
  73. +7 −5 Website/DynamicData/Default.aspx.cs
  74. +7 −6 Website/DynamicData/EntityTemplates/Default.ascx.cs
  75. +7 −8 Website/DynamicData/EntityTemplates/Default_Edit.ascx.cs
  76. +7 −8 Website/DynamicData/EntityTemplates/Default_Insert.ascx.cs
  77. +9 −10 Website/DynamicData/FieldTemplates/Boolean.ascx.cs
  78. +10 −11 Website/DynamicData/FieldTemplates/Boolean_Edit.ascx.cs
  79. +1 −1 Website/DynamicData/FieldTemplates/Children.ascx
  80. +10 −30 Website/DynamicData/FieldTemplates/Children.ascx.cs
  81. +4 −4 Website/DynamicData/FieldTemplates/Children_Insert.ascx.cs
  82. +1 −1 Website/DynamicData/FieldTemplates/DateTime.ascx
  83. +5 −8 Website/DynamicData/FieldTemplates/DateTime.ascx.cs
  84. +1 −1 Website/DynamicData/FieldTemplates/DateTime_Edit.ascx
  85. +11 −13 Website/DynamicData/FieldTemplates/DateTime_Edit.ascx.cs
  86. +1 −1 Website/DynamicData/FieldTemplates/Decimal_Edit.ascx
  87. +8 −11 Website/DynamicData/FieldTemplates/Decimal_Edit.ascx.cs
  88. +1 −1 Website/DynamicData/FieldTemplates/EmailAddress.ascx
  89. +8 −11 Website/DynamicData/FieldTemplates/EmailAddress.ascx.cs
  90. +1 −1 Website/DynamicData/FieldTemplates/Enumeration.ascx
  91. +4 −8 Website/DynamicData/FieldTemplates/Enumeration.ascx.cs
  92. +12 −23 Website/DynamicData/FieldTemplates/Enumeration_Edit.ascx.cs
  93. +2 −2 Website/DynamicData/FieldTemplates/ForeignKey.ascx
  94. +10 −23 Website/DynamicData/FieldTemplates/ForeignKey.ascx.cs
  95. +8 −12 Website/DynamicData/FieldTemplates/ForeignKey_Edit.ascx.cs
  96. +1 −1 Website/DynamicData/FieldTemplates/Integer_Edit.ascx
  97. +8 −11 Website/DynamicData/FieldTemplates/Integer_Edit.ascx.cs
  98. +9 −12 Website/DynamicData/FieldTemplates/ManyToMany.ascx.cs
  99. +20 −20 Website/DynamicData/FieldTemplates/ManyToMany_Edit.ascx.cs
  100. +1 −1 Website/DynamicData/FieldTemplates/MultilineText_Edit.ascx
  101. +8 −11 Website/DynamicData/FieldTemplates/MultilineText_Edit.ascx.cs
  102. +1 −1 Website/DynamicData/FieldTemplates/Text.ascx
  103. +3 −7 Website/DynamicData/FieldTemplates/Text.ascx.cs
  104. +1 −1 Website/DynamicData/FieldTemplates/Text_Edit.ascx
  105. +8 −11 Website/DynamicData/FieldTemplates/Text_Edit.ascx.cs
  106. +1 −1 Website/DynamicData/FieldTemplates/Url.ascx
  107. +8 −11 Website/DynamicData/FieldTemplates/Url.ascx.cs
  108. +12 −9 Website/DynamicData/Filters/Boolean.ascx.cs
  109. +5 −7 Website/DynamicData/Filters/Enumeration.ascx.cs
  110. +6 −12 Website/DynamicData/Filters/ForeignKey.ascx.cs
  111. +3 −3 Website/DynamicData/PageTemplates/Details.aspx.cs
  112. +3 −3 Website/DynamicData/PageTemplates/Edit.aspx.cs
  113. +3 −3 Website/DynamicData/PageTemplates/Insert.aspx.cs
  114. +2 −2 Website/DynamicData/PageTemplates/List.aspx
  115. +7 −8 Website/DynamicData/PageTemplates/List.aspx.cs
  116. +10 −15 Website/DynamicData/Registration.cs
  117. +112 −157 Website/DynamicData/Site.css
  118. +1 −1 Website/DynamicData/Site.master.cs
  119. +1 −2 Website/Entities/CuratedFeed.cs
  120. +1 −2 Website/Entities/CuratedPackage.cs
  121. +2 −4 Website/Entities/EmailMessage.cs
  122. +25 −28 Website/Entities/EntitiesContext.cs
  123. +7 −7 Website/Entities/EntityRepository.cs
  124. +2 −3 Website/Entities/GallerySetting.cs
  125. +1 −2 Website/Entities/IEntity.cs
  126. +20 −15 Website/Entities/Package.cs
  127. +4 −5 Website/Entities/PackageAuthor.cs
  128. +5 −5 Website/Entities/PackageDependency.cs
  129. +12 −19 Website/Entities/PackageFramework.cs
  130. +1 −1 Website/Entities/PackageOwnerRequest.cs
  131. +4 −3 Website/Entities/PackageRegistration.cs
  132. +2 −4 Website/Entities/PackageStatistics.cs
  133. +2 −2 Website/Entities/Role.cs
  134. +4 −6 Website/Entities/User.cs
  135. +10 −9 Website/Errors/404.cshtml
  136. +2 −3 Website/Errors/ErrorLayout.cshtml
  137. +50 −31 Website/ExtensionMethods.cs
  138. +29 −31 Website/Infrastructure/CookieTempDataProvider.cs
  139. +6 −9 Website/Infrastructure/HintAttribute.cs
  140. +6 −6 Website/Infrastructure/HttpHeaderValueProvider.cs
  141. +4 −3 Website/Infrastructure/HttpHeaderValueProviderFactory.cs
  142. +3 −4 Website/Infrastructure/HttpStatusCodeWithBodyResult.cs
  143. +1 −1 Website/Infrastructure/Jobs/UpdateStatisticsJob.cs
  144. +1 −1 Website/Infrastructure/Jobs/WorkItemCleanupJob.cs
  145. +23 −19 Website/Infrastructure/JsonNetResult.cs
  146. +1 −2 Website/Infrastructure/Lucene/LuceneFileSystem.cs
  147. +5 −5 Website/Infrastructure/Lucene/LuceneIndexingJob.cs
  148. +40 −29 Website/Infrastructure/Lucene/LuceneIndexingService.cs
  149. +14 −13 Website/Infrastructure/Lucene/LuceneSearchService.cs
  150. +1 −0 Website/Infrastructure/Lucene/PackageIndexEntity.cs
  151. +85 −86 Website/Migrations/201110060711357_Initial.cs
  152. +4 −4 Website/Migrations/201110102157002_PrereleaseChanges.cs
  153. +18 −18 Website/Migrations/201110180052097_GallerySettings.cs
  154. +11 −11 Website/Migrations/201110230649210_PackageOwnerRequests.cs
  155. +3 −3 Website/Migrations/201111022024584_PackageDependencyVersionSpec.cs
  156. +3 −3 Website/Migrations/201111022051010_PackageReleaseNotes.cs
  157. +4 −4 Website/Migrations/201111080239544_ListPackagesIndexes.cs
  158. +4 −4 Website/Migrations/201111080816426_DisplayPackageIndexes.cs
  159. +6 −5 Website/Migrations/201111081908453_MyPackagesIndexes.cs
  160. +4 −4 Website/Migrations/201111150729167_AddSmtpPassword.cs
  161. +3 −3 Website/Migrations/201111222338036_GalleryOwnerEmailSettings.cs
  162. +4 −4 Website/Migrations/201201031925005_AddPasswordHash.cs
  163. +20 −21 Website/Migrations/201203180016174_CuratedFeeds.cs
  164. +4 −4 Website/Migrations/201203180320147_ChangeCuratedFeedIdToName.cs
  165. +4 −4 Website/Migrations/201203182132476_CuratedPackages.cs
  166. +9 −10 Website/Migrations/201205172325056_FrameworkName.cs
  167. +4 −4 Website/Migrations/201206131919241_AddTargetFxToDependencies.cs
  168. +2 −2 Website/Migrations/201206250141447_ExecuteELMAHSql.cs
  169. +4 −4 Website/Migrations/201208171904586_Language.cs
  170. +5 −5 Website/Migrations/201208222206329_ColumnLengthOfPackageTable.cs
  171. +4 −4 Website/Migrations/201208222227425_PackageIndexes.cs
  172. +4 −5 Website/Migrations/201208230640333_PackageSortingIndexes.cs
  173. +1 −4 Website/Migrations/201208302051344_CreateAggregateStatisticsSP.cs
  174. +2 −4 Website/Migrations/201209181743161_AggregateStatsSp_ReduxLastUpdate.cs
  175. +11 −10 Website/Migrations/MigrationsConfiguration.cs
  176. +2 −2 Website/Migrations/SqlResourceMigration.cs
  177. +3 −5 Website/PackageCurators/TagBasedPackageCurator.cs
  178. +7 −1 Website/PackageCurators/WebMatrixPackageCurator.cs
  179. +1 −4 Website/PackageCurators/Windows8PackageCurator.cs
  180. +3 −1 Website/Properties/AssemblyInfo.cs
  181. +12 −5 Website/Queries/PackageIdsQuery.cs
  182. +6 −2 Website/Queries/PackageRegistrationByIdQuery.cs
  183. +2 −0 Website/Queries/PackageRegistrationByKeyQuery.cs
  184. +8 −3 Website/Queries/PackageVersionsQuery.cs
  185. +5 −3 Website/Queries/UserByUSernameQuery.cs
  186. +2 −2 Website/RequestModels/CreateCuratedPackageRequest.cs
  187. +1 −1 Website/RequestModels/ModifyCuratedPackageRequest.cs
  188. +10 −3 Website/RequestModels/RegisterRequest.cs
  189. +1 −1 Website/RequireRemoteHttpsAttribute.cs
  190. +8 −6 Website/Services/AggregateStatsService.cs
  191. +3 −3 Website/Services/CloudBlobClientWrapper.cs
  192. +5 −5 Website/Services/CloudBlobContainerWrapper.cs
  193. +54 −42 Website/Services/CloudBlobFileStorageService.cs
  194. +9 −9 Website/Services/CloudBlobWrapper.cs
  195. +37 −31 Website/Services/CryptographyService.cs
  196. +23 −21 Website/Services/Extensions.cs
  197. +77 −42 Website/Services/FileSystemFileStorageService.cs
  198. +8 −9 Website/Services/FormsAuthenticationService.cs
  199. +1 −2 Website/Services/IAggregateStatsService.cs
  200. +1 −1 Website/Services/ICloudBlob.cs
  201. +1 −2 Website/Services/ICloudBlobClient.cs
  202. +1 −1 Website/Services/ICloudBlobContainer.cs
  203. +1 −3 Website/Services/ICryptographyService.cs
  204. +3 −3 Website/Services/IFileStorageService.cs
  205. +2 −2 Website/Services/IFormsAuthenticationService.cs
  206. +5 −5 Website/Services/IPackageFileService.cs
  207. +4 −4 Website/Services/ISearchService.cs
  208. +2 −3 Website/Services/IUploadFileService.cs
  209. +63 −53 Website/Services/MessageService.cs
  210. +12 −12 Website/Services/NuGetExeDownloaderService.cs
  211. +14 −7 Website/Services/PackageFileService.cs
  212. +273 −219 Website/Services/PackageService.cs
  213. +3 −4 Website/Services/SearchFilter.cs
  214. +1 −1 Website/Services/TestableStorageClientException.cs
  215. +19 −11 Website/Services/UploadFileService.cs
  216. +54 −50 Website/Services/UserService.cs
  217. +305 −147 Website/T4MVC.cs
  218. +1 −1 Website/ViewModels/AccountViewModel.cs
  219. +1 −2 Website/ViewModels/AggregateStats.cs
  220. +2 −2 Website/ViewModels/ContactOwnersViewModel.cs
  221. +7 −3 Website/ViewModels/DependencySetsViewModel.cs
  222. +5 −5 Website/ViewModels/DisplayPackageViewModel.cs
  223. +3 −1 Website/ViewModels/EditProfileViewModel.cs
  224. +1 −2 Website/ViewModels/EmailConfirmationModel.cs
  225. +2 −2 Website/ViewModels/IPageableEnumerable.cs
  226. +11 −8 Website/ViewModels/ListPackageItemViewModel.cs
  227. +3 −4 Website/ViewModels/ManagePackageOwnersViewModel.cs
  228. +4 −3 Website/ViewModels/PackageListViewModel.cs
  229. +1 −2 Website/ViewModels/PackageOwnerConfirmationModel.cs
  230. +17 −21 Website/ViewModels/PackageViewModel.cs
  231. +4 −2 Website/ViewModels/PreviousNextPagerViewModel.cs
  232. +3 −1 Website/ViewModels/ReportAbuseViewModel.cs
  233. +4 −6 Website/ViewModels/VerifyPackageViewModel.cs
  234. +5 −4 Website/Views/Authentication/LogOn.cshtml
  235. +10 −11 Website/Views/CuratedFeeds/CuratedFeed.cshtml
  236. +4 −2 Website/Views/Packages/ConfirmOwner.cshtml
  237. +6 −4 Website/Views/Packages/ContactOwners.cshtml
  238. +7 −6 Website/Views/Packages/Delete.cshtml
  239. +35 −21 Website/Views/Packages/DisplayPackage.cshtml
  240. +30 −12 Website/Views/Packages/ListPackages.cshtml
  241. +65 −68 Website/Views/Packages/ManagePackageOwners.cshtml
  242. +13 −10 Website/Views/Packages/ReportAbuse.cshtml
  243. +3 −3 Website/Views/Packages/UploadPackage.cshtml
  244. +37 −30 Website/Views/Packages/VerifyPackage.cshtml
  245. +31 −18 Website/Views/Packages/_ListPackage.cshtml
  246. +9 −9 Website/Views/Packages/_PackageDependencies.cshtml
  247. +4 −4 Website/Views/Pages/Home.cshtml
  248. +1 −1 Website/Views/Pages/Privacy.cshtml
  249. +3 −3 Website/Views/Pages/Terms.cshtml
  250. +1 −2 Website/Views/Shared/EditorTemplates/Object.cshtml
  251. +27 −27 Website/Views/Shared/Error.cshtml
  252. +6 −6 Website/Views/Shared/Layout.cshtml
  253. +3 −2 Website/Views/Shared/UserDisplay.cshtml
  254. +14 −14 Website/Views/Users/Account.cshtml
  255. +2 −1 Website/Views/Users/ChangePassword.cshtml
  256. +12 −6 Website/Views/Users/Confirm.cshtml
  257. +4 −2 Website/Views/Users/Edit.cshtml
  258. +2 −1 Website/Views/Users/ForgotPassword.cshtml
  259. +45 −39 Website/Views/Users/Packages.cshtml
  260. +5 −3 Website/Views/Users/PasswordSent.cshtml
  261. +32 −28 Website/Views/Users/Profiles.cshtml
  262. +2 −1 Website/Views/Users/Register.cshtml
  263. +7 −6 Website/Views/Users/ResendConfirmation.cshtml
  264. +2 −1 Website/Views/Users/ResetPassword.cshtml
  265. +15 −9 Website/Views/Users/Thanks.cshtml
  266. +0 −33 Website/Website.csproj
  267. +116 −40 Website/_app_offline.htm
@@ -7,6 +7,30 @@ namespace NuGetGallery.App_Start
{
public class ConfigurationFacts
{
+ public class TestableConfiguration : Configuration
+ {
+ public TestableConfiguration()
+ {
+ StubRequest = new Mock<HttpRequestBase>();
+ StubConfiguredSiteRoot = "http://aSiteRoot/";
+
+ StubRequest.Setup(stub => stub.IsLocal).Returns(false);
+ }
+
+ public string StubConfiguredSiteRoot { get; set; }
+ public Mock<HttpRequestBase> StubRequest { get; set; }
+
+ protected override string GetConfiguredSiteRoot()
+ {
+ return StubConfiguredSiteRoot;
+ }
+
+ protected override HttpRequestBase GetCurrentRequest()
+ {
+ return StubRequest.Object;
+ }
+ }
+
public class TheGetSiteRootMethod
{
[Fact]
@@ -68,35 +92,11 @@ public void WillCacheTheSiteRootLookup()
{
var configuration = new TestableConfiguration();
configuration.GetSiteRoot(useHttps: false);
-
+
configuration.GetSiteRoot(useHttps: true);
configuration.StubRequest.Verify(stub => stub.IsLocal, Times.Once());
}
}
-
- public class TestableConfiguration : Configuration
- {
- public TestableConfiguration()
- {
- StubRequest = new Mock<HttpRequestBase>();
- StubConfiguredSiteRoot = "http://aSiteRoot/";
-
- StubRequest.Setup(stub => stub.IsLocal).Returns(false);
- }
-
- public string StubConfiguredSiteRoot { get; set; }
- public Mock<HttpRequestBase> StubRequest { get; set; }
-
- protected override string GetConfiguredSiteRoot()
- {
- return StubConfiguredSiteRoot;
- }
-
- protected override HttpRequestBase GetCurrentRequest()
- {
- return StubRequest.Object;
- }
- }
}
-}
+}
@@ -9,6 +9,27 @@ namespace NuGetGallery.Commands
{
public class AutomaticallyCuratePackageCommandFacts
{
+ public class TestableAutomaticallyCuratePackageCommand : AutomaticallyCuratePackageCommand
+ {
+ public TestableAutomaticallyCuratePackageCommand()
+ : base(null)
+ {
+ StubCurators = new List<Mock<IAutomaticPackageCurator>>();
+ }
+
+ public List<Mock<IAutomaticPackageCurator>> StubCurators { get; private set; }
+
+ protected override IEnumerable<T> GetServices<T>()
+ {
+ if (typeof (T) == typeof (IAutomaticPackageCurator))
+ {
+ return StubCurators.Select(stub => (T)stub.Object);
+ }
+
+ throw new Exception("Tried to get unexpected servicves");
+ }
+ }
+
public class TheExecuteMethod
{
[Fact]
@@ -26,25 +47,5 @@ public void WillCuratePackageUsingAllPackageCurators()
secondStubCurator.Verify(stub => stub.Curate(It.IsAny<Package>(), It.IsAny<IPackage>()));
}
}
-
- public class TestableAutomaticallyCuratePackageCommand : AutomaticallyCuratePackageCommand
- {
- public TestableAutomaticallyCuratePackageCommand()
- : base(null)
- {
- StubCurators = new List<Mock<IAutomaticPackageCurator>>();
- }
-
- public List<Mock<IAutomaticPackageCurator>> StubCurators { get; private set; }
-
- protected override IEnumerable<T> GetServices<T>()
- {
- if (typeof(T) == typeof(IAutomaticPackageCurator))
- return StubCurators.Select(stub => (T)stub.Object);
-
- throw new Exception("Tried to get unexpected servicves");
- }
- }
}
-}
-
+}
@@ -7,6 +7,49 @@ namespace NuGetGallery
{
public class CreatedCuratedPackageCommandFacts
{
+ public class TestableCreateCuratedPackageCommand : CreateCuratedPackageCommand
+ {
+ public TestableCreateCuratedPackageCommand()
+ : base(null)
+ {
+ StubCuratedFeed = new CuratedFeed { Key = 0, Name = "aName", };
+ StubCuratedFeedByKeyQry = new Mock<ICuratedFeedByKeyQuery>();
+ StubEntitiesContext = new Mock<IEntitiesContext>();
+ StubPackageRegistration = new PackageRegistration { Key = 0, };
+ StubPackageRegistrationByKeyQry = new Mock<IPackageRegistrationByKeyQuery>();
+
+ StubCuratedFeedByKeyQry
+ .Setup(stub => stub.Execute(It.IsAny<int>(), It.IsAny<bool>()))
+ .Returns(StubCuratedFeed);
+ StubPackageRegistrationByKeyQry
+ .Setup(stub => stub.Execute(It.IsAny<int>(), It.IsAny<bool>()))
+ .Returns(StubPackageRegistration);
+
+ Entities = StubEntitiesContext.Object;
+ }
+
+ public CuratedFeed StubCuratedFeed { get; set; }
+ public Mock<ICuratedFeedByKeyQuery> StubCuratedFeedByKeyQry { get; set; }
+ public Mock<IEntitiesContext> StubEntitiesContext { get; private set; }
+ public PackageRegistration StubPackageRegistration { get; set; }
+ public Mock<IPackageRegistrationByKeyQuery> StubPackageRegistrationByKeyQry { get; set; }
+
+ protected override T GetService<T>()
+ {
+ if (typeof (T) == typeof (ICuratedFeedByKeyQuery))
+ {
+ return (T)StubCuratedFeedByKeyQry.Object;
+ }
+
+ if (typeof (T) == typeof (IPackageRegistrationByKeyQuery))
+ {
+ return (T)StubPackageRegistrationByKeyQry.Object;
+ }
+
+ throw new Exception("Tried to get unexpected service");
+ }
+ }
+
public class TheExecuteMethod
{
[Fact]
@@ -17,9 +60,10 @@ public void WillThrowWhenCuratedFeedDoesNotExist()
.Setup(stub => stub.Execute(It.IsAny<int>(), It.IsAny<bool>()))
.Returns((CuratedFeed)null);
- Assert.Throws<InvalidOperationException>(() => cmd.Execute(
- 0,
- 0));
+ Assert.Throws<InvalidOperationException>(
+ () => cmd.Execute(
+ 0,
+ 0));
}
[Fact]
@@ -30,9 +74,10 @@ public void WillThrowWhenPackageRegistrationDoesNotExist()
.Setup(stub => stub.Execute(It.IsAny<int>(), It.IsAny<bool>()))
.Returns((PackageRegistration)null);
- Assert.Throws<InvalidOperationException>(() => cmd.Execute(
- 0,
- 0));
+ Assert.Throws<InvalidOperationException>(
+ () => cmd.Execute(
+ 0,
+ 0));
}
[Fact]
@@ -53,7 +98,6 @@ public void WillAddANewCuratedPackageToTheCuratedFeed()
Assert.Equal(false, curatedPackage.Included);
Assert.Equal(true, curatedPackage.AutomaticallyCurated);
Assert.Equal("theNotes", curatedPackage.Notes);
-
}
[Fact]
@@ -85,47 +129,7 @@ public void WillReturnTheCreatedCuratedPackage()
Assert.Equal(false, curatedPackage.Included);
Assert.Equal(true, curatedPackage.AutomaticallyCurated);
Assert.Equal("theNotes", curatedPackage.Notes);
-
- }
- }
-
- public class TestableCreateCuratedPackageCommand : CreateCuratedPackageCommand
- {
- public TestableCreateCuratedPackageCommand()
- : base(null)
- {
- StubCuratedFeed = new CuratedFeed { Key = 0, Name = "aName", };
- StubCuratedFeedByKeyQry = new Mock<ICuratedFeedByKeyQuery>();
- StubEntitiesContext = new Mock<IEntitiesContext>();
- StubPackageRegistration = new PackageRegistration { Key = 0, };
- StubPackageRegistrationByKeyQry = new Mock<IPackageRegistrationByKeyQuery>();
-
- StubCuratedFeedByKeyQry
- .Setup(stub => stub.Execute(It.IsAny<int>(), It.IsAny<bool>()))
- .Returns(StubCuratedFeed);
- StubPackageRegistrationByKeyQry
- .Setup(stub => stub.Execute(It.IsAny<int>(), It.IsAny<bool>()))
- .Returns(StubPackageRegistration);
-
- Entities = StubEntitiesContext.Object;
- }
-
- public CuratedFeed StubCuratedFeed{ get; set; }
- public Mock<ICuratedFeedByKeyQuery> StubCuratedFeedByKeyQry { get; set; }
- public Mock<IEntitiesContext> StubEntitiesContext { get; private set; }
- public PackageRegistration StubPackageRegistration { get; set; }
- public Mock<IPackageRegistrationByKeyQuery> StubPackageRegistrationByKeyQry { get; set; }
-
- protected override T GetService<T>()
- {
- if (typeof(T) == typeof(ICuratedFeedByKeyQuery))
- return (T) StubCuratedFeedByKeyQry.Object;
-
- if (typeof(T) == typeof(IPackageRegistrationByKeyQuery))
- return (T) StubPackageRegistrationByKeyQry.Object;
-
- throw new Exception("Tried to get unexpected service");
}
}
}
-}
+}
@@ -1,12 +1,48 @@
using System;
+using System.Data.Entity;
using Moq;
using Xunit;
-using System.Data.Entity;
namespace NuGetGallery.Commands
{
public class DeleteCuratedPackageCommandFacts
{
+ public class TestableDeleteCuratedPackageCommand : DeleteCuratedPackageCommand
+ {
+ public TestableDeleteCuratedPackageCommand()
+ : base(null)
+ {
+ StubCuratedFeed = new CuratedFeed { Key = 0, Name = "aName", };
+ StubCuratedPackageDbSet = new Mock<IDbSet<CuratedPackage>>();
+ StubCuratedFeedByKeyQry = new Mock<ICuratedFeedByKeyQuery>();
+ StubEntitiesContext = new Mock<IEntitiesContext>();
+
+ StubCuratedFeedByKeyQry
+ .Setup(stub => stub.Execute(It.IsAny<int>(), It.IsAny<bool>()))
+ .Returns(StubCuratedFeed);
+ StubEntitiesContext
+ .Setup(stub => stub.CuratedPackages)
+ .Returns(StubCuratedPackageDbSet.Object);
+
+ Entities = StubEntitiesContext.Object;
+ }
+
+ public CuratedFeed StubCuratedFeed { get; set; }
+ public Mock<IDbSet<CuratedPackage>> StubCuratedPackageDbSet { get; private set; }
+ public Mock<ICuratedFeedByKeyQuery> StubCuratedFeedByKeyQry { get; set; }
+ public Mock<IEntitiesContext> StubEntitiesContext { get; private set; }
+
+ protected override T GetService<T>()
+ {
+ if (typeof (T) == typeof (ICuratedFeedByKeyQuery))
+ {
+ return (T)StubCuratedFeedByKeyQry.Object;
+ }
+
+ throw new Exception("Tried to get unexpected service");
+ }
+ }
+
public class TheExecuteMethod
{
[Fact]
@@ -17,20 +53,22 @@ public void WillThrowWhenCuratedFeedDoesNotExist()
.Setup(stub => stub.Execute(It.IsAny<int>(), It.IsAny<bool>()))
.Returns((CuratedFeed)null);
- Assert.Throws<InvalidOperationException>(() => cmd.Execute(
- 42,
- 0));
+ Assert.Throws<InvalidOperationException>(
+ () => cmd.Execute(
+ 42,
+ 0));
}
[Fact]
public void WillThrowWhenCuratedPackageDoesNotExist()
{
var cmd = new TestableDeleteCuratedPackageCommand();
- cmd.StubCuratedFeed.Packages = new[] { new CuratedPackage() { Key = 0 } };
+ cmd.StubCuratedFeed.Packages = new[] { new CuratedPackage { Key = 0 } };
- Assert.Throws<InvalidOperationException>(() => cmd.Execute(
- 0,
- 1066));
+ Assert.Throws<InvalidOperationException>(
+ () => cmd.Execute(
+ 0,
+ 1066));
}
[Fact]
@@ -48,39 +86,5 @@ public void WillDeleteTheCuratedPackage()
cmd.StubEntitiesContext.Verify(stub => stub.SaveChanges());
}
}
-
- public class TestableDeleteCuratedPackageCommand : DeleteCuratedPackageCommand
- {
- public TestableDeleteCuratedPackageCommand()
- : base(null)
- {
- StubCuratedFeed = new CuratedFeed { Key = 0, Name = "aName", };
- StubCuratedPackageDbSet = new Mock<IDbSet<CuratedPackage>>();
- StubCuratedFeedByKeyQry = new Mock<ICuratedFeedByKeyQuery>();
- StubEntitiesContext = new Mock<IEntitiesContext>();
-
- StubCuratedFeedByKeyQry
- .Setup(stub => stub.Execute(It.IsAny<int>(), It.IsAny<bool>()))
- .Returns(StubCuratedFeed);
- StubEntitiesContext
- .Setup(stub => stub.CuratedPackages)
- .Returns(StubCuratedPackageDbSet.Object);
-
- Entities = StubEntitiesContext.Object;
- }
-
- public CuratedFeed StubCuratedFeed { get; set; }
- public Mock<IDbSet<CuratedPackage>> StubCuratedPackageDbSet { get; private set; }
- public Mock<ICuratedFeedByKeyQuery> StubCuratedFeedByKeyQry { get; set; }
- public Mock<IEntitiesContext> StubEntitiesContext { get; private set; }
-
- protected override T GetService<T>()
- {
- if (typeof(T) == typeof(ICuratedFeedByKeyQuery))
- return (T)StubCuratedFeedByKeyQry.Object;
-
- throw new Exception("Tried to get unexpected service");
- }
- }
}
-}
+}
Oops, something went wrong.

0 comments on commit 53f6b87

Please sign in to comment.