1+ using System ;
2+ using GitVersion ;
3+ using NUnit . Framework ;
4+
5+ [ TestFixture ]
6+ public class LastMinorVersionFinderTests
7+ {
8+ [ Test ]
9+ public void Should_get_last_minor_release ( )
10+ {
11+ using ( var fixture = new EmptyRepositoryFixture ( new Config ( ) ) )
12+ {
13+ var commit0 = fixture . Repository . MakeACommit ( new DateTimeOffset ( 2000 , 1 , 1 , 1 , 1 , 1 , TimeSpan . Zero ) ) ;
14+ fixture . Repository . Tags . Add ( "1.0.0" , commit0 ) ;
15+ var commit1 = fixture . Repository . MakeACommit ( new DateTimeOffset ( 2001 , 1 , 1 , 1 , 1 , 1 , TimeSpan . Zero ) ) ;
16+ fixture . Repository . Tags . Add ( "1.1.0" , commit1 ) ;
17+ var commit2 = fixture . Repository . MakeACommit ( new DateTimeOffset ( 2002 , 1 , 1 , 1 , 1 , 1 , TimeSpan . Zero ) ) ;
18+ fixture . Repository . Tags . Add ( "1.1.1" , commit2 ) ;
19+
20+ var dateTimeOffset = LastMinorVersionFinder . Execute ( fixture . Repository , new Config ( ) , fixture . Repository . Head . Tip ) ;
21+ Assert . AreEqual ( 2001 , dateTimeOffset . Year ) ;
22+ }
23+ }
24+ [ Test ]
25+ public void Should_ignore_invalid_tag ( )
26+ {
27+ using ( var fixture = new EmptyRepositoryFixture ( new Config ( ) ) )
28+ {
29+ var commit1 = fixture . Repository . MakeACommit ( new DateTimeOffset ( 2001 , 1 , 1 , 1 , 1 , 1 , TimeSpan . Zero ) ) ;
30+ fixture . Repository . Tags . Add ( "1.1.0" , commit1 ) ;
31+ var commit2 = fixture . Repository . MakeACommit ( new DateTimeOffset ( 2002 , 1 , 1 , 1 , 1 , 1 , TimeSpan . Zero ) ) ;
32+ fixture . Repository . Tags . Add ( "BadTag" , commit2 ) ;
33+
34+ var dateTimeOffset = LastMinorVersionFinder . Execute ( fixture . Repository , new Config ( ) , fixture . Repository . Head . Tip ) ;
35+ Assert . AreEqual ( 2001 , dateTimeOffset . Year ) ;
36+ }
37+ }
38+ }
0 commit comments