@Test
public void Suspend()
{
final EventLog log = new EventLog();
final TestElement a = TestElement.TYPE.instantiate();
try
{
a.attach( log, "*" );
final TestElement aa = a.getElement().content( true );
aa.setValue( "abc" );
aa.getList().insert();
assertEquals( 3, log.size() );
assertPropertyContentEvent( log.event( 0 ), a.getElement() );
assertPropertyContentEvent( log.event( 1 ), aa.getValue() );
assertPropertyContentEvent( log.event( 2 ), aa.getList() );
log.clear();
final Disposable suspension = a.getElement().suspend();
try
{
aa.setValue( "def" );
aa.getList().insert().setValue( "ghi" );
aa.getElement().content( true ).setValue( "klm" );
assertEquals( 0, log.size() );
a.setValue( "nop" );
assertEquals( 1, log.size() );
assertPropertyContentEvent( log.event( 0 ), a.getValue() );
log.clear();
}
finally
{
suspension.dispose();
}
assertEquals( 5, log.size() );
assertPropertyContentEvent( log.event( 0 ), aa.getValue() );
assertPropertyContentEvent( log.event( 1 ), aa.getList() );
assertPropertyContentEvent( log.event( 2 ), aa.getList().get( 1 ).getValue() );
assertPropertyContentEvent( log.event( 3 ), aa.getElement() );
assertPropertyContentEvent( log.event( 4 ), aa.getElement().content().getValue() );
}
finally
{
a.dispose();
}