1
1
using System ;
2
2
using System . Collections . Generic ;
3
- using System . Text ;
4
- using FakeItEasy ;
5
- using Microsoft . Extensions . CommandLineUtils ;
6
- using Microsoft . VisualStudio . TestPlatform . TestHost ;
3
+ using Skarp . Version . Cli . CsProj ;
7
4
using Xunit ;
8
5
9
6
namespace Skarp . Version . Cli . Test
@@ -21,7 +18,7 @@ public class ProgramTest
21
18
[ InlineData ( "1.0.1-0" , VersionBump . Specific ) ]
22
19
[ InlineData ( "1.0.1-0+master" , VersionBump . Specific ) ]
23
20
[ InlineData ( "1.0.1-alpha.43+4432fsd" , VersionBump . Specific ) ]
24
- public void GetVersionBumpFromRemaingArgsWork ( string strVersionBump , VersionBump expectedBump )
21
+ public void GetVersionBumpFromRemainingArgsWork ( string strVersionBump , VersionBump expectedBump )
25
22
{
26
23
var args = Program . GetVersionBumpFromRemainingArgs (
27
24
new List < string > ( ) { strVersionBump } ,
@@ -32,6 +29,7 @@ public void GetVersionBumpFromRemaingArgsWork(string strVersionBump, VersionBump
32
29
string . Empty ,
33
30
string . Empty ,
34
31
string . Empty ,
32
+ string . Empty ,
35
33
string . Empty
36
34
) ;
37
35
Assert . Equal ( expectedBump , args . VersionBump ) ;
@@ -54,6 +52,7 @@ public void Get_version_bump_throws_on_missing_value()
54
52
string . Empty ,
55
53
string . Empty ,
56
54
string . Empty ,
55
+ string . Empty ,
57
56
string . Empty
58
57
)
59
58
) ;
@@ -77,12 +76,55 @@ public void Get_version_bump_throws_on_invalid_value()
77
76
string . Empty ,
78
77
string . Empty ,
79
78
string . Empty ,
79
+ string . Empty ,
80
80
string . Empty
81
81
)
82
82
) ;
83
83
Assert . Contains ( $ "Invalid SemVer version string: { invalidVersion } ",
84
84
ex . Message ) ;
85
85
Assert . Equal ( "versionString" , ex . ParamName ) ;
86
86
}
87
+
88
+ [ Fact ]
89
+ public void DefaultsToReadingVersionStringFromVersionProperty ( )
90
+ {
91
+ var args = Program . GetVersionBumpFromRemainingArgs (
92
+ new List < string > ( ) { "patch" } ,
93
+ OutputFormat . Text ,
94
+ true ,
95
+ true ,
96
+ string . Empty ,
97
+ string . Empty ,
98
+ string . Empty ,
99
+ string . Empty ,
100
+ string . Empty ,
101
+ string . Empty
102
+ ) ;
103
+
104
+ Assert . Equal ( ProjectFileProperty . Version , args . ProjectFilePropertyName ) ;
105
+ }
106
+
107
+ [ Theory ]
108
+ [ InlineData ( null , ProjectFileProperty . Version ) ]
109
+ [ InlineData ( "" , ProjectFileProperty . Version ) ]
110
+ [ InlineData ( "verSION" , ProjectFileProperty . Version ) ]
111
+ [ InlineData ( "packageversion" , ProjectFileProperty . PackageVersion ) ]
112
+ public void CanOverrideTheVersionPropertyName ( string input , ProjectFileProperty expected )
113
+ {
114
+ var args = Program . GetVersionBumpFromRemainingArgs (
115
+ new List < string > ( ) { "patch" } ,
116
+ OutputFormat . Text ,
117
+ true ,
118
+ true ,
119
+ string . Empty ,
120
+ string . Empty ,
121
+ string . Empty ,
122
+ string . Empty ,
123
+ string . Empty ,
124
+ input
125
+ ) ;
126
+
127
+ Assert . Equal ( expected , args . ProjectFilePropertyName ) ;
128
+ }
87
129
}
88
130
}
0 commit comments