11// Copyright (c) .NET Foundation. All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
4+ using System ;
45using System . Linq ;
56using NuGet . Server . Core . DataServices ;
67using NuGet . Server . Core . Infrastructure ;
@@ -10,6 +11,52 @@ namespace NuGet.Server.Core.Tests
1011{
1112 public class PackageExtensionsTest
1213 {
14+ [ Fact ]
15+ public void AsODataPackage_Uses1900ForUnlistedPublished ( )
16+ {
17+ // Arrange
18+ var package = new ServerPackage
19+ {
20+ Version = new SemanticVersion ( "0.1.0" ) ,
21+ Authors = Enumerable . Empty < string > ( ) ,
22+ Owners = Enumerable . Empty < string > ( ) ,
23+
24+ Listed = false ,
25+ Created = new DateTimeOffset ( 2017 , 11 , 29 , 21 , 21 , 32 , TimeSpan . FromHours ( - 8 ) ) ,
26+ } ;
27+
28+ // Act
29+ var actual = package . AsODataPackage ( ClientCompatibility . Max ) ;
30+
31+ // Assert
32+ Assert . Equal (
33+ new DateTime ( 1900 , 1 , 1 , 0 , 0 , 0 , DateTimeKind . Utc ) ,
34+ actual . Published ) ;
35+ }
36+
37+ [ Fact ]
38+ public void AsODataPackage_UsesCreatedForListedPublished ( )
39+ {
40+ // Arrange
41+ var package = new ServerPackage
42+ {
43+ Version = new SemanticVersion ( "0.1.0" ) ,
44+ Authors = Enumerable . Empty < string > ( ) ,
45+ Owners = Enumerable . Empty < string > ( ) ,
46+
47+ Listed = true ,
48+ Created = new DateTimeOffset ( 2017 , 11 , 29 , 21 , 21 , 32 , TimeSpan . FromHours ( - 8 ) ) ,
49+ } ;
50+
51+ // Act
52+ var actual = package . AsODataPackage ( ClientCompatibility . Max ) ;
53+
54+ // Assert
55+ Assert . Equal (
56+ new DateTime ( 2017 , 11 , 30 , 5 , 21 , 32 , DateTimeKind . Utc ) ,
57+ actual . Published ) ;
58+ }
59+
1360 [ Theory ]
1461 [ InlineData ( true , true , false , false , 1 , true , true ) ]
1562 [ InlineData ( false , false , true , true , 1 , false , false ) ]
0 commit comments