public void TestThrowDuringAsynchronousPrune() { using ( ParticleSystemManager manager = new ParticleSystemManager( this.mockedGraphicsDeviceService ) ) { ParticleSystem <SimpleParticle> test = new ParticleSystem <SimpleParticle>(4096); for (int index = 0; index < test.Capacity; ++index) { test.AddParticle(new SimpleParticle()); } manager.AddParticleSystem( test, delegate(ref SimpleParticle particle) { throw new ArithmeticException(); }, new DummyRenderer <SimpleParticle>() ); IAsyncResult asyncResult = manager.BeginPrune(null, null); Assert.Throws <ArithmeticException>( delegate() { manager.EndPrune(asyncResult); } ); } }
public void TestAsynchronousPrune() { using ( ParticleSystemManager manager = new ParticleSystemManager( this.mockedGraphicsDeviceService ) ) { // Add one particle system where there's stuff to do ParticleSystem <SimpleParticle> test = new ParticleSystem <SimpleParticle>(16); for (int index = 0; index < test.Capacity; ++index) { test.AddParticle(new SimpleParticle()); } manager.AddParticleSystem(test, slowPrune, new DummyRenderer <SimpleParticle>()); // Add 16 other particle systems for (int index = 0; index < 16; ++index) { manager.AddParticleSystem( new ParticleSystem <SimpleParticle>(100), dontPrune, new DummyRenderer <SimpleParticle>() ); } // Now update everything for (int repetition = 0; repetition < 2; ++repetition) { IAsyncResult asyncResult = manager.BeginPrune(null, null); manager.EndPrune(asyncResult); } } }
public void TestThrowOnWrongAsyncResultInEndPrune() { using ( ParticleSystemManager manager = new ParticleSystemManager( this.mockedGraphicsDeviceService ) ) { IAsyncResult asyncResult = manager.BeginPrune(null, null); try { Assert.Throws <ArgumentException>( delegate() { manager.EndPrune(null); } ); } finally { manager.EndPrune(asyncResult); } } }
public void TestAsynchronousPruneCallback() { using ( ParticleSystemManager manager = new ParticleSystemManager( this.mockedGraphicsDeviceService ) ) { CallbackReceiver receiver = new CallbackReceiver(); object state = new object(); IAsyncResult asyncResult = manager.BeginPrune(receiver.Callback, state); manager.EndPrune(asyncResult); Assert.AreSame(state, receiver.State); Assert.IsFalse(asyncResult.CompletedSynchronously); } }