public void Dispose_DisposesOnlyOnce() { object simulator = Substitute.For <ISimulator, IDisposable>(); ISimulation simulation = Simulation.Create(); ((IAddSimulator)simulation).Add((ISimulator)simulator); #pragma warning disable S3966 // Objects should not be disposed more than once - required for unit test simulation.Dispose(); simulation.Dispose(); #pragma warning restore S3966 // Objects should not be disposed more than once ((IDisposable)simulator).Received(1).Dispose(); }
static void Main(string[] args) { // Setup var form = SlimDXHelper.InitD3D(out _device, out _swapChain, out _renderView); var temp = form.ClientRectangle; _finalRender = new FSQ(_device, _renderView, "SimpleFSQ.fx"); /*_simulation = * new HybridFluidSim( * _finalRender, * _device);*/ _simulation = new SemiGridSPHSimulation(_device, _finalRender.UAV); //_simulation = new MovingGridFluid.MovingGridFluid(_device, _finalRender.UAV); // Main loop MessagePump.Run(form, SimMain); // Tear down _finalRender.Dispose(); _swapChain.Dispose(); _renderView.Dispose(); _simulation.Dispose(); _device.Dispose(); }
public void Dispose_DoesNotThrow_WhenSimulatorDoesNotImplementIDisposable() { ISimulator simulator = Substitute.For <ISimulator>(); ISimulation simulation = Simulation.Create(); ((IAddSimulator)simulation).Add(simulator); Action action = () => simulation.Dispose(); action.ShouldNotThrow(); }
public void Dispose_DoesNotThrow_WhenSimulatorThrowsWhenStopping() { ISimulator simulator = Substitute.For <ISimulator>(); simulator.StopAsync().Returns(_ => Task.FromException(new ArgumentException("Task is null"))); ISimulation simulation = Simulation.Create(); ((IAddSimulator)simulation).Add(simulator); Action action = () => simulation.Dispose(); action.ShouldNotThrow(); }
public async Task TearDown() { await _simulation.StopAllAsync(); _simulation.Dispose(); }
public void TearDown() { _simulation.Dispose(); _testCertificate?.Dispose(); }