@@ -200,28 +200,7 @@ public void UsesFirstBranchConfigWhenMultipleMatch(string branchName, IncrementS
200200 }
201201
202202 [ Test ]
203- public void When_getting_configurations_of_an_orphaned_branch_Given_fallback_configuaration_without_increment_Then_result_should_be_empty ( )
204- {
205- // Arrange
206- var branchMock = GitToolsTestingExtensions . CreateMockBranch ( "develop" , GitToolsTestingExtensions . CreateMockCommit ( ) ) ;
207- var configuration = GitFlowConfigurationBuilder . New
208- . WithIncrement ( null )
209- . WithBranch ( "develop" , builder => builder . WithIncrement ( IncrementStrategy . Inherit ) )
210- . Build ( ) ;
211- var repositoryStoreMock = Substitute . For < IRepositoryStore > ( ) ;
212- repositoryStoreMock . GetSourceBranches ( branchMock , configuration , Arg . Any < HashSet < IBranch > > ( ) ) . Returns ( Enumerable . Empty < IBranch > ( ) ) ;
213-
214- var unitUnderTest = new EffectiveBranchConfigurationFinder ( Substitute . For < ILog > ( ) , repositoryStoreMock ) ;
215-
216- // Act
217- var actual = unitUnderTest . GetConfigurations ( branchMock , configuration ) . ToArray ( ) ;
218-
219- // Assert
220- actual . ShouldBeEmpty ( ) ;
221- }
222-
223- [ Test ]
224- public void When_getting_configurations_of_an_orphaned_branch_Given_fallback_configuration_with_increment_inherit_Then_result_should_have_increment_none ( )
203+ public void When_getting_configurations_of_an_orphaned_branch_Given_fallback_configuration_with_increment_inherit_Then_result_should_be_empty ( )
225204 {
226205 // Arrange
227206 var branchMock = GitToolsTestingExtensions . CreateMockBranch ( "develop" , GitToolsTestingExtensions . CreateMockCommit ( ) ) ;
@@ -238,9 +217,7 @@ public void When_getting_configurations_of_an_orphaned_branch_Given_fallback_con
238217 var actual = unitUnderTest . GetConfigurations ( branchMock , configuration ) . ToArray ( ) ;
239218
240219 // Assert
241- actual . ShouldHaveSingleItem ( ) ;
242- actual [ 0 ] . Branch . ShouldBe ( branchMock ) ;
243- actual [ 0 ] . Value . Increment . ShouldBe ( IncrementStrategy . None ) ;
220+ actual . ShouldBeEmpty ( ) ;
244221 }
245222
246223 [ TestCase ( IncrementStrategy . None ) ]
@@ -271,12 +248,13 @@ public void When_getting_configurations_of_an_orphaned_branch_Given_fallback_con
271248 }
272249
273250 [ Test ]
274- public void When_getting_configurations_of_an_unknown_branch_Given_fallback_configuaration_without_increment_and_unknown_configuration_with_increment_inherit_Then_result_should_be_empty ( )
251+ public void When_getting_configurations_of_an_unknown_branch_Given_fallback_and_unknown_configuration_with_increment_inherit_Then_result_should_be_empty ( )
275252 {
276253 // Arrange
277254 var branchMock = GitToolsTestingExtensions . CreateMockBranch ( "unknown" , GitToolsTestingExtensions . CreateMockCommit ( ) ) ;
278255 var configuration = GitFlowConfigurationBuilder . New
279- . WithIncrement ( null )
256+ . WithIncrement ( IncrementStrategy . Inherit )
257+ . WithBranch ( "unknown" , builder => builder . WithIncrement ( IncrementStrategy . Inherit ) )
280258 . Build ( ) ;
281259 var repositoryStoreMock = Substitute . For < IRepositoryStore > ( ) ;
282260 repositoryStoreMock . GetSourceBranches ( branchMock , configuration , Arg . Any < HashSet < IBranch > > ( ) ) . Returns ( Enumerable . Empty < IBranch > ( ) ) ;
@@ -301,6 +279,7 @@ public void When_getting_configurations_of_an_unknown_branch_Given_fallback_conf
301279 var branchMock = GitToolsTestingExtensions . CreateMockBranch ( "unknown" , GitToolsTestingExtensions . CreateMockCommit ( ) ) ;
302280 var configuration = GitFlowConfigurationBuilder . New
303281 . WithIncrement ( fallbackIncrement )
282+ . WithBranch ( "unknown" , builder => builder . WithIncrement ( IncrementStrategy . Inherit ) )
304283 . Build ( ) ;
305284 var repositoryStoreMock = Substitute . For < IRepositoryStore > ( ) ;
306285 repositoryStoreMock . GetSourceBranches ( branchMock , configuration , Arg . Any < HashSet < IBranch > > ( ) ) . Returns ( Enumerable . Empty < IBranch > ( ) ) ;
@@ -318,13 +297,13 @@ public void When_getting_configurations_of_an_unknown_branch_Given_fallback_conf
318297
319298 [ Theory ]
320299 public void When_getting_configurations_of_an_unknown_branch_Given_fallback_configuaration_with_increment_and_develop_branch_with_increment_Then_result_should_have_develop_increment (
321- IncrementStrategy fallbackIncrement , IncrementStrategy developBranchIncrement )
300+ IncrementStrategy fallbackIncrement , IncrementStrategy developIncrement )
322301 {
323302 // Arrange
324303 var unknownBranchMock = GitToolsTestingExtensions . CreateMockBranch ( "unknown" , GitToolsTestingExtensions . CreateMockCommit ( ) ) ;
325304 var configuration = GitFlowConfigurationBuilder . New
326305 . WithIncrement ( fallbackIncrement )
327- . WithBranch ( "develop" , builder => builder . WithIncrement ( developBranchIncrement ) )
306+ . WithBranch ( "develop" , builder => builder . WithIncrement ( developIncrement ) )
328307 . Build ( ) ;
329308 var repositoryStoreMock = Substitute . For < IRepositoryStore > ( ) ;
330309 var developBranchMock = GitToolsTestingExtensions . CreateMockBranch ( "develop" , GitToolsTestingExtensions . CreateMockCommit ( ) ) ;
@@ -336,22 +315,24 @@ public void When_getting_configurations_of_an_unknown_branch_Given_fallback_conf
336315 var actual = unitUnderTest . GetConfigurations ( unknownBranchMock , configuration ) . ToArray ( ) ;
337316
338317 // Assert
339- actual . ShouldHaveSingleItem ( ) ;
340- actual [ 0 ] . Branch . ShouldBe ( developBranchMock ) ;
341-
342- if ( developBranchIncrement == IncrementStrategy . Inherit )
318+ if ( fallbackIncrement == IncrementStrategy . Inherit && developIncrement == IncrementStrategy . Inherit )
343319 {
344- if ( fallbackIncrement == IncrementStrategy . Inherit )
345- {
346- fallbackIncrement = IncrementStrategy . None ;
347- }
348- actual [ 0 ] . Value . Increment . ShouldBe ( fallbackIncrement ) ;
320+ actual . ShouldBeEmpty ( ) ;
349321 }
350322 else
351323 {
352- actual [ 0 ] . Value . Increment . ShouldBe ( developBranchIncrement ) ;
353- }
324+ actual . ShouldHaveSingleItem ( ) ;
325+ actual [ 0 ] . Branch . ShouldBe ( developBranchMock ) ;
354326
327+ if ( developIncrement == IncrementStrategy . Inherit )
328+ {
329+ actual [ 0 ] . Value . Increment . ShouldBe ( fallbackIncrement ) ;
330+ }
331+ else
332+ {
333+ actual [ 0 ] . Value . Increment . ShouldBe ( developIncrement ) ;
334+ }
335+ }
355336 }
356337
357338 [ Theory ]
@@ -374,14 +355,16 @@ public void When_getting_configurations_of_an_unknown_branch_Given_fallback_conf
374355 var actual = unitUnderTest . GetConfigurations ( unknownBranchMock , configuration ) . ToArray ( ) ;
375356
376357 // Assert
377- actual . ShouldHaveSingleItem ( ) ;
378- actual [ 0 ] . Branch . ShouldBe ( developBranchMock ) ;
379-
380358 if ( fallbackIncrement == IncrementStrategy . Inherit )
381359 {
382- fallbackIncrement = IncrementStrategy . None ;
360+ actual . ShouldBeEmpty ( ) ;
361+ }
362+ else
363+ {
364+ actual . ShouldHaveSingleItem ( ) ;
365+ actual [ 0 ] . Branch . ShouldBe ( developBranchMock ) ;
366+ actual [ 0 ] . Value . Increment . ShouldBe ( fallbackIncrement ) ;
383367 }
384- actual [ 0 ] . Value . Increment . ShouldBe ( fallbackIncrement ) ;
385368 }
386369
387370 [ TestCase ( IncrementStrategy . None ) ]
0 commit comments