Skip to content

Commit

Permalink
Fix ActivityMonitorBridge bug on close groups
Browse files Browse the repository at this point in the history
  • Loading branch information
macdarwin committed Aug 6, 2014
1 parent 7ff0855 commit 7a5c8c4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions CK.Core/ActivityMonitor/Impl/ActivityMonitorBridge.cs
Expand Up @@ -347,6 +347,7 @@ void IActivityMonitorClient.OnGroupClosed( IActivityLogGroup group, IReadOnlyLis
}
_bridgeTarget.CloseGroup( taggedConclusions );
}
_openedGroups[group.Depth - 1] = false;
}
}

Expand Down
43 changes: 43 additions & 0 deletions Tests/CK.Core.Tests/Monitoring/ActivityMonitorTests.cs
Expand Up @@ -132,6 +132,49 @@ public void BridgeArguments()
Assert.Throws<ArgumentNullException>( () => new ActivityMonitorBridge( null, false, false ), "Null guards." );
}

[Test]
[Category( "Console" )]
public void BridgeBalancePrematurelyClose()
{
//Main app monitor
IActivityMonitor mainMonitor = new ActivityMonitor();
var mainDump = mainMonitor.Output.RegisterClient( new StupidStringClient() );
using(mainMonitor.Output.CreateBridgeTo( TestHelper.ConsoleMonitor.Output.BridgeTarget ))
{
//Domain monitor
IActivityMonitor domainMonitor = new ActivityMonitor();
var domainDump = domainMonitor.Output.RegisterClient( new StupidStringClient() );

int i = 0;
for(; i < 10; i++) mainMonitor.OpenInfo().Send( "NOT Bridged n°{0}", i );

using(domainMonitor.Output.CreateBridgeTo( mainMonitor.Output.BridgeTarget ))
{
domainMonitor.OpenInfo().Send( "Bridged n°10" );
domainMonitor.OpenInfo().Send( "Bridged n°20" );
domainMonitor.CloseGroup( "Bridged close n°10" );
domainMonitor.CloseGroup( "Bridged close n°20" );

using(domainMonitor.OpenInfo().Send("Bridged n°50") )
{
using(domainMonitor.OpenInfo().Send( "Bridged n°60" ))
{
using(domainMonitor.OpenInfo().Send( "Bridged n°70" ))
{
// Number of Prematurely closed by Bridge removed depends on the max level of groups open
}
}
}
}

int j = 0;
for(; j < 10; j++) mainMonitor.CloseGroup( String.Format( "NOT Bridge close n°{0}", j ) );
}

string allText = mainDump.ToString();
Assert.That( Regex.Matches( allText, R.ClosedByBridgeRemoved ).Count, Is.EqualTo( 0 ), "All Info groups are closed, no need to automatically close other groups" );
}

[Test]
[Category( "Console" )]
public void BridgeBalance()
Expand Down

0 comments on commit 7a5c8c4

Please sign in to comment.