11using System . IO ;
2+ using System . Linq ;
3+ using System . Reflection ;
24using GitVersion ;
35using NUnit . Framework ;
46using Shouldly ;
7+ using YamlDotNet . Serialization ;
58
69[ TestFixture ]
710public class ConfigReaderTests
@@ -11,15 +14,17 @@ public class ConfigReaderTests
1114 public void CanReadDocument ( )
1215 {
1316 const string text = @"
14- assemblyVersioningScheme : MajorMinor
17+ assembly-versioning-scheme : MajorMinor
1518develop-branch-tag: alpha
1619release-branch-tag: rc
20+ next-version: 2.0.0
1721tag-prefix: '[vV|version-]'
1822" ;
1923 var config = ConfigReader . Read ( new StringReader ( text ) ) ;
2024 config . AssemblyVersioningScheme . ShouldBe ( AssemblyVersioningScheme . MajorMinor ) ;
2125 config . DevelopBranchTag . ShouldBe ( "alpha" ) ;
2226 config . ReleaseBranchTag . ShouldBe ( "rc" ) ;
27+ config . NextVersion . ShouldBe ( "2.0.0" ) ;
2328 config . TagPrefix . ShouldBe ( "[vV|version-]" ) ;
2429 }
2530
@@ -32,5 +37,31 @@ public void CanReadDefaultDocument()
3237 config . DevelopBranchTag . ShouldBe ( "unstable" ) ;
3338 config . ReleaseBranchTag . ShouldBe ( "beta" ) ;
3439 config . TagPrefix . ShouldBe ( "[vV]" ) ;
40+ config . NextVersion . ShouldBe ( null ) ;
41+ }
42+
43+ [ Test ]
44+ public void VerifyInit ( )
45+ {
46+ var config = typeof ( Config ) ;
47+ var aliases = config . GetProperties ( ) . Select ( p => ( ( YamlAliasAttribute ) p . GetCustomAttribute ( typeof ( YamlAliasAttribute ) ) ) . Alias ) ;
48+ var writer = new StringWriter ( ) ;
49+
50+ ConfigReader . WriteSample ( writer ) ;
51+ var initFile = writer . GetStringBuilder ( ) . ToString ( ) ;
52+
53+ foreach ( var alias in aliases )
54+ {
55+ initFile . ShouldContain ( alias ) ;
56+ }
57+ }
58+
59+ [ Test ]
60+ public void VerifyAliases ( )
61+ {
62+ var config = typeof ( Config ) ;
63+ var propertiesMissingAlias = config . GetProperties ( ) . Where ( p => p . GetCustomAttribute ( typeof ( YamlAliasAttribute ) ) == null ) . Select ( p => p . Name ) ;
64+
65+ propertiesMissingAlias . ShouldBeEmpty ( ) ;
3566 }
3667}
0 commit comments