@@ -219,6 +219,63 @@ public void HeightInBuildMetadata()
219219 Assert . Equal ( 2 , oracle . VersionHeightOffset ) ;
220220 }
221221
222+ [ Fact ]
223+ public void VersionHeightOffsetAppliesTo_Matching ( )
224+ {
225+ // When VersionHeightOffsetAppliesTo matches the current version, the offset should be applied
226+ VersionOptions workingCopyVersion = new VersionOptions
227+ {
228+ Version = SemanticVersion . Parse ( "7.8.9-beta" ) ,
229+ VersionHeightOffset = 5 ,
230+ VersionHeightOffsetAppliesTo = SemanticVersion . Parse ( "7.8.9-beta" ) ,
231+ } ;
232+ this . WriteVersionFile ( workingCopyVersion ) ;
233+ this . InitializeSourceControl ( ) ;
234+ var oracle = new VersionOracle ( this . Context ) ;
235+
236+ // The offset should be applied because the version matches
237+ Assert . Equal ( 5 , oracle . VersionHeightOffset ) ;
238+ Assert . Equal ( 1 , oracle . VersionHeight ) ;
239+ }
240+
241+ [ Fact ]
242+ public void VersionHeightOffsetAppliesTo_NotMatching ( )
243+ {
244+ // When VersionHeightOffsetAppliesTo doesn't match the current version, the offset should NOT be applied
245+ VersionOptions workingCopyVersion = new VersionOptions
246+ {
247+ Version = SemanticVersion . Parse ( "7.9-beta" ) ,
248+ VersionHeightOffset = 5 ,
249+ VersionHeightOffsetAppliesTo = SemanticVersion . Parse ( "7.8-beta" ) ,
250+ } ;
251+ this . WriteVersionFile ( workingCopyVersion ) ;
252+ this . InitializeSourceControl ( ) ;
253+ var oracle = new VersionOracle ( this . Context ) ;
254+
255+ // The offset should NOT be applied because the version changed (7.8 -> 7.9)
256+ Assert . Equal ( 0 , oracle . VersionHeightOffset ) ;
257+ Assert . Equal ( 1 , oracle . VersionHeight ) ;
258+ }
259+
260+ [ Fact ]
261+ public void VersionHeightOffsetAppliesTo_BuildNumberChange ( )
262+ {
263+ // When VersionHeightOffsetAppliesTo has a different build number, the offset should NOT be applied
264+ VersionOptions workingCopyVersion = new VersionOptions
265+ {
266+ Version = SemanticVersion . Parse ( "7.9-beta" ) ,
267+ VersionHeightOffset = 5 ,
268+ VersionHeightOffsetAppliesTo = SemanticVersion . Parse ( "7.8-beta" ) ,
269+ } ;
270+ this . WriteVersionFile ( workingCopyVersion ) ;
271+ this . InitializeSourceControl ( ) ;
272+ var oracle = new VersionOracle ( this . Context ) ;
273+
274+ // The offset should NOT be applied because the minor version changed (7.8 -> 7.9)
275+ Assert . Equal ( 0 , oracle . VersionHeightOffset ) ;
276+ Assert . Equal ( 1 , oracle . VersionHeight ) ;
277+ }
278+
222279 [ Theory ]
223280 [ InlineData ( "7.8.9-foo.25" , "7.8.9-foo-0025" ) ]
224281 [ InlineData ( "7.8.9-foo.25s" , "7.8.9-foo-25s" ) ]
0 commit comments