Skip to content
This repository
Browse code

Ensure language property is read from the nupkg

  • Loading branch information...
commit 91995845d04e671871217861cb75f49cf249cfa6 1 parent 5d648f4
Pranav K authored August 17, 2012
3  .gitignore
@@ -9,4 +9,5 @@ _AzurePackage
9 9
 *.bak
10 10
 NuGetGallery.sln.docstates
11 11
 _ReSharper.NuGetGallery
12  
-_PackagedWebsite
  12
+_PackagedWebsite
  13
+TestResults
37  Facts/Services/PackageServiceFacts.cs
@@ -92,6 +92,7 @@ public void WillReadThePropertiesFromTheNuGetPackageWhenCreatingANewPackage()
92 92
                 Assert.Equal("theTags", package.Tags);
93 93
                 Assert.Equal("theTitle", package.Title);
94 94
                 Assert.Equal("theCopyright", package.Copyright);
  95
+                Assert.Null(package.Language);
95 96
                 Assert.False(package.IsPrerelease);
96 97
 
97 98
                 Assert.Equal("theFirstAuthor, theSecondAuthor", package.FlattenedAuthors);
@@ -99,6 +100,27 @@ public void WillReadThePropertiesFromTheNuGetPackageWhenCreatingANewPackage()
99 100
             }
100 101
 
101 102
             [Fact]
  103
+            public void WillReadTheLanguagePropertyFromThePackage()
  104
+            {
  105
+                var packageRegistrationRepo = new Mock<IEntityRepository<PackageRegistration>>();
  106
+                var service = CreateService(
  107
+                    packageRegistrationRepo: packageRegistrationRepo,
  108
+                    setup: mockPackageSvc =>
  109
+                    {
  110
+                        mockPackageSvc.Setup(x => x.FindPackageRegistrationById(It.IsAny<string>())).Returns((PackageRegistration)null);
  111
+                    });
  112
+                var nugetPackage = CreateNuGetPackage(p => p.Setup(s => s.Language).Returns("fr"));
  113
+                var currentUser = new User();
  114
+
  115
+                var package = service.CreatePackage(
  116
+                    nugetPackage.Object,
  117
+                    currentUser);
  118
+
  119
+                // Assert
  120
+                Assert.Equal("fr", package.Language);
  121
+            }
  122
+
  123
+            [Fact]
102 124
             public void WillReadPrereleaseFlagFromNuGetPackage()
103 125
             {
104 126
                 // Arrange
@@ -415,6 +437,21 @@ void WillThrowIfTheNuGetPackageTitleIsLongerThan4000()
415 437
             }
416 438
 
417 439
             [Fact]
  440
+            void WillThrowIfTheNuGetPackageLanguageIsLongerThan20()
  441
+            {
  442
+                // Arrange
  443
+                var service = CreateService();
  444
+                var nugetPackage = CreateNuGetPackage();
  445
+                nugetPackage.Setup(x => x.Language).Returns(new string('a', 21));
  446
+
  447
+                // Act
  448
+                var ex = Assert.Throws<EntityException>(() => service.CreatePackage(nugetPackage.Object, null));
  449
+
  450
+                // Assert
  451
+                Assert.Equal(String.Format(Strings.NuGetPackagePropertyTooLong, "Language", "20"), ex.Message);
  452
+            }
  453
+
  454
+            [Fact]
418 455
             void WillSaveSupportedFrameworks()
419 456
             {
420 457
                 var packageRegistrationRepo = new Mock<IEntityRepository<PackageRegistration>>();
3  Website/DataServices/PackageExtensions.cs
@@ -33,6 +33,7 @@ public static IQueryable<V1FeedPackage> ToV1FeedPackageQuery(this IQueryable<Pac
33 33
                          GalleryDetailsUrl = siteRoot + "packages/" + p.PackageRegistration.Id + "/" + p.Version,
34 34
                          IconUrl = p.IconUrl,
35 35
                          IsLatestVersion = p.IsLatestStable,
  36
+                         Language = p.Language,
36 37
                          LastUpdated = p.LastUpdated,
37 38
                          LicenseUrl = p.LicenseUrl,
38 39
                          PackageHash = p.Hash,
@@ -75,7 +76,7 @@ public static IQueryable<V2FeedPackage> ToV2FeedPackageQuery(this IQueryable<Pac
75 76
                          IsPrerelease = p.IsPrerelease,
76 77
                          LastUpdated = p.LastUpdated,
77 78
                          LicenseUrl = p.LicenseUrl,
78  
-                         Language = null,
  79
+                         Language = p.Language,
79 80
                          PackageHash = p.Hash,
80 81
                          PackageHashAlgorithm = p.HashAlgorithm,
81 82
                          PackageSize = p.PackageFileSize,
2  Website/DataServices/V1FeedPackage.cs
@@ -24,6 +24,7 @@ public class V1FeedPackage
24 24
         public string GalleryDetailsUrl { get; set; }
25 25
         public string IconUrl { get; set; }
26 26
         public bool IsLatestVersion { get; set; }
  27
+        public string Language { get; set; }
27 28
         public DateTime LastUpdated { get; set; }
28 29
         public string LicenseUrl { get; set; }
29 30
         public string PackageHash { get; set; }
@@ -62,7 +63,6 @@ public double VersionRating
62 63
         }
63 64
 
64 65
         public string Categories { get { return String.Empty; } }
65  
-        public string Language { get { return ""; } }
66 66
         public string PackageType { get { return "Package"; } }
67 67
         public decimal Price { get { return 0; } }
68 68
         public bool Prerelease { get { return false; } }
2  Website/DataServices/V2FeedPackage.cs
@@ -25,9 +25,9 @@ public class V2FeedPackage
25 25
         public bool IsLatestVersion { get; set; }
26 26
         public bool IsAbsoluteLatestVersion { get; set; }
27 27
         public bool IsPrerelease { get; set; }
  28
+        public string Language { get; set; }
28 29
         public DateTime LastUpdated { get; set; }
29 30
         public DateTime Published { get; set; }
30  
-        public string Language { get; set; }
31 31
         public string LicenseUrl { get; set; }
32 32
         public string PackageHash { get; set; }
33 33
         public string PackageHashAlgorithm { get; set; }
4  Website/Entities/Package.cs
@@ -36,6 +36,10 @@ public Package()
36 36
         public bool IsLatestStable { get; set; }
37 37
         public DateTime LastUpdated { get; set; }
38 38
         public string LicenseUrl { get; set; }
  39
+
  40
+        [StringLength(20)]
  41
+        public string Language { get; set; }
  42
+
39 43
         public DateTime Published { get; set; }
40 44
         public long PackageFileSize { get; set; }
41 45
         public string ProjectUrl { get; set; }
24  Website/Migrations/201208171904586_Language.Designer.cs
... ...
@@ -0,0 +1,24 @@
  1
+// <auto-generated />
  2
+namespace NuGetGallery.Migrations
  3
+{
  4
+    using System.Data.Entity.Migrations;
  5
+    using System.Data.Entity.Migrations.Infrastructure;
  6
+    
  7
+    public sealed partial class Language : IMigrationMetadata
  8
+    {
  9
+        string IMigrationMetadata.Id
  10
+        {
  11
+            get { return "201208171904586_Language"; }
  12
+        }
  13
+        
  14
+        string IMigrationMetadata.Source
  15
+        {
  16
+            get { return null; }
  17
+        }
  18
+        
  19
+        string IMigrationMetadata.Target
  20
+        {
  21
+            get { return "H4sIAAAAAAAEAO0dy3LcuPGeqvzD1JySVK1GdlKu3S1pt7SyvavEr/LYm6OKG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mhF9rOZt8tMuikOG90vgwQoEBL3tal4ionNJJ52sHxikN2liCaghH7uk+0A225i+x/02WQafCI6bmYYixc6eR8G61IF5CtYl7RNcAX1Sruui7ID/ouuv/Fmya7i5/+H/SzhO608YAQA="; }
  22
+        }
  23
+    }
  24
+}
17  Website/Migrations/201208171904586_Language.cs
... ...
@@ -0,0 +1,17 @@
  1
+namespace NuGetGallery.Migrations
  2
+{
  3
+    using System.Data.Entity.Migrations;
  4
+    
  5
+    public partial class Language : DbMigration
  6
+    {
  7
+        public override void Up()
  8
+        {
  9
+            AddColumn("Packages", "Language", c => c.String(maxLength: 20));
  10
+        }
  11
+        
  12
+        public override void Down()
  13
+        {
  14
+            DropColumn("Packages", "Language");
  15
+        }
  16
+    }
  17
+}
13  Website/Services/PackageService.cs
@@ -266,11 +266,12 @@ Package CreatePackageFromNuGetPackage(PackageRegistration packageRegistration, I
266 266
                 Hash = cryptoSvc.GenerateHash(packageFileStream.ReadAllBytes()),
267 267
                 PackageFileSize = packageFileStream.Length,
268 268
                 Created = now,
  269
+                Language = nugetPackage.Language,
269 270
                 LastUpdated = now,
270 271
                 Published = now,
271 272
                 Copyright = nugetPackage.Copyright,
272 273
                 IsPrerelease = !nugetPackage.IsReleaseVersion(),
273  
-                Listed = true
  274
+                Listed = true,
274 275
             };
275 276
 
276 277
             if (nugetPackage.IconUrl != null)
@@ -326,6 +327,7 @@ public virtual IEnumerable<FrameworkName> GetSupportedFrameworks(IPackage packag
326 327
 
327 328
         static void ValidateNuGetPackage(IPackage nugetPackage)
328 329
         {
  330
+            // TODO: Change this to use DataAnnotations
329 331
             if (nugetPackage.Id.Length > 128)
330 332
                 throw new EntityException(Strings.NuGetPackagePropertyTooLong, "Id", "128");
331 333
             if (nugetPackage.Authors != null && String.Join(",", nugetPackage.Authors.ToArray()).Length > 4000)
@@ -342,12 +344,17 @@ static void ValidateNuGetPackage(IPackage nugetPackage)
342 344
                 throw new EntityException(Strings.NuGetPackagePropertyTooLong, "LicenseUrl", "4000");
343 345
             if (nugetPackage.ProjectUrl != null && nugetPackage.ProjectUrl.ToString().Length > 4000)
344 346
                 throw new EntityException(Strings.NuGetPackagePropertyTooLong, "ProjectUrl", "4000");
345  
-            if (nugetPackage.Summary != null && nugetPackage.Summary.ToString().Length > 4000)
  347
+            if (nugetPackage.Summary != null && nugetPackage.Summary.Length > 4000)
346 348
                 throw new EntityException(Strings.NuGetPackagePropertyTooLong, "Summary", "4000");
347 349
             if (nugetPackage.Tags != null && nugetPackage.Tags.ToString().Length > 4000)
348 350
                 throw new EntityException(Strings.NuGetPackagePropertyTooLong, "Tags", "4000");
349  
-            if (nugetPackage.Title != null && nugetPackage.Title.ToString().Length > 4000)
  351
+            if (nugetPackage.Title != null && nugetPackage.Title.Length > 4000)
350 352
                 throw new EntityException(Strings.NuGetPackagePropertyTooLong, "Title", "4000");
  353
+
  354
+            if (nugetPackage.Language != null && nugetPackage.Language.Length > 20)
  355
+            {
  356
+                throw new EntityException(Strings.NuGetPackagePropertyTooLong, "Language", "20");
  357
+            }
351 358
         }
352 359
 
353 360
         private static void UpdateIsLatest(PackageRegistration packageRegistration)
4  Website/Website.csproj
@@ -355,6 +355,10 @@
355 355
     <Compile Include="Migrations\201206250141447_ExecuteELMAHSql.Designer.cs">
356 356
       <DependentUpon>201206250141447_ExecuteELMAHSql.cs</DependentUpon>
357 357
     </Compile>
  358
+    <Compile Include="Migrations\201208171904586_Language.cs" />
  359
+    <Compile Include="Migrations\201208171904586_Language.Designer.cs">
  360
+      <DependentUpon>201208171904586_Language.cs</DependentUpon>
  361
+    </Compile>
358 362
     <Compile Include="Migrations\MigrationsConfiguration.cs" />
359 363
     <Compile Include="PackageCurators\IAutomaticPackageCurator.cs" />
360 364
     <Compile Include="PackageCurators\AutomaticPackageCurator.cs" />

0 notes on commit 9199584

Please sign in to comment.
Something went wrong with that request. Please try again.